创建项目
建议用命令行创建 因为idea创建会带很多自己的东西
- 不建议驼峰命名 用下划线
flutter create learn_flutter
创建成功
运行项目
cd learn_flutter
flutter run
当然也可以直接打开Xcode 然后运行项目啦
AndroidStuio 打开项目
lib 文件夹 写代码位置
- test 是测试
- .metadata 版本记录 不需要动
- .packages
- pubspec.yml
- pubspec.lock
热重载 、 热重启
冷启动:(从0-1)
Hot Reload:build方法
Hot Restart:
第一个hello world
main() {
// 1.runApp函数
runApp(
const Center(
child: Text(
"hello world",
textDirection: TextDirection.ltr,
style: TextStyle(
fontSize: 30,
color: Colors.orange
),
),
)
);
}
万物皆是 Widget
MaterialApp Scaffold
import 'package:flutter/material.dart';
main() {
// 1.runApp函数
runApp(
MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text("第一个flutter从程序"),
),
body: const Center(
child: Text(
"hello world",
textDirection: TextDirection.ltr,
style: TextStyle(
fontSize: 30,
color: Colors.orange
),
),
),
)
)
);
}