'package:flutter/src/widgets/scroll_controller.dart':断言失败:第 113 行 pos 12:'_positions.length == 1':ScrollController 附加到多个滚动视图。
出现错误后底部导航栏停止更改当前页面的综合浏览量。
PageController pageController;
class MainController extends StatefulWidget {
@override
_MainControllerState createState() => _MainControllerState();
}
class _MainControllerState extends State<MainController>
with TickerProviderStateMixin {
@override
void initState() {
// TODO: implement initState
super.initState();
pageController = PageController(initialPage: 0, keepPage: true);
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
pageController.dispose();
}
PagesList() {
return BlocBuilder<BottomnavbarcubitCubit, BottomnavbarcubitState>(
builder: (context, state) {
return Scaffold(
body: PageView(
allowImplicitScrolling: true,
controller: pageController,
onPageChanged: (int index) => state.currentIndex = index,
children: [
NotificationsScreen(),
NotificationsScreen(),
NotificationsScreen(),
NotificationsScreen(),
],
),
bottomNavigationBar: NormalNavBar(),
);
},
);
}
}
Bottomnavbar 的 onTap 函数会产生错误
try {
if (pageController.hasClients)
await pageController.animateToPage(state.currentIndex,
duration: Duration(milliseconds: 500),
curve: Curves.elasticOut);
} catch (err) {
print(err);
}
E/flutter (30081): #18 GestureBinding._handlePointerEvent
package:flutter/…/gestures/binding.dart:295
E/flutter (30081): #19 GestureBinding._flushPointerEventQueue
package:flutter/…/gestures/binding.dart:240
E/flutter (30081): #20 GestureBinding._handlePointerDataPacket
package:flutter/…/gestures/binding.dart:213
E/flutter (30081): #21 _rootRunUnary (dart:async/zone.dart:1206:13)
E/flutter (30081): #22 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (30081): #23 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter (30081): #24 _invoke1 (dart:ui/hooks.dart:265:10)
E/flutter (30081): #25 _dispatchPointerDataPacket (dart:ui/hooks.dart:174:5)
答案 0 :(得分:0)
当从 firestore 获取数据被取消时发生。然后底部导航栏在重新启动应用程序之前不起作用。