今回は「Align」の基本的な使い方について紹介します。
Alignを使えば、Containerなどの親ウィジェットに対してchild Widgetを好きな位置に指定できます!
目次
Alignmentの基本プロパティ
alignment



alignmentプロパティでContainerなどのWidgetに対し、child Widgetをどの位置に設置したいか指定します。
//ソース(左の画像)
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text("Flutter"),
),
body: Center(
child: Container(
height: 200.0,
width: 200.0,
color: Colors.yellow,
child: const Align(
alignment: Alignment(-1, -1),
child: Text("Hello World"),
),
),
),
),
);
}
使用できるWidget:Alignment, AlignmentDirectional
あわせて読みたい


【Flutter】Alignmentの使い方|Alignで指定したchildの位置を指定
今回は「Alignment」の基本的な使い方について紹介します。 Alignmentを使えば、Containerなどの親ウィジェットに対してchild Widgetの設置する位置を指定できます! 【...
以上です。