-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
Closed
Copy link
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_routerThe go_router packageThe go_router packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.r: duplicateIssue is closed as a duplicate of an existing issueIssue is closed as a duplicate of an existing issue
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Steps to reproduce
- Run shell_route_example, or any example that has a
ShellRoute. - Navigate between routes (in this example a
BottomNavigationBar). - Watch the screen flickering and status bar adapting.
Running on a Xiaomi Redmi 9S Android 12 in dark mode.
In normal routes GoRoute this problem does not seems to happen.
Expected results
No flickering.
Actual results
When we navigate between routes the screen flickers dark.
Even worse this makes status bar re-render white and black.
Code sample
Code sample
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
part 'shell_route_example.g.dart';
void main() => runApp(App());
class App extends StatelessWidget {
App({super.key});
@override
Widget build(BuildContext context) => MaterialApp.router(
routerConfig: _router,
);
final GoRouter _router = GoRouter(
routes: $appRoutes,
initialLocation: '/foo',
);
}
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: const Text('foo')),
);
}
@TypedShellRoute<MyShellRouteData>(
routes: <TypedRoute<RouteData>>[
TypedGoRoute<FooRouteData>(path: '/foo'),
TypedGoRoute<BarRouteData>(path: '/bar'),
],
)
class MyShellRouteData extends ShellRouteData {
const MyShellRouteData();
@override
Widget builder(
BuildContext context,
GoRouterState state,
Widget navigator,
) {
return MyShellRouteScreen(child: navigator);
}
}
class FooRouteData extends GoRouteData {
const FooRouteData();
@override
Widget build(BuildContext context, GoRouterState state) {
return const FooScreen();
}
}
class BarRouteData extends GoRouteData {
const BarRouteData();
@override
Widget build(BuildContext context, GoRouterState state) {
return const BarScreen();
}
}
class MyShellRouteScreen extends StatelessWidget {
const MyShellRouteScreen({required this.child, super.key});
final Widget child;
int getCurrentIndex(BuildContext context) {
final String location = GoRouter.of(context).location;
if (location == '/bar') {
return 1;
}
return 0;
}
@override
Widget build(BuildContext context) {
final int currentIndex = getCurrentIndex(context);
return Scaffold(
body: child,
bottomNavigationBar: BottomNavigationBar(
currentIndex: currentIndex,
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home),
label: 'Foo',
),
BottomNavigationBarItem(
icon: Icon(Icons.business),
label: 'Bar',
),
],
onTap: (int index) {
switch (index) {
case 0:
const FooRouteData().go(context);
break;
case 1:
const BarRouteData().go(context);
break;
}
},
),
);
}
}
class FooScreen extends StatelessWidget {
const FooScreen({super.key});
@override
Widget build(BuildContext context) {
return const Text('Foo');
}
}
class BarScreen extends StatelessWidget {
const BarScreen({super.key});
@override
Widget build(BuildContext context) {
return const Text('Bar');
}
}
@TypedGoRoute<LoginRoute>(path: '/login')
class LoginRoute extends GoRouteData {
const LoginRoute();
@override
Widget build(BuildContext context, GoRouterState state) =>
const LoginScreen();
}
class LoginScreen extends StatelessWidget {
const LoginScreen({super.key});
@override
Widget build(BuildContext context) {
return const Text('Login');
}
}Screenshots or Video
Video demonstration
Screenrecorder-2023-05-12-16-30-38-613.mp4
Flutter Doctor output
Doctor output
[√] Flutter (Channel stable, 3.10.0, on Microsoft Windows [Version 10.0.22621.1702], locale pt-PT)
• Flutter version 3.10.0 on channel stable at C:\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 84a1e904f4 (3 days ago), 2023-05-09 07:41:44 -0700
• Engine revision d44b5a94c9
• Dart version 3.0.0
• DevTools version 2.23.1
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc3)
• Android SDK at C:\Users\Eu\AppData\Local\Android\sdk
• Platform android-33, build-tools 34.0.0-rc3
• Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
• All Android licenses accepted.
[√] Chrome - develop for the web
• CHROME_EXECUTABLE = C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe
[√] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.11.22)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
• Visual Studio Build Tools 2019 version 16.11.33130.400
• Windows 10 SDK version 10.0.19041.0
[√] Android Studio (version 2022.2)
• Android Studio at C:\Program Files\Android\Android Studio
• 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 17.0.6+0-b2043.56-9586694)
[√] VS Code, 64-bit edition (version 1.77.3)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 3.65.20230510
[√] Connected device (4 available)
• Redmi Note 9S (mobile) • 14f27be • android-arm64 • Android 12 (API 31)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22621.1702]
• Chrome (web) • chrome • web-javascript • unknown
• Edge (web) • edge • web-javascript • Microsoft Edge 113.0.1774.35
[√] Network resources
• All expected network resources are available.
• No issues found!FXschwartz
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_routerThe go_router packageThe go_router packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.r: duplicateIssue is closed as a duplicate of an existing issueIssue is closed as a duplicate of an existing issue