Question: 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.

I'v tried to google it up but nothing showed about it and what is really pissing me off is when i call `Scaffold.of(context).showSnackBar(sb);` multiple times they show will show one at a time until they end .

```
import 'package:flutter/material.dart';

const sb = SnackBar(
  content: Text('the snack bar'),
);
void main() => runApp(MaterialApp(
      title: 'Snack bar test',
      home: Scaffold(
        appBar: AppBar(
          title: Text('snack bar demo'),
        ),
        body: Center(
          child: MyApp(),
        ),
      ),
    ));

class MyApp extends StatelessWidget {
  const MyApp({Key key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return RaisedButton(
      child: Text('push to test'),
      onPressed: () {
        // Scaffold.of(context).
        Scaffold.of(context).showSnackBar(sb);
      },
    );
  }
}

```

What i want to achieve is something like this :-

```
if (sb.isShowing()){
  //hide or remove it
  }

```

and thanks in advance .

Answer: 
Use `ScaffoldMessenger.of(context).removeCurrentSnackBar();` since `Scaffold.of(context).removeCurrentSnackBar();` is deprecated.
Adding to what @Sukhi mentioned

//Set this in state
...

```
bool _isSnackbarActive = false;

```

...

.
.
.

//If you want to show snackBar on a button press

```
onPressed: () {
        if (!_isSnackbarActive) {
          showSnack();
        }

```

//This is the showSnack(). When called it'll set the \_isSnackbarActive to true and now even if you click on the button multiple times since it's true a new snackBar will not be shown. Once the current snackBar closes it set \_isSnackbarActive to false and then it can be called again.

```
  showSnack() {
    setState(() {
      _isSnackbarActive = true;
    });
    return ScaffoldMessenger.of(context)
        .showSnackBar(SnackBar(content: Text("Posts updated!")))
        .closed
        .then((SnackBarClosedReason reason) {
      // snackbar is now closed.
      setState(() {
        _isSnackbarActive = false;
      });
    });
  }

```