CustomMultiChildLayout从字面意思就说的很清楚了,自定义多个孩子的布局控件
基本用法 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 CustomMultiChildLayout( delegate: XXXDelegate(dataList), children: dataList.map((e) => LayoutId(id: e['id' ], child: const _FigureBlock())).toList(), ) class _FigureBlock extends StatelessWidget {} class XXXDelegate extends MultiChildLayoutDelegate { XXXDelegate(this .dataList); List dataList; @override void performLayout(Size size) { for (var element in dataList) { String id = element['id' ]; Rect rect = element['rect' ]; layoutChild(id, BoxConstraints(maxHeight: rect.height, maxWidth: size.width)); positionChild(id, Offset(rect.left, rect.top)); } } @override bool shouldRelayout(_BlockEventMultiChildLayoutDelegate oldDelegate) { return oldDelegate.dataList != dataList; } }