[Flutter]ListTileに枠線をつけるには?

Flutter

どうも、ちょげ(@chogetarou)です。

ListTileに枠線をつける方法を紹介します。

スポンサーリンク

方法

インターフェース, インターネット, プログラム, ブラウザ, Www

ListTileに枠線をつけるには、引数「shape」を使います。

まず、ListTileにRoundedRectangleBorderを指定します。

そして、RoundedRectangleBorderの引数「side」にBorderSideを指定します。

ListTile(
  shape: RoundedRectangleBorder(
    side: BorderSide(),
  ),
  title: Text('テキスト'),
);

引数「shape」を使えば、ListTileに枠線をつけることが出来ます。

使用例

以下は、使用例です。

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: ListView.builder(
          shrinkWrap: true,
          padding: EdgeInsets.all(10),
          itemBuilder: (context, index) {
            return ListTile(
              shape: RoundedRectangleBorder(
                side: BorderSide(),
              ),
              title: Text('Item : $index'),
            );
          },
          itemCount: 10,
        ),
      ),
    );
  }

コメント

タイトルとURLをコピーしました