admin管理员组文章数量:1410674
Description I'm using Beamer for navigation in a Flutter web app. Everything works fine, but when I enter or exit fullscreen mode in Chrome, I get the following error: Bad state: No element
Expected Behavior The app should keep the current route when entering/exiting fullscreen. Beamer should not lose its navigation state, and the app should not crash.
Actual Behavior Before fullscreen: Beamer correctly maintains the route. After entering/exiting fullscreen: Beamer loses the path and throws "Bad state: No element". Debugging shows that the path is empty after fullscreen mode, even though it was correct before.
** Relevant Code** This is how I initialize Beamer in my app:
This is the main function, which runs when the app starts:
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
late BeamerDelegate routerDelegate;
@override
void initState() {
super.initState();
routerDelegate = BeamerDelegate(
transitionDelegate: const NoAnimationTransitionDelegate(),
locationBuilder: RoutesLocationBuilder(
routes: {
'*': (context, state, data) => AuthWrapper(),
},
),
);
}
@override
Widget build(BuildContext context) {
return MultiProvider(
providers: [
ChangeNotifierProvider(
create: (context) => MenuAppController(),
),
],
child: MaterialApp.router(
debugShowCheckedModeBanner: false,
routeInformationParser: BeamerParser(),
routerDelegate: routerDelegate, // ✅ Beamer is initialized here
title: 'Dashboard',
theme: ThemeData.dark().copyWith(
scaffoldBackgroundColor: bgColor,
textTheme: GoogleFonts.poppinsTextTheme(Theme.of(context).textTheme)
.apply(bodyColor: Colors.white),
canvasColor: secondaryColor,
),
),
);
}
}
And here’s how I use Beamer inside my MainScreen:
Expanded(
flex: 7,
child: Container(
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
),
child: Beamer(
key: _beamerKey,
routerDelegate: BeamerDelegate(
notFoundPage: BeamPage(
key: ValueKey('NotFound'),
child: Scaffold(
body: Center(child: Text("404 - Page Not Found")),
),
),
locationBuilder: RoutesLocationBuilder(
routes: {
'/dashboard': (context, state, data) => BeamPage(
key: ValueKey('Dashboard'),
type: BeamPageType.noTransition,
child: DashboardScreen(),
),
'/clients': (context, state, data) => BeamPage(
key: ValueKey('Clients'),
type: BeamPageType.noTransition,
child: ClientsScreen(),
),
'/workoutlibrary': (context, state, data) => BeamPage(
key: ValueKey('Workout Library'),
type: BeamPageType.noTransition,
child: WorkoutLibraryScreen(),
),
'/training': (context, state, data) => BeamPage(
key: ValueKey('Training'),
type: BeamPageType.noTransition,
child: TrainingProgramsScreen(),
),
'/chats': (context, state, data) => BeamPage(
key: ValueKey('Chats'),
type: BeamPageType.noTransition,
child: MealPlansDashboardScreen(),
),
'/analytics': (context, state, data) => BeamPage(
key: ValueKey('Analytics'),
type: BeamPageType.noTransition,
child: TrainingProgramsScreen(),
),
'/settings': (context, state, data) => BeamPage(
key: ValueKey('Settings'),
type: BeamPageType.noTransition,
child: TrainingProgramsScreen(),
),
},
),
),
),
),
),
Any help or guidance would be greatly appreciated!
版权声明:本文标题:dart - Flutter Web - Beamer loses path when switching fullscreen → "Bad state: No element" - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744926172a2632610.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论