-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
flutter/packages
#8521Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.10Found to occur in 3.10Found to occur in 3.10found in release: 3.11Found to occur in 3.11Found to occur in 3.11has 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_router_builderThe go_router_builder packageThe go_router_builder packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Related to
Uriwith emptyqueryParameterhas an extra?at the end #122089- Create an issue
Uriwith emptyqueryParameterhas an extra?at the end dart-lang/sdk#51656
With the code generated by go_router_builder, when a route has an empty iterable (which can happen a lot when there is a default value), it always includes {} or [] in the query parameters which leads to a trailing ? at the end of the URL.
Is it possible to not include an empty iterable in the query parameters to avoid this behavior?
Steps to reproduce
- Run flutter run on the code sample given below
- Notice the print is
/?
Expected results
I would expect the location to not have the extra ? if there are no parameters to specify
Actual results
The location ends with a ? and has not query parameters after.
Code sample
Code sample
You can also check out https://github.com/ValentinVignal/flutter_app_stable/tree/go-router-builder/extra-interrogation-mark-in-url
# main.dart
void main() {
print(const MyRoute().location);
}# pages.dart
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
part 'pages.g.dart';
@TypedGoRoute<MyRoute>(path: '/')
class MyRoute extends GoRouteData {
const MyRoute({
this.params = const [],
});
final List<int> params;
@override
Widget build(BuildContext context, GoRouterState state) {
return const Placeholder();
}
}Screenshots or Video
No response
Logs
Logs
/?Flutter Doctor output
Doctor output
[!] Flutter (Channel stable, 3.7.12, on macOS 13.3.1 22E772610a darwin-x64, locale en-GB)
! Warning: `dart` on your path resolves to /usr/local/Cellar/dart/2.18.3/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/valentin/flutter/flutter. Consider adding
/Users/valentin/flutter/flutter/bin to the front of your path.
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] VS Code (version 1.78.2)
[✓] Connected device (2 available)
[✓] HTTP Host Availability
! Doctor found issues in 1 category.rostaingc
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.10Found to occur in 3.10Found to occur in 3.10found in release: 3.11Found to occur in 3.11Found to occur in 3.11has 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_router_builderThe go_router_builder packageThe go_router_builder packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version