【发布时间】:2021-11-13 14:11:34
【问题描述】:
脚手架的原因底部导航栏没有响应并且App UI刚刚进入了一个while循环 1:看来我取得了循环进展 2:我这周应该给这个应用程序 3:我是 Flutter 的新手
所以我想问问大家,也许有人可以向我解释为什么我会收到这个错误,这是什么意思,以及如何摆脱它。
这个问题有什么答案吗?
import 'package:MeeM/pages/notification.dart';
import 'package:MeeM/pages/user.dart';
import 'package:flutter/material.dart';
import 'package:MeeM/pages/Home.dart';
import 'package:MeeM/pages/search.dart';
import 'package:MeeM/add/add.dart';
import 'package:MeeM/profileUI/profile.dart';
import 'package:MeeM/pages/signup_page.dart';
// ignore: camel_case_types
class nav extends StatefulWidget {
@override
_navState createState() => _navState();
}
// ignore: camel_case_types
class _navState extends State<nav> {
int _currentindex = 0;
List<Widget> _widgeroption = <Widget>[
Home(currentUser: currentUser),
search(),
add(currentUser: currentUser),
notification(),
profile(profileId: currentUser?.id),
];
void _onItemTap(int index) {
setState(() {
_currentindex = index;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: IndexedStack(
index: _currentindex,
children: _widgeroption,
),
bottomNavigationBar: BottomNavigationBar(
elevation: 0,
type: BottomNavigationBarType.fixed,
backgroundColor: Colors.white,
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
// ignore: deprecated_member_use
icon: Icon(
Icons.home_outlined,
color: Colors.black,
size: 30,
),
label: 'home',
),
BottomNavigationBarItem(
// ignore: deprecated_member_use
icon: Icon(
Icons.search,
color: Colors.black,
size: 30,
),
label: 'search',
),
BottomNavigationBarItem(
// ignore: deprecated_member_use
icon: Icon(
Icons.add_box_outlined,
color: Colors.black,
size: 30,
),
label: 'upload',
),
BottomNavigationBarItem(
icon: Icon(
Icons.notifications_none_outlined,
color: Colors.black,
size: 30,
),
label: 'feed',
),
BottomNavigationBarItem(
// ignore: deprecated_member_use
icon: Icon(
Icons.person,
color: Colors.black,
size: 30,
),
label: 'profile',
),
],
showSelectedLabels: false,
showUnselectedLabels: false,
currentIndex: _currentindex,
onTap: _onItemTap,
),
);
}
}
~~~!
【问题讨论】:
-
这可能是由于相同的缓存问题,尝试停止应用程序,运行
flutter clean并再次运行它