-
Notifications
You must be signed in to change notification settings - Fork 29.5k
Open
flutter/packages
#10363Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.f: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.found in release: 3.35Found to occur in 3.35Found to occur in 3.35found in release: 3.37Found to occur in 3.37Found to occur in 3.37frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has 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.team-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
Steps to reproduce
go_router: 16.2.1
- Run the app
- Note the "Build count: 1" on the home page
- Click "Call router.refresh()" button
- Expected: The page should rebuild and "Build count" should increase to 2
- Actual: Nothing happens, build count remains 1, builder is not called
Expected results
GoRouter.refresh()should trigger the builder function of the current route- The page should rebuild with updated data
- Build count should increment
Actual results
GoRouter.refresh()executes without errors- No rebuild occurs
- Builder function is not called
- UI remains unchanged
Code sample
Code sample
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp.router(
routerConfig: _router,
title: 'GoRouter Refresh Issue',
);
}
}
// Global counter to track rebuilds
int buildCount = 0;
final GoRouter _router = GoRouter(
routes: [
GoRoute(
path: '/',
builder: (context, state) {
buildCount++;
print('HomePage built: $buildCount times');
return HomePage();
},
),
GoRoute(
path: '/details',
builder: (context, state) {
print('DetailsPage built');
return DetailsPage();
},
),
],
);
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Home')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Build count: $buildCount',
style: TextStyle(fontSize: 24),
),
SizedBox(height: 20),
ElevatedButton(
onPressed: () {
print('Calling router.refresh()...');
_router.refresh();
print('router.refresh() called');
},
child: Text('Call router.refresh()'),
),
SizedBox(height: 20),
ElevatedButton(
onPressed: () => context.go('/details'),
child: Text('Go to Details'),
),
],
),
),
);
}
}
class DetailsPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Details')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Details Page'),
SizedBox(height: 20),
ElevatedButton(
onPressed: () {
print('Calling router.refresh() from DetailsPage...');
_router.refresh();
},
child: Text('Call router.refresh()'),
),
SizedBox(height: 20),
ElevatedButton(
onPressed: () => context.go('/'),
child: Text('Back to Home'),
),
],
),
),
);
}
}Flutter Doctor output
Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.35.3, on macOS 15.6.1 24G90 darwin-arm64, locale
en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2025.1)
[✓] VS Code (version 1.96.4)
[✓] Connected device (4 available)
[✓] Network resources
• No issues found!Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.f: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.found in release: 3.35Found to occur in 3.35Found to occur in 3.35found in release: 3.37Found to occur in 3.37Found to occur in 3.37frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has 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.team-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team