Created
December 26, 2022 11:58
-
-
Save RyouMon/bd072abf4445e711dc8603b30e351c4a to your computer and use it in GitHub Desktop.
Flutter Demo: GridView with SliverGridDelegateWithMaxCrossAxisExtent 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 SliverGridDelegateWithMaxCrossAxisExtentExample extends StatelessWidget { | |
const SliverGridDelegateWithMaxCrossAxisExtentExample({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return GridView( | |
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent( | |
maxCrossAxisExtent: 120.0), | |
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 SliverGridDelegateWithMaxCrossAxisExtentExample(), | |
); | |
} | |
} | |
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 SliverGridDelegateWithMaxCrossAxisExtent Example'), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment