Created
December 26, 2022 11:40
-
-
Save RyouMon/5d84dad0924d7694ae6c10c5e1a90ff3 to your computer and use it in GitHub Desktop.
Flutter Demo: GridView with SliverGridDelegateWithFixedCrossAxisCount 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(const MyApp()); | |
} | |
class SliverGridDelegateWithFixedCrossAxisCountExample extends StatelessWidget { | |
const SliverGridDelegateWithFixedCrossAxisCountExample({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return GridView( | |
gridDelegate: | |
const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3), | |
children: const [ | |
Icon(Icons.ac_unit), | |
Icon(Icons.airport_shuttle), | |
Icon(Icons.all_inclusive), | |
Icon(Icons.beach_access), | |
Icon(Icons.cake), | |
Icon(Icons.free_breakfast), | |
], | |
); | |
} | |
} | |
class HomePage extends StatelessWidget { | |
const HomePage({super.key, required this.title}); | |
final String title; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(title: Text(title)), | |
body: const SliverGridDelegateWithFixedCrossAxisCountExample(), | |
); | |
} | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: const HomePage( | |
title: | |
'GridView with SliverGridDelegateWithFixedCrossAxisCount Example'), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment