0

I have a flutter application using auto_route: ^7.8.0 that is setup with the following route structure:

import 'package:auto_route/auto_route.dart';
import 'app_router.gr.dart';

@AutoRouterConfig()
class AppRouter extends $AppRouter {
  @override
  List<AutoRoute> get routes => [
        AutoRoute(page: Home.page, path: '/', initial: true),
        AutoRoute(page: BottomTabWrapper, path: ‘/wrapper’, children: [
          AutoRoute(
              page: BottomTab1.page,
              path: ‘tab1,
              initial: true,
              children: [
                AutoRoute(page: Main.page, path: '', initial: true),
                AutoRoute(page: Page2.page, path: ‘page2’),
              ]),
          AutoRoute(page: BottomTab2.page, path: ‘tab2’),
        ]),
      ];
}

And my BottomTabWrapper looks like:

@RoutePage()
class BottomTabWrapper extends StatelessWidget {
  const BottomTabWrapper({super.key});

  @override
  Widget build(BuildContext context) {
    return AutoTabsRouter(
      routes: const [BottomTab1(), BottomTab2()],
      builder: (context, child) {
        final tabsRouter = AutoTabsRouter.of(context);
        return Scaffold(
            resizeToAvoidBottomInset: true,
            body: Padding(
                padding: const EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 0.0),
                child: child),
            bottomNavigationBar: BottomNavigationBar(
              type: BottomNavigationBarType.fixed,
              currentIndex: tabsRouter.activeIndex,
              onTap: (index) {
                tabsRouter.setActiveIndex(index);
              },
              items: [
                BottomNavigationBarItem(
                  icon: Icon(Icons.Home),
                  label: 'tab2',
                ),
                const BottomNavigationBarItem(
                  icon: Icon(Icons.receipt_long_rounded),
                  label: 'tab2',
                ),
              ],
            ));
      },
    );
  }
}

When I am on the Main.page and navigating to Page2 using context.router.navigate(const Page2()) I am seeing lag/ghosting during the animation where the previous page lingers and is not scrolled through smoothly even when using --profile or --release on an actual device.

enter image description here]

diaruga11
  • 11
  • 3

1 Answers1

0

You should change your path in AutoRout as below

path: ‘tab1 => path: 'tab1'

I hope this work for you!

Pha HOEUN
  • 1
  • 1