我在我的颤振项目中使用 bottomNavigationBar 我是颤振的新手,我不知道分页和使用资产图像图标而不是 iconData。我在过去 2 天里搜索了它,但没有得到满意的结果。请帮我......
我在这里使用了带有 fab 按钮的底部导航栏 https://medium.com/coding-with-flutter/flutter-bottomappbar-navigation-with-fab-8b962bb55013 https://github.com/bizz84/bottom_bar_fab_flutter
我还尝试从这里使用自定义图标 https://medium.com/flutterpub/how-to-use-custom-icons-in-flutter-834a079d977
但没有成功
我只想更改图标并想知道如何使用分页。我可以在最后一个分页示例代码中做哪些更改。
In my application I have a button navigator bar.
I am implementing multi navigation with bottom navigation bar as shown here; https://medium.com/coding-with-flutter/flutter-case-study-multiple-navigators-with-bottomnavigationbar-90eb6caa6dbf
I have put the title text like this.
BottomNavigationBarItem _buildItem(
{TabItem tabItem, String tabText, IconData iconData}) {
return BottomNavigationBarItem(
icon: Icon(
iconData,
color: widget.currentTab == tabItem
? active_button_color
: Colors.grey,
),
//label: tabText,
title: Text(
tabText,
style: widget.currentTab == tabItem
? Archivo_12_0xff002245
: Archivo_12_grey,
),
);
Run Code Online (Sandbox Code Playgroud)
I get message title is deprecated.
When I use the label parameter …
在我的应用程序中,我有一个搜索页面,当我单击搜索文本字段时,底部导航栏也会随键盘一起向上移动,它应该隐藏在键盘下方。因为当键盘显示时我可以导航到其他页面,这是不良行为。
代码:
class _AppHomeViewState extends State<AppHomeView>
with TickerProviderStateMixin {
TabController tabController;
@override
void initState() {
super.initState();
tabController = TabController(length: 4, vsync: this, initialIndex: 0);
tabController.addListener(handleTabSelection);
}
@override
Widget build(BuildContext context) {
final scaffold = Scaffold(
body: SafeArea(child: _buildBody(context)),
bottomNavigationBar: Container(
height: 48,
decoration: BoxDecoration(
color: StyledColors.BACKGROUND_COLOR,
boxShadow: [
BoxShadow(
color: StyledColors.FORGROUND_COLOR.withOpacity(0.16),
blurRadius: 12,
offset: Offset(0, 0),
),
],
),
child: SafeArea(
child: _buildTabBar(context),
),
),
);
}
Widget _buildBody(BuildContext context) {
return TabBarView(
physics: NeverScrollableScrollPhysics(),
controller: tabController,
children: <Widget>[
HomeView(), …Run Code Online (Sandbox Code Playgroud) 关于使用索引堆栈在选项卡之间导航以显示相关页面的问题。我这样做是为了保持页面的滚动/状态。这工作正常。我可以通过单击选项卡更改当前显示的页面 - 也可以在每个页面内导航(每个页面都用它自己的导航器包装)。这是渲染页面的代码。
Widget build(BuildContext context) {
return IndexedStack(
index: widget.selectedIndex,
children: List.generate(widget._size, (index) {
return _buildNavigator(index);
}));
Run Code Online (Sandbox Code Playgroud)
}
Mu 的问题是 IndexedStack 一次构建所有页面。在我的某些页面中,我想从 API 加载数据,我想在第一次构建小部件时执行此操作,并且仅当页面当前可见时才执行此操作。有没有办法这样做?在我当前的实现中,所有小部件都会同时构建,因此即使对于当前未绘制的页面,也会调用我的所有 API 调用。
不确定我是否在这里遗漏了什么,或者有更好的方法来实现底部导航栏。顺便说一句,我也在使用 Provider 进行状态管理。
pub 上有一个包https://pub.dev/packages/gradient_bottom_navigation_bar
但这已经很长时间没有更新了。那么,有没有办法创建自己的具有渐变效果的自定义导航栏呢?
我正在使用带有页面绑定的 getx 导航 - 例如:
GetPage(
name: Routes.pageone,
page: () => PageOne(),
binding: PageOneBinding(),
),
GetPage(
name: Routes.pagetwo,
page: () => PageTwo(),
binding: PageTwoBinding(),
),
GetPage(
name: Routes.pagethree,
page: () => PageThree(),
binding: PageThreeBinding(),
),
Run Code Online (Sandbox Code Playgroud)
每个页面都有自己的控制器和绑定。
通常,为了导航到其他页面,我会
Get.toNamed(Routes.pageone)像这样使用路由。
但是,当我使用选项卡栏/底部导航栏时,我想保留脚手架的应用程序栏和底部导航栏,而只需使用 getx 切换内容。我能够做的唯一方法是为所有页面提供脚手架,并在每次单击每个选项卡时重新加载所有内容,这是低效的,并且每次切换到页面时都会加载不必要的小部件(应用程序栏、标题、底部导航栏等) .)。
加载选项卡内容的常用方法如下
List<Widget> _widgetOptions = <Widget>[
PageOne(),
PageTwo(),
PageThree(),
];
Run Code Online (Sandbox Code Playgroud)
不使用 getx GetPage() 进行绑定,并且会加载所有页面的所有控制器。我找不到使用 GetPage() 和底部导航栏的正确参考。
例如,加载应用程序时我的导航堆栈将/main/pageone在每次切换选项卡时将每个页面堆叠到我的堆栈中。(/main/pageone单击 tab3-> /main/pageone/pagethree)当我按下每个选项卡时,该选项卡的控制器将被加载,并且先前的控制器将被删除。
我不确定应该将什么放入body脚手架中,该脚手架会接收小部件,但使用带有绑定的 GetPage 让我感到困惑。
这是我的应用程序的页面文件代码
class MyPage extends GetView<MyPageController> {
@override …Run Code Online (Sandbox Code Playgroud) flutter flutter-navigation flutter-bottomnavigation flutter-getx
有人可以帮我解决这个问题吗?我目前找到的唯一解决方案是将 showSelectedLabels 和 showUnselecedLabels 设置为 false。但是,这将删除所有标签,但我只想删除添加按钮的标签。如果我只使用占位符“”作为标签,我的添加按钮就会水平偏离中心......
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: tabs[_selectedIndex],
),
bottomNavigationBar: BottomNavigationBar(
elevation: 10,
backgroundColor: Colors.white,
type: BottomNavigationBarType.fixed,
selectedIconTheme: IconThemeData(color: kPrimaryMagentaColor),
selectedLabelStyle: TextStyle(fontWeight: FontWeight.w500),
selectedItemColor: Colors.black,
showSelectedLabels: true,
showUnselectedLabels: true,
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Container(
padding: kBottomNavIconLabelSpace,
child: Icon(
FeatherIcons.map,
size: 26.5,
),
),
label: 'Map',
),
BottomNavigationBarItem(
icon: Container(
padding: kBottomNavIconLabelSpace,
child: Icon(
FeatherIcons.compass,
size: 28,
),
),
label: 'Discover',
),
BottomNavigationBarItem(
icon: Container(
decoration: BoxDecoration(
color: kPrimaryMagentaColor,
shape: BoxShape.circle, …Run Code Online (Sandbox Code Playgroud) 我想将横幅广告放置在 Flutter 的google_mobile_ads上方或下方。BottomNavigationBar
我尝试将 BottomNavigationBar 放置在Containerad add Margin 中,但没有选项可以在 Container 内添加 2 个子项。
我尝试Column在其中添加一个小部件,BottomNavigationBar但该列转到页面的顶部。
关于如何在 的google_mobile_ads上方或下方留出一个位置有什么想法吗BottomNavigationBar?
我可以共享代码,但我需要有关如何实现它的建议、指导或指示。
我想使用底部导航栏上的路线和 Navigator.pushNamed() 浏览页面。在这里,我使用 FlashyTab 栏来提高美观性。更具体地说,按导航栏上的每个图标应该会将我带到不同的页面,我想使用路线来实现这一点。
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Scaffold(
bottomNavigationBar: FlashyTabBar(
animationCurve: Curves.linear,
selectedIndex: _selectedIndex,
showElevation: true,
onItemSelected: (index) => setState(() {
_selectedIndex = index;
}),
items: [
FlashyTabBarItem(
icon: const Icon(Icons.account_box),
title: const Text('Challenger'),
),
FlashyTabBarItem(
icon: const Icon(Icons.phone),
title: const Text('Contact'),
),
FlashyTabBarItem(
icon: const Icon(Icons.dashboard_rounded),
title: const Text('Events'),
),
FlashyTabBarItem(
icon: const Icon(Icons.badge),
title: const Text('Quick Scan'),
),
],
),
body:
);
}
Run Code Online (Sandbox Code Playgroud)