【发布时间】:2019-11-16 11:19:41
【问题描述】:
我正在尝试在颤振中构建一个底部弯曲导航栏,我尝试了很多示例,但对我没有任何帮助。即使我使用了与他们官方网站上相同的示例,但什么也没发生。 我正在尝试在颤振中构建一个底部弯曲的导航栏,我尝试了很多示例,但对我没有任何帮助。即使我使用了与他们官方网站上相同的示例,但什么也没发生。
import 'package:flutter/material.dart';
import 'package:curved_navigation_bar/curved_navigation_bar.dart';
void main() => runApp(MaterialApp(home: BottomNavBar()));
class BottomNavBar extends StatefulWidget {
@override
_BottomNavBarState createState() => _BottomNavBarState();
}
class _BottomNavBarState extends State<BottomNavBar> {
int _page = 0;
GlobalKey _bottomNavigationKey = GlobalKey();
@override
Widget build(BuildContext context) {
return Scaffold(
bottomNavigationBar: CurvedNavigationBar(
key: _bottomNavigationKey,
index: 0,
height: 50.0,
items: <Widget>[
Icon(Icons.add, size: 30),
Icon(Icons.list, size: 30),
Icon(Icons.compare_arrows, size: 30),
Icon(Icons.call_split, size: 30),
Icon(Icons.perm_identity, size: 30),
],
color: Colors.white,
buttonBackgroundColor: Colors.white,
backgroundColor: Colors.blueAccent,
animationCurve: Curves.easeInOut,
animationDuration: Duration(milliseconds: 600),
onTap: (index) {
setState(() {
_page = index;
});
},
),
body: Container(
color: Colors.blueAccent,
child: Center(
child: Column(
children: <Widget>[
Text(_page.toString(), textScaleFactor: 10.0),
RaisedButton(
child: Text('Go To Page of index 1'),
onPressed: () {
final CurvedNavigationBarState navBarState =
_bottomNavigationKey.currentState;
navBarState.setPage(1);
},
)
],
),
),
));
}
}
【问题讨论】:
-
对我来说一切正常。我在 iOS 虚拟设备上试用了 Flutter 1.9.1+hotfix.6 • 通道稳定。你有什么配置?
-
assert(items != null), assert(items.length >= 2), assert( items.every((BottomNavigationBarItem item) => item.title != null) == true, '每个项目都必须有一个非空标题',
-
这是个例外
-
您使用哪个版本的库?库版本 0.3.1 中没有
assert(items.length >= 2),因此请尝试使用flutter pub get更新您的库,并让我知道发生错误的文件是什么。 -
我正在使用 ^0.3.1
标签: android ios flutter dart navigation