Yashir khan
Yashir khan

Reputation: 486

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

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

Upvotes: 2

Views: 1932

Answers (1)

BLKKKBVSIK
BLKKKBVSIK

Reputation: 3548

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
        ),
      ),
    );

Upvotes: 7

Related Questions