-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
flutter/packages
#2826Closed
Copy link
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterp: 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
Use case
It would be nice to support default values like secondParameter in the snippet below:
@TypedGoRoute<HomeRoute>(path: '/')
class HomeRoute extends GoRouteData {
const HomeRoute({
this.firstParameter,
this.secondParameter = 'default',
});
final String? firstParameter;
final String secondParameter;
@override
Widget build(BuildContext context) {
return const SizedBox();
}
}Right now, it is not supported and throws compilation errors:
error • The argument type 'String?' can't be assigned to the parameter type 'String' • lib/routes.g.dart:21:26 • argument_type_not_assignable
in
extension $HomeRouteExtension on HomeRoute {
static HomeRoute _fromState(GoRouterState state) => HomeRoute(
firstParameter: state.queryParams['first-parameter'],
secondParameter: state.queryParams['second-parameter'], // <- The argument type 'String?' can't be assigned to the parameter type 'String'.
);
}You can also checkout https://github.com/ValentinVignal/flutter_app_stable/tree/go-router-builder/default-value-for-parameter
Proposal
Default values for route parameters could be supported.
heeyunlee
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterp: 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