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:
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"),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user