Created
December 4, 2019 04:11
-
-
Save Andrious/a7cba18985870dcdb8bef8ec77c62292 to your computer and use it in GitHub Desktop.
GridView base constructor example
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 { | |
// This widget is the root of your application. | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: MyHomePage(), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
MyHomePage({Key key}) : super(key: key); | |
@override | |
_MyHomePageState createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: Center( | |
child: GridView( | |
primary: false, | |
padding: const EdgeInsets.all(20), | |
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( | |
crossAxisSpacing: 10, | |
mainAxisSpacing: 10, | |
crossAxisCount: 2), | |
children: <Widget>[ | |
Container( | |
padding: const EdgeInsets.all(8), | |
child: const Text('He\'d have you all unravel at the'), | |
color: Colors.teal[100], | |
), | |
Container( | |
padding: const EdgeInsets.all(8), | |
child: const Text('Heed not the rabble'), | |
color: Colors.teal[200], | |
), | |
Container( | |
padding: const EdgeInsets.all(8), | |
child: const Text('Sound of screams but the'), | |
color: Colors.teal[300], | |
), | |
Container( | |
padding: const EdgeInsets.all(8), | |
child: const Text('Who scream'), | |
color: Colors.teal[400], | |
), | |
Container( | |
padding: const EdgeInsets.all(8), | |
child: const Text('Revolution is coming...'), | |
color: Colors.teal[500], | |
), | |
Container( | |
padding: const EdgeInsets.all(8), | |
child: const Text('Revolution, they...'), | |
color: Colors.teal[600], | |
), | |
], | |
)), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment