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

Hero issue onFinish and skipFunctionOverride with GoRouter #296

Open
baptistesx opened this issue Jul 24, 2024 · 0 comments
Open

Hero issue onFinish and skipFunctionOverride with GoRouter #296

baptistesx opened this issue Jul 24, 2024 · 0 comments
Assignees
Labels
Appinio onboarding slider This label is used to indicate that this issue belongs to Appinio onboarding slider plugin

Comments

@baptistesx
Copy link

baptistesx commented Jul 24, 2024

Plugin name
flutter_onboarding_slider

Describe the bug

Here is my OnBoardingPage with the Slider:

class OnBoardingPage extends StatelessWidget {

  const OnBoardingPage({super.key});

  @override
  Widget build(BuildContext context) {
    return OnBoardingSlider(
      headerBackgroundColor: Theme.of(context).colorScheme.background,
      pageBackgroundColor: Theme.of(context).colorScheme.background,
      controllerColor: Theme.of(context).primaryColor,
      finishButtonText: 'Register',
      finishButtonStyle: const FinishButtonStyle(
        backgroundColor: Colors.black,
      ),
      skipTextButton: const Text('Skip'),
      skipFunctionOverride: () => const SigninRoute().go(context),
      trailing: const Text('Login'),
      onFinish: () => const SigninRoute().go(context),
      background: <Widget>[
        Image.asset(
          'assets/images/onboarding/img1.jpg',
          width: MediaQuery.of(context).size.width,
        ),
        Image.asset(
          'assets/images/onboarding/img2.jpg',
          width: MediaQuery.of(context).size.width,
        ),
        Image.asset(
          'assets/images/onboarding/img3.jpg',
          width: MediaQuery.of(context).size.width,
        ),
      ],
      totalPage: 3,
      speed: 1.8,
      pageBodies: <Widget>[
        Container(
          alignment: Alignment.center,
          width: MediaQuery.of(context).size.width,
          padding: const EdgeInsets.symmetric(horizontal: 40),
          child: Column(
            children: <Widget>[
              const SizedBox(
                height: 480,
              ),
              Text(
                'On your way...',
                textAlign: TextAlign.center,
                style: Theme.of(context).textTheme.headlineLarge?.copyWith(
                      color: Theme.of(context).primaryColor,
                    ),
              ),
              const SizedBox(
                height: 16,
              ),
              Text(
                'to find the perfect looking Onboarding for your app?',
                textAlign: TextAlign.center,
                style: Theme.of(context).textTheme.bodyLarge,
              ),
            ],
          ),
        ),
        Container(
          alignment: Alignment.center,
          width: MediaQuery.of(context).size.width,
          padding: const EdgeInsets.symmetric(horizontal: 40),
          child: Column(
            children: <Widget>[
              const SizedBox(
                height: 480,
              ),
              Text(
                'Still on your way...',
                textAlign: TextAlign.center,
                style: Theme.of(context).textTheme.headlineLarge?.copyWith(
                      color: Theme.of(context).primaryColor,
                    ),
              ),
              const SizedBox(
                height: 16,
              ),
              Text(
                'Second slide text',
                textAlign: TextAlign.center,
                style: Theme.of(context).textTheme.bodyLarge,
              ),
            ],
          ),
        ),
        Container(
          alignment: Alignment.center,
          width: MediaQuery.of(context).size.width,
          padding: const EdgeInsets.symmetric(horizontal: 40),
          child: Column(
            children: <Widget>[
              const SizedBox(
                height: 450,
              ),
              Text(
                'You are almost there...',
                textAlign: TextAlign.center,
                style: Theme.of(context).textTheme.headlineLarge?.copyWith(
                      color: Theme.of(context).primaryColor,
                    ),
              ),
              const SizedBox(
                height: 16,
              ),
              Text(
                'Customize the Onboarding to your needs',
                textAlign: TextAlign.center,
                style: Theme.of(context).textTheme.bodyLarge,
              ),
            ],
          ),
        ),
      ],
    );
  }
}

I'm using GoRouter (and GoRouterGenerator). I need to push the SigninRoute on skip and finish.

I receive this error:

═══════ Exception caught by scheduler library ═════════════════════════════════
The following assertion was thrown during a scheduler callback:
'package:flutter/src/widgets/heroes.dart': Failed assertion: line 657 pos 12: '() {
      final Animation<double> initial = initialManifest.animation;
      final HeroFlightDirection type = initialManifest.type;
      switch (type) {
        case HeroFlightDirection.pop:
          return initial.value == 1.0 && initialManifest.isUserGestureTransition
              // During user gesture transitions, the animation controller isn't
              // driving the reverse transition, but should still be in a previously
              // completed stage with the initial value at 1.0.
              ? initial.status == AnimationStatus.completed
              : initial.status == AnimationStatus.reverse;
        case HeroFlightDirection.push:
          return initial.value == 0.0 && initial.status == AnimationStatus.forward;
      }
    }()': is not true.

Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.yml

When the exception was thrown, this was the stack:
#2      _HeroFlight.start (package:flutter/src/widgets/heroes.dart:657:12)
heroes.dart:657
#3      HeroController._startHeroTransition (package:flutter/src/widgets/heroes.dart:992:60)
heroes.dart:992
#4      HeroController._maybeStartHeroTransition.<anonymous closure> (package:flutter/src/widgets/heroes.dart:914:9)
heroes.dart:914
#5      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1432:15)
binding.dart:1432
#6      SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1362:11)
binding.dart:1362
#7      SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1203:5)
binding.dart:1203
#8      _invoke (dart:ui/hooks.dart:312:13)
hooks.dart:312
#9      PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:399:5)
platform_dispatcher.dart:399
#10     _drawFrame (dart:ui/hooks.dart:283:31)
hooks.dart:283
(elided 2 frames from class _AssertionError)
════════════════════════════════════════════════════════════════════════════════

then it navigates.

Here are my routes:

class OnboardingRoute extends GoRouteData {
  const OnboardingRoute();

  @override
  Widget build(BuildContext context, GoRouterState state) {
    return const OnBoardingPage();
  }
}

class SigninRoute extends GoRouteData {
  const SigninRoute();

  @override
  Widget build(BuildContext context, GoRouterState state) {
    return const SigninPage();
  }
}

@TypedGoRoute<OnboardingRoute>(
  path: '/onboarding',
  routes: <TypedRoute<RouteData>>[
    TypedGoRoute<SigninRoute>(
      path: 'signin',
    ),
  ],
)

Any Idea?

@khanmujeeb687 khanmujeeb687 added the Appinio onboarding slider This label is used to indicate that this issue belongs to Appinio onboarding slider plugin label Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Appinio onboarding slider This label is used to indicate that this issue belongs to Appinio onboarding slider plugin
Projects
None yet
Development

No branches or pull requests

2 participants