自定义底部导航栏项目(提取为小部件)
我如何提取底部努力范围,以便拥有更可读的代码并重复使用该项目窗口小部件?
如果我在无状态小部件中提取它们,我会发现一个错误:
无法分配到列表类型'bottomNavigationBariTem'
BottomNavigationBarItem(
icon: Container(
decoration: const BoxDecoration(
color: Colors.black,
shape: BoxShape.circle,
),
height: 56,
width: 56,
child: const Icon(Icons.favorite),
),
label: '')
内提取容器,但是我想提取整个小部件。 先感谢您!
How can I extract BottomNavigationBarItem in order to have a more readable code and reuse the item widget?
If I extract them in a Stateless Widget I get an error:
can't be assigned to the list type 'BottomNavigationBarItem'
BottomNavigationBarItem(
icon: Container(
decoration: const BoxDecoration(
color: Colors.black,
shape: BoxShape.circle,
),
height: 56,
width: 56,
child: const Icon(Icons.favorite),
),
label: '')
I know I could extract the Container inside the icon property, but I'd like to extract the whole Widget.
Thank you in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要为特定小部件创建任何方法,您需要定义该项目的返回类型。
您可以在底部导航项目列表中调用此GetItem。
For creating any method for the particular widget , you need to define return type of that item.eg.
And you can call this getItem inside your Bottom Navigation item List.