Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rexludus opened this issue May 11, 2023 · 2 comments
Open

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

rexludus opened this issue May 11, 2023 · 2 comments

Comments

@rexludus
Copy link

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
Copy link

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants