当前位置:网站首页>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
边栏推荐
- Pinda general permission system (day 3~day 4)
- Project practice 6: distributed transaction Seata
- [kubernetes] kubernetes principle analysis and practical application (under update)
- 转:实事求是
- 抖音实战~分享模块~短视频下载(保存到相册)
- Why don't I recommend going to sap training institution for training?
- 515. 在每个树行中找最大值
- Résolution du problème: la machine virtuelle n'a pas pu copier et coller le fichier
- Development of NFT for digital collection platform
- Summary of knowledge points
猜你喜欢

抖音实战~搜索页面~视频详情

品达通用权限系统(Day 1~Day 2)

Tiktok practice ~ sharing module ~ copy short video link

阿里云个人镜像仓库日常基本使用

Boot指标监测

Unit test of boot

Refresh the strong pointer assignment problem in the HP-UX system of Sanguan

Some cold knowledge about QT database development

Uni app uses canvas to draw QR code

Microservice architecture
随机推荐
抖音实战~分享模块~生成短视频二维码
Résolution du problème: la machine virtuelle n'a pas pu copier et coller le fichier
710. 黑名单中的随机数
抖音实战~首页视频~下拉刷新
一些基本错误
Redis single sign on system + voting system
转:苹果CEO库克:伟大的想法来自不断拒绝接受现状
515. 在每个树行中找最大值
Invocation failed Unexpected end of file from server
Project practice 5: build elk log collection system
To: Apple CEO Cook: great ideas come from constantly rejecting the status quo
8VC Venture Cup 2017 - Final Round C. Nikita and stack
Separate save file for debug symbols after strip
Tiktok practice ~ sharing module ~ copy short video link
证券开户安全吗,有没有什么危险呢
mysql的充值问题
IK分词器
Kubernetes resource topology aware scheduling optimization
Reading notes: process consulting III
When are global variables initialized before entering the main function?