Skip to content

Instantly share code, notes, and snippets.

@leighajarett
Created November 4, 2022 15:23
Show Gist options
  • Save leighajarett/4ac2d2433390042d25c97f1e819ec337 to your computer and use it in GitHub Desktop.
Save leighajarett/4ac2d2433390042d25c97f1e819ec337 to your computer and use it in GitHub Desktop.
Flutter Grid Example
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