Created
August 21, 2020 14:59
-
-
Save e200/6f3a5428bbd143dc65f51a5e7a8f3e71 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(LazyGridViewApp()); | |
} | |
class LazyGridViewApp extends StatelessWidget { | |
final _list = List.generate(42, (index) => index); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Scaffold( | |
appBar: AppBar( | |
title: Text('Lazy Grid View'), | |
), | |
body: CustomScrollView( | |
slivers: [ | |
SliverGrid( | |
delegate: SliverChildBuilderDelegate( | |
(context, index) { | |
return Container( | |
color: Colors.blue.withOpacity(index.isEven ? .1 : .4), | |
child: Center( | |
child: Text(index.toString()), | |
), | |
); | |
}, | |
childCount: _list.length, | |
), | |
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( | |
crossAxisCount: 3, | |
), | |
), | |
SliverToBoxAdapter( | |
child: Center( | |
child: Padding( | |
padding: const EdgeInsets.all(15), | |
child: CircularProgressIndicator(), | |
), | |
), | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment