public DropdownButtonFormField( Key key = null, T value = null, List <DropdownMenuItem <T> > items = null, ValueChanged <T> onChanged = null, InputDecoration decoration = null, FormFieldSetter <T> onSaved = null, FormFieldValidator <T> validator = null, Widget hint = null ) : base( key: key, onSaved: onSaved, initialValue: value, validator: validator, builder: (FormFieldState <T> field) => { InputDecoration effectiveDecoration = (decoration ?? new InputDecoration()) .applyDefaults(Theme.of(field.context).inputDecorationTheme); return(new InputDecorator( decoration: effectiveDecoration.copyWith(errorText: field.errorText), isEmpty: value == null, child: new DropdownButtonHideUnderline( child: new DropdownButton <T>( isDense: true, value: value, items: items, hint: hint, onChanged: field.didChange ) ) )); } ) { this.onChanged = onChanged; }
public FormField( Key key = null, FormFieldBuilder <T> builder = null, FormFieldSetter <T> onSaved = null, FormFieldValidator <T> validator = null, T initialValue = null, bool autovalidate = false, bool enabled = true ) : base(key: key) { D.assert(builder != null); this.onSaved = onSaved; this.validator = validator; this.builder = builder; this.initialValue = initialValue; this.autovalidate = autovalidate; this.enabled = enabled; }
public PasswordField( Key fieldKey = null, string hintText = null, string labelText = null, string helperText = null, FormFieldSetter <string> onSaved = null, FormFieldValidator <string> validator = null, ValueChanged <string> onFieldSubmitted = null ) { this.fieldKey = fieldKey; this.hintText = hintText; this.labelText = labelText; this.helperText = helperText; this.onSaved = onSaved; this.validator = validator; this.onFieldSubmitted = onFieldSubmitted; }
public TextFormField( Key key = null, TextEditingController controller = null, string initialValue = null, FocusNode focusNode = null, InputDecoration decoration = null, TextInputType keyboardType = null, TextCapitalization textCapitalization = TextCapitalization.none, TextInputAction?textInputAction = null, TextStyle style = null, TextDirection?textDirection = null, TextAlign textAlign = TextAlign.left, bool autofocus = false, bool obscureText = false, bool autocorrect = true, bool autovalidate = false, bool maxLengthEnforced = true, int maxLines = 1, int?maxLength = null, VoidCallback onEditingComplete = null, ValueChanged <string> onFieldSubmitted = null, FormFieldSetter <string> onSaved = null, FormFieldValidator <string> validator = null, List <TextInputFormatter> inputFormatters = null, bool enabled = true, float cursorWidth = 2.0f, Radius cursorRadius = null, Color cursorColor = null, Brightness?keyboardAppearance = null, EdgeInsets scrollPadding = null, bool enableInteractiveSelection = true, InputCounterWidgetBuilder buildCounter = null ) : base( key: key, initialValue: controller != null ? controller.text : (initialValue ?? ""), onSaved: onSaved, validator: validator, autovalidate: autovalidate, enabled: enabled, builder: (FormFieldState <string> field) => { _TextFormFieldState state = (_TextFormFieldState)field; InputDecoration effectiveDecoration = (decoration ?? new InputDecoration()) .applyDefaults(Theme.of(field.context).inputDecorationTheme); return(new TextField( controller: state._effectiveController, focusNode: focusNode, decoration: effectiveDecoration.copyWith(errorText: field.errorText), keyboardType: keyboardType, textInputAction: textInputAction, style: style, textAlign: textAlign, textDirection: textDirection ?? TextDirection.ltr, textCapitalization: textCapitalization, autofocus: autofocus, obscureText: obscureText, autocorrect: autocorrect, maxLengthEnforced: maxLengthEnforced, maxLines: maxLines, maxLength: maxLength, onChanged: field.didChange, onEditingComplete: onEditingComplete, onSubmitted: onFieldSubmitted, inputFormatters: inputFormatters, enabled: enabled, cursorWidth: cursorWidth, cursorRadius: cursorRadius, cursorColor: cursorColor, scrollPadding: scrollPadding ?? EdgeInsets.all(20.0f), keyboardAppearance: keyboardAppearance, enableInteractiveSelection: enableInteractiveSelection, buildCounter: buildCounter )); } ) { D.assert(initialValue == null || controller == null); D.assert(maxLines > 0); D.assert(maxLength == null || maxLength > 0); this.controller = controller; }
public FileFormFiled( string title, string lead, string ext = "", FormFieldSetter <string> onSaved = null, string initialValue = "", bool autovalidate = false, bool enabled = true ) : base( onSaved: onSaved, initialValue: initialValue, autovalidate: autovalidate, enabled: enabled, builder: state => new Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: new List <Widget> { new Container( margin: EdgeInsets.only(top: 8f), child: new Text( title ) ), new Row( children: new List <Widget> { new Container( padding: EdgeInsets.all(8f), child: new RaisedButton( child: new Text("Select"), onPressed: () => { var ret = DataUploader.OpenFile( lead, "", ext ); state.didChange(ret); } ) ), new Flexible( child: new Container( padding: EdgeInsets.all(4f), width: float.MaxValue, decoration: new BoxDecoration( border: new Border( bottom: new BorderSide( width: 1f, color: Theme .of(state.context) .primaryColorDark ) ) ), child: new Text( data: state.value ?? "", overflow: TextOverflow.ellipsis, maxLines: 1 ) ) ) } ), new Container( height: string.IsNullOrEmpty(state.errorText) ? new float?(0f) : null, padding: EdgeInsets.only(top: 4f), child: new Text( state.errorText ?? "", style: new TextStyle( color: Theme.of(state.context).errorColor ) ) ) } ), validator: value => { if (string.IsNullOrEmpty(value)) { return("Please select a file."); } return(null); } ) {}
public ImageFileFormSetField( string title = null, string lead = "", FormFieldSetter <List <string> > onSaved = null, List <string> initialValue = null, bool autovalidate = false, bool enabled = true ) : base( onSaved: onSaved, initialValue: initialValue, autovalidate: autovalidate, enabled: enabled, builder: state => { var list = new List <Widget> { new Card( child: new Container( width: 64f, height: 64f, child: new ConstrainedBox( constraints: BoxConstraints.expand(), child: new FlatButton( onPressed: () => { var ret = DataUploader.OpenFile( lead, "", "png, jpg" ); if (state.value == null) { state.didChange(new List <string> { ret }); } else { state.value.Add(ret); state.didChange(state.value); } }, padding: EdgeInsets.all(0f), child: new Icon(Icons.add) ) ) ) ) }; if (state.value != null) { list.AddRange( state .value .Select((path, i) => new Card( child: new Container( width: 64f, height: 64f, child: new ConstrainedBox( constraints: BoxConstraints.expand(), child: new FlatButton( onPressed: () => { var ret = DataUploader.OpenFile( lead, "", "png, jpg" ); state.value[i] = ret; state.didChange(state.value); }, padding: EdgeInsets.all(0f), child: Image.file(path) ) ) ) ) ) ); } return(new Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: new List <Widget> { new Container( margin: EdgeInsets.only(top: 8f), height: string.IsNullOrEmpty(title) ? new float?(0f) : null, width: float.MaxValue, child: string.IsNullOrEmpty(title) ? null : new Text(title) ), new Container( height: 72f, child: new ListView( scrollDirection: Axis.horizontal, children: list ) ) } )); }, validator: value => { return(null); } ) {}
public ImageFileFormField( string title = null, string lead = "", FormFieldSetter <string> onSaved = null, string initialValue = "", bool autovalidate = false, bool enabled = true ) : base( onSaved: onSaved, initialValue: initialValue, autovalidate: autovalidate, enabled: enabled, builder: state => new Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: new List <Widget> { new Container( margin: EdgeInsets.only(top: 8f), height: string.IsNullOrEmpty(title) ? new float?(0f) : null, child: string.IsNullOrEmpty(title) ? null : new Text(title) ), new Card( child: new Container( width: 128, height: 128, child: new ConstrainedBox( constraints: BoxConstraints.expand(), child: new FlatButton( onPressed: () => { var ret = DataUploader.OpenFile( lead, "", "png, jpg" ); state.didChange(ret); }, padding: EdgeInsets.all(0f), child: string.IsNullOrEmpty(state.value) ? (Widget)(new Icon(Icons.add)) : (Widget)Image.file(state.value) ) ) ) ), new Container( height: string.IsNullOrEmpty(state.errorText) ? new float?(0f) : null, padding: EdgeInsets.only(top: 4f), child: new Text( state.errorText ?? "", style: new TextStyle( color: Theme.of(state.context).errorColor ) ) ) } ), validator: value => { if (string.IsNullOrEmpty(value)) { return("Please select an image."); } return(null); } ) {}
public TextFormField( Key key = null, TextEditingController controller = null, string initialValue = null, FocusNode focusNode = null, InputDecoration decoration = null, TextInputType keyboardType = null, TextCapitalization textCapitalization = TextCapitalization.none, TextInputAction?textInputAction = null, TextStyle style = null, StrutStyle strutStyle = null, TextDirection?textDirection = null, TextAlign textAlign = TextAlign.left, TextAlignVertical textAlignVertical = null, bool autofocus = false, bool readOnly = false, ToolbarOptions toolbarOptions = null, bool?showCursor = null, bool obscureText = false, bool autocorrect = true, SmartDashesType?smartDashesType = null, SmartQuotesType?smartQuotesType = null, bool enableSuggestions = true, bool autovalidate = false, bool maxLengthEnforced = true, int?maxLines = 1, int?minLines = null, bool expands = false, int?maxLength = null, ValueChanged <string> onChanged = null, GestureTapCallback onTap = null, VoidCallback onEditingComplete = null, ValueChanged <string> onFieldSubmitted = null, FormFieldSetter <string> onSaved = null, FormFieldValidator <string> validator = null, List <TextInputFormatter> inputFormatters = null, bool enabled = true, float cursorWidth = 2.0f, Radius cursorRadius = null, Color cursorColor = null, Brightness?keyboardAppearance = null, EdgeInsets scrollPadding = null, bool enableInteractiveSelection = true, InputCounterWidgetBuilder buildCounter = null, ScrollPhysics scrollPhysics = null ) : base( key: key, initialValue: controller != null ? controller.text : (initialValue ?? ""), onSaved: onSaved, validator: validator, autovalidate: autovalidate, enabled: enabled, builder: (FormFieldState <string> field) => { _TextFormFieldState state = (_TextFormFieldState)field; InputDecoration effectiveDecoration = (decoration ?? new InputDecoration()) .applyDefaults(Theme.of(field.context).inputDecorationTheme); void onChangedHandler(string value) { if (onChanged != null) { onChanged(value); } field.didChange(value); } return(new TextField( controller: state._effectiveController, focusNode: focusNode, decoration: effectiveDecoration.copyWith(errorText: field.errorText), keyboardType: keyboardType, textInputAction: textInputAction, style: style, strutStyle: strutStyle, textAlign: textAlign, textAlignVertical: textAlignVertical, textDirection: textDirection ?? TextDirection.ltr, textCapitalization: textCapitalization, autofocus: autofocus, toolbarOptions: toolbarOptions, readOnly: readOnly, showCursor: showCursor, obscureText: obscureText, autocorrect: autocorrect, smartDashesType: smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled), smartQuotesType: smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled), enableSuggestions: enableSuggestions, maxLengthEnforced: maxLengthEnforced, maxLines: maxLines, minLines: minLines, expands: expands, maxLength: maxLength, onChanged: onChangedHandler, onTap: onTap, onEditingComplete: onEditingComplete, onSubmitted: onFieldSubmitted, inputFormatters: inputFormatters, enabled: enabled, cursorWidth: cursorWidth, cursorRadius: cursorRadius, cursorColor: cursorColor, scrollPadding: scrollPadding ?? EdgeInsets.all(20.0f), scrollPhysics: scrollPhysics, keyboardAppearance: keyboardAppearance, enableInteractiveSelection: enableInteractiveSelection, buildCounter: buildCounter )); } ) { D.assert(initialValue == null || controller == null); D.assert(maxLines > 0); D.assert(maxLines == null || maxLines > 0); D.assert(minLines == null || minLines > 0); D.assert((maxLines == null) || (minLines == null) || (maxLines >= minLines), () => "minLines can't be greater than maxLines"); D.assert(!expands || (maxLines == null && minLines == null), () => "minLines and maxLines must be null when expands is true."); D.assert(!obscureText || maxLines == 1, () => "Obscured fields cannot be multiline."); D.assert(maxLength == null || maxLength > 0); this.controller = controller; }