-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
flutter/packages
#5497Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.7Found to occur in 3.7Found to occur in 3.7found in release: 3.8Found to occur in 3.8Found to occur in 3.8has 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.r: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
Steps to Reproduce
- Execute
flutter runon the code sample (see "Code sample" section below)
There are 4 pages. 2 of them are in aShellRoutewhile the 2 others are outside - Navigate with
go, notice that everything works fine - Navigate with
pushand/orpushReplacement. - Notice that the
ShellRouteis off (You can see a "Shell" blue box on tap). When pushing a page, the "Shell" blue box doesn't disappear/appear when it should, it remains in the current state (shown or hidden).
Expected results:
When pushing to a route
- Inside the shell: I expect to see the blue box "Shell"
- Outside the shell: I expect to not see the blue box "Shell"
Actual results:
The blue box "Shell" remains hidden/shown and is not updated.
Code sample
Or you can checkout https://github.com/ValentinVignal/flutter_app_stable/tree/go-router/push-and-push-replacement-do-not-update-shell-route
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
void main() {
runApp(const MyApp());
}
final router = GoRouter(
initialLocation: '/out-shell-0',
routes: [
GoRoute(
path: '/out-shell-0',
builder: (context, state) {
return const Screen(name: 'Out shell 0');
},
),
GoRoute(
path: '/out-shell-1',
builder: (context, state) {
return const Screen(name: 'Out shell 1');
},
),
ShellRoute(
routes: [
GoRoute(
path: '/in-shell-0',
builder: (context, state) {
return const Screen(name: 'In shell 0');
},
),
GoRoute(
path: '/in-shell-1',
builder: (context, state) {
return const Screen(name: 'In shell 1');
},
),
],
builder: (context, state, child) {
return Shell(child: child);
},
),
],
);
class Shell extends StatelessWidget {
const Shell({
required this.child,
super.key,
});
final Widget child;
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Material(
color: Colors.blue,
child: Text('In Shell'),
),
Expanded(
child: child,
),
],
);
}
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp.router(
routerConfig: router,
);
}
}
class Screen extends StatelessWidget {
const Screen({
required this.name,
super.key,
});
final String name;
@override
Widget build(BuildContext context) {
return Scaffold(
body: ListView(
children: [
Text(name),
const _Tile(route: '/in-shell-0'),
const _Tile(route: '/in-shell-1'),
const _Tile(route: '/out-shell-0'),
const _Tile(route: '/out-shell-1'),
],
),
);
}
}
class _Tile extends StatelessWidget {
const _Tile({
required this.route,
Key? key,
}) : super(key: key);
final String route;
@override
Widget build(BuildContext context) {
final router = GoRouter.of(context);
return ListTile(
title: Text(route),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
TextButton(
onPressed: () {
router.go(route);
},
child: const Text('go'),
),
TextButton(
onPressed: () {
router.push(route);
},
child: const Text('push'),
),
TextButton(
onPressed: () {
router.pushReplacement(route);
},
child: const Text('pushReplacement'),
),
],
),
);
}
}Logs
Launching lib/main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome... 34.1s
This app is linked to the debug service: ws://127.0.0.1:62518/h8E-lMlKvWY=/ws
Debug service listening on ws://127.0.0.1:62518/h8E-lMlKvWY=/ws
💪 Running with sound null safety 💪
🔥 To hot restart changes while running, press "r" or "R".
For a more detailed help message, press "h". To quit, press "q".
An Observatory debugger and profiler on Chrome is available at: http://127.0.0.1:62518/h8E-lMlKvWY=
The Flutter DevTools debugger and profiler on Chrome is available at: http://127.0.0.1:9101?uri=http://127.0.0.1:62518/h8E-lMlKvWY=
Application finished.
Analyzing flutter_app_stable...
No issues found! (ran in 15.1s)
[✓] Flutter (Channel stable, 3.7.3, on macOS 11.6.8 20G730 darwin-x64, locale en-GB)
• Flutter version 3.7.3 on channel stable at /Users/valentin/flutter/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 9944297138 (5 days ago), 2023-02-08 15:46:04 -0800
• Engine revision 248290d6d5
• Dart version 2.19.2
• DevTools version 2.20.1
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /usr/local/Caskroom/android-sdk/4333796
• Platform android-33, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 13C100
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.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 11.0.11+0-b60-7590822)
[✓] VS Code (version 1.75.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.58.0
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-x64 • macOS 11.6.8 20G730 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.119
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Video
Screen.Recording.2023-02-14.at.2.39.51.PM.mov
szelemeh, m1n093, JohnF17 and Maatteogekko
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.7Found to occur in 3.7Found to occur in 3.7found in release: 3.8Found to occur in 3.8Found to occur in 3.8has 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.r: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version