main.dart
import 'dart:math';
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
theme: ThemeData(primarySwatch: Colors.blueGrey),
home: Scaffold(
appBar: AppBar(
title: const Text("Flutter - GridView")
),
body: bodyContent()
)
)
);
}
bodyContent(){
final items = <Container>[];
for(int i=0; i<102; i++){
items.add(
Container(
color: Colors.primaries[
Random().nextInt(Colors.primaries.length)
].shade400
)
);
}
return GridView.count(
crossAxisCount: 3,
crossAxisSpacing: 8,
mainAxisSpacing: 8,
children: items
);
}
More flutter tutorials
- flutter – How to use LimitedBox
- flutter – GridView builder
- flutter – GridView item height
- flutter – GridView physics
- flutter – GridView in column
- flutter – GridView onTap
- flutter – GridView disable scroll
- flutter – How to use Card
- flutter – Card border radius
- flutter – Card height
- flutter – Card padding
- flutter – Card with image
- flutter – Card with image and text
- flutter – Card circle image padding
- flutter – Card rounded corners image