【FlutterDart】 listView.builder例子二(14 /100)
上效果图
上代码:
import 'package:flutter/material.dart';
class ListRoles extends StatelessWidget {
ListRoles({super.key});
final List<String> entries = <String>['+', '-', '*', '/'];
final List<int> colorCodes = <int>[600, 500, 100, 50];
Widget build(BuildContext context) {
return ListView.builder(
padding: const EdgeInsets.all(8),
itemCount: entries.length,
itemBuilder: (BuildContext context, int index) {
return Container(
height: 50,
color: Colors.amber[colorCodes[index]],
child: Center(
child: Text('Entry ${entries[index]}'),
),
);
});
}
}
还是官网例子蛤!!!
==============End