-
Notifications
You must be signed in to change notification settings - Fork 120
Open
Description
Describe the bug
So I followed the example to add custom animation to navigate to a page.
But it gives me an error and stuck on the loading screen forever.
To Reproduce
Steps to reproduce the behavior:
https://pub.dev/packages/splashscreen#adding-a-custom-page-tranistion I followed this example.
Expected behavior
So I expected to go to my desired page with animation when the loading is finished.
Code
Here is the code.
class MySplash extends StatefulWidget {
@override
_MySplashState createState() => _MySplashState();
}
class _MySplashState extends State<MySplash> {
@override
Widget build(BuildContext context) {
return SplashScreen(
seconds: 2,
pageRoute: _createRoute(),
title: Text(
"Birdometer",
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 30.0, color: Colors.black),
),
image: Image.asset('assets/images/bird.png'),
backgroundColor: kCardPopupBackgroundColor,
photoSize: 100,
loaderColor: Color(0xFFC5CBD6),
);
}
}
Route _createRoute() {
return PageRouteBuilder(
pageBuilder: (context, animation, secondaryAnimation) => Home(),
transitionsBuilder: (context, animation, secondaryAnimation, child) {
var begin = Offset(0.0, 1.0);
var end = Offset.zero;
var curve = Curves.ease;
var tween = Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
return SlideTransition(
position: animation.drive(tween),
child: child,
);
},
);
}
Error output
Restarted application in 990ms.
E/flutter (11091): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: Invalid argument(s): widget.navigateAfterSeconds must either be a String or Widget
E/flutter (11091): #0 _SplashScreenState.initState.<anonymous closure>
package:splashscreen/splashscreen.dart:172
E/flutter (11091): #1 _rootRun (dart:async/zone.dart:1182:47)
E/flutter (11091): #2 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (11091): #3 _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter (11091): #4 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
E/flutter (11091): #5 _rootRun (dart:async/zone.dart:1190:13)
E/flutter (11091): #6 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (11091): #7 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1021:23)
Metadata
Metadata
Assignees
Labels
No labels