当前位置:网站首页>Detailed explanation of shutter textfield
Detailed explanation of shutter textfield
2022-06-26 19:54:00 【InfoQ】
effect :

TextFieldBasic attributes
TextFieldmaterial designInputDecorationTextField
const TextField({
Key key,
this.controller,// controller
this.focusNode,// The focus of
this.decoration = const InputDecoration(),// decorate
TextInputType keyboardType,// Keyboard type , Input type
this.textInputAction,// Keyboard button
this.textCapitalization = TextCapitalization.none,// Case write
this.style,// style
this.strutStyle,
this.textAlign = TextAlign.start,// Alignment mode
this.textDirection,
this.autofocus = false,// Autofocus
this.obscureText = false,// Whether to hide the text , The password type is displayed
this.autocorrect = true,// AutoCorrect
this.maxLines = 1,// Maximum number of rows , The height is synchronized with the number of rows
this.minLines,// The minimum number of lines
this.expands = false,
this.maxLength,// Maximum number of entries , When there is a value, there will be a counter in the lower right corner
this.maxLengthEnforced = true,
this.onChanged,// Input change callback
this.onEditingComplete,// When input is complete , coordination TextInputAction.done Use
this.onSubmitted,// When submitting , coordination TextInputAction
this.inputFormatters,// Input verification
this.enabled,// Is it available
this.cursorWidth = 2.0,// Cursor width
this.cursorRadius,// Cursor fillet
this.cursorColor,// Cursor color
this.keyboardAppearance,
this.scrollPadding = const EdgeInsets.all(20.0),
this.dragStartBehavior = DragStartBehavior.start,
this.enableInteractiveSelection,
this.onTap,// Click event
this.buildCounter,
this.scrollPhysics,
})
InputDecoration
const InputDecoration({
this.icon,// The icon outside the left
this.labelText,// Suspended prompt , May replace hintText
this.labelStyle,// Style of floating prompt text
this.helperText,// Help text
this.helperStyle,
this.hintText,// Input prompt
this.hintStyle,
this.hintMaxLines,
this.errorText,// Error message
this.errorStyle,
this.errorMaxLines,
this.hasFloatingPlaceholder = true,// Whether to display levitation prompt text
this.isDense,
this.contentPadding,// Infill
this.prefixIcon,// The icon in the left side
this.prefix,
this.prefixText,// Text on the left
this.prefixStyle,
this.suffixIcon,// Right inner icon
this.suffix,
this.suffixText,
this.suffixStyle,
this.counter,// Custom counters
this.counterText,// Count text
this.counterStyle,// Count style
this.filled,// Whether to fill
this.fillColor,// Fill color
this.errorBorder,
this.focusedBorder,
this.focusedErrorBorder,
this.disabledBorder,
this.enabledBorder,
this.border,// Frame
this.enabled = true,
this.semanticCounterText,
this.alignLabelWithHint,
})
style
Basic style
TextField(),

Hide text
obscureText TextField(
obscureText: true,
),

Keyboard type
number TextField(
keyboardType: TextInputType.number,
),

TextInputType- text
- multiline
- number
- phone
- datetime
- emailAddress
- url
Keyboard button
TextField(
textInputAction: TextInputAction.done,
),
TextInputAction- none
- unspecified
- done
- go
- search
- send
- next
- previous
- continueAction
- join
- route
- emergencyCall
- newline
Case write
TextField(
textCapitalization: TextCapitalization.words,
),

TextCapitalization- words: Capitalize the first letter of a word
- sentences: The first letter of a sentence is capitalized
- characters: All capitals
- none: The default is no
cursor
TextField(
cursorColor: Colors.orange,
cursorWidth: 15,
cursorRadius: Radius.circular(15),
),

Maximum number of rows
TextField(
maxLines: 3,
),

minLines TextField(
maxLines: 3,
minLines: 1,
),

Counter
TextField(
maxLength: 8,
),

TextField(
maxLength: 8,
decoration: InputDecoration(
counter: Text(" Custom count 0/100"),
),
),

InputDecorationcounterwidgetTextcounterTextcounterStyleIcon
- The icon outside the left
TextField(
decoration: InputDecoration(
icon: Icon(Icons.person),
),
),

- Left inner icon
TextField(
decoration: InputDecoration(
prefixIcon: Icon(Icons.phone_android),
),
),

- Right inner icon
TextField(
decoration: InputDecoration(
suffixIcon: IconButton(
icon: Icon(Icons.close),
onPressed: () {
controller.clear();
},
),
),
),

IconButtonprefixIcon this.prefix,
this.prefixText,
this.prefixStyle,
Prompt text
- Input prompt text
TextField(
controller: controller,
decoration: InputDecoration(
hintText: ' Please enter your account number aaa',
),
),

- Floating prompt text
TextField(
controller: controller,
decoration: InputDecoration(
hintText: ' Please enter your account number aaa',
labelText: ' Please enter your account number ',
),
),

labelTexthintText- Help prompt text
TextField(
controller: controller,
decoration: InputDecoration(
helperText: " Help text ",
helperStyle: TextStyle(color: Colors.blue)
),
),

- Error message text
TextField(
controller: controller,
decoration: InputDecoration(
errorText: " You didn't enter anything ",
),
),

Remove underscores
TextField(
decoration: InputDecoration.collapsed(hintText: " Input box without underline "),
),

decoration: nullFrame
TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
),
),

TextField(
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(30)),
),
),
),

Get input
- onChanged
onChangedIt is a callback when the input content changes , Return to oneStringType value , You can use a variable to record
TextField(
onChanged: (text) {
print(" When input changes " + text);
},
),
- controller I.e. controller , initialization :
var controller;
@override
void initState() {
super.initState();
controller = TextEditingController();
controller.addListener(() {});
}
TextField(
controller: controller,
),
controller.text
controller.textTurn off the soft keyboard
focusNodeFocusNode userFocusNode = FocusNode();
TextField(
focusNode: userFocusNode,
),
userFocusNode.unfocus();
check
inputFormatters final List<TextInputFormatter> inputFormatters;
- BlacklistingTextInputFormatter
- WhitelistingTextInputFormatter
- LengthLimitingTextInputFormatter
static final BlacklistingTextInputFormatter singleLineFormatter
= BlacklistingTextInputFormatter(RegExp(r'\n'));
RegExp String validateMobile(String value) {
String patttern = r'(^[0-9]*$)';
RegExp regExp = new RegExp(patttern);
if (value.length == 0) {
return " Cell phone number is empty ";
} else if (!regExp.hasMatch(value)) {
return " The phone number format is incorrect ";
}
return null;
}
FromTextFormFieldabnormal
- After the soft keyboard pops up
- After the soft keyboard pops up, the height overflows
summary

github:
https://github.com/yechaoa/wanandroid_flutter
边栏推荐
- 转:实事求是
- WebView load pdf
- Using cache in vuex to solve the problem of data loss in refreshing state
- 460million zongzi were sold in half a year. How big is the "imagination space" of time-honored brands?
- Flutter TextField详解
- JSONUtils工具类(基于alibaba fastjson)
- Résolution du problème: la machine virtuelle n'a pas pu copier et coller le fichier
- 数据库范式和主码的选择
- 飞天+CIPU体为元宇宙带来更大想象空间
- Invocation failed Unexpected end of file from server
猜你喜欢

Tiktok practice ~ homepage video ~ pull-down refresh

Tree array

stm32和电机开发(直流有刷电机和步进电机)

Convex hull problem

【Kubernetes】Kubernetes 原理剖析与实战应用(更新中)

Microservice architecture

Six necessary threat tracking tools for threat hunters

Daily basic use of alicloud personal image warehouse

刷新三观的HP-UX系统中的强指针赋值出core问题

Solidity - contract inheritance sub contract contains constructor errors and one contract calls the view function of another contract to charge gas fees
随机推荐
When does the mobile phone video roll off?
转:苹果CEO库克:伟大的想法来自不断拒绝接受现状
(几何) 凸包问题
Project practice 5: build elk log collection system
mysql的充值问题
Redis single sign on system + voting system
BOM and DOM operations
Why don't I recommend going to sap training institution for training?
论数据库的传统与未来之争之溯源溯本----AWS系列专栏
开户可以在网上开么?能安全吗?
On the escape of inequality value
ImageView, glide load long picture (glide load picture)
一些基本错误
JSONUtils工具类(基于alibaba fastjson)
回溯思路详解
stm32和电机开发(直流有刷电机和步进电机)
find_ path、find_ Library memo
Super VRT
Guomingyu: Apple's AR / MR head mounted display is the most complicated product in its history and will be released in January 2023
Uni app uses canvas to draw QR code