【发布时间】:2021-02-20 15:17:31
【问题描述】:
【问题讨论】:
标签: flutter flutter-widget flutter-bottomnavigation
【问题讨论】:
标签: flutter flutter-widget flutter-bottomnavigation
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: Icon(Icons.add),
elevation: 2.0,
),
bottomNavigationBar: BottomAppBar(
clipBehavior: Clip.antiAlias,
notchMargin: 5,
shape: CircularNotchedRectangle(),
child: Wrap(
children: [
BottomNavigationBar(
type: BottomNavigationBarType.fixed,
currentIndex: 0,
onTap: (int index) {},
items: [
BottomNavigationBarItem(icon: Icon(Icons.radio), label: 'A'),
BottomNavigationBarItem(icon: Icon(Icons.radio), label: 'A'),
BottomNavigationBarItem(icon: Icon(Icons.radio), label: 'A'),
BottomNavigationBarItem(icon: Icon(Icons.radio), label: 'A'),
],
),
],
),
),
检查此代码。
【讨论】:
看看这个包:convex_bottom_bar。
可以通过编写一个扩展 NotchedShape 的类并实现包含缺口曲线逻辑的 getOuterPath 来自定义缺口形状。检查这个以了解确切的实现convex_shape.dart
在底部有一个绿色图标:
import 'package:convex_bottom_bar/convex_bottom_bar.dart';
Scaffold(
bottomNavigationBar: ConvexAppBar(
items: [
TabItem(icon: Icons.home, title: 'Left'),
TabItem(icon: new Icon(Icons.add, color: Colors.green,), activeIcon: new Icon(Icons.add, color: Colors.green,) title: 'Middle'),
TabItem(icon: Icons.message, title: 'Right'),
],
initialActiveIndex: 2,//optional, default as 0
onTap: (int i) => print('click index=$i'),
)
);
【讨论】:
activeIcon 等于icon(如果未提供)。所以你应该能够在没有activeIcon的情况下实现你想要的(固定的绿色)