# 杂乱问题收集
# 图片圆边角
图片圆角不能像 web 端一样,元素外面包裹,设置外面元素的圆角实现!
child: ClipRRect(
borderRadius: BorderRadius.circular(20),
child: FadeInImage.assetNetwork(
placeholder: 'images/plac.png',
image: '${SwiperList[index]['imageUrl']}',
fit: BoxFit.fill,
),
)
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
# 登录页键盘弹出页面溢出警告
Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.white,
body: _buildVerticalLayout()
);
1
2
3
4
5
2
3
4
5
# 好用的占位图
- 默认效果http://temp.im/ + 尺寸
http://temp.im/640x260
1
- 背景色 http://temp.im/ + 尺寸 + 背景色
http://temp.im/640x260/ccc
1
- 字体颜色 http://temp.im/ + 尺寸 + 背景色 +字体颜色
http://temp.im/640x260/ff5a5f/fff
1
# 解决 FutureBuilder 重复请求的问题
class SongListPage extends StatefulWidget {
final String songListId;
SongListPage(this.songListId);
_SongListPageState createState() => _SongListPageState();
}
class _SongListPageState extends State<SongListPage> {
AsyncMemoizer _memoizer = AsyncMemoizer();
Widget build(BuildContext context) {
return Scaffold(
body: FutureBuilder(
future: _getDetail(context),
builder: (context, snapshot) {
if (snapshot.connectionState != ConnectionState.waiting) {
return NestedScrollView(
headerSliverBuilder: _sliverBuilder,
body: BottomList(),
);
} else {
return Scaffold(
appBar: AppBar(
title: Text(''),
elevation: 0,
),
body: Center(
child: Text('数据加载中!'),
),
);
}
},
),
);
}
List<Widget> _sliverBuilder(BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
TopArea()
];
}
_getDetail(BuildContext context) {
return _memoizer.runOnce(() async {
return await Provider.of<SongDetailProvider>(context)
.getSongDetail(widget.songListId);
});
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
← 打包