Last active
November 26, 2019 16:43
-
-
Save brianegan/888156b5bd929c45e7e0551700e5ebbe to your computer and use it in GitHub Desktop.
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'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
final appTitle = 'Orientation Demo'; | |
return MaterialApp( | |
title: appTitle, | |
home: OrientationList( | |
title: appTitle, | |
), | |
); | |
} | |
} | |
class OrientationList extends StatelessWidget { | |
final String title; | |
OrientationList({Key key, this.title}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(title: Text(title)), | |
body: OrientationBuilder( | |
builder: (context, orientation) { | |
return GridView.count( | |
// Create a grid with 2 columns in portrait mode, or 3 columns in | |
// landscape mode. | |
crossAxisCount: orientation == Orientation.portrait ? 2 : 3, | |
// Generate 100 widgets that display their index in the List. | |
children: List.generate(100, (index) { | |
return Center( | |
child: Text( | |
'Item $index', | |
style: Theme.of(context).textTheme.headline, | |
), | |
); | |
}), | |
); | |
}, | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment