Show beautiful bottom sheet as confirmation dialog quickly and easily.

Overview

sweetsheet

Show beautiful bottom sheet as confirmation dialog quickly and easily.

nice warning
nice warning
success danger
success danger

and since version 0.2.0 , it is fully customizable.

custom dark custom light
success danger

Getting Started

With increasingly large smartphones, it has become almost impossible to have good ergonomics in an application using confirmation dialogs. The SweetSheet package allows you to show beautiful bottoms sheets to replace your confirmation dialogs and maintain a good user experience.

How to use?

Add this to your package's pubspec.yaml file:

dependencies:
  sweetsheet: ^0.4.0

And import it:

import 'package:sweetsheet/sweetsheet.dart';

to start using the sheets, you have to create the instance of the SweetSheet class first.

final SweetSheet _sweetSheet = SweetSheet();

Now you can show the bottom sheet by calling the method show() on the instance. This is the signature of the show method

  show({
    required BuildContext context,
    Text? title,
    required Text description,
    required CustomSheetColor color,
    required SweetSheetAction positive,
    EdgeInsets? contentPadding = const EdgeInsets.symmetric(horizontal: 24.0, vertical: 24.0),
    EdgeInsets? actionPadding = const EdgeInsets.all(8.0),
    SweetSheetAction? negative,
    IconData? icon,
    bool useRootNavigator = false,
    bool isDismissible = true,
  }) {}

This is the signature of the SweetSheetAction widget.

class SweetSheetAction extends StatelessWidget {
  final String title;
  final VoidCallback onPressed;
  final IconData icon;
  final Color color;

  SweetSheetAction({
    @required this.title,
    @required this.onPressed,
    this.icon,
    this.color = Colors.white,
  });  
}

Attention : At least one action is required and the icons are IconData for uniformity purpose.

The SweetSheetColor is a class which have four static values and it determine the color of the sheet by creating a CustomSheetColor:

  • SweetSheetColor.SUCCESS (green)
  • SweetSheetColor.DANGER (red)
  • SweetSheetColor.WARNING (orange)
  • SweetSheetColor.NICE (blue)

Customisation

To customise, create a new instance of CustomSheetColor and pass it to the argument color when calling the method show. signature of CustomSheetColor:

class CustomSheetColor {
  Color main;
  Color accent;
  Color icon;

  CustomSheetColor({@required this.main, @required this.accent, this.icon});
}

To customise the action, pass a new color to color argument of SweetSheetAction.

Example:

Warning

_sweetSheet.show(
    context: context,
    title: Text("Attention"),
    description: Text(
        'Your app is not connected to internet actually, please turn on Wifi/Celullar data.'),
    color: SweetSheetColor.WARNING,
    icon: Icons.portable_wifi_off,
    positive: SweetSheetAction(
      onPressed: () {
        Navigator.of(context).pop();
      },
      title: 'OPEN SETTING',
      icon: Icons.open_in_new,
    ),
    negative: SweetSheetAction(
      onPressed: () {
        Navigator.of(context).pop();
      },
      title: 'CANCEL',
    ),
);

Custom Light

_sweetSheet.show(
    context: context,
    description: Text(
      'Place your order. Please confirm the placement of your order : Iphone X 128GB',
      style: TextStyle(color: Color(0xff2D3748)),
    ),
    color: CustomSheetColor(
      main: Colors.white,
      accent: Color(0xff5A67D8),
      icon: Color(0xff5A67D8),
    ),
    icon: Icons.local_shipping,
    positive: SweetSheetAction(
      onPressed: () {
        Navigator.of(context).pop();
      },
      title: 'CONTINUE',
    ),
    negative: SweetSheetAction(
      onPressed: () {
        Navigator.of(context).pop();
      },
      title: 'CANCEL',
  ),
);

That is all. Have fun!

Comments
  • Prevent Clicking Off the Alert

    Prevent Clicking Off the Alert

    Can we prevent clicking off the alert itself? Would be nice to force user to click the button on the alert itself, or at least have a callback function if dismissing the alert anywhere other than the alert itself.

    opened by RichieMcMullen 1
  • SweetSheet improvement - 2/3 : Allow for a root navigator

    SweetSheet improvement - 2/3 : Allow for a root navigator

    Hi ,

    The show(...) method requires an additional argument to allow for root navigators.

    Its advised to therefore extend the existing show :

    show({
        @required BuildContext context,
        Text title,
        @required Text description,
        @required CustomSheetColor color,
        @required SweetSheetAction positive,
        SweetSheetAction negative,
        IconData icon,
      }) 
    
    

    and change to :

    
      show({
        @required BuildContext context,
        Widget title,
        @required Widget description,
        @required CustomSheetColor color,
        @required SweetSheetAction positive,
        SweetSheetAction negative,
        bool useRootNavigator = false,
        IconData icon,
      }) {
    

    Here you can see a rootNavigator has been added. You will then amend your showModalBottomSheet to make use of this boolean :

    
    showModalBottomSheet(
          context: context,
          useRootNavigator: useRootNavigator,
    
    opened by MsXam 1
  • how can i use 'custom light' for flutter web?

    how can i use 'custom light' for flutter web?

    i would like to use this for flutter web, but it will be appear at the bottom of the screen and covers the whole space. i tried to wrap it in center or other widgets but it is impossible.

    thank you.

    opened by kania-gh 2
  • Cannot change button text colour once set the icon

    Cannot change button text colour once set the icon

    @override Widget build(BuildContext context) { return icon == null ? FlatButton( onPressed: onPressed, child: Text( title, style: TextStyle( color: color, ), ), ) : FlatButton.icon( onPressed: onPressed, label: Text( title, ), icon: Icon( icon, color: color, ), ); }

    TextStyle is missing once set the icon, please kindly add it to the FlatButton if icon != null style: TextStyle( color: color, )

    opened by howej 1
  • SweetSheet improvement - 3/3 :Provide proper async/await handling for returning data

    SweetSheet improvement - 3/3 :Provide proper async/await handling for returning data

    Hi

    showModalBottomSheet provides a return value of Future. However - the current implementation of SweetSheet does not provide a provision to return action data choices (Return values when buttons are tapped). It is therefore suggested to correctly amend the signature of show() to capture return data.

    
    Future<dynamic> show({
        @required BuildContext context,
        Widget title,
        @required Widget description,
        @required CustomSheetColor color,
        @required SweetSheetAction positive,
        SweetSheetAction negative,
        bool useRootNavigator = false,
        IconData icon,
      }) {
        var rv = showModalBottomSheet(...);
        return rv;
      }
    

    And this can then be accessed as in a specific warning helper method that just wraps SweetSheetColor.WARNING & Associated Icon

    
      static Future<dynamic> warning(
          String title, String description, BuildContext context) async {
        assert(title != null);
        assert(description != null);
        var rv = await bottomDialog(context, Text(title),
            description: Text(description),
            color: SweetSheetColor.WARNING,
            icon: 'yourAssetFile.zip',
            useRootNavigator: true);
        return rv;
      }
    

    An example of how the SweetSheet.bottomDialog can be called and how we now process the Navigator return values is :

    
    var continueRunning = await SweetSheetHelper.bottomDialog(
              context, Text('This is your title'),
              description: Text(
                  'This is your description'),
              color: SweetSheetColor.WARNING,
              icon: 'assets/lottie/warningWhiteCircle.zip',
              useRootNavigator: true,
              positive: SweetSheetAction(
                icon: MdiIcons.runFast,
                title: 'CONTINUE',
                onPressed: () =>
                    Navigator.of(context, rootNavigator: true).pop(true),
              ),
              negative: SweetSheetAction(
                title: 'CANCEL',
                onPressed: () =>
                    Navigator.of(context, rootNavigator: true).pop(false),
              ));
    
          /// And here you will be able to get the RETURN values from the navigators (true/false/null etc)
         
          if (continueRunning == null || !continueRunning) {
            return; // User tapped cancel or discarded the MODAL sheet 
          }
    
    opened by MsXam 0
  • SweetSheet improvement - 1/3 : Do not use Strings for Title and Description

    SweetSheet improvement - 1/3 : Do not use Strings for Title and Description

    Hi there ...

    Currently your Component has a method signature such that it expects Strings for Title and Description. This should be changed so that a Widget is supplied in-place of the Strings. You need this because your current component does not support accessibility meaning that the Text(...) widget that you internally use to render the Title & Description will take its TextScaleFactor for MediaQuery.

    This can lead to overflow errors when the Bottom sheet is rendered.

    Suggestion

    Change the method :

    show({ @required BuildContext context, Text title, @required Text description, @required CustomSheetColor color, @required SweetSheetAction positive, SweetSheetAction negative, IconData icon, }) {

    To

    show({ @required BuildContext context, Widget title, @required Widget description, @required CustomSheetColor color, @required SweetSheetAction positive, SweetSheetAction negative, IconData icon, }) {

    This will allow callers of Show to handle their own Accessibility for both Title & Description and Since these will be changed to Widget, we can further use composition to wrap them , i.e

    
    show(context:context,
               title:FixedSizedTitle(child:Text('My SweetTitle')),
    description:FixedSizedTitle(child:Text('My Sweet description etc')),
    ....
    )
    
    opened by MsXam 0
Owner
Ayao Corneille ALLOGBALO
Backend/Cloud architect and developer. From TOGO 🇹🇬. Bachelor in Computer Science in India 🇮🇳. Master in Systems and Software Engineering in France 🇫🇷
Ayao Corneille ALLOGBALO
A new flutter package project which contains lots of beautiful alert dialog that will help you lot to create beautiful awesome alert box very quickly and easily.

A new flutter package project which contains lots of beautiful alert dialog that will help you lot to create beautiful awesome alert box very quickly and easily.

Karan Soni 8 Jan 8, 2022
This package will help you to manage the overlays in your projects. Show a dialog, notification, window, or a panel easily

This package will help you to manage the overlays in your projects. Show a dialog, notification, window, or a panel easily. or use one of the helping widgets like AutoComplete, Expander(Dropdown).

Schaban Bochi 25 Dec 4, 2022
A action bottom sheet that adapts to the platform (Android/iOS).

Adaptive action sheet A action bottom sheet that adapts to the platform (Android/iOS). iOS Android Getting Started Add the package to your pubspec.yam

Daniel Ioannou 26 Sep 26, 2022
Flutter: Rating bottom sheet

Rating bottom sheet Features Getting started pubspec.yaml rating: <lastest version> Usage Implement the RatingController class PrintRatingController e

David Araujo 3 Aug 18, 2022
Custom bottom bar - A bottom tool bar that can be swiped left or right to expose more tools.

custom_bottom_bar A bottom tool bar that can be swiped left or right to expose more tools. usage Create your custom bottom bars with up to four custom

null 4 Jan 26, 2020
Flutter-nav-bottom-bar-tutorial - A flutter bottom navigation bar tutorial

Flutter Bottom Navigation Bar Tutorial A tutorial with various Flutter bottom na

Aleyna Eser 2 Oct 25, 2022
Localize your flutter application quickly and easily.

EzLocalization This package allows you to setup a powerful localization system with ease and in only a few minutes. Features Here are some features: E

Hugo Delaunay 13 Sep 22, 2022
A beautiful and customizable Star Rating Dialog package for Flutter

rating_dialog A beautiful and customizable Rating Dialog package for Flutter! Supports all platforms that flutter supports! Import the rating_dialog p

Oliver Martinez 40 Jul 13, 2022
Show a draggable floating chat icon button and show messages on screens

Show a draggable floating chat icon button and show messages on screens Features A widget for displaying a chat icon (or custom widget) on top of a ba

CU Apps 4 May 5, 2022
A most easily usable cookie management library in Dart. With SweetCookieJar, you can easily manage cookie on your application.

A most easily usable cookie management library in Dart! 1. About 1.1. Introduction 1.1.1. Install Library 1.1.2. Import It 1.1.3. Use SweetCookieJar 1

Kato Shinya 9 Oct 27, 2022
A most easily usable cache management library in Dart. With CacheStorage, you can easily manage cache on your application.

A most easily usable cache management library in Dart! 1. About 1.1. Introduction 1.1.1. Install Library 1.1.2. Import It 1.1.3. Use CacheStorage 1.2.

Kato Shinya 1 Dec 13, 2021
A most easily usable RESAS API wrapper in Dart. With this library, you can easily integrate your application with the RESAS API.

A most easily usable RESAS API wrapper library in Dart! 1. About 1.1. What Is RESAS? 1.2. Introduction 1.2.1. Install Library 1.2.2. Import It 1.2.3.

Kato Shinya 2 Apr 7, 2022
A package that provides a highly customizable sheet widget that snaps to different vertical & horizontal positions

Snapping Sheet A package that provides a highly customizable sheet widget that snaps to different vertical & horizontal positions Can adapt to scrolla

Adam Jonsson 364 Dec 6, 2022
A super powerful widget to help developers build complex views quickly and comfortably.

FSuper FSuper can help developers build complex views quickly and comfortably. It supports rich text, rounded corners, borders, pictures, small red do

Fliggy Mobile 481 Dec 29, 2022
A super powerful widget to help developers build complex views quickly and comfortably.

FSuper FSuper can help developers build complex views quickly and comfortably. It supports rich text, rounded corners, borders, pictures, small red do

Fliggy Mobile 481 Dec 29, 2022
Flutter plugin for building pull to refresh effects with PullToRefreshNotification and PullToRefreshContainer quickly.

pull_to_refresh_notification Language: English | 中文简体 widget to build pull to refresh effects. Web demo for PullToRefreshNotification Chinese blog pul

FlutterCandies 165 Dec 28, 2022
腾讯云 1 Feb 10, 2022
Quickly is build as a tool to enhance your Flutter UI development experience and make code easier

Quickly is build as a tool to enhance your Flutter UI development experience and make code easier. It is highly inspired by Bootstrap and Tailwind CSS. It also provide lots of extension methods on String, List and Map.

Aniket Khote 11 Oct 24, 2022
Quickly configure three theme styles

flytheme 快速实现三种主题效果。 本插件是从矿小助App中拆分出来的,优化了很多细节,更加简单易用。 内置持久化存储(使用share_preference实现) 矿小助App:https://kxz.atcumt.com/ pub插件地址:https://pub.dev/packages/f

CUMT-Atom 2 Aug 2, 2022