Testing Custom BottomNavbar with Mocktail - Flutter/Dart

Viewed 14

i am writing some code and i am struggling to test my navigation on my custom bottom navbar, here is my code:

BottomNavigationBar(
  key: const Key('BottomNavBar'),
  currentIndex: currentIndex,
  elevation: 10,
  selectedItemColor: const Color.fromRGBO(224, 43, 87, 1),
  items: [
    BottomNavigationBarItem(
      icon: InkWell(
        key: const Key('firstIconBottomNavBar'),
        onTap: () {
          Navigator.of(context)
              .pushReplacementNamed(PageOne.pageOneRoute);
        },
        child: const ImageIcon(
          AssetImage('assets/icons/customIcon.png'),
        ),
      ),
      label: L10n.of(context)?.firstIconTextBottomNavBar,
    ),
    BottomNavigationBarItem(
      icon: IconButton(
        key: const Key('secondIconBottomNavBar'),
        onPressed: () {
          Navigator.of(context)
              .pushReplacementNamed(PageTwo.pageTwoRoute);
        },
        icon: const Icon(Icons.currency_exchange),
      ),
      label: L10n.of(context)?.secondIconTextBottomNavBar,
    ),
  ],
);

How can i properly test this custom Widget? Im struggling with the documentation of mocktail and flutter.

0 Answers
Related