11import 'package:flutter/material.dart' ;
2- import 'package:flutter_brand_palettes/palettes .dart' ;
2+ import 'package:flutter_brand_palettes/flutter_brand_palettes .dart' ;
33import 'package:eo_color/eo_color.dart' ;
44
5- void main () {
6- runApp (MyApp ());
7- }
5+ void main () => runApp (MyApp ());
86
97class MyApp extends StatelessWidget {
108 @override
@@ -23,53 +21,30 @@ class InstagramPalettePage extends StatelessWidget {
2321 super (key: key);
2422
2523 final String _title;
26-
27- /// The 'late' modifier ensures the lazy initialization of [_gradient] . In
28- /// other words, the _gradient's initializer expression runs only the first
29- /// time the variable is used.
30- static late final _gradient = _toGradient ();
31-
32- // Application's bar backgroud color.
33- static const _bgAppBar = Grey .veryLight ();
34-
35- /// Builds the Instagram's gradient color scheme.
36- static List <Color > _toGradient () {
37- return const [
38- Instagram .lightYellow (),
39- Instagram .yellow (),
40- Instagram .orange (),
41- Instagram .darkOrange (),
42- Instagram .red (),
43- Instagram .purpleRed (),
44- Instagram .darkPink (),
45- Instagram .purple (),
46- Instagram .blue (),
47- Instagram .royalBlue (),
48- ].map ((picked) => picked.color).toList (growable: false );
49- }
24+ static final _gradient = const InstagramGrad ().colors;
5025
5126 @override
5227 Widget build (BuildContext context) {
5328 return Scaffold (
5429 appBar: AppBar (
55- backgroundColor: _bgAppBar .color,
30+ backgroundColor: const Grey . veryLight () .color,
5631 elevation: 2.0 ,
5732 title: GradientTitle (_title, _gradient),
5833 ),
5934 body: ListView (
60- padding: const EdgeInsets .all (12 ),
35+ padding: const EdgeInsets .all (16 ),
6136 children: [
6237 _ColorItem .gradient ('Gradient' , colors: _gradient),
63- _ColorItem ('Light Yellow' , _gradient[0 ]),
64- _ColorItem ('Yellow' , _gradient[1 ]),
65- _ColorItem ('Orange' , _gradient[2 ]),
66- _ColorItem ('Dark Orange' , _gradient[3 ]),
67- _ColorItem ('Red' , _gradient[4 ]),
68- _ColorItem ('Purple-Red' , _gradient[5 ]),
69- _ColorItem ('Dark Pink' , _gradient[6 ]),
70- _ColorItem ('Purple' , _gradient[7 ]),
71- _ColorItem ('Blue' , _gradient[8 ]),
72- _ColorItem ('Royal Blue' , _gradient[9 ]),
38+ _ColorItem ('Light Yellow' , _gradient[9 ]),
39+ _ColorItem ('Yellow' , _gradient[8 ]),
40+ _ColorItem ('Orange' , _gradient[7 ]),
41+ _ColorItem ('Dark Orange' , _gradient[6 ]),
42+ _ColorItem ('Red' , _gradient[5 ]),
43+ _ColorItem ('Purple-Red' , _gradient[4 ]),
44+ _ColorItem ('Dark Pink' , _gradient[3 ]),
45+ _ColorItem ('Purple' , _gradient[2 ]),
46+ _ColorItem ('Blue' , _gradient[1 ]),
47+ _ColorItem ('Royal Blue' , _gradient[0 ]),
7348 ],
7449 ),
7550 );
@@ -92,6 +67,8 @@ class GradientTitle extends StatelessWidget {
9267 fontStyle: FontStyle .italic,
9368 foreground: Paint ()
9469 ..shader = LinearGradient (
70+ begin: Alignment .topRight,
71+ end: Alignment .bottomLeft,
9572 colors: _colors,
9673 ).createShader (const Rect .fromLTRB (0.0 , 0.0 , 200.0 , 70.0 )),
9774 ),
@@ -101,29 +78,27 @@ class GradientTitle extends StatelessWidget {
10178}
10279
10380class _ColorItem extends StatelessWidget {
104- /// Ctor. Color rectangle.
81+ /// A rectangle filled with a solid color .
10582 _ColorItem (String label, Color color)
106- : this .decoration (label, () => BoxDecoration (color: color));
83+ : this .deco (label, () => BoxDecoration (color: color));
10784
108- /// Ctor. Gradient rectangle.
85+ /// A rectangle with linear gradient background .
10986 _ColorItem .gradient (String label, {required List <Color > colors})
110- : this .decoration (
87+ : this .deco (
11188 label,
11289 () => BoxDecoration (
11390 gradient: LinearGradient (
114- // begin: Alignment.topRight,
115- // end: Alignment.bottomLeft,
91+ begin: Alignment .topRight,
92+ end: Alignment .bottomLeft,
11693 colors: colors,
11794 ),
11895 ),
11996 );
120- const _ColorItem .decoration (this ._label, this ._boxDecoration);
12197
122- final String _label;
123- final BoxDecoration Function () _boxDecoration;
98+ const _ColorItem .deco (this ._label, this ._deco);
12499
125- // Normal font color.
126- static const _normal = Grey . dark () ;
100+ final String _label;
101+ final BoxDecoration Function () _deco ;
127102
128103 @override
129104 Widget build (BuildContext context) {
@@ -134,16 +109,12 @@ class _ColorItem extends StatelessWidget {
134109 child: Text (
135110 _label,
136111 textAlign: TextAlign .center,
137- style: TextStyle (
138- color: _normal (), // or _normal.color
139- fontWeight: FontWeight .bold,
140- ),
112+ style: TextStyle (color: const Grey .veryDark ().color),
141113 ),
142114 ),
143115 Expanded (
144116 flex: 5 ,
145- child: Container (
146- height: kToolbarHeight / 1.5 , decoration: _boxDecoration ()),
117+ child: Container (height: kToolbarHeight / 1.5 , decoration: _deco ()),
147118 ),
148119 ],
149120 ),
0 commit comments