728x90
class TestApp extends StatefulWidget {
const TestApp({Key? key}) : super(key: key);
@override
_TestAppState createState() => _TestAppState();
}
class _TestAppState extends State<TestApp> {
final List<String> entries = <String>["A", "B", "C"];
final List<int> numbers = <int>[600, 500, 400];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text(
"example",
),
),
body: ListViewBuilder(entries: entries, numbers: numbers),
);
}
}
class ListViewBuilder extends StatelessWidget {
const ListViewBuilder({Key? key, required this.entires, required this.numbers}) : super(key: key);
final List<String> entries;
final List<int> numbers;
@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: entries.length,
itemBuilder: (BuildContext context, int index) {
return Container(
height: 50,
color: Colors.amber[numbers[index]],
child: Center(
child: Text(
"Entry ${entries[index]}",
),
),
);
}
);
}
}
반응형
'Programming > Dart, Flutter' 카테고리의 다른 글
캐스케이드(Cascade Notation) (0) | 2022.01.11 |
---|---|
얕은 복사(shallow copy), 깊은 복사(deep copy) (0) | 2022.01.11 |
Error: The argument type 'String' can't be assigned to the parameter type 'Uri'. (0) | 2021.12.30 |
Function(optional parameters, named parameters) (0) | 2021.01.29 |
Fixed length List (0) | 2021.01.28 |
Comments