/** * Created with Android Studio. * User: 三帆 * Date: 07/01/2019 * Time: 10:31 * email: sanfan.hx@alibaba-inc.com * tartget: xxx */ import 'package:flutter/material.dart'; class SliverGridDemo extends StatefulWidget { _Demo createState() => _Demo(); } class _Demo extends State { Widget showCustomScrollView() { return new CustomScrollView( slivers: [ new SliverGrid( gridDelegate: new SliverGridDelegateWithMaxCrossAxisExtent( maxCrossAxisExtent: 200.0, mainAxisSpacing: 10.0, crossAxisSpacing: 10.0, childAspectRatio: 4.0, ), delegate: new SliverChildBuilderDelegate( (BuildContext context, int index) { return new Container( alignment: Alignment.center, color: Colors.cyan[100 * (index % 5)], child: new Text('grid item $index'), ); }, childCount: 20, ), ), // new SliverFixedExtentList( // itemExtent: 100.0, // delegate: new SliverChildBuilderDelegate( // (BuildContext context, int index) { // return new Container( // alignment: Alignment.center, // color: Colors.lightBlue[100 * (index % 9)], // child: new Text('list item $index'), // ); // }, // ), // ), ], ); } Widget build(BuildContext context) { return Container( height: 400, color: Color(0xffc91b3a), child: showCustomScrollView() ); } }