|
5 | 5 | // [FloatingActionButtonLocation.centerDocked]. The [FloatingActionButton] is |
6 | 6 | // connected to a callback that increments a counter. |
7 | 7 |
|
| 8 | +import 'package:flutter/cupertino.dart'; |
8 | 9 | import 'package:flutter/material.dart'; |
9 | 10 | import 'package:loading_indicator/loading_indicator.dart'; |
10 | 11 |
|
@@ -43,7 +44,8 @@ class MainWidget extends StatelessWidget { |
43 | 44 | padding: const EdgeInsets.all(64), |
44 | 45 | child: LoadingIndicator( |
45 | 46 | indicatorType: indicator, |
46 | | - color: Colors.white, |
| 47 | + colors: const [Colors.white], |
| 48 | + backgroundColor: Colors.black38, |
47 | 49 | ), |
48 | 50 | ), |
49 | 51 | ); |
@@ -93,35 +95,45 @@ class GridWidget extends StatelessWidget { |
93 | 95 | Widget build(BuildContext context) { |
94 | 96 | return Scaffold( |
95 | 97 | backgroundColor: Colors.pink, |
96 | | - body: GridView.builder( |
97 | | - itemCount: Indicator.values.length, |
98 | | - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( |
99 | | - crossAxisCount: 4, |
100 | | - childAspectRatio: 1, |
101 | | - ), |
102 | | - itemBuilder: (ctx, index) => Stack( |
103 | | - fit: StackFit.expand, |
104 | | - alignment: Alignment.center, |
105 | | - children: <Widget>[ |
106 | | - Padding( |
107 | | - padding: const EdgeInsets.all(16), |
108 | | - child: LoadingIndicator( |
109 | | - color: Colors.white, |
110 | | - indicatorType: Indicator.values[index], |
111 | | - ), |
| 98 | + body: CustomScrollView( |
| 99 | + slivers: [ |
| 100 | + SliverAppBar( |
| 101 | + title: Text('Grid Demo'), |
| 102 | + floating: true, |
| 103 | + ), |
| 104 | + SliverGrid( |
| 105 | + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( |
| 106 | + crossAxisCount: 4, |
| 107 | + childAspectRatio: 1, |
112 | 108 | ), |
113 | | - Align( |
114 | | - alignment: Alignment.bottomLeft, |
115 | | - child: Text( |
116 | | - '${index + 1}', |
117 | | - style: TextStyle( |
118 | | - color: Colors.white, |
119 | | - fontSize: 14, |
120 | | - ), |
| 109 | + delegate: SliverChildBuilderDelegate( |
| 110 | + (ctx, index) => Stack( |
| 111 | + fit: StackFit.expand, |
| 112 | + alignment: Alignment.center, |
| 113 | + children: <Widget>[ |
| 114 | + Padding( |
| 115 | + padding: const EdgeInsets.all(16), |
| 116 | + child: LoadingIndicator( |
| 117 | + colors: const [Colors.white], |
| 118 | + indicatorType: Indicator.values[index], |
| 119 | + ), |
| 120 | + ), |
| 121 | + Align( |
| 122 | + alignment: Alignment.bottomLeft, |
| 123 | + child: Text( |
| 124 | + '${index + 1}', |
| 125 | + style: TextStyle( |
| 126 | + color: Colors.white, |
| 127 | + fontSize: 14, |
| 128 | + ), |
| 129 | + ), |
| 130 | + ) |
| 131 | + ], |
121 | 132 | ), |
122 | | - ) |
123 | | - ], |
124 | | - ), |
| 133 | + childCount: Indicator.values.length, |
| 134 | + ), |
| 135 | + ), |
| 136 | + ], |
125 | 137 | ), |
126 | 138 | ); |
127 | 139 | } |
|
0 commit comments