-
Notifications
You must be signed in to change notification settings - Fork 28.6k
StatefulShellRouteData generated as const on extension #161305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The generated code: // GENERATED CODE - DO NOT MODIFY BY HAND
part of 'router.dart';
// **************************************************************************
// GoRouterGenerator
// **************************************************************************
List<RouteBase> get $appRoutes => [
$appShellRouteData,
];
RouteBase get $appShellRouteData => StatefulShellRouteData.$route(
factory: $AppShellRouteDataExtension._fromState,
branches: [
StatefulShellBranchData.$branch(
routes: [
GoRouteData.$route(
path: '/',
factory: $HomePageRouteExtension._fromState,
),
],
),
StatefulShellBranchData.$branch(
routes: [
GoRouteData.$route(
path: '/my-class',
factory: $MyClassPageRouteExtension._fromState,
),
],
),
StatefulShellBranchData.$branch(
routes: [
GoRouteData.$route(
path: '/homework',
factory: $HomeworkPageRouteExtension._fromState,
),
],
),
StatefulShellBranchData.$branch(
routes: [
GoRouteData.$route(
path: '/assignments',
factory: $AssignmentsPageRouteExtension._fromState,
),
],
),
StatefulShellBranchData.$branch(
routes: [
GoRouteData.$route(
path: '/chat',
factory: $ChatPageRouteExtension._fromState,
),
],
),
],
);
extension $AppShellRouteDataExtension on AppShellRouteData {
static AppShellRouteData _fromState(GoRouterState state) =>
const AppShellRouteData();
}
extension $HomePageRouteExtension on HomePageRoute {
static HomePageRoute _fromState(GoRouterState state) => HomePageRoute();
String get location => GoRouteData.$location(
'/',
);
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);
}
extension $MyClassPageRouteExtension on MyClassPageRoute {
static MyClassPageRoute _fromState(GoRouterState state) => MyClassPageRoute();
String get location => GoRouteData.$location(
'/my-class',
);
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);
}
extension $HomeworkPageRouteExtension on HomeworkPageRoute {
static HomeworkPageRoute _fromState(GoRouterState state) =>
HomeworkPageRoute();
String get location => GoRouteData.$location(
'/homework',
);
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);
}
extension $AssignmentsPageRouteExtension on AssignmentsPageRoute {
static AssignmentsPageRoute _fromState(GoRouterState state) =>
AssignmentsPageRoute();
String get location => GoRouteData.$location(
'/assignments',
);
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);
}
extension $ChatPageRouteExtension on ChatPageRoute {
static ChatPageRoute _fromState(GoRouterState state) => ChatPageRoute();
String get location => GoRouteData.$location(
'/chat',
);
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);
} |
@on3ss I code sample you shared here can you provide only minimal or complete runnable one ? I see that you have lot of imports there, but try to trim down to absolutely minimum code that still triggers the reported error. |
Sure. Here is the minimal code required to run: // router.dart
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:academix/ui/home/home.dart';
part 'router.g.dart';
@TypedStatefulShellRoute<AppShellRouteData>(
branches: [
TypedStatefulShellBranch(
routes: [TypedGoRoute<HomeScreenRoute>(path: '/')],
),
],
)
class AppShellRouteData extends StatefulShellRouteData {
@override
Widget builder(
BuildContext context,
GoRouterState state,
StatefulNavigationShell navigationShell,
) =>
HomeScreen();
}
@immutable
class HomeScreenRoute extends GoRouteData {
@override
Widget build(BuildContext context, GoRouterState state) {
return const HomeScreen();
}
} //home.dart
import 'package:flutter/material.dart';
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(body: Placeholder());
}
}
|
Thanks for the update. I was able to replicate the reported behavior using details provided above.
|
Can we expect a fix for this with the next update? For those who often use build_runner with their project this can be annoying. |
fixes:flutter/flutter#161305 also fix some typos: statefull* -> stateful*
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Uh oh!
There was an error while loading. Please reload this page.
Steps to reproduce
Expected results
on the generated file, the extension on the class that extends StatefulShellRouteData must not be returned as const.
Actual results
on the generated file, the extension on the class that extends StatefulShellRouteData returned as const.
Code sample
Code sample
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: