【发布时间】:2019-05-27 14:06:23
【问题描述】:
我正在使用底部导航栏,而在里面我正在使用标签栏。但是标签栏有交换行为。我想禁用交换行为。所以,我使用了NeverScrollableScrollPhysics但这显示了一个错误。错误是Multiple widgets used the same GlobalKey。我为每个标签栏视图项提供了不同的键,但同样的问题出现了。
这是我的代码:
Widget build(BuildContext context) {
return new Scaffold(
key: _homeScaffoldKey,
body: new TabBarView(
physics: NeverScrollableScrollPhysics(),
children: <Widget>[
new page1(),
new page2(),
new page3(),
new page4(),
],
controller: tabController,
),
bottomNavigationBar: new Material(
color: Colors.blue,
child: new TabBar(
isScrollable: true,
indicatorColor: Color.fromRGBO(255, 25, 255, 0.0),
controller: tabController,
tabs: <Widget>[
new Tab(
icon: new Icon(Icons.accessibility),
),
new Tab(
icon: new Icon(Icons.accessibility),
),
new Tab(
icon: new Icon(Icons.accessibility),
),
new Tab(
new Icon(Icons.accessibility),
),
],
),
),
);
}
这里是错误:
I/flutter (26947): Another exception was thrown: NoSuchMethodError: The method 'dispose' was called on null.
I/flutter (26947): Another exception was thrown: Multiple widgets used the same GlobalKey.
I/flutter (26947): Another exception was thrown: Multiple widgets used the same GlobalKey.
I/flutter (26947): Another exception was thrown: NoSuchMethodError: The method 'dispose' was called on null.
【问题讨论】: