PersistentBottomNavBar
PersistentBottomNavBar copied to clipboard
Style15 and Style16 doesn't work.
Throw errors like this:
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderCustomPaint#20b8b relayoutBoundary=up8
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1940 pos 12: 'hasSize'
The relevant error-causing widget was
PersistentTabView
lib\main.dart:139
Here is my code:
PersistentTabController _controller;
bool _hideNavBar;
@override
void initState() {
super.initState();
_controller = PersistentTabController(initialIndex: 1);
_hideNavBar = false;
}
List<Widget> _buildScreens(context) {
return [
MainScreen(menuScreenContext: context, child: Start()),
MainScreen(menuScreenContext: context, child: EditTarget()),
MainScreen(menuScreenContext: context, child: Management()),
];
}
List<PersistentBottomNavBarItem> _navBarsItems() {
return [
PersistentBottomNavBarItem(
icon: Icon(CupertinoIcons.home),
title: ("XXX"),
activeColorPrimary: CupertinoColors.activeBlue,
inactiveColorPrimary: CupertinoColors.systemGrey,
routeAndNavigatorSettings: RouteAndNavigatorSettings(initialRoute: '/'),
),
PersistentBottomNavBarItem(
icon: Icon(Icons.add),
title: (""),
contentPadding: 12,
activeColorPrimary: CupertinoColors.destructiveRed,
activeColorSecondary: Colors.white,
inactiveColorPrimary: Colors.white,
routeAndNavigatorSettings: RouteAndNavigatorSettings(
initialRoute: '/',
),
),
PersistentBottomNavBarItem(
icon: Icon(CupertinoIcons.settings),
title: ("XXX"),
activeColorPrimary: CupertinoColors.activeBlue,
inactiveColorPrimary: CupertinoColors.systemGrey,
routeAndNavigatorSettings: RouteAndNavigatorSettings(initialRoute: '/'),
),
];
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: PersistentTabView(
context,
controller: _controller,
screens: _buildScreens(context),
items: _navBarsItems(),
confineInSafeArea: true,
backgroundColor: Colors.white,
handleAndroidBackButtonPress: true,
resizeToAvoidBottomInset: true,
stateManagement: true,
navBarHeight: MediaQuery.of(context).viewInsets.bottom > 0
? 0.0
: kBottomNavigationBarHeight,
hideNavigationBarWhenKeyboardShows: true,
margin: EdgeInsets.all(0.0),
popActionScreens: PopActionScreensType.all,
bottomScreenMargin: 0.0,
hideNavigationBar: _hideNavBar,
selectedTabScreenContext: (context) {
testContext = context;
},
decoration: NavBarDecoration(
colorBehindNavBar: Colors.indigo,
borderRadius: BorderRadius.circular(20.0)),
popAllScreensOnTapOfSelectedTab: true,
itemAnimationProperties: ItemAnimationProperties(
duration: Duration(milliseconds: 400),
curve: Curves.ease,
),
screenTransitionAnimation: ScreenTransitionAnimation(
animateTabTransition: true,
curve: Curves.ease,
duration: Duration(milliseconds: 200),
),
navBarStyle:
NavBarStyle.style15, // Choose the nav bar style with this property
),
);
}
And how to navigate to another existing tab ?
pushNewScreen
will add new screen that won't match my tabs.
Please fix this issue, I need this style