File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -445,14 +445,23 @@ class Formatter with Invokable {
445445 'prettyDateTime' : (input) => InvokablePrimitive .prettyDateTime (input),
446446 'prettyCurrency' : (input) => InvokablePrimitive .prettyCurrency (input),
447447 'prettyDuration' : (input) =>
448- InvokablePrimitive .prettyDuration (input, locale: locale)
448+ InvokablePrimitive .prettyDuration (input, locale: locale),
449+ 'pluralize' : pluralize
449450 };
450451 }
451452
452453 @override
453454 Map <String , Function > setters () {
454455 return {};
455456 }
457+
458+ String pluralize (String singularText, int ? count, [pluralText]) {
459+ count ?? = 1 ;
460+ if (count <= 1 ) {
461+ return singularText;
462+ }
463+ return pluralText ?? '${singularText }s' ;
464+ }
456465}
457466
458467class UserInfo with Invokable {
Original file line number Diff line number Diff line change @@ -27,13 +27,22 @@ abstract class WidgetState<W extends HasController> extends BaseWidgetState<W> {
2727 return const SizedBox .shrink ();
2828 }
2929 Widget rtn = buildWidget (context);
30+
31+ // wrap inside Align if specified
32+ if ((widget.controller as WidgetController ).alignToParent != null ) {
33+ rtn = Align (
34+ alignment: (widget.controller as WidgetController ).alignToParent! ,
35+ child: rtn);
36+ }
37+
3038 if ((widget.controller as WidgetController ).expanded == true ) {
3139 /// Important notes:
3240 /// 1. If the Column/Row is scrollable, putting Expanded on the child will cause layout exception
3341 /// 2. If Column/Row is inside a parent without height/width constraint, it will collapse its size.
3442 /// So if we put Expanded on the Column's child, layout exception will occur
3543 rtn = Expanded (child: rtn);
3644 }
45+
3746 return rtn;
3847 }
3948 throw LanguageError ("Wrong usage of widget controller!" );
Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ abstract class WidgetController extends Controller {
1212 bool visible = true ;
1313 String ? id; // do we need this?
1414
15+ // wrap widget inside an Align widget
16+ Alignment ? alignToParent;
17+
1518 // optional label/labelHint for use in Forms
1619 String ? label;
1720 String ? description;
@@ -30,6 +33,7 @@ abstract class WidgetController extends Controller {
3033 return {
3134 'expanded' : (value) => expanded = Utils .getBool (value, fallback: false ),
3235 'visible' : (value) => visible = Utils .getBool (value, fallback: true ),
36+ 'alignToParent' : (value) => alignToParent = Utils .getAlignment (value),
3337 'label' : (value) => label = Utils .optionalString (value),
3438 'description' : (value) => description = Utils .optionalString (value),
3539 'labelHint' : (value) => labelHint = Utils .optionalString (value),
You can’t perform that action at this time.
0 commit comments