flutter_begin
环境变量
- bash_profile
~/.bash_profile
1 |
|
~/.zshrc
,在其中添加:source ~/.bash_profile
Project struct -> Modules -> no sdk 选择
https://mp.weixin.qq.com/s/YfzcvebruRk4LJRTQFVDXA
https://github.com/toly1994328/FlutterUnit
build apk
出错解决: rm /Users/john/development/flutter/bin/cache
A problem occurred evaluating root project ‘agora_rtm’.
Could not get unknown property ‘kotlin_version’ for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
版本配置
/Users/***/flutter/.pub-cache/hosted/pub.flutter-io.cn/cipher2-xxxx/android/build.gradle’ , ext.kotlin_version = 1.3.10
Users/john/.pub-cache/hosted/pub.flutter-io.cn/agora_rtm-0.9.9/android/build.gradle’
https://blog.csdn.net/weixin_44416513/article/details/90298303
Widget
Text
1 |
|
Image
1 |
|
ListView
- 横向
1 |
|
动态数据
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21class MyApp extends StatelessWidget {
final List<String> items;
MyApp({@required this.items}) : super();
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'JSPang Flutter Demo',
home: Scaffold(
appBar: AppBar(title: Text('ListView Widget')),
body: ListView.builder(
itemCount: items.length,
itemBuilder: (context,index){
return ListTile(
title: Text('${items[index]}'),
);
},
)));
}
}gridview
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'JSPang Flutter Demo',
home: Scaffold(
appBar: AppBar(title: Text('ListView Widget')),
body: GridView.count(
padding: EdgeInsets.all(20),
crossAxisSpacing: 10,
crossAxisCount: 4,
children: <Widget>[
Text('I am JOHN'),
Text('I am LI'),
Text('I am JON'),
Text('I am HEHE'),
Text('I am LILI'),
Text('I am SIYUE'),
Text('I am QIQI'),
],
)));
}
}
row
固定
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
33class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// TODO: implement build
return MaterialApp(
title: 'Row Widget Demo',
home: Scaffold(
appBar: AppBar(
title: Text("水平方向布局"),
),
body: Row(
children: <Widget>[
RaisedButton(
onPressed: () {},
color: Colors.amber,
child: Text('red Button'),
),
RaisedButton(
onPressed: () {},
color: Colors.lightBlue,
child: Text('lightBlue Button'),
),
RaisedButton(
onPressed: () {},
color: Colors.redAccent,
child: Text('redAccent Button'),
),
]
),
),
);
}
}不固定
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
37class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// TODO: implement build
return MaterialApp(
title: 'Row Widget Demo',
home: Scaffold(
appBar: AppBar(
title: Text("水平方向布局"),
),
body: Row(children: <Widget>[
Expanded(
child: RaisedButton(
onPressed: () {},
color: Colors.lightBlue,
child: Text('lightBlue Button'),
),
),
Expanded(
child: RaisedButton(
onPressed: () {},
color: Colors.redAccent,
child: Text('redAccent Button'),
),
),
Expanded(
child: RaisedButton(
onPressed: () {},
color: Colors.deepPurpleAccent,
child: Text('deepPurpleAccent Button'),
),
),
]),
),
);
}
}
coloumn
1 |
|
- CrossAxisAlignment 相对于最长的布局
StackWidget
1 |
|
FractionalOffset 0-1 相对于当前容器的 X Y轴
Position Widget
1 |
|
Positioned 相对于当前容器 padding?
card
1 |
|
页面跳转
1 |
|
列表传参
1 |
|
跳转返回
1 |
|
flutter_begin
https://noteforme.github.io/2020/01/04/flutter-begin/