Flutter之Center
1、Center介紹
Center將子控件放在其內(nèi)部中心,里面只能放一個(gè)child,但是child里面可以放Container
Center繼承勒Align,然后Align默認(rèn)是center.
2、測(cè)試代碼
測(cè)試1、
@override
Widget 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"),
),
),
);
}
}
測(cè)試2、
@override
Widget 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、運(yùn)行結(jié)果
測(cè)試1效果、
測(cè)試2效果、
作者:chen.yu
深信服三年半工作經(jīng)驗(yàn),目前就職游戲廠商,希望能和大家交流和學(xué)習(xí),
微信公眾號(hào):編程入門(mén)到禿頭 或掃描下面二維碼
零基礎(chǔ)入門(mén)進(jìn)階人工智能(鏈接)