Here my style of my textfiled and when ever i click to write the border is disappear
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: white,
),
borderRadius: BorderRadius.circular(30.0),
),
hintText: (hintText),
hintStyle: TextStyle(
fontSize: 23, fontWeight: FontWeight.bold, color: white),
You need to set focusedBorder as well for InputDecoration.
TextField(
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white,
),
borderRadius: BorderRadius.circular(30.0),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white,
),
borderRadius: BorderRadius.circular(30.0),
),
),
);
Related
The function 'InputDecorationTheme' isn't defined.
Try importing the library that defines 'InputDecorationTheme', correcting the name to the name of an existing function, or defining a function named 'InputDecorationTheme'
inputDecorationTheme: InputDecorationTheme (
contentPadding: EdgeInsets.all(
AppPadding.p8,
),
hintStyle: getReglarStyle(
color: ColorManager.grey,
fontSize: FontSize.s14,
),
labelStyle: getReglarStyle(
color: ColorManager.grey,
fontSize: FontSize.s14,
),
errorStyle: getReglarStyle(
color: ColorManager.error,
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: ColorManager.grey,
width: AppSize.s1_5,
),
borderRadius: BorderRadius.circular(AppSize.s8),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: ColorManager.primary,
width: AppSize.s1_5,
),
borderRadius: BorderRadius.circular(AppSize.s8),
),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(
color: ColorManager.primary,
width: AppSize.s14,
),
borderRadius: BorderRadius.circular(AppSize.s8),
),
)
);
}
I want to remove this underline.
This is my input field
TextField(
decoration: InputDecoration(
contentPadding:
const EdgeInsets.symmetric(vertical: 10, horizontal: 20),
hintText: label,
hintStyle: TextStyle(color: Colors.grey[400]),
fillColor: Colors.white,
filled: true,
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(30),
borderSide:
const BorderSide(color: AppColors.textGrey2, width: 0.5),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(30),
borderSide:
const BorderSide(color: AppColors.textGrey2, width: 0.5),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(30),
borderSide:
const BorderSide(color: AppColors.textGrey2, width: 0.5)),
),
obscureText: obscureText,
),
I need this output
try to remove the styling from the text, add this line to your TextField
style: TextStyle(decoration:TextDecoration.none),
Do you see the underline in the hint text of your TextField?
If you put a Material widget above in your widget tree this should go by default.
Otherwise you can set it in the TextStyle of your hintText
hintStyle: TextStyle(decoration: TextDecoration.none)
I want to change TextFiled underline color when it is disabled
child: TextField(
***enabled: false,***
controller: resultController,
style: TextStyle(
color: Colors.orange, fontSize: 18, fontWeight: FontWeight.bold),
keyboardType: TextInputType.number,
decoration: InputDecoration(
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.white)),
labelText: resultLableText,
labelStyle: TextStyle(color: Colors.white)),
),
Look at the below code, it will easily solve your problem:
TextField(
decoration: InputDecoration(
hintText: "Your hint here",
//defalult border
border: OutlineInputBorder(
borderSide: BorderSide(width: 1, color: Colors.green)),
//disabled border
disabledBorder: OutlineInputBorder(
borderSide: BorderSide(width: 1, color: Colors.grey)),
//enabled border
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(width: 1, color: Colors.blue)),
//error boreder
errorBorder: OutlineInputBorder(
borderSide: BorderSide(width: 1, color: Colors.red)),
//focused border
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(width: 1, color: Colors.purple)),
//error while focused border
focusedErrorBorder: OutlineInputBorder(
borderSide: BorderSide(width: 1, color: Colors.amber)),
),
),
I am unsure that there is a method you can use to check if a TextField is disabled, but a way you can do it is you can create a bool that keeps track if the TextField is disabled.
Create the bool
bool isDisabled = false;
Make a function that changes the value
Function<void> changeDisabled() {
setState() {
isDisabled ? isDisabled = false : isDisabled = true
}
}
Check the status of isDisabled in your code.
child: TextField(
enabled: false,
controller: resultController,
style: TextStyle(
color: Colors.orange, fontSize: 18, fontWeight: FontWeight.bold),
keyboardType: TextInputType.number,
decoration: InputDecoration(
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: isDisabled ? Colors.white : Colors.black)),
labelText: resultLableText,
labelStyle: TextStyle(color: Colors.white)),
),
You can specify the underline color of the TextField if its disabled in the same way you did for when its enabled by using the disabledBorder property of the InputDecoration like :
InputDecoration(
enabledBorder:
UnderlineInputBorder(borderSide: BorderSide(color: Colors.white)),
labelText: resultLableText,
labelStyle: TextStyle(color: Colors.white),
disabledBorder:
UnderlineInputBorder(borderSide: BorderSide(color: Colors.green)),
),
or specifying it in the ThemeData like :
MaterialApp(
theme: ThemeData.light().copyWith(
inputDecorationTheme: InputDecorationTheme(
disabledBorder:
UnderlineInputBorder(borderSide: BorderSide(color: Colors.green)),
)),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: MyWidget(),
),
),
);
}
I am trying to change the color of input border but its not changing. Only the color change when its on focus but normally its not changing the color
Code
Container(
height: Height * 0.08,
width: Width * 0.9,
child: TextFormField(
style: TextStyle(
fontSize: 15,
color: Color(0xff04385f),
fontFamily: 'UbuntuRegular'),
decoration: new InputDecoration(
border: new OutlineInputBorder(
borderSide: const BorderSide(
color: Colors.red, width: 1.25),
borderRadius: const BorderRadius.all(
const Radius.circular(10.0),
),
),
filled: true,
hintStyle: new TextStyle(
color: Colors.grey[800],
fontFamily: 'UbuntuRegular'),
hintText: "Username",
fillColor: Colors.white70,
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: Color(0xff04385f), width: 1.25),
borderRadius: const BorderRadius.all(
const Radius.circular(10.0),
),
),
),
),
),
As you can see i define red color on inputborder but its showing some dark grey color
add enabledColor:
enabledBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: Colors.red, width: 1.25),
borderRadius: const BorderRadius.all(
const Radius.circular(10.0),
),
),
Unable to change the default border color when TextFormField is not active. When TextFormField is not active this shows DarkGrey-Border color. So, how to change that.
Theme(
data: new ThemeData(
primaryColor: Colors.red,
primaryColorDark: Colors.black,
),
child: TextFormField(
decoration: new InputDecoration(
labelText: "Enter Email",
fillColor: Colors.white,
border: new OutlineInputBorder(
borderRadius: new BorderRadius.circular(25.0),
borderSide: new BorderSide(),
),
//fillColor: Colors.green
),
validator: (val) {
if (val.length == 0) {
return "Email cannot be empty";
} else {
return null;
}
},
keyboardType: TextInputType.emailAddress,
style: new TextStyle(
fontFamily: "Poppins",
),
),
),
Use enabledBorder of the InputDecoration, don't forget you can also use the focusedBorder, like this :
InputDecoration(
labelText: "Enter Email",
fillColor: Colors.white,
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(25.0),
borderSide: BorderSide(
color: Colors.blue,
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(25.0),
borderSide: BorderSide(
color: Colors.red,
width: 2.0,
),
),
)
Here you have more info: https://api.flutter.dev/flutter/material/InputDecoration/enabledBorder.html
OutlineInputBorder(
borderSide: BorderSide(
color: AppColor.secondaryBackground)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color:
AppColor.secondaryBackground)),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color:
AppColor.secondaryBackground),
),