0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【学習メモ:Flutter入門編】レイアウトの基礎 (Column/Row)

Last updated at Posted at 2024-03-27

これから「Flutter」を勉強していこうと思っている人向けには「メモ」程度で参照してみてください。

■ const or final
「Flutter」ではできる限り「const」を使った方がよい。

【理由】

  • アプリを軽くする(無駄な処理を自動で減らしてくれる)

新しい「Widget」には「Const」に対応しておらず、仕方がなく「final」を利用する場面が存在する。

■ Column(カラム)
Widgetどうしを縦に配置する。

■ Row(ロウ)
Widgetどうしを横に配置する。

■ 配置調整は各「Widget」単位で子供(children)の設定を変更
「mainAxisAlignment」は縦方向の調整で合計「6種類」

  • start(スタート):上寄せ
  • center(センター):中央寄せ
  • end(エンド);下寄せ
  • spaceEvenly(スペースイーブンリー):均等配置
  • spaceBetween(スペースビトウィーン):均等配置(両端のスペースが存在しない)
  • spaceAround(スペースアラウンド):均等配置(両端のスペースが少しだけ存在)

「crossAxisAlignment」は横方向の調整で合計「4種類」

  • start(スタート):右寄せ
  • center(センター):中央寄せ
  • end(エンド);左寄せ
  • stretch(ストレッチ):伸縮(右から左まで引き延ばす)

■ 「Column」と「Row」のサイズ調整
「mainAxisSize」を「min」に設定することで、余分なスペースを削りコンパクトに設定する事が可能

■ 「Widget」の組み合わせ
「Column」に「Row」を代入したり、「Row」に「Column」を代入することでレイアウトを構築していく

最後に

Flutter(Dart言語)に関する最低限の情報を「学習メモ」としてまとめてみました。
内容に誤りがありそうであれば、遠慮なくご指摘いただけますと幸いです。

【学習の参考にした動画】
素敵な解説動画の作成ありがとうございます。
本記事の内容より。動画を見た方が解りやすいと思います。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?