Skip to content

Instantly share code, notes, and snippets.

@jimit24365
Created February 16, 2020 06:22
Show Gist options
  • Save jimit24365/0047b5c8fc6799171b7b8b15ad127108 to your computer and use it in GitHub Desktop.
Save jimit24365/0047b5c8fc6799171b7b8b15ad127108 to your computer and use it in GitHub Desktop.
Infinite Seperated ListView
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.light(),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: MyWidget(),
),
),
);
}
}
class MyWidget extends StatelessWidget {
final List<String> entries = <String>['A', 'B', 'C', 'D', 'E'];
final List<int> colorCodes = <int>[600, 500, 100, 700, 900];
@override
Widget build(BuildContext context) {
return ListView.separated(
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]}')),
);
},
separatorBuilder: (BuildContext context, int index) => const Divider(),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment