Search code examples
flutterhidetextfieldflutter-layout

How to hide the things behind the textfield border?


I am trying to make a textfield with rounded border and some drop shadow, when i use elevation it shows some parts outside the border, please have alook in the image i had attached.

Container(
      child: Padding(
        padding: const EdgeInsets.all(8.0),
        child: Container(
          height: 30.0,
          child: Material(
            elevation: 2.0,
            shadowColor: Colors.grey,
            child: TextField(
              autofocus: false,
              style: TextStyle(
                  color: Colors.black,
              ),
              decoration: kTextFieldDecorationCircular,
              onChanged: (value){
                searchWord = value;
              },
              onEditingComplete: searchTheWord,
            ),
          ),
        ),
      ),
    );

const kTextFieldDecorationCircular = InputDecoration(
  contentPadding: EdgeInsets.all(2.0),
  filled: true,
  fillColor: Colors.white,
  prefixIcon: Icon(Icons.search, color: Colors.grey,),
  hintText: 'Search',
  hintStyle: TextStyle(color: Colors.grey),
  border: OutlineInputBorder(
      borderRadius: BorderRadius.all(Radius.circular(50.0)),
  ),
);

enter image description here

This is my code. Thank you in advance.


Solution

  • You could add this to your Material widget:

    borderRadius: BorderRadius.all(Radius.circular(50.0)),