PersistentBottomNavBar icon indicating copy to clipboard operation
PersistentBottomNavBar copied to clipboard

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

Open rexludus opened this issue 2 years ago • 2 comments

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<BNB> createState() => _BNBState(); }

class _BNBState extends State<BNB> { final int _selectedIndex = 0;

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

List<PersistentBottomNavBarItem> _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, ), ); } } `

rexludus avatar May 11 '23 09:05 rexludus

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

diegoalex avatar Dec 04 '23 10:12 diegoalex

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)'