Create a Button with Gradient Borders in Flutter

To create a gradient border for a button in Flutter, we can use the BoxDecoration property of the DecoratedBox widget. This property provides a variety of options for specifying how a box should be decorated.

DecoratedBox(
  decoration: const BoxDecoration(gradient: LinearGradient(colors: [Colors.indigo, Colors.blueAccent])),
  child: Container(
    color: Colors.white,
    margin: const EdgeInsets.all(4.0),
    child: TextButton(
      onPressed: () {},
      child: const Text("Gradient Button"),
    ),
  ),
),
DecoratedBox(
  decoration: const BoxDecoration(gradient: SweepGradient(colors: [Colors.red, Colors.orangeAccent])),
  child: Container(
    color: Colors.white,
    margin: const EdgeInsets.all(6.0),
    child: TextButton(
      onPressed: () {},
      child: const Text("Gradient Button"),
    ),
  ),
),
Scroll to Top

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close