我试图定义Input装饰来更改输入TextField下划线的颜色。但这不起作用。有人可以建议我在这里错过什么吗?
这是代码段:
Dim deleg As New ValidationCallBack(AddressOf ValidationCallBackEvent)
Dim processor = New Processor(True)
Dim sXsdPathUri As String = "c:\temp\the.xsd"
Dim sXmlPathUri As String = "c:\temp\the.xml"
processor.SetProperty("http://saxon.sf.net/feature/timing", "true")
processor.SetProperty("http://saxon.sf.net/feature/validation-warnings", "false")
Dim manager As SchemaManager = processor.SchemaManager
Dim schemaUri As System.Uri
schemaUri = New System.Uri(sXsdPathUri)
manager.Compile(schemaUri)
Dim validator As SchemaValidator = manager.NewSchemaValidator
Dim settings As System.Xml.XmlReaderSettings = New System.Xml.XmlReaderSettings
settings.DtdProcessing = System.Xml.DtdProcessing.Ignore
Dim inputFileName As String = New Uri(sXmlPathUri).ToString()
Dim xmlReader As System.Xml.XmlReader = System.Xml.XmlReader.Create(inputFileName, settings)
validator.SetSource(xmlReader)
validator.SetInvalidityHandler(IIH) 'suss; but it needs a Saxon.Api.IInvalidityHandler..
validator.Run()
Try
validator.Run()
sResult = "Valid!!"
Catch ex As Exception
Dim err As StaticError
For Each err In validator.ErrorList 'still goes here
答案 0 :(得分:4)
decoration: InputDecoration(
hintText: 'Username',
hintStyle: TextStyle(color: Colors.white),
enabledBorder: new UnderlineInputBorder(
borderSide: BorderSide(color: Colors.white,
width: 1.0, style: BorderStyle.none ),
),
只需将“ border”更改为“ enabledBorder”即可。希望有帮助!
答案 1 :(得分:4)
我们必须同时使用enabledBorder
和focusedBorder
。
enabledBorder
:当TextField
没有重点时它将起作用。 focusedBorder
:当TextField
成为焦点时,它将起作用。enabledBorder: new UnderlineInputBorder(
borderSide: BorderSide(
color: Colors.black
),
),
// and:
focusedBorder: new UnderlineInputBorder(
borderSide: BorderSide(
color: Colors.black
),
),
答案 2 :(得分:2)
刚刚使用-:
decoration: InputDecoration(
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.cyan),
),
),
对我有用:)
答案 3 :(得分:1)
您必须将小部件层次结构放在 MaterialApp 下。
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter WebView Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new Container(
**//put widget here.**
));
}
}
答案 4 :(得分:1)
您可以将TextField
包裹在Theme
中,然后像这样更改accentColor
:
Theme(
data: Theme.of(context).copyWith(accentColor: Colors.red),
child: TextField(),
)
答案 5 :(得分:0)
child: TextField(
controller: email,
enabled: true,
keyboardType: TextInputType.emailAddress,
decoration: InputDecoration(
filled: true,
fillColor: Color(0xFFF2F2F2),
enabledBorder: new OutlineInputBorder(
borderSide: new BorderSide(color: Colors.orange)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.orange),
),
hintText: ' Email ',
icon: Icon(
Icons.email,
color: Colors.orange,
size: 30.0,
),
)
)