widget style
this widget style package requires dart 2.6.0 or newer which implies a flutter version supporting this dart version. as of right now flutter stable does not support these constraints
basic example
final styledwidget = (widget child) => styled.widget(child)
.padding(all: 20)
.backgroundcolor(colors.blue)
.constraints(width: 100, height: 100)
.borderradius(all: 10)
.elevation(10)
.alignment(alignment.center);
@override
widget build(buildcontext context) => styledwidget(flutterlogo());
native flutter equivilent
align(
alignment: alignment.center,
child: decoratedbox(
decoration: boxdecoration(
boxshadow: [
boxshadow(
color: color(0x55000000),
offset: offset(0, 10),
blurradius: 10,
),
],
),
child: cliprrect(
borderradius: borderradius.circular(10),
child: constrainedbox(
constraints: boxconstraints.tightfor(width: 100, height: 100),
child: decoratedbox(
decoration: boxdecoration(color: colors.blue),
child: padding(
padding: edgeinsets.all(10),
child: flutterlogo(),
),
),
),
),
),
),
result
example
text('some text')
.textcolor(colors.white)
.bold()
.alignment(alignment.center) // aligns text
.constraints(width: 100, height: 100)
.ripple()
.backgroundcolor(colors.blue)
.borderradius(all: 10)
.elevation(10)
.alignment(alignment.center), // aligns widget
icon(icons.portable_wifi_off)
.iconcolor(colors.yellow)
.iconsize(24)
.padding(all: 30)
.backgroundcolor(colors.amber),
native flutter equivilent
align(
alignment: alignment.center,
child: cliprrect(
borderradius: borderradius.circular(10),
child: decoratedbox(
decoration: boxdecoration(
color: colors.blue,
),
child: constrainedbox(
constraints: boxconstraints.tightfor(width: 100, height: 100),
child: align(
alignment: alignment.center,
child: text(
'some text',
style: textstyle(
fontweight: fontweight.bold, color: colors.white),
),
),
),
),
),
),
decoratedbox(
decoration: boxdecoration(color: colors.amber),
child: padding(
padding: edgeinsets.all(30),
child: icon(
icons.portable_wifi_off,
size: 24,
color: colors.yellow,
),
),
),
result
Comments are closed.