Created
November 4, 2022 15:23
-
-
Save leighajarett/4ac2d2433390042d25c97f1e819ec337 to your computer and use it in GitHub Desktop.
Flutter Grid Example
This file contains hidden or 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'; | |
import 'package:flutter/cupertino.dart'; | |
void main() { | |
runApp( | |
const App(), | |
); | |
} | |
class App extends StatelessWidget { | |
const App({ | |
Key? key, | |
}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return const CupertinoApp( | |
home: HomePage(), | |
); | |
} | |
} | |
const widgets = [ | |
Text('Row 1'), | |
Icon(CupertinoIcons.arrow_down_square), | |
Icon(CupertinoIcons.arrow_up_square), | |
Text('Row 2'), | |
Icon(CupertinoIcons.arrow_down_square), | |
Icon(CupertinoIcons.arrow_up_square), | |
]; | |
class HomePage extends StatelessWidget { | |
const HomePage({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: GridView.builder( | |
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( | |
crossAxisCount: 3, | |
mainAxisExtent: 40.0, | |
), | |
itemCount: widgets.length, | |
itemBuilder: (context, index) => widgets[index], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment