-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Open
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectfound in release: 3.32Found to occur in 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33Found to occur in 3.33has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: go_routerThe go_router packageThe go_router packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-webWeb applications specificallyWeb applications specificallyteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
Steps to reproduce
Put special characters, encoded or not, in url, then hit Refresh. They are automatically converted back to its non-encoded form.
Expected results
Special characters are not encoded in urls
Actual results
Special characters are encoded in urls
Code sample
main.dart
import 'package:flutter/material.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
import 'package:go_router/go_router.dart';
import 'package:testing_textfield/router.dart';
void main() {
GoRouter.optionURLReflectsImperativeAPIs = true;
setUrlStrategy(PathUrlStrategy());
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
late final _router = GoRouter(
initialLocation: '/',
routes: $appRoutes,
debugLogDiagnostics: true,
);
@override
Widget build(BuildContext context) {
return MaterialApp.router(
title: 'TESTING GO ROUTER',
theme: ThemeData(
primarySwatch: Colors.blue,
scaffoldBackgroundColor: const Color.fromARGB(255, 235, 235, 241),
),
routeInformationParser: _router.routeInformationParser,
routeInformationProvider: _router.routeInformationProvider,
routerDelegate: _router.routerDelegate,
);
}
}
router.dart
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:testing_textfield/test_text_field.dart';
part 'router.g.dart';
@TypedGoRoute<HomeRouter>(path: '/')
class HomeRouter extends GoRouteData {
const HomeRouter({this.text});
final String? text;
@override
Page<void> buildPage(BuildContext context, GoRouterState state) {
return NoTransitionPage(
child: Scaffold(
backgroundColor: Colors.white,
key: UniqueKey(),
body: TestTextFieldScreen(text: text),
));
}
}
router.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'router.dart';
// **************************************************************************
// GoRouterGenerator
// **************************************************************************
List<RouteBase> get $appRoutes => [
$homeRouter,
];
RouteBase get $homeRouter => GoRouteData.$route(
path: '/',
factory: $HomeRouterExtension._fromState,
);
extension $HomeRouterExtension on HomeRouter {
static HomeRouter _fromState(GoRouterState state) => HomeRouter(
text: state.uri.queryParameters['text'],
);
String get location => GoRouteData.$location(
'/',
queryParams: {
if (text != null) 'text': text,
},
);
void go(BuildContext context) => context.go(location);
Future<T?> push<T>(BuildContext context) => context.push<T>(location);
void pushReplacement(BuildContext context) =>
context.pushReplacement(location);
void replace(BuildContext context) => context.replace(location);
}
test_text_field.dart
import 'package:flutter/material.dart';
import 'package:testing_textfield/router.dart';
class TestTextFieldScreen extends StatefulWidget {
const TestTextFieldScreen({super.key, this.text});
final String? text;
@override
State<TestTextFieldScreen> createState() => _TestTextFieldScreenState();
}
class _TestTextFieldScreenState extends State<TestTextFieldScreen> {
final ctrl = TextEditingController();
@override
void dispose() {
ctrl.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Center(
child: Column(
children: [
TextFormField(
controller: ctrl,
),
const SizedBox(height: 20),
Text('Non decoded text: ' + (widget.text ?? '')),
const SizedBox(height: 20),
Text('Decoded text: ' + Uri.decodeQueryComponent(widget.text ?? '')),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
OutlinedButton(
onPressed: () {
HomeRouter(text: ctrl.text).go(context);
},
child: const Text('Send non encoded text')),
const SizedBox(width: 20),
OutlinedButton(
onPressed: () {
HomeRouter(text: Uri.encodeQueryComponent(ctrl.text))
.go(context);
},
child: const Text('Send encoded text')),
],
)
],
),
);
}
}
Screenshots or Video
Screen.Recording.2025-07-08.at.15.58.19.mov
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
Launching lib/main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...
This app is linked to the debug service: ws://127.0.0.1:53889/-RI1VrrJ2k8=/ws
Debug service listening on ws://127.0.0.1:53889/-RI1VrrJ2k8=/ws
Debug service listening on ws://127.0.0.1:53889/-RI1VrrJ2k8=/ws
[GoRouter] Full paths for routes:
└─/ (Widget)
[GoRouter] setting initial location /
[GoRouter] going to /?text=a%2Bb
[GoRouter] Full paths for routes:
└─/ (Widget)
[GoRouter] setting initial location /
[GoRouter] going to /?text=a%252Bb
[GoRouter] Full paths for routes:
└─/ (Widget)
[GoRouter] setting initial location /
Flutter Doctor output
Doctor output
[!] Flutter (Channel [user-branch], 3.24.3, on macOS 15.2 24C101 darwin-arm64, locale en-VN)
! Flutter version 3.24.3 on channel [user-branch] at /Users/mht/flutter
Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/setup.
! Upstream repository unknown source is not a standard remote.
Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
• Framework revision 2663184aa7 (10 months ago), 2024-09-11 16:27:48 -0500
• Engine revision 36335019a8
• Dart version 3.5.3
• DevTools version 2.37.3
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /Users/mht/Library/Android/sdk
• Platform android-34, build-tools 33.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
• All Android licenses accepted.
[!] Xcode - develop for iOS and macOS (Xcode 14.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14C18
! Flutter recommends a minimum Xcode version of 15.
Download the latest version or update via the Mac App Store.
! CocoaPods 1.11.3 out of date (1.13.0 is recommended).
CocoaPods is a package manager for iOS or macOS platform code.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/to/platform-plugins
To update CocoaPods, see https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
[✓] Android Studio (version 2021.2)
• Android Studio at /Volumes/Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
[✓] VS Code (version 1.96.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] VS Code (version 1.98.2)
• VS Code at /Volumes/Applications/Visual Studio Code.app/Contents
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (3 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 15.2 24C101 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.2 24C101 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 138.0.7204.93
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 2 categories.
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectfound in release: 3.32Found to occur in 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33Found to occur in 3.33has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: go_routerThe go_router packageThe go_router packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-webWeb applications specificallyWeb applications specificallyteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team