Provide easy and flexible way to show SnackBar. Simple text, undo, and error style are supported.

Overview

snack_bar_presenter

Provide easy and flexible way to show SnackBar. Simple text, undo, and error style are supported.

. . .
Screenshot_1594537088 Screenshot_1594537095 Screenshot_1594537100

Usage

import 'package:example/providers/providers.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:snack_bar_presenter/snack_bar_presenter.dart';

class BasicPage extends HookWidget {
  const BasicPage({
    Key key,
    this.index = 0,
  }) : super(key: key);

  final int index;

  static const routeName = '/basic';

  @override
  Widget build(BuildContext context) {
    final controller = useProvider(_controllers(index));
    final canPop = useProvider(navigatorKeyProvider).currentState.canPop();
    return Scaffold(
      key: controller.scaffoldKey,
      appBar: AppBar(title: Text('index: $index')),
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            RaisedButton(
              child: const Text('Show SnackBar'),
              onPressed: () => controller.showSnackBarMessage('Hey( ´・‿・`)'),
            ),
            RaisedButton(
              child: const Text('👉 Navigate to next page'),
              onPressed: () {
                Navigator.of(context).push<void>(
                  MaterialPageRoute(
                    builder: (context) => BasicPage(
                      index: index + 1,
                    ),
                  ),
                );
              },
            ),
            if (canPop)
              RaisedButton(
                child: const Text('👈 Pop and show SnackBar'),
                onPressed: controller.popAndShowSnackBar,
              ),
          ],
        ),
      ),
      bottomNavigationBar: BottomAppBar(
        child: Row(
          children: [
            IconButton(
              icon: const Icon(Icons.add),
              onPressed: () {},
            )
          ],
        ),
      ),
    );
  }
}

final _controllers = Provider.autoDispose.family<_Controller, int>(
  (ref, __) {
    final controller = _Controller(ref);
    ref.onDispose(controller.dispose);
    return controller;
  },
);

class _Controller with SnackBarMixin {
  _Controller(this._ref) {
    registerToStackBarPresenter();
  }

  final ProviderReference _ref;

  @override
  SnackBarPresenter get snackBarPresenter =>
      _ref.read(snackBarPresenterProvider);

  void popAndShowSnackBar() {
    _ref.read(navigatorKeyProvider).currentState.pop();
    // Remove registration before showing SnackBar
    unregisterFromStackBarPresenter();
    showSnackBarMessage('Came back( ´・‿・`)');
  }

  void dispose() {
    unregisterFromStackBarPresenter();
  }
}
You might also like...

A flexible tool for application localization using Google Sheets.

A flexible tool for application localization using Google Sheets.

goloc A flexible tool for application localization using Google Sheets. Table of Contents Features Supported OS / architectures Supported platforms /

Oct 17, 2022

This is not an app. I made this architecture to build robust and easy-to-maintain products but in a faster way.

simple_architecture_flutter This is not an app. I made this architecture to build robust and easy-to-maintain products but in a faster way. Info I use

Oct 28, 2022

Easy way to store http response.

Easy way to store http response.

Starlight Http Cached The easiest way to store data such as http response,String,int,double,bool,map,list. Features ☑️ Set Cached ☑️ Get Cached ☑️ Del

Jan 9, 2023

Tubles is a simple applications to provide any tubles in in google maps and we as the user can navigate into the selected tubles location.

Tubles is a simple applications to provide any tubles in in google maps and we as the user can navigate into the selected tubles location.

Tubles Tubles is a simple applications to provide any tubles place in google maps and we as the user can navigate into the selected tubles location. F

Jan 8, 2023

Server that provide API to simple note application

Server that provide API to simple note application

note-app-api-mobile end-to-end note application API Golang for the web application MongoDB for the database PostMan requests Collection Flutter simple

Oct 4, 2022

Generate a new file by compressed video, and provide metadata. Get video thumbnail from a video path, supports JPEG/GIF. To reduce app size not using FFmpeg in IOS.

Generate a new file by compressed video, and provide metadata. Get video thumbnail from a video path, supports JPEG/GIF. To reduce app size not using FFmpeg in IOS.

flutter_video_compress Generate a new path by compressed video, Choose to keep the source video or delete it by a parameter. Get video thumbnail from

Dec 8, 2022

💪 Helm is an app that gamifies stress/anxiety/depression management in an actionable manner to provide relief.

💪 Helm is an app that gamifies stress/anxiety/depression management in an actionable manner to provide relief.

Helm Helm is an app that gamifies stress/anxiety/depression management in an actionable manner to provide relief. To try it out, setup flutter on your

Dec 30, 2022

This App Currently is a Simple Budget Manager Show Analytics Based on Your Past Transactions

This App Currently is a Simple Budget Manager Show Analytics Based on Your Past Transactions

Budgex [In Progress] This App Currently is a Simple Budget Manager Show Analytics Based on Your Past Transactions Features Localization Persistant Sto

Nov 14, 2022
Owner
Masayuki Ono (mono)
Software Engineer (Flutter/Dart, Firebase/GCP, iOS/Swift, TypeScript)
Masayuki Ono (mono)
A Flutter package which implements a ConvexAppBar to show a convex tab in the bottom bar. Theming supported.

English | 简体中文 The official BottomAppBar can only display a notch FAB with an app bar, and sometimes we need a convex FAB. BottomAppBar and NotchShape

Thinking in code 647 Dec 28, 2022
Undo/Redo for Flutter and Dart

undo An undo redo library for Dart/Flutter. Forked from here and updated for Flutter. Demo can be viewed here. Usage Create an ChangeStack to store ch

Rody Davis 55 Dec 15, 2022
Been together app with undo button

been_together_undo A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you start

Nguyễn Đức Mạnh 5 Nov 24, 2021
This plugin lets you show a message in a simple way.

error_message This plugin lets you show a message in a simple way. Usage ErrorMessage( icon: Icon(Icons.error), title: "Error Title",

TamilKannan-Developer 0 Dec 5, 2021
A flutter package which contains a collection of Splash Screen example for your app to display logo and different text style.

splash_screen_view They say, first impression is the last! Yep, truly for any amazingly crafted application, it's easier to start impressing your audi

Sandip Kalola (SK) 17 Nov 25, 2022
The easiest way to show notification.

Starlight Notification The easiest way to show notification. Features ☑️ Show Notification ☑️ Cancel Notification ☑️ Cancel All Notification Watch the

Ye Myo Aung 1 Oct 19, 2022
A flutter widget that show the camera stream and allow ML vision recognition on it, it allow you to detect barcodes, labels, text, faces...

Flutter Camera Ml Vision A Flutter package for iOS and Android to show a preview of the camera and detect things with Firebase ML Vision. Installation

Rushio Consulting 257 Jan 2, 2023
A Flutter application implementing AR core, Text-to-speech, and Speech-to-text technologies.

ar_x_ai A Flutter application implementing AR core, Text to speech and Speech to text technologies. Getting Started This project is a starting point f

Alston Fernandes 1 Dec 17, 2021
A Translator App Which is Build using Flutter, Speech To Text, Google ML Kit, Google Translator and Text To Speech.

AI Translator This is a Translator App Which is Build using Flutter, Speech To Text, Google ML Kit, Google Translator and Text To Speech. Download App

null 4 Jul 16, 2022
LinkWell is a Text widget that highlight all the links in the text which then navigates the user to the URL when tapped

LinkWell LinkWell is Text Plugin that detects URLs and Emails in a String and when tapped opens in user browsers, linkwell GitHub ScreenShots Basic Us

Samuel Ezedi 31 Sep 27, 2022