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
f0bb9d57
Unverified
Commit
f0bb9d57
authored
Feb 09, 2024
by
David Martos
Committed by
GitHub
Feb 09, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
barrierColor property in DialogTheme (#142490)
parent
8b228b9e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
3 deletions
+28
-3
dialog.dart
packages/flutter/lib/src/material/dialog.dart
+3
-2
dialog_theme.dart
packages/flutter/lib/src/material/dialog_theme.dart
+10
-1
dialog_theme_test.dart
packages/flutter/test/material/dialog_theme_test.dart
+15
-0
No files found.
packages/flutter/lib/src/material/dialog.dart
View file @
f0bb9d57
...
...
@@ -1327,7 +1327,8 @@ Widget _buildMaterialDialogTransitions(BuildContext context, Animation<double> a
/// barrier will dismiss the dialog. It is `true` by default and can not be `null`.
///
/// The `barrierColor` argument is used to specify the color of the modal
/// barrier that darkens everything below the dialog. If `null` the default color
/// barrier that darkens everything below the dialog. If `null` the `barrierColor`
/// field from `DialogTheme` is used. If that is `null` the default color
/// `Colors.black54` is used.
///
/// The `useSafeArea` argument is used to indicate if the dialog should only
...
...
@@ -1428,7 +1429,7 @@ Future<T?> showDialog<T>({
return
Navigator
.
of
(
context
,
rootNavigator:
useRootNavigator
).
push
<
T
>(
DialogRoute
<
T
>(
context:
context
,
builder:
builder
,
barrierColor:
barrierColor
??
Colors
.
black54
,
barrierColor:
barrierColor
??
Theme
.
of
(
context
).
dialogTheme
.
barrierColor
??
Colors
.
black54
,
barrierDismissible:
barrierDismissible
,
barrierLabel:
barrierLabel
,
useSafeArea:
useSafeArea
,
...
...
packages/flutter/lib/src/material/dialog_theme.dart
View file @
f0bb9d57
...
...
@@ -38,6 +38,7 @@ class DialogTheme with Diagnosticable {
this
.
titleTextStyle
,
this
.
contentTextStyle
,
this
.
actionsPadding
,
this
.
barrierColor
,
});
/// Overrides the default value for [Dialog.backgroundColor].
...
...
@@ -72,6 +73,9 @@ class DialogTheme with Diagnosticable {
/// Used to configure the [IconTheme] for the [AlertDialog.icon] widget.
final
Color
?
iconColor
;
/// Overrides the default value for [barrierColor] in [showDialog].
final
Color
?
barrierColor
;
/// Creates a copy of this object but with the given fields replaced with the
/// new values.
DialogTheme
copyWith
({
...
...
@@ -85,6 +89,7 @@ class DialogTheme with Diagnosticable {
TextStyle
?
titleTextStyle
,
TextStyle
?
contentTextStyle
,
EdgeInsetsGeometry
?
actionsPadding
,
Color
?
barrierColor
,
})
{
return
DialogTheme
(
backgroundColor:
backgroundColor
??
this
.
backgroundColor
,
...
...
@@ -97,6 +102,7 @@ class DialogTheme with Diagnosticable {
titleTextStyle:
titleTextStyle
??
this
.
titleTextStyle
,
contentTextStyle:
contentTextStyle
??
this
.
contentTextStyle
,
actionsPadding:
actionsPadding
??
this
.
actionsPadding
,
barrierColor:
barrierColor
??
this
.
barrierColor
,
);
}
...
...
@@ -123,6 +129,7 @@ class DialogTheme with Diagnosticable {
titleTextStyle:
TextStyle
.
lerp
(
a
?.
titleTextStyle
,
b
?.
titleTextStyle
,
t
),
contentTextStyle:
TextStyle
.
lerp
(
a
?.
contentTextStyle
,
b
?.
contentTextStyle
,
t
),
actionsPadding:
EdgeInsetsGeometry
.
lerp
(
a
?.
actionsPadding
,
b
?.
actionsPadding
,
t
),
barrierColor:
Color
.
lerp
(
a
?.
barrierColor
,
b
?.
barrierColor
,
t
),
);
}
...
...
@@ -147,7 +154,8 @@ class DialogTheme with Diagnosticable {
&&
other
.
iconColor
==
iconColor
&&
other
.
titleTextStyle
==
titleTextStyle
&&
other
.
contentTextStyle
==
contentTextStyle
&&
other
.
actionsPadding
==
actionsPadding
;
&&
other
.
actionsPadding
==
actionsPadding
&&
other
.
barrierColor
==
barrierColor
;
}
@override
...
...
@@ -163,5 +171,6 @@ class DialogTheme with Diagnosticable {
properties
.
add
(
DiagnosticsProperty
<
TextStyle
>(
'titleTextStyle'
,
titleTextStyle
,
defaultValue:
null
));
properties
.
add
(
DiagnosticsProperty
<
TextStyle
>(
'contentTextStyle'
,
contentTextStyle
,
defaultValue:
null
));
properties
.
add
(
DiagnosticsProperty
<
EdgeInsetsGeometry
>(
'actionsPadding'
,
actionsPadding
,
defaultValue:
null
));
properties
.
add
(
ColorProperty
(
'barrierColor'
,
barrierColor
));
}
}
packages/flutter/test/material/dialog_theme_test.dart
View file @
f0bb9d57
...
...
@@ -66,6 +66,7 @@ void main() {
titleTextStyle:
TextStyle
(
color:
Color
(
0xffffffff
)),
contentTextStyle:
TextStyle
(
color:
Color
(
0xff000000
)),
actionsPadding:
EdgeInsets
.
all
(
8.0
),
barrierColor:
Color
(
0xff000005
),
).
debugFillProperties
(
builder
);
final
List
<
String
>
description
=
builder
.
properties
.
where
((
DiagnosticsNode
n
)
=>
!
n
.
isFiltered
(
DiagnosticLevel
.
info
))
...
...
@@ -80,6 +81,7 @@ void main() {
'titleTextStyle: TextStyle(inherit: true, color: Color(0xffffffff))'
,
'contentTextStyle: TextStyle(inherit: true, color: Color(0xff000000))'
,
'actionsPadding: EdgeInsets.all(8.0)'
,
'barrierColor: Color(0xff000005)'
,
]);
});
...
...
@@ -499,4 +501,17 @@ void main() {
final
RenderParagraph
content
=
_getTextRenderObject
(
tester
,
contentText
);
expect
(
content
.
text
.
style
!.
color
,
contentTextStyle
.
color
);
});
testWidgets
(
'Custom barrierColor - Theme'
,
(
WidgetTester
tester
)
async
{
const
Color
barrierColor
=
Colors
.
blue
;
const
SimpleDialog
dialog
=
SimpleDialog
();
final
ThemeData
theme
=
ThemeData
(
dialogTheme:
const
DialogTheme
(
barrierColor:
barrierColor
));
await
tester
.
pumpWidget
(
_appWithDialog
(
tester
,
dialog
,
theme:
theme
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
final
ModalBarrier
modalBarrier
=
tester
.
widget
(
find
.
byType
(
ModalBarrier
).
last
);
expect
(
modalBarrier
.
color
,
barrierColor
);
});
}
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