@@ -26,8 +26,7 @@ const Color _kSnackBackground = const Color(0xFF323232);
26
26
// TODO(ianh): Implement the Tablet version of snackbar if we're "on a tablet".
27
27
28
28
const Duration _kSnackBarTransitionDuration = const Duration (milliseconds: 250 );
29
- const Duration _kSnackBarShortDisplayDuration = const Duration (milliseconds: 1500 );
30
- const Duration _kSnackBarMediumDisplayDuration = const Duration (milliseconds: 2750 );
29
+ const Duration _kSnackBarDisplayDuration = const Duration (milliseconds: 1500 );
31
30
const Curve _snackBarHeightCurve = Curves .fastOutSlowIn;
32
31
const Curve _snackBarFadeCurve = const Interval (0.72 , 1.0 , curve: Curves .fastOutSlowIn);
33
32
@@ -92,12 +91,20 @@ class _SnackBarActionState extends State<SnackBarAction> {
92
91
/// A lightweight message with an optional action which briefly displays at the
93
92
/// bottom of the screen.
94
93
///
95
- /// Displayed with the Scaffold.of().showSnackBar() API.
94
+ /// To display a snack bar, call `Scaffold.of(context).showSnackBar()` , passing
95
+ /// an instance of [SnackBar] that describes the message.
96
+ ///
97
+ /// To control how long the [SnackBar] remains visible, specify a [duration] .
96
98
///
97
99
/// See also:
98
100
///
99
- /// * [Scaffold.of] and [ScaffoldState.showSnackBar]
100
- /// * [SnackBarAction]
101
+ /// * [Scaffold.of] , to obtain the current [ScaffoldState] , which manages the
102
+ /// display and animation of snack bars.
103
+ /// * [ScaffoldState.showSnackBar] , which displays a [SnackBar] .
104
+ /// * [ScaffoldState.removeCurrentSnackBar] , which abruptly hides the currently
105
+ /// displayed snack bar, if any, and allows the next to be displayed.
106
+ /// * [SnackBarAction] , which is used to specify an [action] button to show
107
+ /// on the snack bar.
101
108
/// * <https://material.google.com/components/snackbars-toasts.html>
102
109
class SnackBar extends StatelessWidget {
103
110
/// Creates a snack bar.
@@ -107,7 +114,7 @@ class SnackBar extends StatelessWidget {
107
114
Key key,
108
115
this .content,
109
116
this .action,
110
- this .duration: _kSnackBarShortDisplayDuration ,
117
+ this .duration: _kSnackBarDisplayDuration ,
111
118
this .animation
112
119
}) : super (key: key) {
113
120
assert (content != null );
@@ -122,9 +129,20 @@ class SnackBar extends StatelessWidget {
122
129
///
123
130
/// For example, the snack bar might let the user undo the operation that
124
131
/// prompted the snackbar. Snack bars can have at most one action.
132
+ ///
133
+ /// The action should not be "dismiss" or "cancel".
125
134
final SnackBarAction action;
126
135
127
136
/// The amount of time the snack bar should be displayed.
137
+ ///
138
+ /// Defaults to 1.5s.
139
+ ///
140
+ /// See also:
141
+ ///
142
+ /// * [ScaffoldState.removeCurrentSnackBar] , which abruptly hides the
143
+ /// currently displayed snack bar, if any, and allows the next to be
144
+ /// displayed.
145
+ /// * <https://material.google.com/components/snackbars-toasts.html>
128
146
final Duration duration;
129
147
130
148
/// The animation driving the entrance and exit of the snack bar.
0 commit comments