[Flutter翻译]GSoC ‘21:为Flutter创建一个桌面样本_flutter 桌面模板
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Desktop Template',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Flutter Desktop Template'),
),
body: const Center(
child: Text('Hello, Desktop!'),
),
);
}
}
这段代码创建了一个简单的Flutter应用,它设置了应用的标题、主题颜色,并展示了一个包含文本的基本页面。这是学习如何为Flutter创建桌面应用的一个很好的起点。
评论已关闭