import 'package:flutter/material.dart'; import 'package:flutter_app_test_2/sliver_grid.dart'; void main() { runApp(new App()); } class App extends StatelessWidget { final List tileSizes = [ new TileSize(1, 1.0), new TileSize(1, 1.0), new TileSize(1, 2.0), new TileSize(1, 1.0), new TileSize(2, 1.0), new TileSize(1, 2.0), new TileSize(1, 1.0), new TileSize(2, 2.0), new TileSize(2, 1.0), new TileSize(1, 1.0), new TileSize(2, 2.0), new TileSize(2, 1.0), new TileSize(1, 2.0), new TileSize(2, 4.0), new TileSize(3, 1.0), new TileSize(4, 2.0), new TileSize(1, 1.0), new TileSize(3, 2.0), new TileSize(2, 1.0), ]; // This widget is the root of your application. @override Widget build(BuildContext context) { return new MaterialApp( title: 'Flutter Demo', theme: new ThemeData( // This is the theme of your application. // // Try running your application with "flutter run". You'll see the // application has a blue toolbar. Then, without quitting the app, try // changing the primarySwatch below to Colors.green and then invoke // "hot reload" (press "r" in the console where you ran "flutter run", // or press Run > Flutter Hot Reload in IntelliJ). Notice that the // counter didn't reset back to zero; the application is not restarted. primarySwatch: Colors.blue, ), home: new Container( decoration: new BoxDecoration( color: Colors.white, shape: BoxShape.rectangle), child: new VariableSizedTileGridView.builder( padding: new EdgeInsets.all(10.0), itemCount: tileSizes.length, mainAxisSpacing: 10.0, crossAxisSpacing: 10.0, mainAxisRatio: 1.0, crossAxisSpans: 4, tileSizeBuilder: _tileSizeBuilder, itemBuilder: _itemBuilder))); } Widget _itemBuilder(BuildContext context, int index) { if (index >= tileSizes.length) return null; var color = index.isEven ? Colors.green : Colors.blue; return new Container( decoration: new BoxDecoration(color: color, shape: BoxShape.rectangle), child: new Center( child: new CircleAvatar( backgroundColor: Colors.white, child: new Text("$index"), ), )); } TileSize _tileSizeBuilder(int index) { if (index >= tileSizes.length) return null; return tileSizes[index]; } }