Giter Club home page Giter Club logo

material_snackbar's Introduction

Material snackbar

A flutter plugin for displaying snackbars with the newest material design on desktop and mobile.

style: effective dart CodeFactor

Features

showcase

Usage

First, add the material_snackbar package to your pubspec dependencies.

To import material_snackbar:

import 'package:material_snackbar/material_snackbar.dart';

For displaying a material snackbar you need to obtain the [MaterialSnackbarMessengerState] of the current [BuildContext] by using [MaterialSnackBarMessenger.of].

Material snackbar

Here is an example how to display a simple snackbar.

MaterialSnackBarMessenger.of(context).showSnackBar(
  snackbar: MaterialSnackbar(
    content: Text('Deleted 142 important documents'),
  ),
);

Use actionBuilder to add an action button that can dismiss the snackbar.

MaterialSnackBarMessenger.of(context).showSnackBar(
  snackbar: MaterialSnackbar(
    content: Text('Deleted 142 important documents.'),
    actionBuilder: (context, close) => TextButton(
      child: Text('DISMISS'),
      onPressed: close,
    ),
  ),
);

Snackbar queue

When you show multiple snackbars they are not displayed all at one time. They are added to the snackbar queue and are displayed individually after the previously shown snackbar.

snackbar queue

To empty the snackbar queue use:

MaterialSnackBarMessenger.of(context).emptyQueue();

Faster ⚡

When you just need a normal snackbar you can use snack() to save time.

 MaterialSnackBarMessenger.of(context).snack(
   'I am speed',
   actionText: 'REPLY',
   onAction: () => print('Speeeed'),
 );

For more examples see the example tab ➡

material_snackbar's People

Contributors

roundedinfinity avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

rvndsngwn

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.