Make Flutter code shorter with super_widgets package
Published in
1 min readJul 31, 2019
super_widgets
package can make Flutter code shorter by combining 2 or multiple widgets into single widget.
For example, to create a Stack with padding, background color or alignment:
Container(
color: Colors.blueAccent,
margin: EdgeInsets.all(10),
padding: EdgeInsets.all(20),
alignment: Alignment.bottomCenter,
child: Stack(
fit: StackFit.loose,
alignment: Alignment.centerRight,
children: <Widget>[
Container(color: Colors.red, width: 200, height: 200),
Container(color: Colors.green, width: 100, height: 100),
Text(‘SuperStack demo’),
],
),
)
Instead, with SuperStack
, code will be like this:
SuperStack(
color: Colors.blueAccent,
margin: EdgeInsets.all(10),
padding: EdgeInsets.all(20),
alignment: Alignment.bottomCenter,
childAlignment: Alignment.centerRight,
fit: StackFit.loose,
children: <Widget>[
Container(color: Colors.red, width: 200, height: 200),
Container(color: Colors.green, width: 100, height: 100),
Text('SuperStack demo'),
],
)
At the time of writing, this package only have SuperStack
, SuperIndexedStack
, SuperColumn
and SuperRow
. But more supported widgets will come later.
For more information, here is the link to Github repo: