Search code snippets, questions, articles...

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);
  }
}
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place.
Was this helpful?
0 Comments