Questions tagged [snackbar]

Snackbars provide lightweight feedback about an operation. They show a brief message at the bottom of the screen on mobile and lower left on larger devices. Snackbars appear above all other elements on screen and only one can be displayed at a time.

Introduction

Snackbars provide lightweight feedback about an operation. They show a brief message at the bottom of the screen on mobile and lower left on larger devices. Snackbars appear above all other elements on screen and only one can be displayed at a time.

They automatically disappear after a timeout or after user interaction elsewhere on the screen, particularly after interactions that summon a new surface or activity. Snackbars can be swiped off screen.

Snackbars can contain an action which is set via setAction(CharSequence, android.view.View.OnClickListener).

Documentation

Usage of SnackBar

493 questions
354
votes
16 answers

Scaffold.of() called with a context that does not contain a Scaffold

As you can see, my button is inside the Scaffold's body. But I get this exception: Scaffold.of() called with a context that does not contain a Scaffold. import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends…
Figen Güngör
  • 12,169
  • 14
  • 66
  • 108
110
votes
12 answers

how to customize snackBar's layout?

Is there any method to change the layout of a snackBar to custom View? Now it comes black and we can change the background color. But I don't know the right way to inflate a new layout and making it as snackBars background? Thanks...
110
votes
13 answers

How can I be notified when a Snackbar has dismissed itself?

I'm using a Snackbar from the com.android.support:design:22.2.0 library. I'm using it to undo deletions. To make my life easier, I'm going to make the UI look like things are actually deleted from the data source, and if the undo button in the snack…
104
votes
24 answers

How to set support library snackbar text color to something other than android:textColor?

So I've started using the new Snackbar in the Design Support Library, but I found that when you define "android:textColor" in your theme, it applies to the text color of the snackbar. This is obviously a problem if your primary text color is…
81
votes
20 answers

Display SnackBar in Flutter

I want to display a simple SnackBar inside Flutter's Stateful widget. My application creates new instance of MaterialApp with a stateful widget called MyHomePage. I try to show the SnackBar in showSnackBar() method. But it fails with The method…
76
votes
13 answers

Move snackbar above the bottom bar

I am facing some problems with new bottom bar. I can't force to move the snackbar above the bottom bar (this is how design guideline told me should be…
Wladislaw
  • 1,200
  • 2
  • 12
  • 23
61
votes
8 answers

How to use setDuration() method in SnackBar (Android Design Support Library)

From Documentation: parameter duration - either be one of the predefined lengths: LENGTH_SHORT, LENGTH_LONG, or a custom duration in milliseconds. But I can't set custom duration. For example Snackbar .make(parentLayout, "Feed cat?", 8000) //…
tehnolog
  • 1,204
  • 1
  • 11
  • 23
48
votes
11 answers

Flutter snackbar dismiss on SnackBarAction onPressed

I want to dismiss SnackBar on SnackBarAction's onPressed method. I tried with Navigator.of(context).pop(); but SnackBar is not dismissing my screen get black instead. Here is code: void showInSnackBar(String value)…
Ammy Kang
  • 11,283
  • 21
  • 46
  • 68
42
votes
5 answers

How can you adjust Android SnackBar to a specific position on screen

Follwing the new android snackbar, i'm trying to set it to be positioned on a specific y coordinate. Its seems to be not even a possible. I've tried with getting the parent of the snackbar's view, but, there's nothing to be done to the parent for it…
Dus
  • 4,052
  • 5
  • 30
  • 49
40
votes
8 answers

Can we perform 2 different actions in Snack bar at a time in android?

I am creating an android application in which i want to use Snack Bar, In a that snack bar i want 2 different words on which we have to perform 2 different actions.
Anjali Patel
  • 807
  • 2
  • 11
  • 23
31
votes
5 answers

Android Support Library Snackbar with indefinite length

I see that the Snackbar will only take either LENGTH_LONG or LENGTH_SHORT when determining the length of its display on screen. I would like to have it displayed until someone swipes it off the screen. This is for some cases when you have persistent…
Simon
  • 19,658
  • 27
  • 149
  • 217
28
votes
5 answers

How to show snackBar without Scaffold

I am trying to show snackbar in my app to notify User but without scaffold it shows me error. My current code is: scaffoldKey.currentState?.showSnackBar( new SnackBar( backgroundColor: color ?? Colors.red, duration:…
Code Hunter
  • 10,075
  • 23
  • 72
  • 102
26
votes
4 answers

Snackbar duration and height

I'm trying to show a snackbar. After I click on a gesture detector, this snack has two buttons. The problem is that the snackbar appears for seconds and then disappears. So I have two questions: How to stop the snackbar from disappearing until…
Mee
  • 1,413
  • 5
  • 24
  • 40
26
votes
20 answers

Add margins to Snackbar view

I'm updating my current app to use snackbars, in the Google spec they show various ways of using them http://www.google.com/design/spec/components/snackbars-toasts.html#snackbars-toasts-specs Example A: Example B: Here's my code atm: Snackbar…
AndroidEnthusiast
  • 6,557
  • 10
  • 42
  • 56
24
votes
4 answers

To add line break in snack bar Angular 4

I want to add multiline text message with proper line breaks that are provided by me. this.sampleStringErrorMsg = 'The sample is not valid:\n' + '- The key and key value are required in the sample.\n ' + '- The delimiter…
Sarfraz Shaikh
  • 492
  • 1
  • 3
  • 11
1
2 3
32 33