我想做一个简单的主页,每当我运行程序,我得到这个错误,它一直显示相同的错误
======== Exception caught by widgets library =======================================================
The following assertion was thrown building DefaultTextStyle(debugLabel: (englishLike bodyMedium 2014).merge(blackMountainView bodyMedium), inherit: false, color: Color(0xdd000000), family: Roboto, size: 14.0, weight: 400, baseline: alphabetic, decoration: TextDecoration.none, softWrap: wrapping at box width, overflow: clip):
'package:flutter/src/widgets/framework.dart': Failed assertion: line 4675 pos 16: 'owner!._debugCurrentBuildTarget == this': is not true.
Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new?template=2_bug.md
The relevant error-causing widget was:
Scaffold Scaffold:file:///C:/Users/taehy/AndroidStudioProjects/surrfy/lib/pages/homepage.dart:30:12
When the exception was thrown, this was the stack:
#2 Element.rebuild.<anonymous closure> (package:flutter/src/widgets/framework.dart:4675:16)
#3 Element.rebuild (package:flutter/src/widgets/framework.dart:4678:8)
#4 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4934:5)
#5 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:5108:11)
#6 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4928:5)
... Normal element mounting (115 frames)
#121 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#122 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#123 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#260 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#261 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#262 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#399 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#400 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#401 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#538 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#539 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#540 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#677 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#678 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#679 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#816 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#817 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#818 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#955 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#956 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#957 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#1094 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#1095 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#1096 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#1233 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#1234 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#1235 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#1372 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#1373 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#1374 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#1511 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#1512 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#1513 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#1650 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#1651 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#1652 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#1789 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#1790 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#1791 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#1928 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#1929 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#1930 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#2067 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#2068 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#2069 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#2206 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#2207 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#2208 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#2345 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#2346 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#2347 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#2484 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#2485 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#2486 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#2623 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#2624 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#2625 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#2762 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#2763 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#2764 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#2901 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#2902 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#2903 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#3040 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#3041 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#3042 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#3179 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#3180 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#3181 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#3318 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#3319 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#3320 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#3457 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#3458 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#3459 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#3596 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#3597 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#3598 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#3735 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#3736 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#3737 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#3874 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#3875 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#3876 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#4013 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#4014 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#4015 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#4152 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#4153 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#4154 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#4291 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#4292 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#4293 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#4430 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#4431 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#4432 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#4569 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#4570 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#4571 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#4708 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#4709 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#4710 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#4847 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#4848 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#4849 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#4986 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#4987 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#4988 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#5125 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#5126 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#5127 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#5264 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#5265 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#5266 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#5403 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#5404 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#5405 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#5542 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#5543 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#5544 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#5681 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#5682 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#5683 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#5820 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#5821 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#5822 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#5959 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#5960 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#5961 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#6098 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#6099 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#6100 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#6237 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#6238 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#6239 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#6376 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#6377 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#6378 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#6515 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#6516 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#6517 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#6654 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#6655 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#6656 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#6793 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#6794 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#6795 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#6932 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#6933 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#6934 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#7071 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#7072 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#7073 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#7210 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#7211 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#7212 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#7349 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#7350 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#7351 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#7488 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#7489 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#7490 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#7627 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#7628 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#7629 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#7766 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#7767 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#7768 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#7905 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#7906 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#7907 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (137 frames)
#8044 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#8045 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#8046 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (326 frames)
#8372 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#8373 MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6491:36)
#8374 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6503:32)
... Normal element mounting (464 frames)
#8838 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3940:16)
#8839 Element.updateChild (package:flutter/src/widgets/framework.dart:3677:18)
#8840 RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:1196:16)
#8841 RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:1165:5)
#8842 RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure> (package:flutter/src/widgets/binding.dart:1112:18)
#8843 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2689:19)
#8844 RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:1111:13)
#8845 WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:945:7)
#8846 WidgetsBinding.scheduleAttachRootWidget.<anonymous closure> (package:flutter/src/widgets/binding.dart:925:7)
#8850 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:192:26)
(elided 5 frames from class _AssertionError, class _Timer, and dart:async-patch)
====================================================================================================
我发现这部分:body: _items[_selectedIndex],
在我的代码中使它发生。
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:surrfy/navbar_pages/favorites.dart';
import 'package:surrfy/navbar_pages/profile.dart';
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
int _selectedIndex = 0;
void _navigatorBottomNavBar(int index) {
setState(() {
_selectedIndex = index;
});
}
final List<Widget> _items = [
HomePage(),
Favorites(),
Profiles(),
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: _items[_selectedIndex],
bottomNavigationBar: BottomNavigationBar(
currentIndex: _selectedIndex,
onTap: _navigatorBottomNavBar,
type: BottomNavigationBarType.fixed,
items: [
BottomNavigationBarItem(icon: Icon(Icons.home, size: 35,), label: '',),
BottomNavigationBarItem(icon: Icon(Icons.favorite_outline, size: 35,), label: '',),
BottomNavigationBarItem(icon: Icon(Icons.person_outline_rounded, size: 35,), label: '',),
],
),
);
}
}
这是完整的代码。
我想做一个底部导航栏,当我按下图标时让页面改变,但是这个错误一直出现
你的代码生成了一个无限循环,在这里创建嵌套的主页小部件:身体:_items [_selectedIndex]
你可以更新_items变量来停止这个错误:
final List<Widget> _items = [
Text('Home Page'),
Favorites(),
Profiles(),
];
希望对你有帮助。