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.

TextWidget内の文字を左寄せしたい時

0
Posted at

はじめに

テキストウィジェット内の要素を左寄せする時の流れです。

結論

TextをWidgetでラッピングし、WidgetをAlignに変更。Alignウィジェット内に、alignment: Alignment.centerLeftを追加。

コード比較

sample.dart
Text(
  headerText,
  style: TextStyle(
    fontFamily: "Cera Pro",
    color: Pallete.blackColor,
    fontSize: 20,
    fontWeight: FontWeight.bold,
  ),
),

この表示を左に寄せたい時
カーソルをTextの上に合わせ、右クリックからリファクターを選択。
その中のWidgetを選択し、以下のように変更。

sample.dart
// WidgetをAlignに変更
Align(
  // 以下の行を追加
  alignment: Alignment.centerLeft,
  child: Text(
    headerText,
    style: TextStyle(
      fontFamily: "Cera Pro",
      color: Pallete.blackColor,
      fontSize: 20,
      fontWeight: FontWeight.bold,
    ),
  ),
),

以上。

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?