Skip to content
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

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

Open
AbhijitL opened this issue Jan 28, 2021 · 5 comments

Comments

@AbhijitL
Copy link

AbhijitL commented Jan 28, 2021

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
Copy link
Member

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

@ahmedmgh67
Copy link
Member

@AbhijitL

@AbhijitL
Copy link
Author

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

@11dj
Copy link

11dj commented Feb 4, 2021

I got the same issue and error like this too

@ghost
Copy link

ghost commented Feb 14, 2021

I double it. Does not work in this configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants