我正在使用
NavigationBar
构建 Material Design 3
,这基本上是一个新的 bottom navigation bar
。在 NavigationBar
上有一个名为 NavigationBarTheme
的小部件,我可以在其中放置 indicator
颜色。现在的问题是 indicator
颜色是 Color
类型,我想用 Gradient Color
类型显示它。我在互联网上查了好几个小时,但找不到将 Color
类型转换为 Gradient Color
类型的解决方案。下面是示例代码
NavigationBarTheme(
data: NavigationBarThemeData(
indicatorColor: const Color(0xFF5fc9b9), // Here want to show in gradient color
indicatorShape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
labelTextStyle: MaterialStateProperty.all(
GoogleFonts.almarai(fontSize: 12, fontWeight: FontWeight.w600))),
child: NavigationBar(
selectedIndex: widget.index,
destinations: [
NavigationDestination(
icon: const Icon(Icons.meeting_room_outlined),
selectedIcon: const Icon(
Icons.meeting_room_rounded,
color: Colors.white,
),
label: listOfMeetings),
NavigationDestination(
icon: const Icon(Icons.account_balance_outlined),
selectedIcon: const Icon(
Icons.account_balance_rounded,
color: Colors.white,
),
label: financialData),
],
),
);