Flutter之Center
生活随笔
收集整理的這篇文章主要介紹了
Flutter之Center
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
1、Center介紹
Center將子控件放在其內(nèi)部中心,里面只能放一個child,但是child里面可以放Container
Center繼承勒Align,然后Align默認(rèn)是center.
?
?
?
?
?
?
?
?
2、測試代碼
測試1、
@overrideWidget build(BuildContext context) {return MaterialApp(title: 'open url',home: Scaffold(appBar: AppBar(// Here we take the value from the MyHomePage object that was created by// the App.build method, and use it to set our appbar title.title: Text('hello flutter'),),body: Center(child: Text("chenyu"),),),);} }?
?
?
?
?
測試2、
@overrideWidget build(BuildContext context) {return MaterialApp(title: 'open url',home: Scaffold(appBar: AppBar(// Here we take the value from the MyHomePage object that was created by// the App.build method, and use it to set our appbar title.title: Text('hello flutter'),),body: Center(child: Container(color: Colors.blue,width: 200,height: 200,),),),);} }?
?
?
?
?
?
3、運行結(jié)果
測試1效果、
?
?
?
測試2效果、
?
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
以上是生活随笔為你收集整理的Flutter之Center的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Flutter之Align
- 下一篇: Flutter之Decoration