android - “A RenderFlex 在底部溢出 60 像素”颤动错误
问题描述
所以,我正在尝试制作一个像这样的页面,但现在我遇到了溢出错误:
我在网上看到有人用 修复了这个问题SingleChildScrollView
,但是上面的文章NestedScrollView
使用了 slivers,所以我不知道该怎么做。
由于下面的错误,我还尝试将Extended
所有地方都放了,但没有任何效果。
代码就是这样一个:(完整的代码在我的 github上可用)
return Scaffold(
appBar: AppBar(
elevation: 0.0,
backgroundColor: Color(0x00ffffff),
title: Text('Account'),
),
body: DefaultTabController(
length: 2,
child: RefreshIndicator(
onRefresh: getArtistImage,
key: _refreshIndicatorKey,
child: NestedScrollView(
headerSliverBuilder: (context, _) {
return [
SliverList(
delegate: SliverChildListDelegate([
Column(
children: <Widget>[
!loaded
? SafeArea(
top: true,
child: Column(
children: <Widget>[
Container(
child: LinearProgressIndicator(
backgroundColor: whiteLoadingBackground,
valueColor: AlwaysStoppedAnimation(
Colors.white60),
),
height: 3,
),
UserProfile(widget.user, recentTracks)
],
),
)
: Container(
child: Stack(
children: <Widget>[
Container(
height: MediaQuery
.of(context)
.size
.width,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0x56000000),
Color(0x88000000),
Color(0xff000000)
],
begin: FractionalOffset.topCenter,
end: AlignmentDirectional.bottomCenter,
)),
),
PageModel(
title: 'My Account',
children: UserProfile(
widget.user, recentTracks))
],
),
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(artistImage),
alignment: Alignment.topCenter,
fit: BoxFit.fitWidth),
))
],
),
]),
)
];
},
physics:
AlwaysScrollableScrollPhysics(parent: BouncingScrollPhysics()),
body: Column(
children: <Widget>[
TabBar(
tabs: <Widget>[
Tab(
text: 'Last Scrobbles',
icon: Icon(Icons.queue_music),
),
Tab(
text: 'Charts',
icon: Icon(Icons.show_chart),
)
],
),
Expanded(
child: TabBarView(
children: <Widget>[
recentTracks != null
? Container(
child: UserBottomInformation(
widget.user, recentTracks),
)
: Text('ue'),
Text('pag 2')
],
),
)
],
),
),
),
),
);
解决方案
Column(
children:<Widget>[
Flexible(child:put your child here),
Flexible(child:put your child here),
Flexible(child:put your child here),
..,
]
)
考虑使用小部件的flex:
属性,Flexible
如果这是一个可滚动的,它告诉孩子应该消耗多少可用空间,只需将列包装在一个SingleChildScrollView
推荐阅读
- node.js - 尝试运行刚刚建立的服务器时找不到 manifest.json 404
- ios - onesignal警报通知在ios中打开通知后强制关闭
- javascript - MongoDB:获取最近五分钟内新增用户的列表
- vue.js - 为什么 Vuex-persist 不在 localStorage 中存储任何内容?
- c# - MVC 后集合作为没有有序索引的模型
- asp.net-core - 当 nopcommerce 4.2 重新启动应用程序时,Visual Studio 2017 停止
- python - 如何将存储在 sqlite 中的图像显示到 tkinter 窗口中
- sql-server - 数据库的 MSSQL 用户
- redirect - 如何阻止重定向的 URL 被屏蔽?
- java - 如何使用片段在 viewpager 中打开 sd 卡中的多个图像?