BilalShahid13 / PersistentBottomNavBar

A highly customizable persistent bottom navigation bar for Flutter
BSD 3-Clause "New" or "Revised" License
507 stars 368 forks source link

style15 returns "Null check operator used on a null value" #335

Open rexludus opened 1 year ago

rexludus commented 1 year ago

what am i missing in here?

here is my code:

`import 'package:airfryer_delight/features/add_recipe/views/add_recipe.dart'; import 'package:flutter/material.dart'; import 'package:persistent_bottom_nav_bar/persistent_tab_view.dart';

import '../../helpers/colorbook.dart'; import '../articles/views/articles.dart'; import '../home/views/home.dart'; import '../profile/views/profile.dart'; import '../recipes/views/recipes.dart';

class BNB extends StatefulWidget { const BNB({Key? key}) : super(key: key);

@override State createState() => _BNBState(); }

class _BNBState extends State { final int _selectedIndex = 0;

List _buildScreens() { return [ HomeScreen(), RecipesScreen(), AddRecipeScreen(), ArticlesScreen(), ProfileScreen(), ]; }

List _navBarsItems() { return [ PersistentBottomNavBarItem( icon: Icon(Icons.home), activeColorPrimary: activeColor, inactiveColorPrimary: Colors.grey, ), PersistentBottomNavBarItem( icon: Icon(Icons.restaurant), activeColorPrimary: activeColor, inactiveColorPrimary: Colors.grey, ), PersistentBottomNavBarItem( // icon: Icon(Icons.add, color: Colors.white), icon: Icon(Icons.add), activeColorPrimary: activeColor, inactiveColorPrimary: Colors.grey, ), PersistentBottomNavBarItem( icon: Icon(Icons.article), activeColorPrimary: activeColor, inactiveColorPrimary: Colors.grey, ), PersistentBottomNavBarItem( icon: Icon(Icons.person), activeColorPrimary: activeColor, inactiveColorPrimary: Colors.grey, ), ]; }

@override Widget build(BuildContext context) { return Scaffold( body: PersistentTabView( context, controller: PersistentTabController(initialIndex: _selectedIndex), screens: _buildScreens(), items: _navBarsItems(), confineInSafeArea: true, handleAndroidBackButtonPress: true, resizeToAvoidBottomInset: true, stateManagement: true, hideNavigationBarWhenKeyboardShows: true, popAllScreensOnTapOfSelectedTab: true, popActionScreens: PopActionScreensType.all, itemAnimationProperties: ItemAnimationProperties( // Navigation Bar's items animation properties. duration: Duration(milliseconds: 200), curve: Curves.ease, ), screenTransitionAnimation: ScreenTransitionAnimation( // Screen transition animation on change of selected tab. animateTabTransition: true, curve: Curves.ease, duration: Duration(milliseconds: 200), ), navBarStyle: NavBarStyle.style15, navBarHeight: MediaQuery.of(context).viewInsets.bottom > 0 ? 0.0 : kBottomNavigationBarHeight, ), ); } } `

diegoalex commented 6 months ago

HI, I've figured out the issue while setting the style 15.

It happens because it's requiring to set the decoration border radius.

image

Setting the decoration on your PersistentTabView will fix this problem.

image
5exceptions-megharaypuriya commented 2 months ago

I am still getting issue with above code

NavBar styles 15-18 only accept 3 or 5 PersistentBottomNavBarItem items. 'package:persistent_bottom_nav_bar/persistent_tab_view.widget.dart': Failed assertion: line 43 pos 16: 'assertMidButtonStyles(navBarStyle, items!.length)'