Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
995bd989
Unverified
Commit
995bd989
authored
Mar 02, 2021
by
Nathan Walker
Committed by
GitHub
Mar 02, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SliverAppBar default backwards compatibility fix (#77022)
parent
aa16a8ca
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
3 deletions
+48
-3
app_bar.dart
packages/flutter/lib/src/material/app_bar.dart
+3
-3
app_bar_theme_test.dart
packages/flutter/test/material/app_bar_theme_test.dart
+45
-0
No files found.
packages/flutter/lib/src/material/app_bar.dart
View file @
995bd989
...
@@ -1105,7 +1105,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
...
@@ -1105,7 +1105,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
final
ShapeBorder
?
shape
;
final
ShapeBorder
?
shape
;
final
double
?
toolbarHeight
;
final
double
?
toolbarHeight
;
final
double
?
leadingWidth
;
final
double
?
leadingWidth
;
final
bool
backwardsCompatibility
;
final
bool
?
backwardsCompatibility
;
final
TextStyle
?
toolbarTextStyle
;
final
TextStyle
?
toolbarTextStyle
;
final
TextStyle
?
titleTextStyle
;
final
TextStyle
?
titleTextStyle
;
final
SystemUiOverlayStyle
?
systemOverlayStyle
;
final
SystemUiOverlayStyle
?
systemOverlayStyle
;
...
@@ -1450,7 +1450,7 @@ class SliverAppBar extends StatefulWidget {
...
@@ -1450,7 +1450,7 @@ class SliverAppBar extends StatefulWidget {
this
.
shape
,
this
.
shape
,
this
.
toolbarHeight
=
kToolbarHeight
,
this
.
toolbarHeight
=
kToolbarHeight
,
this
.
leadingWidth
,
this
.
leadingWidth
,
this
.
backwardsCompatibility
=
true
,
this
.
backwardsCompatibility
,
this
.
toolbarTextStyle
,
this
.
toolbarTextStyle
,
this
.
titleTextStyle
,
this
.
titleTextStyle
,
this
.
systemOverlayStyle
,
this
.
systemOverlayStyle
,
...
@@ -1702,7 +1702,7 @@ class SliverAppBar extends StatefulWidget {
...
@@ -1702,7 +1702,7 @@ class SliverAppBar extends StatefulWidget {
/// {@macro flutter.material.appbar.backwardsCompatibility}
/// {@macro flutter.material.appbar.backwardsCompatibility}
///
///
/// This property is used to configure an [AppBar].
/// This property is used to configure an [AppBar].
final
bool
backwardsCompatibility
;
final
bool
?
backwardsCompatibility
;
/// {@macro flutter.material.appbar.toolbarTextStyle}
/// {@macro flutter.material.appbar.toolbarTextStyle}
///
///
...
...
packages/flutter/test/material/app_bar_theme_test.dart
View file @
995bd989
...
@@ -70,6 +70,51 @@ void main() {
...
@@ -70,6 +70,51 @@ void main() {
expect
(
text
.
style
,
appBarTheme
.
toolbarTextStyle
);
expect
(
text
.
style
,
appBarTheme
.
toolbarTextStyle
);
});
});
testWidgets
(
'SliverAppBar allows AppBar to determine backwardsCompatibility'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/77016
const
AppBarTheme
appBarTheme
=
AppBarTheme
(
backwardsCompatibility:
false
,
backgroundColor:
Colors
.
lightBlue
,
foregroundColor:
Colors
.
black
,
);
Widget
_buildWithBackwardsCompatibility
([
bool
?
enabled
])
=>
MaterialApp
(
theme:
ThemeData
(
appBarTheme:
appBarTheme
),
home:
Scaffold
(
body:
CustomScrollView
(
slivers:
<
Widget
>[
SliverAppBar
(
title:
const
Text
(
'App Bar Title'
),
backwardsCompatibility:
enabled
,
actions:
<
Widget
>[
IconButton
(
icon:
const
Icon
(
Icons
.
share
),
onPressed:
()
{
}),
],
),
],
)),
);
// Backwards compatibility enabled, AppBar should be built with true.
await
tester
.
pumpWidget
(
_buildWithBackwardsCompatibility
(
true
));
AppBar
appBar
=
tester
.
widget
<
AppBar
>(
find
.
byType
(
AppBar
));
expect
(
appBar
.
backwardsCompatibility
,
true
);
// Backwards compatibility disabled, AppBar should be built with false.
await
tester
.
pumpWidget
(
_buildWithBackwardsCompatibility
(
false
));
appBar
=
tester
.
widget
<
AppBar
>(
find
.
byType
(
AppBar
));
expect
(
appBar
.
backwardsCompatibility
,
false
);
// Backwards compatibility unspecified, AppBar should be built with null.
await
tester
.
pumpWidget
(
_buildWithBackwardsCompatibility
());
appBar
=
tester
.
widget
<
AppBar
>(
find
.
byType
(
AppBar
));
expect
(
appBar
.
backwardsCompatibility
,
null
);
// AppBar should use the backwardsCompatibility of AppBarTheme.
// Since backwardsCompatibility is false, the text color should match the
// foreground color of the AppBarTheme.
final
DefaultTextStyle
text
=
_getAppBarText
(
tester
);
expect
(
text
.
style
.
color
,
appBarTheme
.
foregroundColor
);
});
testWidgets
(
'AppBar widget properties take priority over theme'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'AppBar widget properties take priority over theme'
,
(
WidgetTester
tester
)
async
{
const
Brightness
brightness
=
Brightness
.
dark
;
const
Brightness
brightness
=
Brightness
.
dark
;
const
SystemUiOverlayStyle
systemOverlayStyle
=
SystemUiOverlayStyle
.
light
;
const
SystemUiOverlayStyle
systemOverlayStyle
=
SystemUiOverlayStyle
.
light
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment