How do I add a gradient background in my flutter app?

913

You can simply use the right parameter in BoxDecoration

https://api.flutter.dev/flutter/painting/LinearGradient-class.html

Container(
      decoration: BoxDecoration(
        gradient: LinearGradient(
          begin: Alignment.topLeft,
          end:
              Alignment(0.8, 0.0), // 10% of the width, so there are ten blinds.
          colors: [
            const Color(0xffee0000),
            const Color(0xffeeee00)
          ], // red to yellow
          tileMode: TileMode.repeated, // repeats the gradient over the canvas
        ),
      ),
    );
Share:
913
Yashir khan
Author by

Yashir khan

I am a 17 years old boy with expertise in app development, web development. I love coding it inspire me to make something new with it. I have expertise in many frameworks and languages included kotlin, java, flutter, html, CSS, JavaScript, reactjs, NodeJS etc. Expertise in working with MySQL ,php, firebase, firebase firestore, RESTAPI, etc.

Updated on December 25, 2022

Comments

  • Yashir khan
    Yashir khan over 1 year

    I want a Liner gradient color style in my flutter app's background how can I achieve it in my flutter app?