I need to add shadow on my textfield
My code
TextField(
style: TextStyle(
fontSize: 25.0,
color: Colors.blueAccent,
),
decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0),
prefixIcon: Image.asset('assets/searchIcon#2x.png'),
hintText: "Search services",
border: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.white, width: 32.0),
borderRadius: BorderRadius.circular(25.0),
),
focusedBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.white, width: 32.0),
borderRadius: BorderRadius.circular(25.0))))
Also i want to change the inside color of textfied in white
Want to achieve something like this
You can try something like this below or you can wrap your TextField with Container and use BoxDecoration --> BoxShadow to add drop down shadow to it:
Material(
elevation: 20.0,
shadowColor: Colors.blue,
child: TextField(
obscureText: true,
autofocus: false,
decoration: InputDecoration(
icon: new Icon(Icons.lock, color: Color(0xff224597)),
hintText: 'Password',
fillColor: Colors.white,
filled: true,
contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
enabledBorder: OutlineInputBorder(borderRadius:BorderRadius.circular(5.0),
borderSide: BorderSide(color: Colors.white, width: 3.0))
),
),
)
You can wrap your TextField widget with Material. Material has property about the shadow. You can use it like this:
Material(
elevation: 3.0, // Set here what you wish!
shadowColor: Colors.grey,
child: TextField(
style: TextStyle(
fontSize: 25.0,
color: Colors.blueAccent,
),
decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0),
prefixIcon: Image.asset('assets/searchIcon#2x.png'),
hintText: "Search services",
border: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.white, width: 32.0),
borderRadius: BorderRadius.circular(25.0),
),
focusedBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.white, width: 32.0),
borderRadius: BorderRadius.circular(25.0))))
I could give you an idea. Try something like this,
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(25.0),
boxShadow: [
BoxShadow(
offset: Offset(0,5),
blurRadius: 10.0,
color: Colors.black.withOpacity(0.5),
),
],
),
child: TextField(
style: TextStyle(
fontSize: 25.0,
color: Colors.blueAccent,
),
decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0),
prefixIcon: Image.asset('assets/searchIcon#2x.png'),
hintText: "Search services",
border: OutlineInputBorder(
borderSide: BorderSide(color: Colors.white, width: 32.0),
borderRadius: BorderRadius.circular(25.0),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.white, width: 32.0),
borderRadius: BorderRadius.circular(25.0),
),
),
),
),
Play around with the color and offset value, you will get the desired output!
Hope that suits your case!
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(6),
boxShadow: const [
BoxShadow(
color: Colors.grey,
blurRadius: 10.0, // soften the shadow
spreadRadius: 1.0, //extend the shadow
offset: Offset(
1.0, // Move to right 5 horizontally
1.0, // Move to bottom 5 Vertically
),
)
]),
child: Row(
children: [
Expanded(
child: TextField(
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(6),
borderSide: const BorderSide(
color: Colors.transparent,
)),
disabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(6),
borderSide: const BorderSide(
color: Colors.transparent,
)),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(6),
borderSide: const BorderSide(
color: Colors.transparent,
)),
fillColor: Colors.white,
filled: true,
hintText: "Search by Jewelers Name",
border: InputBorder.none,
hintStyle:
const TextStyle(color: Colors.grey))),
),
],
),
),
Related
I need the login screen with the shared images text field look so I am stock if anyone have idea so kindly share with me. thanks:
You can use Container and InputDecoration:
Container(
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 10,
offset: Offset(1, -1),
),
],
),
child: TextField(
decoration: InputDecoration(
fillColor: Colors.white,
filled: true,
disabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Colors.blue, width: 4, style: BorderStyle.solid),
),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Colors.blue, width: 4, style: BorderStyle.solid),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Colors.blue, width: 4, style: BorderStyle.solid),
),
errorBorder: UnderlineInputBorder(
borderSide: BorderSide(width: 4, style: BorderStyle.solid),
),
),
),
)
Wrap your TextField with DecoratedBox.
DecoratedBox(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: Border(
bottom: BorderSide(color: Colors.blue),
),
),
child: TextField(),
);
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),
),
),
I want both the app bar and the search textbox to stick on screen even while I scroll down
By using bottom property of appbar
bottom: PreferredSize(
preferredSize: Size.fromHeight(70),
child: Container(
//width: MediaQuery.of(context).size.width*0.90,
height: 70,
width: MediaQuery.of(context).size.width,
padding: EdgeInsets.symmetric(vertical: 14,horizontal: 20),
color: Colors.white,
child: TextFormField(
decoration: InputDecoration(
prefixIcon: Icon(Icons.search_rounded,color: Colors.grey,size: 40,),
border: InputBorder.none,
fillColor: Colors.grey.shade300,
enabledBorder: OutlineInputBorder(borderSide: BorderSide(
color: Colors.grey.shade500,
),borderRadius: BorderRadius.circular(10),),
filled: true,
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
color: Colors.grey.shade300
)
),hoverColor: Colors.black,
),
),
),'
I have a rounded textfield. It works well, but when the user taps on it, a grey color background appears. How can I disable that splash effect?
This is my code and result:
new Container(
margin: const EdgeInsets.only(left: 30.0, top: 60.0, right:
30.0),
height: 40.0,
decoration: new BoxDecoration(
color: Colors.white,
borderRadius: new BorderRadius.all(new Radius.circular(25.7))
),
child: new Directionality(
textDirection: TextDirection.ltr,
child: new TextField(
controller: null,
autofocus: false,
style:
new TextStyle(fontSize: 22.0, color: Color(0xFFbdc6cf)),
decoration: new InputDecoration(
filled: true,
fillColor: Colors.white,
hintText: 'Username',
contentPadding: const EdgeInsets.only(
left: 14.0, bottom: 8.0, top: 8.0),
focusedBorder: OutlineInputBorder(
borderSide: new BorderSide(color: Colors.white),
borderRadius: new BorderRadius.circular(25.7),
),
enabledBorder: UnderlineInputBorder(
borderSide: new BorderSide(color: Colors.white),
borderRadius: new BorderRadius.circular(25.7),
),
),
))),
It looks like it's caused by the splash effect on the textfield. I couldn't find a way to disable it for that specific widget but you can make it transparent by wrapping your TextField in a Theme widget and setting the splashColor to transparent:
Theme(
data: Theme.of(context).copyWith(splashColor: Colors.transparent),
child: TextField(
autofocus: false,
style: TextStyle(fontSize: 22.0, color: Color(0xFFbdc6cf)),
decoration: InputDecoration(
filled: true,
fillColor: Colors.white,
hintText: 'Username',
contentPadding:
const EdgeInsets.only(left: 14.0, bottom: 8.0, top: 8.0),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.white),
borderRadius: BorderRadius.circular(25.7),
),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.white),
borderRadius: BorderRadius.circular(25.7),
),
),
),
);
“Flutter Textfield background color”
*Change border color of TextField in flutter
TextFormField(
decoration: InputDecoration(
labelText: "Resevior Name",
fillColor: Colors.white,
focusedBorder:OutlineInputBorder(
borderSide: const BorderSide(color: Colors.white, width: 2.0),
borderRadius: BorderRadius.circular(25.0),
),
),
)
text fieldform color flutter
TextField(
style: TextStyle(color: Colors.red),
decoration: InputDecoration(fillColor: Colors.orange, filled: true),
)
Flutter TextFormField background color
TextFormField(
decoration: InputDecoration(
labelText: "Resevior Name",
fillColor: Colors.white,
filled: true, // dont forget this line
...
)
...
)
Flutter textfield label color
labelStyle: TextStyle(
color: Colors.white,
)
Color textfield text flutter
TextField(
style: TextStyle(color: Colors.white),
...
)
use BorderSide.none as:
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
borderSide: BorderSide.none,
),
Material Design for iOS doesn't look good, especially the TextField. So is there any way to create your own ? Or Is ther any way to add some styling to TextField so it will look rounded ?
You can add rounded corners to a TextField within the decoration parameter of it
TextField(
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
),
filled: true,
hintStyle: TextStyle(color: Colors.grey[800]),
hintText: "Type in your text",
fillColor: Colors.white70),
)
#Rockvole answer is correct but just in case u don't like the default border around the TextField, you can achieve it by overriding the borderSide attribute of the OutlineInputBorder like this:
TextField(
textAlign: TextAlign.center,
controller: searchCtrl,
keyboardType: TextInputType.text,
decoration: InputDecoration(
hintText: 'Enter a product name eg. pension',
hintStyle: TextStyle(fontSize: 16),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: BorderSide(
width: 0,
style: BorderStyle.none,
),
),
filled: true,
contentPadding: EdgeInsets.all(16),
fillColor: colorSearchBg,
),
),
You can get desired output with the help of Container Have a look..
new Container(
child: new Text (
"Text with rounded edges.",
style: new TextStyle(
color: Colors.blue[500],
fontWeight: FontWeight.w900
)
),
decoration: new BoxDecoration (
borderRadius: new BorderRadius.all(new Radius.circular(10.0)),
color: Colors.black
),
padding: new EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 16.0),
),
You can try this code bellow:
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: const BorderRadius.all(
const Radius.circular(10.0),
),
borderSide: BorderSide(
width: 0,
style: BorderStyle.none,
),
),
)
I've collected this solution from several methods and solutions over the internet, it works very well with me, so it could help someone out there:
This solution will control the width and height of the TextField, and other properties
Container(
child: Theme(
data: Theme.of(context).copyWith(splashColor: Colors.transparent),
child: TextField(
autofocus: false,
style: TextStyle(fontSize: 15.0, color: Color(0xFFbdc6cf)),
decoration: InputDecoration(
filled: true,
fillColor: Colors.white,
hintText: 'Search',
contentPadding:
const EdgeInsets.only(left: 14.0, bottom: 12.0, top: 0.0),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.white),
borderRadius: BorderRadius.circular(25.7),
),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.white),
borderRadius: BorderRadius.circular(25.7),
),
),
),
),
decoration: new BoxDecoration (
borderRadius: new BorderRadius.all(new Radius.circular(30.0)),
color: Colors.white ), width: 250, height: 50, margin: new EdgeInsets.fromLTRB(20, 20, 20, 210), padding: new EdgeInsets.fromLTRB(8, 8, 8, 8),
),
You could approach the purpose in a few different ways:
First Approach:
Container(
child: new Text (
"Some Text",
style: TextStyle(
color: Colors.black
)
),
decoration: BoxDecoration (
borderRadius: BorderRadius.all( Radius.circular(15)),
color: Colors.white
),
padding: EdgeInsets.all(16.0),
),
Second Approach:
TextField(
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: const BorderRadius.all(
Radius.circular(15.0),
),
),
filled: true,
hintStyle: new TextStyle(color: Colors.grey[600]),
hintText: "Hint text",
fillColor: Colors.white),
)
Third Approach:
TextField(
textAlign: TextAlign.center,
controller: someTextXontroller,
keyboardType: TextInputType.text,
decoration: InputDecoration(
hintText: 'Hint Text',
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(
width: 0,
style: BorderStyle.none,
),
),
filled: true,
contentPadding: EdgeInsets.all(16),
fillColor: Colors.blue,
),
),
Try this in TextFormField:
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(20.0),
),
),