Flutter简单启动

1.我们的代码片在lib里面写
2.记住别的包不要打开,因为会出现报错,虽然没有什么影响,但是影响美观
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(title: '我的程序',home: MyScaffold(),));
}
class MyScaffold extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Material(
child: Column(
children: [
MyappBar(),
Expanded(child: Center(child: Text("hellow,world"),))
],
),
);
}
}
class MyappBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
height: 56.0,
padding: const EdgeInsets.symmetric(horizontal: 8.0),
decoration: BoxDecoration(color: Colors.blue) ,
child: Row(
children: [
],
),
);
}
}
这篇博客介绍了如何使用Flutter框架创建第一个简单的应用。主要步骤包括在lib目录下编写代码,导入必要的material包,定义主入口点`main`函数,创建`MyScaffold`和`MyAppBar`两个自定义组件,展示基本布局结构,如Column和Container,并在屏幕中显示'hellow,world'文本。
430

被折叠的 条评论
为什么被折叠?



