import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: Text('Remove TextField Underline'), ), body: Center( child: TextField(...
By default, Flutter renders an underline at the bottom. If you don't want the underline to appear, read the examples in this tutorial. Remove Border/Underline of a Specific TextField/TextFormField The TextField and TextFormField have an argument named decoration that allows you to pass a ...
TextField(decoration: InputDecoration(errorBorder: UnderlineInputBorder(/*边角*/borderRadius: BorderRadius.all( Radius.circular(30),//边角为30),borderSide: BorderSide(color: Colors.amber,//边线颜色为黄色width:2,//边线宽度为2), ),focusedErrorBorder: UnderlineInputBorder(borderSide: BorderSide(color...
2. UnderlineInputBorder(底边线,默认就是这个) TextField( decoration: InputDecoration( errorBorder: UnderlineInputBorder( /*边角*/ borderRadius: BorderRadius.all( Radius.circular(30), //边角为30 ), borderSide: BorderSide( color: Colors.amber, //边线颜色为黄色 width: 2, //边线宽度为2 ), )...
I/flutter ( 1091): 编辑输入的值: FocusNode? focusNode 编辑框输入获取或失去焦点监听 .编辑框首次显示输入光标时默认为没有获取焦点, 当进行了输入操作后就等同于获取了焦点 . ///编辑框获取或者失去焦点监听 VoidCallback? _focusNodeListener; FocusNode _focusNode = FocusNode(); ...
// UnderlineInputBorder 类型 return TextField( decoration: InputDecoration(enabled: false, filled: true, fillColor: Colors.green.withOpacity(0.4), disabledBorder: UnderlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.pink, width: 4.0))); ...
小菜测试发现UnderlineInputBorder和OutlineInputBorder对于设置border边框颜色无效,需要通过ThemeData来更改属性; enabledBorder为可用时边框样式,enabled为true; Tips: errorText存在时enabledBorder不生效; 若不设置其他border属性,获取焦点默认是ThemeData中焦点边框,设置border或focusedBorder等生效; ...
c.OutlineInputBorder一般设置为包围的圆角边框;相较于UnderlineInputBorder多了gapPadding属性,用于浮动的labelText与边框的间距; return TextField(decoration: InputDecoration( labelText: '用户名:', labelStyle: TextStyle(color: Colors.purple), border: OutlineInputBorder( ...
今天,我主要讲解Flutter中文本组件方面的Widget,包括Text、RichText、TextField,希望你们会喜欢。 示意图 1. Text 应用场景:普通文本 示意图 属性设置 Text(this.data,{Key key,this.style,// 设置文字样式,具体见下面的说明this.textAlign,// 文字对齐方式:(center居中,left左对齐,right右对齐,justfy两端对齐)th...
分析源码可知,Flutter不仅提供了全面的构建装饰器的方式,还提供了简单便利的构建方式collapsed默认是无边框的,且无法设置标签等其他属性; 案例尝试 icon为装饰器外小图标,可灵活设置图标或其他Widget,默认距输入框16dp,主题可通过IconTheme设置; returnTextField(decoration:InputDecoration(icon:Image.asset('images/ic_la...