logo头像
Snippet 博客主题

flutter项目问题记录

1.appBar的leading控件无法改大小

image.png

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
appBar: AppBar(
leading: Container(
width: 100,
height: 30,
color: Colors.red,
margin: EdgeInsets.only(left: ScreenAdapter.width(20)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ImageUtils.name("icon_Location.png"),
SizedBox(width: 10),
Text("东莞市")
],
),
),
title: Text("首页"),
),

leading不能改变大小,网上看是使用title写
改造后

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
return Scaffold(
appBar: AppBar(
title: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
ImageUtils.name("Location_icon.png"),
SizedBox(width: 10),
Text(
"东莞市",
style: TextStyle(color: Colors.white),
)
],
),
),
body: Text("aaa"),
);

image.png

2.真机模拟器突然运行不了

检查代码发现是一句代码的问题 ,太他妈坑了
image.png

3.点击空白处回收键盘

1
2
3
4
5
6
7
8
 return GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
//点击空白关闭软键盘
FocusScope.of(context).requestFocus(FocusNode());
},
child: Container();//此处输入框
);

4.flutter 图片地址有效但是返回404导致崩溃

参考# Flutter cached_network_image图片缓存异常/加载失败优化

微信打赏

赞赏是不耍流氓的鼓励