mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2025-08-05 22:01:22 +08:00
implemented: grid_layout
This commit is contained in:
BIN
grid_layout/data_repo/img/ic_launcher.png
Normal file
BIN
grid_layout/data_repo/img/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
BIN
grid_layout/data_repo/img/social/facebook.png
Normal file
BIN
grid_layout/data_repo/img/social/facebook.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
BIN
grid_layout/data_repo/img/social/google_plus.png
Normal file
BIN
grid_layout/data_repo/img/social/google_plus.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.4 KiB |
BIN
grid_layout/data_repo/img/social/instagram.png
Normal file
BIN
grid_layout/data_repo/img/social/instagram.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.0 KiB |
BIN
grid_layout/data_repo/img/social/linkedin.png
Normal file
BIN
grid_layout/data_repo/img/social/linkedin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.6 KiB |
BIN
grid_layout/data_repo/img/social/twitter.png
Normal file
BIN
grid_layout/data_repo/img/social/twitter.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
38
grid_layout/lib/gridview.dart
Normal file
38
grid_layout/lib/gridview.dart
Normal 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"),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@ -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(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -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.
|
||||
|
Reference in New Issue
Block a user