1

I have a NavBar with some items. For one specific item I would like to push with a Navigator, for the other ones I am using a Global-PageView. My problem is that my app is crashing when trying to add the Navigator.push... :

This is where I build the navBarItems (the 2nd one is the relevant one):

List<BottomNavBarItem> _buildBottomNavBarItems(BuildContext context) {
  return [
  BottomNavBarItem(
    index: 0,
    selectedIndex: Provider.of<BottomNavBarProvider>(context, listen: true)
        .selectedTabIndex,
    text: 'Startseite',
    iconBaseUrl: 'images/icons/home_',
    onTap:
        Provider.of<BottomNavBarProvider>(context, listen: false).selectTab,
  ),
  BottomNavBarItem(
    index: 1,
    selectedIndex: Provider.of<BottomNavBarProvider>(context, listen: true)
        .selectedTabIndex,
    text: 'Eintrag',
    iconBaseUrl: 'images/icons/add_black.png',
    hasDynamicIconColor: false,
    onTap: () {
      Navigator.push(
        context,
        PageTransition(
          type: PageTransitionType.bottomToTop,
          child: EntryPage(),
          duration: Duration(milliseconds: 200),
          reverseDuration: Duration(milliseconds: 200),
          curve: Curves.easeInOut,
        ),
      );
    },
  ),
  BottomNavBarItem(
    index: 2,
    selectedIndex: Provider.of<BottomNavBarProvider>(context, listen: true)
        .selectedTabIndex,
    text: 'Verlauf',
    iconBaseUrl: 'images/icons/progress_',
    onTap:
        Provider.of<BottomNavBarProvider>(context, listen: false).selectTab,
  ),

When tapping the item at index 1 this is the error I get:

Closure call with mismatched arguments: function 'BottomNavBarState._buildBottomNavBarItems.<anonymous closure>'
Receiver: Closure: () => Null
Tried calling: BottomNavBarState._buildBottomNavBarItems.<anonymous closure>(1)
Found: BottomNavBarState._buildBottomNavBarItems.<anonymous closure>() => Null

My Provider (which is working just fine) looks like this:

class BottomNavBarProvider extends ChangeNotifier {
  final PageController navigationController = PageController(initialPage: 0);
  int selectedTabIndex = 0;

  BottomNavBarProvider() {}

  void selectTab(int index) {
    navigationController.jumpToPage(index);
    selectedTabIndex = navigationController.page?.round() ?? 0;
    notifyListeners();
  }
}

What am I missing here? Let me know if you need any more details!

Chris
  • 1,828
  • 6
  • 40
  • 108

0 Answers0