New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
auto_route compatibility #103
Comments
This doesn't seem to be an error caused by bot_toast, but an assertion error caused by you not meeting the MaterialApp parameter passing requirements. You can see if the necessary parameters are missing, or you can try to remove botToastBuilder to see if it still reports an error. |
Yes, everything is fine before botToastBuilder append. return MaterialApp(
builder: ExtendedNavigator.builder(
initialRoute: '/',
router: Router(),
),
// ...
); The assertion error occurred on nested builder block only. |
What is your flutter version? |
Flutter 1.22.5 |
I used the following code, did not use bot_toast at all, and reported the same error. class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
builder: (context, child) {
return child;
},
);
}
}
WidgetsApp: assert(
(home != null ||
routes.isNotEmpty ||
onGenerateRoute != null ||
onUnknownRoute != null)
||
(builder != null &&
navigatorKey == null &&
initialRoute == null &&
navigatorObservers.isEmpty),
'If no route is provided using '
'home, routes, onGenerateRoute, or onUnknownRoute, '
'a non-null callback for the builder property must be provided, '
'and the other navigator-related properties, '
'navigatorKey, initialRoute, and navigatorObservers, '
'must have their initial values '
'(null, null, and the empty list, respectively).'
) |
This error is caused by the use of builder != null &&
navigatorKey == null &&
initialRoute == null &&
navigatorObservers.isEmpty |
Yes, it is. But in this case, I used I declared some routes like below in It means the import 'package:auto_route/auto_route.dart';
import 'package:auto_route/auto_route_annotations.dart';
import 'home_page.dart';
@AdaptiveAutoRouter(
routes: <AutoRoute>[
AdaptiveRoute<void>(
initial: true,
name: 'home',
page: HomePage,
),
],
)
class $Router {} class Routes {
static const String home = '/';
static const all = <String>{
home,
};
}
class Router extends RouterBase {
@override
List<RouteDef> get routes => _routes;
final _routes = <RouteDef>[
RouteDef(Routes.home, page: HomePage),
];
@override
Map<Type, AutoRouteFactory> get pagesMap => _pagesMap;
final _pagesMap = <Type, AutoRouteFactory>{
HomePage: (data) {
return buildAdaptivePageRoute<void>(
builder: (context) => HomePage(),
settings: data,
);
},
};
} Then I add the builder function of return MaterialApp(
builder: ExtendedNavigator.builder(
initialRoute: '/',
router: Router(),
),
title: 'Title',
// ...
); That works for me. |
The code works fine. final botToastBuilder = BotToastInit();
return MaterialApp(
builder: (context, child) {
final navigatorBuilder = ExtendedNavigator.builder(
observers: [BotToastNavigatorObserver()],
router: Router(),
);
return botToastBuilder(context, navigatorBuilder(context, child));
},
title: 'Title',
); |
Oh! Everything worked! Thank you for your response 🚀 |
Describe the bug
The
home
property of MaterialApp is unnecessary when use auto_route package.But if I use this package together without the
home
property, build will be failed because assertion failure.To Reproduce
Steps to reproduce the behavior:
auto_route: ^0.6.9
andbot_toast: ^3.0.5
topubspec.yaml
flutter pub get
auto_route
andbot_toast
like belowExpected behavior
The text was updated successfully, but these errors were encountered: