|
| 1 | +/// |
| 2 | +/// Created by NieBin on 2019/5/26 |
| 3 | +/// Github: https://github.com/nb312 |
| 4 | + |
| 5 | +import "package:flutter/material.dart"; |
| 6 | +import 'package:flutter_widgets/const/_const.dart'; |
| 7 | + |
| 8 | +class LayoutPage extends StatefulWidget { |
| 9 | + @override |
| 10 | + LayoutState createState() => LayoutState(); |
| 11 | +} |
| 12 | + |
| 13 | +class LayoutState extends State<LayoutPage> { |
| 14 | + Widget _builder(BuildContext context, BoxConstraints constraints) => |
| 15 | + Container( |
| 16 | + constraints: |
| 17 | + BoxConstraints.expand(height: 100, width: constraints.maxWidth), |
| 18 | + color: RED, |
| 19 | + ); |
| 20 | + |
| 21 | + Widget _listView() => ListView( |
| 22 | + shrinkWrap: true, |
| 23 | + itemExtent: 100, |
| 24 | + controller: ScrollController(initialScrollOffset: 100), |
| 25 | + children: <Widget>[ |
| 26 | + Container( |
| 27 | + constraints: BoxConstraints.expand(height: 100), |
| 28 | + color: RED, |
| 29 | + ), |
| 30 | + Container( |
| 31 | + constraints: BoxConstraints.expand(height: 100), |
| 32 | + color: BLUE, |
| 33 | + ), |
| 34 | + Container( |
| 35 | + constraints: BoxConstraints.expand(height: 100), |
| 36 | + color: YELLOW, |
| 37 | + ), |
| 38 | + Container( |
| 39 | + constraints: BoxConstraints.expand(height: 100), |
| 40 | + color: RED_LIGHT, |
| 41 | + ), |
| 42 | + Container( |
| 43 | + constraints: BoxConstraints.expand(height: 100), |
| 44 | + color: BLUE_DEEP, |
| 45 | + ), |
| 46 | + Container( |
| 47 | + constraints: BoxConstraints.expand(height: 100), |
| 48 | + color: RED, |
| 49 | + ), |
| 50 | + Container( |
| 51 | + constraints: BoxConstraints.expand(height: 100), |
| 52 | + color: BLUE, |
| 53 | + ), |
| 54 | + Container( |
| 55 | + constraints: BoxConstraints.expand(height: 100), |
| 56 | + color: YELLOW, |
| 57 | + ), |
| 58 | + Container( |
| 59 | + constraints: BoxConstraints.expand(height: 100), |
| 60 | + color: RED_LIGHT, |
| 61 | + ), |
| 62 | + Container( |
| 63 | + constraints: BoxConstraints.expand(height: 100), |
| 64 | + color: BLUE_DEEP, |
| 65 | + ) |
| 66 | + ], |
| 67 | + ); |
| 68 | + |
| 69 | + @override |
| 70 | + Widget build(BuildContext context) { |
| 71 | + return Scaffold( |
| 72 | + appBar: AppBar( |
| 73 | + title: Text(""), |
| 74 | + ), |
| 75 | + body: _listView(), |
| 76 | + ); |
| 77 | + } |
| 78 | +} |
0 commit comments