Form的方法與屬性如下:
const Form({Navigator 的使用可參考:https://yanwei-liu.medium.com/learning-navigation-route-of-flutter-bbc0ee964222
Key? key, //Form的key,這個key在form常會用到。
required this.child, //內容
this.onWillPop, //傳出去的連結是否要提供navigator回傳至上一頁。
this.onChanged, //改變時的回調
AutovalidateMode? autovalidateMode, //autovalidateMode: AutovalidateMode.onUserInteraction,
TextFormField()有以下的屬性,基本上跟TextField是相同的。
可參考:http://acao0429.blogspot.com/search?updated-max=2022-08-07T10:04:00-07:00&max-results=3
TextFormField({這裡只介紹validator的用法。
Key? key,
this.controller,
String? initialValue,
FocusNode? focusNode,
InputDecoration? decoration = const InputDecoration(),
TextInputType? keyboardType,
TextCapitalization textCapitalization = TextCapitalization.none,
TextInputAction? textInputAction,
TextStyle? style,
StrutStyle? strutStyle,
TextDirection? textDirection,
TextAlign textAlign = TextAlign.start,
TextAlignVertical? textAlignVertical,
bool autofocus = false,
bool readOnly = false,
ToolbarOptions? toolbarOptions,
bool? showCursor,
String obscuringCharacter = '•',
bool obscureText = false,
bool autocorrect = true,
SmartDashesType? smartDashesType,
SmartQuotesType? smartQuotesType,
bool enableSuggestions = true,
MaxLengthEnforcement? maxLengthEnforcement,
int? maxLines = 1,
int? minLines,
bool expands = false,
int? maxLength,
ValueChanged<String>? onChanged,
GestureTapCallback? onTap,
VoidCallback? onEditingComplete,
ValueChanged<String>? onFieldSubmitted,
FormFieldSetter<String>? onSaved,
FormFieldValidator<String>? validator,
List<TextInputFormatter>? inputFormatters,
bool? enabled,
double cursorWidth = 2.0,
double? cursorHeight,
Radius? cursorRadius,
Color? cursorColor,
Brightness? keyboardAppearance,
EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
bool? enableInteractiveSelection,
TextSelectionControls? selectionControls,
InputCounterWidgetBuilder? buildCounter,
ScrollPhysics? scrollPhysics,
Iterable<String>? autofillHints,
AutovalidateMode? autovalidateMode,
ScrollController? scrollController,
String? restorationId,
bool enableIMEPersonalizedLearning = true,
MouseCursor? mouseCursor,
在validator中可以檢查你輸入的時候,是否符合你要求格式的要求,並將它顯示在框的上面。
沒有留言:
張貼留言