How to specify stops in a gradient?

This Article is posted by seven.srikanth at 9/13/2019 4:26:53 AM



Here is an example of how to specify stops inside a gradient.

You gonna achieve the below output through this example.


Here is the code from main.dart file.

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  double padValue = 0;
  @override
  Widget build(BuildContext context) {

    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("Container Example"),
        ),
        body: Container(
          margin: EdgeInsets.all(100.0),
          decoration: BoxDecoration(
            gradient: LinearGradient(
              tileMode: TileMode.clamp,
              stops: [0.3,0.6,0.9],
              colors: [Colors.orange, Colors.red, Colors.blue]
            ),
            shape: BoxShape.rectangle,
          ),
        )
      ),
    );
  }
}

Thanks,
Srikanth


Tags: Multiple colors inside a Container;








0 Comments
Login to comment.
Recent Comments

Be the first to Comment. You can ask a Query or Share your toughts or Just say thanks.


© 2018 - Fluttercentral | Email to me - seven.srikanth@gmail.com