Skip to content

Instantly share code, notes, and snippets.

@felipecastrosales
Last active January 29, 2021 13:40
Show Gist options
  • Save felipecastrosales/2198622f6e0d0ac02ba7d54964402ff1 to your computer and use it in GitHub Desktop.
Save felipecastrosales/2198622f6e0d0ac02ba7d54964402ff1 to your computer and use it in GitHub Desktop.
GridView.extent
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: GridViewExtentWidget(),
);
}
}
class GridViewExtentWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('GridView.extend'),
centerTitle: true,
),
body: GridViewWidgetDemo(),
);
}
}
class GridViewWidgetDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GridView.extent(
maxCrossAxisExtent: 200,
children: [
Item1(), Item2(), Item3(), Item4(),
],
);
}
}
class Item1 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
color: Colors.pinkAccent,
);
}
}
class Item2 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
color: Colors.red,
);
}
}
class Item3 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
color: Colors.blue[900],
);
}
}
class Item4 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
color: Colors.orange,
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment