Skip to content

Instantly share code, notes, and snippets.

@sethladd
Last active July 12, 2017 22:29
Show Gist options
  • Save sethladd/df690b2eb5923a5699aabbdbb869b1b9 to your computer and use it in GitHub Desktop.
Save sethladd/df690b2eb5923a5699aabbdbb869b1b9 to your computer and use it in GitHub Desktop.
return new SingleChildScrollView(
child: new Container(
margin: const EdgeInsets.all(16.0),
child: new Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new Expanded(child: new LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints){
return new Container(
constraints: new BoxConstraints.tightFor(width: constraints.maxWidth, height: constraints.maxWidth),
padding: const EdgeInsets.all(2.0),
child: new FoodTile(name:"hallo",onPressed: (bool state){}),
);
})),
new Expanded(child: new LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints){
return new Container(
constraints: new BoxConstraints.tightFor(width: constraints.maxWidth, height: constraints.maxWidth),
padding: const EdgeInsets.all(2.0),
child: new FoodTile(name:"hallo 2",onPressed: (bool state){}),
);
})),
new Expanded(child: new LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints){
return new Container(
constraints: new BoxConstraints.tightFor(width: constraints.maxWidth, height: constraints.maxWidth),
padding: const EdgeInsets.all(2.0),
child: new FoodTile(name:"hallo 3",onPressed: (bool state){}),
);
})),
],
),
return SingleChildScrollView(
child: Container(
margin: EdgeInsets.all(16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisSize: MainAxisSize.min,
children: [
Expanded(child: LayoutBuilder(builder: (_, constraints) =>
Container(
constraints: BoxConstraints.tightFor(width: constraints.maxWidth, height: constraints.maxWidth),
padding: EdgeInsets.all(2.0),
child: FoodTile(name:"hallo", onPressed: (_){}),
);
)),
Expanded(child: LayoutBuilder(builder: (_, constraints) =>
Container(
constraints: BoxConstraints.tightFor(width: constraints.maxWidth, height: constraints.maxWidth),
padding: EdgeInsets.all(2.0),
child: FoodTile(name:"hallo 2", onPressed: (_){}),
);
)),
Expanded(child: LayoutBuilder(builder: (_, constraints) =>
Container(
constraints: BoxConstraints.tightFor(width: constraints.maxWidth, height: constraints.maxWidth),
padding: EdgeInsets.all(2.0),
child: FoodTile(name:"hallo 3", onPressed: (_){}),
);
)),
],
),
Widget expandedContainer(Widget child) {
return Expanded(
child: LayoutBuilder(
builder: (_, constraints) {
return Container(
constraints: BoxConstraints.tightFor(width: constraints.maxWidth, height: constraints.maxWidth),
padding: EdgeInsets.all(2.0),
child: child),
);
},
),
);
}
return SingleChildScrollView(
child: Container(
margin: EdgeInsets.all(16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisSize: MainAxisSize.min,
children: [
expandedContainer(FoodTile(name:"hallo", onPressed: (_){})),
expandedContainer(FoodTile(name:"hallo 2", onPressed: (_){})),
expandedContainer(FoodTile(name:"hallo 3", onPressed: (_){})),
],
),
@yjbanov
Copy link

yjbanov commented Jul 12, 2017

return SingleChildScrollView(
    child: Container(
      margin: EdgeInsets.all(16.0),

      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        mainAxisSize: MainAxisSize.min,
        children: [
          FoodTile(name:"hallo", onPressed: (_){}),
          FoodTile(name:"hallo 2", onPressed: (_){}),
          FoodTile(name:"hallo 3", onPressed: (_){}),
        ].map((child) => Expanded(
            child: LayoutBuilder(builder: (_, constraints) => Container(
              constraints: BoxConstraints.tightFor(width: constraints.maxWidth, height: constraints.maxWidth),
              padding: EdgeInsets.all(2.0),
              child: child),
            );
          ))).toList(),
      ),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment