implemented: grid_layout

This commit is contained in:
Nishant Srivastava
2018-02-10 19:50:17 +05:30
parent b2c80a698e
commit 354d387278
9 changed files with 49 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@ -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: <Widget>[
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: <Widget>[
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"),
],
);
}
}

View File

@ -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(),
),
);
}

View File

@ -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.