diff --git a/grid_layout/data_repo/img/ic_launcher.png b/grid_layout/data_repo/img/ic_launcher.png new file mode 100644 index 0000000..20ed372 Binary files /dev/null and b/grid_layout/data_repo/img/ic_launcher.png differ diff --git a/grid_layout/data_repo/img/social/facebook.png b/grid_layout/data_repo/img/social/facebook.png new file mode 100644 index 0000000..da3f9a8 Binary files /dev/null and b/grid_layout/data_repo/img/social/facebook.png differ diff --git a/grid_layout/data_repo/img/social/google_plus.png b/grid_layout/data_repo/img/social/google_plus.png new file mode 100644 index 0000000..d254896 Binary files /dev/null and b/grid_layout/data_repo/img/social/google_plus.png differ diff --git a/grid_layout/data_repo/img/social/instagram.png b/grid_layout/data_repo/img/social/instagram.png new file mode 100644 index 0000000..4840d3b Binary files /dev/null and b/grid_layout/data_repo/img/social/instagram.png differ diff --git a/grid_layout/data_repo/img/social/linkedin.png b/grid_layout/data_repo/img/social/linkedin.png new file mode 100644 index 0000000..db6b168 Binary files /dev/null and b/grid_layout/data_repo/img/social/linkedin.png differ diff --git a/grid_layout/data_repo/img/social/twitter.png b/grid_layout/data_repo/img/social/twitter.png new file mode 100644 index 0000000..e577ce1 Binary files /dev/null and b/grid_layout/data_repo/img/social/twitter.png differ diff --git a/grid_layout/lib/gridview.dart b/grid_layout/lib/gridview.dart new file mode 100644 index 0000000..989cc57 --- /dev/null +++ b/grid_layout/lib/gridview.dart @@ -0,0 +1,38 @@ +import 'package:flutter/material.dart'; + +class MyGridView { + Card getStructuredGridCell(name, image) { + return new Card( + elevation: 1.5, + child: new Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + mainAxisSize: MainAxisSize.min, + verticalDirection: VerticalDirection.down, + children: [ + new Image(image: new AssetImage('data_repo/img/' + image)), + new Center( + child: new Text(name), + ) + ], + )); + } + + GridView build() { + return new GridView.count( + primary: true, + padding: const EdgeInsets.all(1.0), + crossAxisCount: 2, + childAspectRatio: 0.85, + mainAxisSpacing: 1.0, + crossAxisSpacing: 1.0, + children: [ + getStructuredGridCell("Facebook", "social/facebook.png"), + getStructuredGridCell("Twitter", "social/twitter.png"), + getStructuredGridCell("Instagram", "social/instagram.png"), + getStructuredGridCell("Linkedin", "social/linkedin.png"), + getStructuredGridCell("Gooogle Plus", "social/google_plus.png"), + getStructuredGridCell("Launcher Icon", "ic_launcher.png"), + ], + ); + } +} diff --git a/grid_layout/lib/main.dart b/grid_layout/lib/main.dart index aa3eeb8..7d0fcc6 100644 --- a/grid_layout/lib/main.dart +++ b/grid_layout/lib/main.dart @@ -1,8 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:grid_layout/gridview.dart'; void main() => runApp(new MyApp()); class MyApp extends StatelessWidget { + final MyGridView myGridView = new MyGridView(); + @override Widget build(BuildContext context) { return new MaterialApp( @@ -12,9 +15,7 @@ class MyApp extends StatelessWidget { // the App.build method, and use it to set our appbar title. title: new Text("GridView Example"), ), - body: new Container( - child: new Center(child: new Text("Hello World")), - ), + body: myGridView.build(), ), ); } diff --git a/grid_layout/pubspec.yaml b/grid_layout/pubspec.yaml index 014d34b..cfe6e7a 100644 --- a/grid_layout/pubspec.yaml +++ b/grid_layout/pubspec.yaml @@ -29,6 +29,13 @@ flutter: # assets: # - images/a_dot_burr.jpeg # - images/a_dot_ham.jpeg + assets: + - data_repo/img/ic_launcher.png + - data_repo/img/social/facebook.png + - data_repo/img/social/instagram.png + - data_repo/img/social/google_plus.png + - data_repo/img/social/linkedin.png + - data_repo/img/social/twitter.png # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.io/assets-and-images/#resolution-aware.