buildListView method
Widget
buildListView(
- BuildContext context,
- ListBindingStyle style,
- ListBindingFieldController controller
override
Implementation
@override
Widget buildListView(
BuildContext context,
ListBindingStyle style,
ListBindingFieldController controller,
) {
var verticalGap = style.spacing ?? 8.0;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
ReorderableListView.builder(
itemCount: controller.fieldOrder.length,
proxyDecorator: (Widget child, int index, Animation<double> animation) {
return Material(color: Colors.transparent, child: child);
},
itemBuilder: (context, index) {
final fieldName = controller.fieldOrder[index];
final fieldController = controller.field(fieldName);
return Padding(
key: Key(fieldName),
padding: index == 0 ? EdgeInsets.zero : EdgeInsets.only(top: verticalGap),
child: Row(
children: [
Expanded(
child: FieldBinding(
field: fieldName,
controller: fieldController,
style: BindingStyle(label: style.itemLabel),
),
),
IconButton(
icon: Icon(Icons.delete),
onPressed: () {
controller.removeFieldAt(index);
},
),
SizedBox(width: 32.0),
],
),
);
},
onReorder: (int oldIndex, int newIndex) {
controller.reorderFields(oldIndex, newIndex);
},
shrinkWrap: true,
),
if (controller.fieldOrder.isNotEmpty) SizedBox(height: verticalGap),
FilledButton(
onPressed: () {
controller.addField();
},
child: Text(style.addButtonLabel ?? "Add"),
),
],
);
}