How to add a border to a widget in Flutter?

Posted by Jessica Taylor | Updated on

Want to add a border to a widget in Flutter? You can add the TextField as a child to a Container that has a BoxDecoration with border property:

add a border to a widget in Flutter

Here is an expanded answer. A DecoratedBox is what you need to add a border, but I am using a Container for the convenience of adding margin and padding.

add a border to a widget in Flutter


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers