ToyZ-95/another_flutter_splash_screen

allow no `defaultNextScreen` nor `setNextScreenAsyncCallback`

Closed this issue · 3 comments

I'm using auto_route, I want to implement my own navigation logic, which will push auto_route's own PageRouteInfo object:

FlutterSplashScreen(
      defaultNextScreen: null,
      onEnd: context.router.replaceAll([const HomeRoute()]),
      ...
)

But even though I provided defaultNextScreen: null, it seems like FlutterSplashScreen is still trying to navigate somewhere. This error gets printed to my console:

'package:flutter/src/widgets/navigator.dart': Failed assertion: line 3040 pos 7: '!pageBased || isWaitingForExitingDecision': A page-based route cannot be completed using imperative api, provide a new list without the corresponding Page to Navigator.pages instead. 
#0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
#1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
#2      _RouteEntry.complete (package:flutter/src/widgets/navigator.dart:3040:7)
#3      NavigatorState._pushReplacementEntry (package:flutter/src/widgets/navigator.dart:4661:56)
#4      NavigatorState.pushReplacement (package:flutter/src/widgets/navigator.dart:4617:5)
#5      Navigator.pushReplacement (package:flutter/src/widgets/navigator.dart:2187:34)
#6      _FlutterSplashScreenState.initState.<anonymous closure> (package:another_flutter_splash_screen/another_flutter_splash_screen.dart:303:17)
#7      new Future.delayed.<anonymous closure> (dart:async/future.dart:427:39)
#8      Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
#9      _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
#10     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
#11     _RawReceivePort._handleMessage (dart:isolate-pa

Here is the code from FlutterSplashScreen that's causing this issue:

widget.onEnd?.call();
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (BuildContext context) {
return widget.defaultNextScreen ?? Container();
},
),
);
});

As you can see, even if a null is passed, it will still try to push an empty Container(). I would prefer if it did nothing, or if there would be a boolean parameter to disable navigation.

@dJani97 Sure, We will fix the issue ASAP

Hi, @michalss thanks for reporting the issue. It will be fixed this weekend as I will get some free time to work on. I will update you as soon as it is fixed.

@dJani97 Fixed