Instantly share code, notes, and snippets.

@MarcinusX /main.dart Secret
Created Dec 30, 2018

Embed
What would you like to do?
[...]
class MyHomePage extends StatefulWidget {
MyHomePage({Key key}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Grid to Pager')),
body: Stack(
children: <Widget>[
_buildGridView(),
],
),
);
}
Widget _buildGridView() {
return GridView.count(
crossAxisCount: 2,
children: images.map((imageName) {
return Card(
child: Center(
child: Image.asset("assets/$imageName"),
),
);
}).toList(),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment