学习flutter过程中,我经常需要快速创建一个app然后测试一些功能,下面就是我常用的测试基础app
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
// TODO 初始化是代码
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('基础 应用'),
),
body:
//TODO step01 add SingleChildScrollView
SingleChildScrollView(
child: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
RaisedButton(
child: const Text('测试按钮'),
onPressed: (){
print("点击了一下");
},
)
],
),
),
)
),
);
}
}
网友评论