flutter
Wrap widgets
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Wrap(
direction: Axis.horizontal,
alignment: WrapAlignment.center,
spacing: 20.0,
runSpacing: 20.0,
children: [
Container(child: Text("1").center(), color: Colors.red, width: 100, height: 100),
Container(child: Text("1").center(), color: Colors.red, width: 100, height: 100),
Container(child: Text("1").center(), color: Colors.red, width: 100, height: 100),
Container(child: Text("1").center(), color: Colors.red, width: 100, height: 100),
],
);
}
}
extension UIHelper on Widget {
Widget center() {
return Center(child: this);
}
}
Was this helpful?
Similar Posts