DPLYR-dev / SplashScreenFlutterPackage

A small splashscreen used as intro for flutter applications easily with a lot of customizations ❤️🥳
MIT License
294 stars 122 forks source link

Doesn't navigate to page after loading is finish when using custom animation #60

Open AbhijitL opened 3 years ago

AbhijitL commented 3 years ago

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)
ahmedmgh67 commented 3 years ago

Please add the navigateAfterSeconds field Try it and tell me the updates

ahmedmgh67 commented 3 years ago

@AbhijitL

AbhijitL commented 3 years ago

@ahmedmgh67 sorry for the late reply and nope it doesn't work.

11dj commented 3 years ago

I got the same issue and error like this too

ghost commented 3 years ago

I double it. Does not work in this configuration.