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.

snackbar
Filter by
Sorted by
Tagged with
363 votes
16 answers
155k views

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 ...
Figen Güngör's user avatar
111 votes
13 answers
45k views

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 ...
Tyler Pfaff's user avatar
  • 4,960
111 votes
12 answers
110k views

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 ...
noobEinstien's user avatar
  • 3,253
104 votes
24 answers
50k views

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 ...
Mahonster's user avatar
  • 1,381
85 votes
20 answers
181k views

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 ...
kosiara - Bartosz Kosarzycki's user avatar
77 votes
13 answers
67k views

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 https://www.google.com/design/spec/components/...
Wladislaw's user avatar
  • 1,230
61 votes
8 answers
46k views

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 ...
tehnolog's user avatar
  • 1,204
52 votes
13 answers
45k views

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 ...
Ammy Kang's user avatar
  • 12k
43 votes
8 answers
28k views

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's user avatar
42 votes
5 answers
43k views

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, ...
Dus's user avatar
  • 4,182
31 votes
5 answers
23k views

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 ...
Simon's user avatar
  • 19.8k
29 votes
5 answers
37k views

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: ...
Code Hunter's user avatar
  • 10.7k
28 votes
20 answers
31k views

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 ...
AndroidEnthusiast's user avatar
26 votes
4 answers
35k views

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: ...
Mee's user avatar
  • 1,561
24 votes
4 answers
20k views

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 ...
Sarfraz Shaikh's user avatar
24 votes
3 answers
2k views

Is it a good practice to wrap all layouts in CoordinatorLayout?

I'm thinking of a way to implement Android Snackbars in my app. Basically, I want to be able to show Snackbar from anywhere in the app. As I found out, android.support.design.widget.Snackbar ...
Marcel Bro's user avatar
  • 4,977
23 votes
5 answers
12k views

In a snackbar action, how can I be sure it's safe to permanently delete a soft-deleted record from the database?

I am using Snackbar in android and I have implemented an action so that user can undo the action (the action is clearing all the items in the listview).Removing and adding the items back to the ...
chathura's user avatar
  • 3,382
22 votes
4 answers
21k views

How to add a margin or padding to a Snackbar?

I have been working on the Snackbar and achieved in my project successfully. However, there is this little thing which I want to add to Snackbar and that is the margins. I have seen in this link : ...
Alok's user avatar
  • 8,702
22 votes
5 answers
26k views

How to use SnackBar on service to use in every component in Angular 2

I have a working snackbar, but it is only on each component, I want to add it on my service so I will just call it. This is my sample on my component.ts import { MdSnackBar, MdSnackBarRef } from '@...
Storm Spirit's user avatar
  • 1,480
22 votes
5 answers
13k views

How can I show a snackbar after navigator.pop(context) in Flutter?

We need close one screen and open a second screen. And show snackbar on the second screen from first screen. I tried to use Navigator.push, but this screen is already open and we have this error Bad ...
Emily Harkness's user avatar
20 votes
3 answers
25k views

autoHideDuration is not working in Snackbar @material-ui

I have used Snackbar from Material-ui to display an alert. I want to hide that Snackbar automatically after 5 seconds but autoHideDuration is not working . <Snackbar autoHideDuration={3000} ...
Arun Kumar's user avatar
19 votes
8 answers
11k views

How to disable snackbar's swipe-to-dismiss behavior

Is there a way to prevent the user from dismissing a snackbar by swiping on it? I have an app that shows a snack bar during network login, I want to avoid it to be dismissed. According to Nikola ...
Paolone's user avatar
  • 485
18 votes
3 answers
19k views

How to implement material-ui Snackbar as a global function?

I am creating my react app with material-ui Snackbar. In my project I have a lot of components and don't want to insert <Snackbar/> in each of them. Is there a way to create function that will ...
Luciferous's user avatar
18 votes
1 answer
16k views

Android SnackBar: error inflating SnackbarLayout

I wanted to try out the new Snackbar from the official design library provided by Google. Its usage is very close to a Toast so I thought it would be simple enough to try out. I've tried it out on an ...
Andreas N's user avatar
  • 193
17 votes
3 answers
14k views

How do you implement the snackbar that has the button at the bottom?

On the material design specs there is a snackbar that has the button at the bottom. How do you implement that? Here is the image from the spec. I'm talking about the last one.
casolorz's user avatar
  • 9,096
17 votes
4 answers
9k views

Make Snackbar push view upwards

Is there a way to make the snackbar push the view upwards when it is shown? Currently, when the snackbar is shown, it overlays the view below so it looks like half the button is cut off but I want it ...
Simon's user avatar
  • 19.8k
16 votes
4 answers
17k views

How to inject snackBarRef into a component with openFromComponent

The latest Material documentation says the following.. If you want to close a custom snack-bar that was opened via openFromComponent, from within the component itself, you can inject the ...
AppDreamer's user avatar
  • 1,386
15 votes
5 answers
30k views

The method 'showSnackBar' isn't defined for the type 'BuildContext'

Here i create a DropdownItemMenu which get the element from firebase collection, but it shows me an error The method 'showSnackBar' isn't defined for the type 'BuildContext' Container( ...
Badi Ais's user avatar
  • 161
15 votes
8 answers
15k views

How to check if there is a snack bar showing?

I'm trying to get the current snack bar (showing one) to determine if it is the same snack that am trying to show or not ; in other words ,i don't want to duplicate the snack , but i couldn't get it. ...
OverLoadedBurden's user avatar
15 votes
1 answer
7k views

Wrapping content height on a SnackBar

is there any way to make a SnackBar wrapping its text content? You can look up my problem below: As you can see the text ends at "contact us at...." and it should display the entire message. Thank ...
Fábio Carballo's user avatar
15 votes
5 answers
11k views

How can I set duration of a snack-bar in angular2 (material2)

This example stays forever on the screen: snack-bar-demo.ts import {Component, ViewContainerRef} from '@angular/core'; import {MdSnackBar, MdSnackBarConfig} from '@angular/material'; @Component({ ...
j809809jkdljfja's user avatar
14 votes
5 answers
25k views

How do I change an Android Snackbar's initial alignment from bottom to top?

The recent android library came out just a few days ago, but I would like to have the SnackBar appear on top of the screen, preferably within a RelativeLayout as it's parent view. How does one change ...
apollow's user avatar
  • 1,250
14 votes
5 answers
16k views

Android Compose with single event

Right now I have an Event class in the ViewModel that is exposed as a Flow this way: abstract class BaseViewModel() : ViewModel() { ... private val eventChannel = Channel<Event>(...
Duqe's user avatar
  • 329
14 votes
7 answers
48k views

Kotlin create a snackbar

We are trying to create a Snackbar. The code from a Java app was converted using the Java to Kotlin converter in Android Studio. Next we looked at various examples on many different websites and even ...
Vector's user avatar
  • 3,153
14 votes
4 answers
19k views

How to properly display a Snackbar in Flutter? [duplicate]

I am trying to show a Snackbar on click of a floatingActionbutton. But when I click on the floatingactionbutton it's not showing anything. Here is my code. I am using a StatefulWidget. I debugged and ...
sagar suri's user avatar
  • 4,541
14 votes
6 answers
14k views

Android Snackbar NullPointerException in Fragment

I want to add a basic snackbar to my application but i have received an error that i couldn't figure out why. I added this code in the onCreateView() method in my Fragment. Snackbar.make(view, "...
Murat Erdogan's user avatar
14 votes
1 answer
14k views

How to display snackbar infinite duration in flutter?

I created flutter project in android studio and tried to show snackbar infinite duration.This is my code final snackBar = SnackBar( content: Text('Cart:'+countProducts.toString()+" Products($...
Brutal's user avatar
  • 852
13 votes
4 answers
3k views

Android KitKat: Snackbar is not in the bottom of the screen

I add a Snackbar to my app. The problem is that in API 19 it's not at the bottom of the screen. In API 21 it's ok. Here is my layout <?xml version="1.0" encoding="utf-8"?> <layout xmlns:...
Vitalii's user avatar
  • 10.5k
13 votes
2 answers
800 views

FAB not animated when one-line Snackbar is swiped away

I have a CoordinatorLayout with support FloatingActionButton in which I want to display a Snackbar.. <android.support.design.widget.CoordinatorLayout android:id="@+id/rootView" xmlns:...
Marcel Bro's user avatar
  • 4,977
12 votes
2 answers
5k views

Move views up when SnackBar appears in CoordinatorLayout

I have a TextView at the bottom of the CoordinatorLayout. But when I show a SnackBar , it will cover the TextView. I know I have to customize a Behavior for the TextView and override layoutDependsOn ...
xiaoyuan's user avatar
  • 423
12 votes
3 answers
3k views

FloatingActionButton does not come down when dismissing Snackbar

I am trying to use a Snackbar. I have a FloatingActionButton wrapped in a CoordinatorLayout. When the Snackbar shows, the button is correctly moved up. When it dismisses automatically, the button ...
allo86's user avatar
  • 1,006
11 votes
4 answers
17k views

Display Snackbar without CoordinatorLayout

I have Displayed Snackbar using CoordinatorLayout but in some layout i did't used CoordinatorLayout layout and i want to display snackbar but faced problem with it. I have tried following way to ...
Nilesh Panchal's user avatar
11 votes
5 answers
11k views

Angular Material Snackbar not shown correctly

Stackblitz example Hi community I implemented a global error handler and a global loading component (angular material spinner) to my angular 7 project. When detecting a HttpErrorResponse the loader ...
MatterOfFact's user avatar
  • 1,413
11 votes
2 answers
6k views

show snack bar message in SwiftUI

Is there a way to show an HStack like a snack bar message which dismisses after (n) seconds using SwiftUI ? I have the following struct which's a container to my message: struct MessageBuilder<...
JAHelia's user avatar
  • 7,480
10 votes
5 answers
13k views

android how to show progress dialog on snackBar?

Is there way to show progress dialog on snackBar while getting data from server for pagination inside AsyncTask.If is this possible then how to do this.Please give suggestions.
Sachin Mandhare's user avatar
10 votes
3 answers
5k views

Flutter: How to display a snackbar from an appbar action

I'm trying to display a SnackBar after performing an action from the AppBar. The AppBar cannot be built from a builder so it can't access is Scaffold ancestor. I know we can use a GlobalKey object to ...
Quentin's user avatar
  • 606
10 votes
5 answers
10k views

How to add a SnackBar on the bottom of a dialog's overlay

I have an android application which has many different pop-ups. I want to add a SnackBar over dialog's overlay on the bottom of the screen. I tried the following code if (fragment!= null) { ...
roroinpho21's user avatar
10 votes
2 answers
17k views

How to show several snackbar without overlapping

Can I display multiple messages on the screen without overlapping others with snackBar? I have a service to display messages in my application, but the problem is that when more than one event occurs ...
Luiz Ricardo Cardoso's user avatar
10 votes
2 answers
5k views

How to write a simple test for a Snack Bar in Flutter?

I'm surprised no one seems to have asked this before, which means the answer might be obvious, but I have a screen with a text field and a button. The user enters their email in the text field. Then ...
TheBranch's user avatar
  • 113
10 votes
3 answers
3k views

How to keep the snackbar open after action is called

I use a snackbar to notify the users of my app that they aren't connected to the internet. I added a "retry" action to the snackbar which re-checks the connection. I want the snackbar to stay ...
DeryckeS's user avatar
  • 101

1
2 3 4 5
11