Flutter Gradient Background — CSS Equivalent Reference and Free Generator
Table of Contents
Flutter and CSS handle gradients differently in syntax but identically in concept. If you are building a Flutter app and a companion web product, or you want to prototype gradient values visually before coding them into Flutter — this reference maps the two systems together and shows how to use the free CSS generator to quickly find gradient values before translating them into Dart.
Flutter Gradient Types vs CSS Gradient Equivalents
| Flutter | CSS Equivalent |
|---|---|
| LinearGradient | linear-gradient() |
| RadialGradient | radial-gradient() |
| SweepGradient | conic-gradient() |
The underlying maths is the same — the syntax is different. Once you know the colours and direction/shape you want, the gradient value you build in the CSS generator translates directly to the equivalent Flutter widget properties.
Converting CSS linear-gradient to Flutter LinearGradient
CSS: linear-gradient(135deg, #7c3aed, #2563eb)
Flutter equivalent:
Container( decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [Color(0xFF7c3aed), Color(0xFF2563eb)], ), ),)
Key conversions: CSS hex (#7c3aed) becomes Flutter Color(0xFF7c3aed). CSS angle (135deg) maps to Flutter alignment pairs — 135deg maps to topLeft→bottomRight. CSS colour stops as percentages map to Flutter stops: stops: [0.0, 1.0].
Using the CSS Generator to Find Flutter Gradient Colours Fast
The free CSS gradient generator is a useful prototyping tool even for Flutter developers:
- Open the generator and build your gradient visually — drag stops, adjust colours, see the live preview
- When it looks right, note the hex values from each stop
- Convert the hex values to Flutter Color format (prefix # with 0xFF: #7c3aed becomes 0xFF7c3aed)
- Determine the Flutter alignment from the CSS angle
- Write the Flutter LinearGradient with your confirmed values
This is faster than iterating blindly in Flutter, since the CSS generator gives you an instant visual preview while Flutter requires a rebuild cycle.
Flutter RadialGradient and SweepGradient CSS Reference
RadialGradient (CSS: radial-gradient):
Flutter: RadialGradient(center: Alignment.center, radius: 0.8, colors: [Color(0xFF7c3aed), Color(0xFF000000)])
CSS equivalent: radial-gradient(circle at center, #7c3aed, #000000)
SweepGradient (CSS: conic-gradient):
Flutter: SweepGradient(startAngle: 0.0, endAngle: 6.28, colors: [Colors.red, Colors.blue, Colors.red])
CSS equivalent: conic-gradient(red, blue, red)
Flutter uses radians for SweepGradient (0 to 6.28 = full 360 degrees). CSS conic-gradient uses degrees (0deg to 360deg). Convert: radians = degrees x (pi/180).
Try It Free — No Signup Required
Runs 100% in your browser. No account, no install, no limits.
Open Free CSS Gradient GeneratorFrequently Asked Questions
Can I use CSS gradients directly in Flutter?
No. Flutter uses Dart code with its own gradient widget system. There is no CSS in Flutter. Use the CSS generator to prototype visually, then translate the values to Flutter widget syntax.
How do I convert a CSS hex color to a Flutter Color?
Replace the # with 0xFF. #7c3aed becomes Color(0xFF7c3aed). For rgba colours with opacity: Color.fromRGBO(r, g, b, opacity) where r, g, b are 0-255 values.
Does Flutter have a gradient generator tool?
There is no official Flutter gradient generator. Developers typically use CSS gradient generators to preview values visually, then translate to Dart. This is the fastest workflow for gradient prototyping in Flutter.

