<p>In this example, I'm sharing code on how to add multiple colors to a container. Here is how the final output is going to look. ; background-color: rgb(30, 30, 30); font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;](color: #4ec9b0;](Container( margin: color: #4ec9b0;](EdgeInsets.color: #dcdcaa;](all(color: #b5cea8;](100.0), )</li> <li>Add decoration to it. color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;](decoration: color: #4ec9b0;](BoxDecoration( color: color: #4ec9b0;](Colors.red ),</li> <li>Modify decoration property of the Container to show a List of Colors. In order to achieve this, we will add gradient and pass List of Colors. Along with the direction of colors to be displayed. color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;](decoration: color: #4ec9b0;](BoxDecoration( gradient: color: #4ec9b0;](LinearGradient( begin: color: #4ec9b0;](Alignment.topLeft, end: color: #4ec9b0;](Alignment.topRight, colors: [color: #4ec9b0;](Colors.orange, color: #4ec9b0;](Colors.red] ), ), Here is the final code from main.dart file. color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre-wrap;](color: #569cd6;](import color: #ce9178;]('package:flutter/material.dart'; color: #569cd6;](void color: #dcdcaa;](main() => color: #dcdcaa;](runApp(color: #4ec9b0;](MyApp()); color: #569cd6;](class color: #4ec9b0;](MyApp color: #569cd6;](extends color: #4ec9b0;](StatefulWidget { color: #569cd6;](@override color: #4ec9b0;](_MyAppState color: #dcdcaa;](createState() => color: #4ec9b0;](_MyAppState();} color: #569cd6;](class color: #4ec9b0;](_MyAppState color: #569cd6;](extends color: #4ec9b0;](State { color: #4ec9b0;](double padValue = color: #b5cea8;](0; color: #569cd6;](@override color: #4ec9b0;](Widget color: #dcdcaa;](build(color: #4ec9b0;](BuildContext context) { color: #c586c0;](return color: #4ec9b0;](MaterialApp( home: color: #4ec9b0;](Scaffold( appBar: color: #4ec9b0;](AppBar( title: color: #4ec9b0;](Text(color: #ce9178;]("Container Example"), ), body: color: #4ec9b0;](Container( margin: color: #4ec9b0;](EdgeInsets.color: #dcdcaa;](all(color: #b5cea8;](100.0), decoration: color: #4ec9b0;](BoxDecoration( gradient: color: #4ec9b0;](LinearGradient( begin: color: #4ec9b0;](Alignment.topLeft, end: color: #4ec9b0;](Alignment.topRight, colors: [color: #4ec9b0;](Colors.orange, color: #4ec9b0;](Colors.red] ), shape: color: #4ec9b0;](BoxShape.rectangle, ), ) ), ); }}</li> </ol> <p>Thanks,Srikanth</p>
How to add multiple colors to a container?
This Article is posted by seven.srikanth at 9/11/2019 3:22:07 AM
Check out our other latest articles
Safearea widget - How to avoid visual overlap with Notch on flutter mobile app?How to convert row of widgets into column of widgets in flutter based on screen size?
How to run Flutter programs from GitHub?
How to get screen orientation in flutter?
NavigationRail example in flutter
Tags: Add more than one color to container; multiple colors to a container; gradient example; decoration example;
Check out our other latest articles
Safearea widget - How to avoid visual overlap with Notch on flutter mobile app?How to convert row of widgets into column of widgets in flutter based on screen size?
How to run Flutter programs from GitHub?
How to get screen orientation in flutter?
NavigationRail example in flutter