1、Center介紹
Center將子控件放在其內部中心,里面只能放一個child,但是child里面可以放Container
Center繼承勒Align,然后Align默認是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、運行結果
測試1效果、
?
?
?
測試2效果、
?