main.dart
import 'dart:math';
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
theme: ThemeData(primarySwatch: Colors.green),
home: Scaffold(
appBar: AppBar(
title: const Text("Flutter - GridView Item Height")
),
body: bodyContent()
)
)
);
}
bodyContent(){
return GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
mainAxisExtent: 200 // item height
),
itemCount: 100,
itemBuilder: (context, index) {
return Card(
color: Colors.primaries[
Random().nextInt(Colors.primaries.length)
].shade400,
child: Center(child: Text("${index+1}"))
);
}
);
}
More flutter tutorials
- flutter – How to use LimitedBox
- flutter – How to use GridView
- flutter – GridView builder
- 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 – Column space between
- flutter – Column space around