beamer
beamer copied to clipboard
Navigator.onGenerateRoute was null error on hot reload
Describe the bug
If the class passed as a parameter to runApp
does not return MaterialApp
directly, when a hot reload is triggered, the following error occurs:
Navigator.onGenerateRoute was null, but the route named "/" was referenced.
Beamer version: 1.5.0
To Reproduce Steps to reproduce the behavior:
- Generate a new Flutter project
- Copy-paste the following code in
main.dart
:
import 'package:beamer/beamer.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MyAppView();
}
}
class MyAppView extends StatelessWidget {
MyAppView({Key? key}) : super(key: key);
final _routerDelegate = BeamerDelegate(
locationBuilder: RoutesLocationBuilder(
routes: {
"/": (context, state, data) => const Center(
child: Text("Hello, World!"),
),
},
),
);
@override
Widget build(BuildContext context) {
return MaterialApp.router(
routerDelegate: _routerDelegate,
routeInformationParser: BeamerParser(),
);
}
}
- Run the app
- Trigger hot reload
- See error
Smartphone (please complete the following information):
- Device: Pixel 5 (Emulator)
- OS: Android 12
Hey @MrSquaare :wave: Thanks for creating an issue!
This looks like a general behavior in Flutter, not specific to Beamer. Can we reproduce that with vanilla Router API?