How to create a widget test that uses go_router's StatefulNavigationShell

217 Views Asked by At

I'm trying to write a widget test for a screen that uses go_router's StatefulNavigationShell, but I'm having trouble mocking the router and getting the expected results.

This is the screen that uses StatefulNavigationShell and I want to do a widget test

class MainScreen extends StatelessWidget {
const MainScreen({
    required this.navigationShell,
    super.key,
});

final StatefulNavigationShell navigationShell;

@override
Widget build(BuildContext context) => Scaffold(
      body: Center(
        child: navigationShell,
      ),
      bottomNavigationBar: CustomNavBar(
        navigationShell: navigationShell,
      ),
    ),
  );
}

For additional context this is an example of how I implement StatefulNavigationShell in my project

0

There are 0 best solutions below