Flutter shapeを使ってListTileに枠線をつけるサンプル

環境
Windows11 pro 64bit
Flutter 3.3.7

構文
shape: RoundedRectangleBorder(
side: BorderSide(),
)
ListTileにRoundedRectangleBorderを指定します。
ListTileに枠線をつけるには、引数「shape」を使います。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: ListView.builder(
shrinkWrap: true,
padding: EdgeInsets.all(8),
itemBuilder: (context, index) {
return ListTile(
shape: RoundedRectangleBorder(
side: BorderSide(),
),
title: Text('ttt : $index'),
);
},
itemCount: 3,
),
),
);
}
@override Widget build(BuildContext context) { return Scaffold( body: Center( child: ListView.builder( shrinkWrap: true, padding: EdgeInsets.all(8), itemBuilder: (context, index) { return ListTile( shape: RoundedRectangleBorder( side: BorderSide(), ), title: Text('ttt : $index'), ); }, itemCount: 3, ), ), ); }
@override
Widget build(BuildContext context) {
  return Scaffold(
    body: Center(
      child: ListView.builder(
        shrinkWrap: true,
        padding: EdgeInsets.all(8),
        itemBuilder: (context, index) {
          return ListTile(
            shape: RoundedRectangleBorder(
              side: BorderSide(),
            ),
            title: Text('ttt : $index'),
          );
        },
        itemCount: 3,
      ),
    ),
  );
}

 

Flutter

Posted by arkgame