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

Stop the animations from previous screens when transitioning #76

Closed
cekrozl1 opened this issue Oct 4, 2022 · 1 comment
Closed

Stop the animations from previous screens when transitioning #76

cekrozl1 opened this issue Oct 4, 2022 · 1 comment

Comments

@cekrozl1
Copy link

cekrozl1 commented Oct 4, 2022

Hi !

Can you please have a look at this post: flutter/flutter#112824 and more specifically, the 2 last videos.

It seems that the page_transition widget is not stopping the animations from the previous pages while using a MaterialPageRoute is. Can you confirm this? Here is the full main.dart I used for this test.

import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';
import 'package:page_transition/page_transition.dart';

void main() {
  runApp(const MaterialApp(
    showPerformanceOverlay: true,
    title: 'Navigation Basics',
    home: FirstRoute(),
  ));
}

class FirstRoute extends StatelessWidget {
  const FirstRoute({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('First Route'),
      ),
      body: Center(
        child: Wrap(children: [
          SizedBox(
              height: 100,
              child: Lottie.asset('assets/img/*-gradient-dots-bg.json', fit: BoxFit.contain)),
          SizedBox(
              height: 100,
              child: Lottie.asset('assets/img/*-gradient-dots-bg.json', fit: BoxFit.contain)),
          SizedBox(
              height: 100,
              child: Lottie.asset('assets/img/*-gradient-dots-bg.json', fit: BoxFit.contain)),
          SizedBox(
              height: 100,
              child: Lottie.asset('assets/img/*-gradient-dots-bg.json', fit: BoxFit.contain)),
          SizedBox(
              height: 100,
              child: Lottie.asset('assets/img/*-gradient-dots-bg.json', fit: BoxFit.contain)),
          SizedBox(
              height: 100,
              child: Lottie.asset('assets/img/*-gradient-dots-bg.json', fit: BoxFit.contain)),
          SizedBox(
              height: 100,
              child: Lottie.asset('assets/img/*-gradient-dots-bg.json', fit: BoxFit.contain)),
          SizedBox(
              height: 100,
              child: Lottie.asset('assets/img/*-gradient-dots-bg.json', fit: BoxFit.contain)),
          SizedBox(
              height: 100,
              child: Lottie.asset('assets/img/*-gradient-dots-bg.json', fit: BoxFit.contain)),
          SizedBox(
              height: 100,
              child: Lottie.asset('assets/img/*-gradient-dots-bg.json', fit: BoxFit.contain)),
          ElevatedButton(
            child: const Text('Open route'),
            onPressed: () {
              Navigator.push(context,
                  PageTransition(child: SecondRoute(), type: PageTransitionType.bottomToTop)
                  // MaterialPageRoute(builder: (context) => const ),
                  );
            },
          ),
        ]),
      ),
    );
  }
}

class SecondRoute extends StatelessWidget {
  const SecondRoute({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Second Route'),
      ),
      body: Center(
        child: Wrap(children: [
          SizedBox(
              height: 100,
              child: Lottie.asset('assets/img/*-gradient-dots-bg.json', fit: BoxFit.contain)),
          ElevatedButton(
            onPressed: () {
              Navigator.pop(context);
            },
            child: const Text('Go back!'),
          ),
        ]),
      ),
    );
  }
}
@kalismeras61
Copy link
Owner

Use latest version and set maintainState false.

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

2 participants