|
48 | 48 | - [Outer Line Style ](#outer-line-style )
|
49 | 49 | - [TextFormField](#textformfield)
|
50 | 50 | - [Navigation Drawer](#navigation-drawer)
|
| 51 | + - [Sliver List](#sliver-list) |
| 52 | + |
51 | 53 |
|
52 | 54 | - [Utilities](#utilities)
|
53 | 55 |
|
@@ -1000,6 +1002,39 @@ TextFormField(
|
1000 | 1002 | labelStyle: TextStyle(color: Colors.yellow))
|
1001 | 1003 | )
|
1002 | 1004 | ```
|
| 1005 | +## Sliver List |
| 1006 | + |
| 1007 | + |
| 1008 | + |
| 1009 | + |
| 1010 | +* SliverList takes a delegate parameter which provides the items in the list as they scroll into view. |
| 1011 | + |
| 1012 | +* You can specify the actual list of children with a SliverChildListDelegate Or build them lazily with a SliverChildBuilderDelegate. |
| 1013 | + |
| 1014 | +``` |
| 1015 | +SliverList( |
| 1016 | + delegate: SliverChildListDelegate( |
| 1017 | + [ |
| 1018 | + Container(color: Colors.red, height: 150.0), |
| 1019 | + Container(color: Colors.purple, height: 150.0), |
| 1020 | + Container(color: Colors.green, height: 150.0), |
| 1021 | + ], |
| 1022 | + ), |
| 1023 | +); |
| 1024 | +// This builds an infinite scrollable list of differently colored |
| 1025 | +// Containers. |
| 1026 | +SliverList( |
| 1027 | + delegate: SliverChildBuilderDelegate((BuildContext context, int index) { |
| 1028 | + // To convert this infinite list to a list with three items, |
| 1029 | + // uncomment the following line: |
| 1030 | + // if (index > 3) return null; |
| 1031 | + return Container(color: getRandomColor(), height: 150.0); |
| 1032 | + }, |
| 1033 | + // Or, uncomment the following line: |
| 1034 | + // childCount: 3, |
| 1035 | + ), |
| 1036 | +); |
| 1037 | +``` |
1003 | 1038 |
|
1004 | 1039 | > **References:**
|
1005 | 1040 | 1. https://medium.com/@anilcan/forms-in-flutter-6e1364eafdb5
|
|
0 commit comments