【发布时间】:2020-11-19 19:17:36
【问题描述】:
当我运行以下代码时,我收到错误:A RenderFlex overflowed by 99523 pixels on the bottom.。我尝试了各种错误修复,例如将扩展的小部件作为 TabView 的子级和其他组合,但似乎没有一个有效。我正在努力实现下图。我见过各种解决方案,其中 TabView 小部件包装在展开的小部件中,但没有任何效果。
下面是我当前的代码。
class Discover extends StatefulWidget {
@override
_DiscoverState createState() => _DiscoverState();
}
class _DiscoverState extends State<Discover> {
final _auth = FirebaseAuth.instance;
String request;
FirebaseUser loggedInUser;
@override
void initState() {
// TODO: implement initState
super.initState();
getCurrentUser();
}
void getCurrentUser () async {
try{
final user = await _auth.currentUser();
if (user != null){
loggedInUser = user;
print(loggedInUser.email);
}
} catch (e){
print(e);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: kSnow,//Color(0xffDCE3E5),
appBar: AppBar(
backgroundColor: kSnow,
leading: IconButton(
icon: Icon(Icons.menu),
iconSize: 30.0,
color: kOnyx,
onPressed: () {},
),
elevation: 0.0,
actions: <Widget>[
FlatButton.icon(
icon: Icon(
Icons.person,
color: kOnyx,
size: 30.0,
),
label: Text('Log Out'),
onPressed: () {
_auth.signOut();
Navigator.push(context, MaterialPageRoute(builder: (context) => Authentication()));
},
),
],
),
body: Column(
children: <Widget>[
Container(
color: kSnow,
padding: EdgeInsets.only(left: 15.0, top: 15.0, bottom: 30.0),
child: FractionallySizedBox(
widthFactor: 1.0,
child: Text(
'DISCOVER',
style: TextStyle(
color: kOnyx,
fontSize: 30.0,
//fontWeight: FontWeight.w600,
fontFamily: 'Baukasten'),
),
),
),
DefaultTabController(
length: 4,
child: Column(
children: <Widget>[
TabBar(
isScrollable: true,
labelColor: kOnyx,
unselectedLabelColor: kFossil,
indicatorSize: TabBarIndicatorSize.label,
indicator: BoxDecoration(
color: kSnow),
tabs: [Tab(text: 'HOME'), Tab(text: 'CREATE'), Tab(text: 'PROFILE'), Tab(text: 'SETTINGS')],
indicatorColor: kOnyx,
labelStyle: TextStyle(
//ntSize: 10.0,
fontFamily: 'Baukasten'
),
),
TabBarView(
children: <Widget>[
Text('hello'),
Text('hello'),
Text('hello'),
Text('hello')
],
)
],
),
),
//Container(height: 45, color: kOnyx,),
],
),
);
}
}
【问题讨论】:
-
这能回答你的问题吗? stackoverflow.com/questions/53747149/…
-
谢谢,但没有。我对使用 Sliverbar 不感兴趣。我希望我当前的标题保持可见。
标签: android ios flutter dart flutter-layout