-
-
Notifications
You must be signed in to change notification settings - Fork 124
Description
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(),
),
},
),
),
),
),
),
Things I’ve Tried
- Using a static BeamerDelegate to prevent re-creation → still happens.
- Adding a notFoundPage to Beamer to avoid crashes → still happens.
- Printing Beamer.of(context).currentBeamLocation.state.uri → shows empty after fullscreen.
- Testing beamToNamed() right after fullscreen exit → still crashes.
Any help or guidance would be greatly appreciated! 🚀