flex_list
유연한 목록을 위한 Flutter 레이아웃 위젯입니다. wrap 내에서 Expand 위젯이 어떻게 동작할 것인지와 같이 작동합니다.
유연한 목록 레이아웃을 위한 플러터 위젯
{"sdk":"flutter"}{"sdk":"flutter"}^5.0.0아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
Provides a flexible list layout that behaves as you would expect from Expand widgets within
a Wrap.
FlexList puts as many provided elements as possible in one row (like Wrap), but also extends the
width of the elements by the remaining space per row. This means that each row is filled to the
maximum width.
In the pubspec.yaml of your flutter project, add the following dependency:
dependencies:
...
flex_list: <latest_version>
In your library add the following import:
import 'package:flex_list/flex_list.dart';
The following example shows how to use FlexList. Beside the children property, you can
set horizontalSpacing and verticalSpacing to define the spacing between the elements.
Note: Both spacing values are 10 by default.
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'FlexList Demo',
theme: ThemeData(),
home: Scaffold(
body: Center(
child: SizedBox(
width: 300,
child: FlexList(
horizontalSpacing: 5,
verticalSpacing: 10,
children: [
for (var i = 0; i < 10; i++)
Container(
color: Theme
.of(context)
.colorScheme.surfaceContainer,
padding: EdgeInsets.symmetric(
horizontal: 20 + 20 * (i % 4), vertical: 10),
child: Text("Item $i"),
)
],
)),
),
));
}
}
This package was written because of the lack of such layout function. The package repository is maintained on Github and published on pub.dev