dart初始化项目的分析
生活随笔
收集整理的這篇文章主要介紹了
dart初始化项目的分析
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
dart初始化項目的分析
import 'package:flutter/material.dart';void main() {runApp(LJHomePage()); }class LJHomePage extends StatelessWidget {@overrideWidget build(BuildContext context) {return const MaterialApp(debugShowCheckedModeBanner: false,title: 'demo',home: HomePage(title: '魯軍',),);} }//有狀態的Widget class HomePage extends StatefulWidget {const HomePage({Key? key, required this.title}) : super(key: key);final String title;@overrideState<StatefulWidget> createState() => _LJHomeContent();// State<StatefulWidget> createState() {// return _LJHomeContent();// } }//無狀態 Widget class _LJHomeContent extends State<HomePage> {int _incrementValue = 1;void incrementCounter() {// print('增加函數被調用了');setState(() {_incrementValue += 10;});}@overrideWidget build(BuildContext context) {return Scaffold(appBar: AppBar(backgroundColor: Colors.yellow,elevation: 0,title: const Text('魯軍',style: TextStyle(color: Colors.blue),),),body: Center(child: Column(mainAxisAlignment: MainAxisAlignment.center,children: [const Text('請按 按鈕改變值值',style: TextStyle(fontSize: 40, color: Colors.grey),textDirection: TextDirection.rtl,),Text('$_incrementValue',style: const TextStyle(fontSize: 40, color: Colors.grey),textDirection: TextDirection.rtl,),],),),floatingActionButton: FloatingActionButton(onPressed: incrementCounter,foregroundColor: Colors.yellow,tooltip: "add",backgroundColor: Colors.purple,child: const Icon(Icons.add),),);} }總結
以上是生活随笔為你收集整理的dart初始化项目的分析的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Flutter的文本控件的基本使用
- 下一篇: 从另一个角度看大数据量处理利器:布隆过滤