@@ -17,8 +17,12 @@ import 'framework.dart';
17
17
18
18
const double _kOffset = 40.0 ; // distance to bottom of banner, at a 45 degree angle inwards
19
19
const double _kHeight = 12.0 ; // height of banner
20
- const double _kBottomOffset = _kOffset + 0.707 * _kHeight; // offset plus sqrt(2)/2 * banner height
20
+ const double _kBottomOffset = _kOffset + math.sqrt1_2 * _kHeight;
21
21
const Rect _kRect = Rect .fromLTWH (- _kOffset, _kOffset - _kHeight, _kOffset * 2.0 , _kHeight);
22
+ const BoxShadow _kShadow = BoxShadow (
23
+ color: Color (0x7F000000 ),
24
+ blurRadius: 6.0 ,
25
+ );
22
26
23
27
const Color _kColor = Color (0xA0B71C1C );
24
28
const TextStyle _kTextStyle = TextStyle (
@@ -68,6 +72,7 @@ class BannerPainter extends CustomPainter {
68
72
required this .layoutDirection,
69
73
this .color = _kColor,
70
74
this .textStyle = _kTextStyle,
75
+ this .shadow = _kShadow,
71
76
}) : super (repaint: PaintingBinding .instance.systemFonts) {
72
77
// TODO(polina-c): stop duplicating code across disposables
73
78
// https://github.com/flutter/flutter/issues/137435
@@ -120,10 +125,12 @@ class BannerPainter extends CustomPainter {
120
125
/// Defaults to bold, white text.
121
126
final TextStyle textStyle;
122
127
123
- static const BoxShadow _shadow = BoxShadow (
124
- color: Color (0x7F000000 ),
125
- blurRadius: 6.0 ,
126
- );
128
+ /// The shadow properties for the banner.
129
+ ///
130
+ /// Use a [BoxShadow] object to define the shadow's color, blur radius,
131
+ /// and spread radius. These properties can be used to create different
132
+ /// shadow effects.
133
+ final BoxShadow shadow;
127
134
128
135
bool _prepared = false ;
129
136
TextPainter ? _textPainter;
@@ -144,7 +151,7 @@ class BannerPainter extends CustomPainter {
144
151
}
145
152
146
153
void _prepare () {
147
- _paintShadow = _shadow .toPaint ();
154
+ _paintShadow = shadow .toPaint ();
148
155
_paintBanner = Paint ()
149
156
..color = color;
150
157
_textPainter? .dispose ();
@@ -232,6 +239,7 @@ class Banner extends StatefulWidget {
232
239
this .layoutDirection,
233
240
this .color = _kColor,
234
241
this .textStyle = _kTextStyle,
242
+ this .shadow = _kShadow,
235
243
});
236
244
237
245
/// The widget to show behind the banner.
@@ -278,6 +286,13 @@ class Banner extends StatefulWidget {
278
286
/// The style of the text shown on the banner.
279
287
final TextStyle textStyle;
280
288
289
+ /// The shadow properties for the banner.
290
+ ///
291
+ /// Use a [BoxShadow] object to define the shadow's color, blur radius,
292
+ /// and spread radius. These properties can be used to create different
293
+ /// shadow effects.
294
+ final BoxShadow shadow;
295
+
281
296
@override
282
297
State <Banner > createState () => _BannerState ();
283
298
}
@@ -303,6 +318,7 @@ class _BannerState extends State<Banner> {
303
318
layoutDirection: widget.layoutDirection ?? Directionality .of (context),
304
319
color: widget.color,
305
320
textStyle: widget.textStyle,
321
+ shadow: widget.shadow,
306
322
);
307
323
308
324
return CustomPaint (
0 commit comments