6.1.material.dart?
設(shè)計(jì)語(yǔ)言設(shè)計(jì)規(guī)范技潘,顏色文字排版等,可以用來(lái)創(chuàng)建界面
2.runApp唉地,加載應(yīng)用
child嗽桩,子部件
3.class NAME extends XXXX
NAME 繼承 XXXX
class Appextends StatelessWidget{
@override
? Widget build(BuildContext context) {
// TODO: implement build
? ? return null;
? }
}
Widget 返回值類型
override 覆蓋父類里build的方法
4.當(dāng)函數(shù)只有一個(gè)返回結(jié)果的時(shí)候可以簡(jiǎn)寫(xiě)成一行
void main(){
runApp(
App()
);
}
void mian() => runApp(App());
5,修改部件屬性
test有個(gè)style屬性在TextStyle下設(shè)置屬性
class Appextends StatelessWidget{
@override
? Widgetbuild(BuildContext context) {
// TODO: implement build
? ? return Center(
child:Text(
'hello',
? ? ? ? textDirection: TextDirection.ltr,
? ? ? ? style:TextStyle(
fontSize:40,
? ? ? ? ? fontWeight: FontWeight.bold,
? ? ? ? ? color: Colors.yellow,
? ? ? ? ),
? ? ? ),
? ? );
? }
}
6.MaterialApp:使用界面組件與定制界面主題
home屬性設(shè)置默認(rèn)首頁(yè)
Scaffold是Material常用的頁(yè)面組件
elevation bar陰影
body設(shè)置頁(yè)面主體
theme:ThemeData(
) 設(shè)置主題
primarySwatch:主題顏色
class Appextends StatelessWidget{
@override
? Widgetbuild(BuildContext context) {
// TODO: implement build
? ? return MaterialApp(
home:Scaffold(
appBar:AppBar(
title:Text('helloflutter'),
? ? ? ? ? elevation:4.0,
? ? ? ? ),
? ? ? ? body:hello(),
? ? ? ),
? ? ? theme:ThemeData(
primarySwatch: Colors.yellow,
? ? ? ),
? ? );
? }
}
class helloextends StatelessWidget{
@override
? Widgetbuild(BuildContext context) {
// TODO: implement build
? ? return Center(
child:Text(
'hello',
? ? ? ? textDirection: TextDirection.ltr,
? ? ? ? style:TextStyle(
fontSize:40,
? ? ? ? ? fontWeight: FontWeight.bold,
? ? ? ? ? color: Colors.black27,
? ? ? ? ),
? ? ? ),
? ? );;
? }
}