show static method

void show(
  1. BuildContext context,
  2. String message, {
  3. Duration duration = _defaultShowDuration,
})

Displays a plain SnackBar message.

显示普通文本的 SnackBar 消息。

context The BuildContext to display the SnackBar. message The message to be displayed. duration Optional duration for how long the SnackBar should be shown.

Implementation

static void show(
  BuildContext context,
  String message, {
  Duration duration = _defaultShowDuration,
}) {
  ScaffoldMessenger.of(context).showSnackBar(
    _buildSnackBar(
      content: Text(message),
      backgroundColor: Colors.black87,
      duration: duration,
    ),
  );
}