Last active
January 29, 2021 13:40
-
-
Save felipecastrosales/2198622f6e0d0ac02ba7d54964402ff1 to your computer and use it in GitHub Desktop.
GridView.extent
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(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