探索Flutter的魅力:深入浅出Flutter_learn_demo项目
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: HomePage(),
);
}
}
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Flutter Demo HomePage'),
),
body: Center(
child: Text('You have pushed the button this many times:'),
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
这段代码是一个简单的Flutter应用程序,展示了如何使用Flutter创建一个包含AppBar、文本、浮动动作按钮的基本页面。它是学习Flutter的一个很好的起点,并展示了Flutter的基本结构和Widget的使用方法。
评论已关闭