5
5
import 'dart:ui' as ui;
6
6
7
7
import 'package:flutter/material.dart' ;
8
+ import 'package:flutter/services.dart' ;
9
+ import 'package:flutter_common_exports/flutter_common_exports.dart' ;
8
10
9
11
import '../constants/constants.dart' ;
10
12
@@ -18,7 +20,7 @@ class FixedAppBar extends StatelessWidget {
18
20
this .leading,
19
21
this .centerTitle = true ,
20
22
this .backgroundColor,
21
- this .elevation = 2.0 ,
23
+ this .elevation,
22
24
this .actions,
23
25
this .actionsPadding,
24
26
this .height,
@@ -67,27 +69,18 @@ class FixedAppBar extends StatelessWidget {
67
69
68
70
@override
69
71
Widget build (BuildContext context) {
72
+ final Color color = (backgroundColor ?? Theme .of (context).primaryColor)
73
+ .withOpacity (blurRadius > 0.0 ? 0.90 : 1.0 );
74
+
70
75
Widget _title = title;
71
76
if (centerTitle) {
72
77
_title = Center (child: _title);
73
78
}
79
+
74
80
Widget child = Container (
75
81
width: Screens .width,
76
82
height: (height ?? kToolbarHeight) + MediaQuery .of (context).padding.top,
77
83
padding: EdgeInsets .only (top: MediaQuery .of (context).padding.top),
78
- decoration: BoxDecoration (
79
- boxShadow: elevation > 0
80
- ? < BoxShadow > [
81
- BoxShadow (
82
- color: const Color (0x0d000000 ),
83
- blurRadius: elevation * 1.0 ,
84
- offset: Offset (0 , elevation * 2.0 ),
85
- ),
86
- ]
87
- : null ,
88
- color: (backgroundColor ?? Theme .of (context).primaryColor)
89
- .withOpacity (blurRadius > 0.0 ? 0.90 : 1.0 ),
90
- ),
91
84
child: Stack (
92
85
children: < Widget > [
93
86
if (automaticallyImplyLeading && Navigator .of (context).canPop ())
@@ -132,6 +125,7 @@ class FixedAppBar extends StatelessWidget {
132
125
],
133
126
),
134
127
);
128
+
135
129
if (blurRadius > 0.0 ) {
136
130
child = ClipRect (
137
131
child: BackdropFilter (
@@ -140,7 +134,21 @@ class FixedAppBar extends StatelessWidget {
140
134
),
141
135
);
142
136
}
143
- return Material (type: MaterialType .transparency, child: child);
137
+
138
+ return AnnotatedRegion <SystemUiOverlayStyle >(
139
+ value: context.themeData.appBarTheme.brightness.isDark
140
+ ? SystemUiOverlayStyle .light
141
+ : SystemUiOverlayStyle .dark,
142
+ child: Material (
143
+ type: color.isTransparent
144
+ ? MaterialType .transparency
145
+ : MaterialType .canvas,
146
+ color: (backgroundColor ?? Theme .of (context).primaryColor)
147
+ .withOpacity (blurRadius > 0.0 ? 0.90 : 1.0 ),
148
+ elevation: elevation ?? context.themeData.appBarTheme.elevation ?? 4.0 ,
149
+ child: child,
150
+ ),
151
+ );
144
152
}
145
153
}
146
154
0 commit comments