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
d8e93ffb
Unverified
Commit
d8e93ffb
authored
Feb 25, 2022
by
Taha Tesser
Committed by
GitHub
Feb 25, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `clipBehavior` to `Snackbar` (#98252)
parent
0b5032a0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
1 deletion
+46
-1
snack_bar.dart
packages/flutter/lib/src/material/snack_bar.dart
+12
-1
snack_bar_test.dart
packages/flutter/test/material/snack_bar_test.dart
+34
-0
No files found.
packages/flutter/lib/src/material/snack_bar.dart
View file @
d8e93ffb
...
@@ -204,6 +204,7 @@ class SnackBar extends StatefulWidget {
...
@@ -204,6 +204,7 @@ class SnackBar extends StatefulWidget {
this
.
animation
,
this
.
animation
,
this
.
onVisible
,
this
.
onVisible
,
this
.
dismissDirection
=
DismissDirection
.
down
,
this
.
dismissDirection
=
DismissDirection
.
down
,
this
.
clipBehavior
=
Clip
.
hardEdge
,
})
:
assert
(
elevation
==
null
||
elevation
>=
0.0
),
})
:
assert
(
elevation
==
null
||
elevation
>=
0.0
),
assert
(
content
!=
null
),
assert
(
content
!=
null
),
assert
(
assert
(
...
@@ -211,6 +212,7 @@ class SnackBar extends StatefulWidget {
...
@@ -211,6 +212,7 @@ class SnackBar extends StatefulWidget {
'Width and margin can not be used together'
,
'Width and margin can not be used together'
,
),
),
assert
(
duration
!=
null
),
assert
(
duration
!=
null
),
assert
(
clipBehavior
!=
null
),
super
(
key:
key
);
super
(
key:
key
);
/// The primary content of the snack bar.
/// The primary content of the snack bar.
...
@@ -336,6 +338,11 @@ class SnackBar extends StatefulWidget {
...
@@ -336,6 +338,11 @@ class SnackBar extends StatefulWidget {
/// Cannot be null, defaults to [DismissDirection.down].
/// Cannot be null, defaults to [DismissDirection.down].
final
DismissDirection
dismissDirection
;
final
DismissDirection
dismissDirection
;
/// {@macro flutter.material.Material.clipBehavior}
///
/// Defaults to [Clip.hardEdge], and must not be null.
final
Clip
clipBehavior
;
// API for ScaffoldMessengerState.showSnackBar():
// API for ScaffoldMessengerState.showSnackBar():
/// Creates an animation controller useful for driving a snack bar's entrance and exit animation.
/// Creates an animation controller useful for driving a snack bar's entrance and exit animation.
...
@@ -367,6 +374,7 @@ class SnackBar extends StatefulWidget {
...
@@ -367,6 +374,7 @@ class SnackBar extends StatefulWidget {
animation:
newAnimation
,
animation:
newAnimation
,
onVisible:
onVisible
,
onVisible:
onVisible
,
dismissDirection:
dismissDirection
,
dismissDirection:
dismissDirection
,
clipBehavior:
clipBehavior
,
);
);
}
}
...
@@ -612,7 +620,10 @@ class _SnackBarState extends State<SnackBar> {
...
@@ -612,7 +620,10 @@ class _SnackBarState extends State<SnackBar> {
return
Hero
(
return
Hero
(
tag:
'<SnackBar Hero tag -
${widget.content}
>'
,
tag:
'<SnackBar Hero tag -
${widget.content}
>'
,
child:
snackBarTransition
,
child:
ClipRect
(
clipBehavior:
widget
.
clipBehavior
,
child:
snackBarTransition
,
),
);
);
}
}
}
}
packages/flutter/test/material/snack_bar_test.dart
View file @
d8e93ffb
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
// machines.
// machines.
@Tags
(<
String
>[
'reduced-test-set'
])
@Tags
(<
String
>[
'reduced-test-set'
])
import
'dart:ui'
;
import
'package:flutter/foundation.dart'
show
FlutterExceptionHandler
;
import
'package:flutter/foundation.dart'
show
FlutterExceptionHandler
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
...
@@ -2558,6 +2560,38 @@ void main() {
...
@@ -2558,6 +2560,38 @@ void main() {
'was set by default.'
,
'was set by default.'
,
);
);
});
});
testWidgets
(
'Snackbar by default clips BackdropFilter'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/98205
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
const
Scaffold
(),
floatingActionButton:
FloatingActionButton
(
onPressed:
()
{}),
),
));
final
ScaffoldMessengerState
scaffoldMessengerState
=
tester
.
state
<
ScaffoldMessengerState
>(
find
.
byType
(
ScaffoldMessenger
),
);
scaffoldMessengerState
.
showSnackBar
(
SnackBar
(
backgroundColor:
Colors
.
transparent
,
content:
BackdropFilter
(
filter:
ImageFilter
.
blur
(
sigmaX:
20.0
,
sigmaY:
20.0
,
),
child:
const
Text
(
'I am a snack bar.'
),
),
duration:
const
Duration
(
seconds:
2
),
action:
SnackBarAction
(
label:
'ACTION'
,
onPressed:
()
{}),
behavior:
SnackBarBehavior
.
fixed
,
));
await
tester
.
pumpAndSettle
();
await
tester
.
tap
(
find
.
text
(
'I am a snack bar.'
));
await
tester
.
pump
();
// start animation
await
tester
.
pump
(
const
Duration
(
milliseconds:
750
));
await
expectLater
(
find
.
byType
(
MaterialApp
),
matchesGoldenFile
(
'snack_bar.goldenTest.backdropFilter.png'
));
});
}
}
/// Start test for "SnackBar dismiss test".
/// Start test for "SnackBar dismiss test".
...
...
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