A Styled Toast Flutter package.

Overview

flutter_styled_toast

A Styled Toast Flutter package. You can highly customize toast ever. Beautify toast with a series of animations and make toast more beautiful.

demo

Getting Started

dependencies:
  flutter_styled_toast: ^1.5.2+1
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
//Simple to use, no global configuration
showToast("hello styled toast",context:context);

//Customize toast content widget, no global configuration
showToastWidget(Text('hello styled toast'),context:context);
//Interactive toast, set [isIgnoring] false.
showToastWidget(
   Container(
       padding: EdgeInsets.symmetric(horizontal: 18.0),
       margin: EdgeInsets.symmetric(horizontal: 50.0),
       decoration: ShapeDecoration(
           shape: RoundedRectangleBorder(
               borderRadius: BorderRadius.circular(5.0),
           ),
           color: Colors.green[600],
       ),
       child: Row(
           children: [
               Text(
                   'Jump to new page',
                   style: TextStyle(
                       color: Colors.white,
                   ),
               ),
               IconButton(
                   onPressed: () {
                       ToastManager().dismissAll(showAnim: true);
                       Navigator.push(context,
                           MaterialPageRoute(builder: (context) {
                           return SecondPage();
                       }));
                   },
                   icon: Icon(
                       Icons.add_circle_outline_outlined,
                       color: Colors.white,
                   ),
               ),
           ],
           mainAxisAlignment: MainAxisAlignment.spaceBetween,
       ),
   ),
   context: context,
   isIgnoring: false,
   duration: Duration.zero,
);
//Set an animation
showToast('This is normal toast with animation',
   context: context,
   animation: StyledToastAnimation.scale,
);

///Set both animation and reverse animation,
///combination different animation and reverse animation to achieve amazing effect.
showToast('This is normal toast with animation',
   context: context,
   animation: StyledToastAnimation.scale,
   reverseAnimation: StyledToastAnimation.fade,
   position: StyledToastPosition.center,
   animDuration: Duration(seconds: 1),
   duration: Duration(seconds: 4),
   curve: Curves.elasticOut,
   reverseCurve: Curves.linear,
);

```dart


```dart
///Custom animation and custom reverse animation,
///combination different animation and reverse animation to achieve amazing effect.

AnimationController mController;
AnimationController mReverseController;

@override
void initState() {
  super.initState();
  mController =
      AnimationController(vsync: this, duration: Duration(milliseconds: 200));
  mReverseController =
      AnimationController(vsync: this, duration: Duration(milliseconds: 200));
}

showToast('This is normal toast with custom animation',
   context: context,
   position: StyledToastPosition.bottom,
   animDuration: Duration(seconds: 1),
   duration: Duration(seconds: 4),
   animationBuilder: (
       BuildContext context,
       AnimationController controller,
       Duration duration,
       Widget child,
   ) {
      return SlideTransition(
          position: getAnimation<Offset>(
          Offset(0.0, 3.0), Offset(0, 0), controller,
          curve: Curves.bounceInOut),
          child: child,
      );
   },
   reverseAnimBuilder: (
      BuildContext context,
      AnimationController controller,
      Duration duration,
      Widget child,
   ) {
      return SlideTransition(
          position: getAnimation<Offset>(
          Offset(0.0, 0.0), Offset(-3.0, 0), controller,
          curve: Curves.bounceInOut),
          child: child,
      );
   },
);

```dart


```dart
///Custom animation, custom reverse animation and custom animation controller
showToast('This is normal toast with custom animation and controller',
   context: context,
   position: StyledToastPosition.bottom,
   animDuration: Duration(seconds: 1),
   duration: Duration(seconds: 4),
   onInitState:(Duration toastDuration, Duration animDuration) async {
      try {
         await mController.forward().orCancel;
         Future.delayed(toastDuration - animDuration, () async {
            await mReverseController.forward().orCancel;
            mController.reset();
            mReverseController.reset();
         });
      } on TickerCanceled {}
   },
   animationBuilder: (
       BuildContext context,
       AnimationController controller,
       Duration duration,
       Widget child,
   ) {
      return SlideTransition(
          position: getAnimation<Offset>(
          Offset(0.0, 3.0), Offset(0, 0), controller,
          curve: Curves.bounceInOut),
          child: child,
      );
   },
   reverseAnimBuilder: (
      BuildContext context,
      AnimationController controller,
      Duration duration,
      Widget child,
   ) {
      return SlideTransition(
          position: getAnimation<Offset>(
          Offset(0.0, 0.0), Offset(-3.0, 0), controller,
          curve: Curves.bounceInOut),
          child: child,
      );
   },
);

```dart



Simple global configuration, wrap you app with StyledToast.
```dart
StyledToast(
  locale: const Locale('en', 'US'),
  child: MaterialApp(
            title: appTitle,
            showPerformanceOverlay: showPerformance,
            home: LayoutBuilder(
              builder: (BuildContext context, BoxConstraints constraints) {
                return MyHomePage(
                  title: appTitle,
                  onSetting: onSettingCallback,
                );
              },
            ),
          ),
);

Highly Customizable global configuration

StyledToast(
  locale: const Locale('en', 'US'),  //You have to set this parameters to your locale
  textStyle: TextStyle(fontSize: 16.0, color: Colors.white), //Default text style of toast
  backgroundColor: Color(0x99000000),  //Background color of toast
  borderRadius: BorderRadius.circular(5.0), //Border radius of toast
  textPadding: EdgeInsets.symmetric(horizontal: 17.0, vertical: 10.0),//The padding of toast text
  toastPositions: StyledToastPosition.bottom, //The position of toast
  toastAnimation: StyledToastAnimation.fade,  //The animation type of toast
  reverseAnimation: StyledToastAnimation.fade, //The reverse animation of toast (display When dismiss toast)
  curve: Curves.fastOutSlowIn,  //The curve of animation
  reverseCurve: Curves.fastLinearToSlowEaseIn, //The curve of reverse animation
  duration: Duration(seconds: 4), //The duration of toast showing, when set [duration] to Duration.zero, toast won't dismiss automatically.
  animDuration: Duration(seconds: 1), //The duration of animation(including reverse) of toast 
  dismissOtherOnShow: true,  //When we show a toast and other toast is showing, dismiss any other showing toast before.
  movingOnWindowChange: true, //When the window configuration changes, move the toast.
  fullWidth: false, //Whether the toast is full screen (subtract the horizontal margin)
  isHideKeyboard: false, //Is hide keyboard when toast show
  isIgnoring: true, //Is the input ignored for the toast
  animationBuilder: (BuildContext context,AnimationController controller,Duration duration,Widget child,){  // Builder method for custom animation
     return SlideTransition(
        position: getAnimation<Offset>(Offset(0.0, 3.0),Offset(0,0), controller,curve: Curves.bounceInOut),
        child: child,
     );
  },
  reverseAnimBuilder: (BuildContext context,AnimationController controller,Duration duration,Widget child,){ // Builder method for custom reverse animation
     return SlideTransition(
        position: getAnimation<Offset>(Offset(0.0, 0.0),Offset(-3.0,0), controller,curve: Curves.bounceInOut),
        child: child,
     );
  },
  child: MaterialApp(
          title: appTitle,
          showPerformanceOverlay: showPerformance,
          home: LayoutBuilder(
            builder: (BuildContext context, BoxConstraints constraints) {
              return MyHomePage(
                title: appTitle,
                onSetting: onSettingCallback,
              );
            },
          ),
        ),
);
```dart

```dart
//After global configuration, use in a single line.
showToast("hello styled toast");

//After global configuration, Customize toast content widget
showToastWidget(Text('hello styled toast'));

๐Ÿš€ Roadmap


DefaultToastWidget

FadeAnim

SlideFromTopAnim

SlideFromBottomAnim

SlideFromLeftAnim

SlideFromRightAnim

ScaleAnim

FadeScaleAnim

RotateAnim

FadeRotateAnim

ScaleRotateAnim

OnDismiss

CustomToastWidget

CustomFailToastWidget

CustomSuccessToastWidget

StyledToast param

property description
locale Locale (Not Null)(required You have to set this parameters to your locale)
child Widget (Not Null)(required)
textAlign TextAlign (default TextAlign.center)
textDirection TextDirection (default TextDirection.ltr)
borderRadius BorderRadius (BorderRadius.circular(5.0))
backgroundColor Color (default Color(0x99000000))
textPadding EdgeInsetsGeometry (default EdgeInsets.symmetric(horizontal: 17.0,vertical: 8.0))
toastHorizontalMargin double (default 50.0)
textStyle TextStyle (default TextStyle(fontSize: 16.0,fontWeight: FontWeight.normal,color: Colors.white))
shapeBorder ShapeBorder (default RoundedRectangleBorder(borderRadius: borderRadius))
duration Duration (default 2.3s)(When set [duration] to Duration.zero, toast won't dismiss automatically)
animDuration Duration (default 400 milliseconds, animDuration * 2 <= duration, conditions must be met for toast to display properly)
toastPositions StyledToastPosition (default StyledToastPosition.bottom)
toastAnimation StyledToastAnimation (default StyledToastAnimation.fade)
reverseAnimation StyledToastAnimation
alignment AlignmentGeometry (default Alignment.center)
axis Axis (default Axis.vertical)
startOffset Offset
endOffset Offset
reverseStartOffset Offset
reverseEndOffset Offset
curve Curve (default Curves.linear)
reverseCurve Curve (default Curves.linear)
dismissOtherOnShow bool (default true)
movingOnWindowChange bool (default true)
onDismiss VoidCallback (Invoked when toast dismiss)
fullWidth bool (default false)(Full width parameter that the width of the screen minus the width of the margin.)
isHideKeyboard bool (default false)(Is hide keyboard when toast show)
animationBuilder CustomAnimationBuilder (Builder method for custom animation)
reverseAnimBuilder CustomAnimationBuilder (Builder method for custom reverse animation)
isIgnoring bool (default true)
onInitState OnInitStateCallback (When toast widget [initState], this callback will be called)

showToast param

property description
msg String (Not Null)(required)
context BuildContext (If you don't wrap app with StyledToast, context is required, otherwise, is not)
duration Duration (default 2.3s)(When set [duration] to Duration.zero, toast won't dismiss automatically)
animDuration Duration (default 400 milliseconds, animDuration * 2 <= duration, conditions must be met for toast to display properly)
position StyledToastPosition (default StyledToastPosition.bottom)
textStyle TextStyle (default TextStyle(fontSize: 16.0,fontWeight: FontWeight.normal,color: Colors.white))
textPadding EdgeInsetsGeometry (default EdgeInsets.symmetric(horizontal: 17.0,vertical: 8.0))
backgroundColor Color (default Color(0x99000000))
borderRadius BorderRadius (BorderRadius.circular(5.0))
shapeBorder ShapeBorder (default RoundedRectangleBorder(borderRadius: borderRadius))
onDismiss VoidCallback (Invoked when toast dismiss)
textDirection TextDirection (default TextDirection.ltr)
dismissOtherOnShow bool (default true)
movingOnWindowChange bool (default true)
toastAnimation StyledToastAnimation (default StyledToastAnimation.fade)
reverseAnimation StyledToastAnimation
alignment AlignmentGeometry (default Alignment.center)
axis Axis (default Axis.vertical)
startOffset Offset
endOffset Offset
reverseStartOffset Offset
reverseEndOffset Offset
textAlign TextAlign (default TextAlign.center)
curve Curve (default Curves.linear)
reverseCurve Curve (default Curves.linear)
fullWidth bool (default false)(Full width parameter that the width of the screen minus the width of the margin)
isHideKeyboard bool (default false)(Is hide keyboard when toast show)
animationBuilder CustomAnimationBuilder (Builder method for custom animation)
reverseAnimBuilder CustomAnimationBuilder (Builder method for custom reverse animation)
isIgnoring bool (default true)(Is the input ignored for the toast)
onInitState OnInitStateCallback (When toast widget [initState], this callback will be called)

showToastWidget param

property description
widget Widget (Not Null)(required)
context BuildContext (If you don't wrap app with StyledToast, context is required, otherwise, is not)
duration Duration (default 2.3s)(When set [duration] to Duration.zero, toast won't dismiss automatically)
animDuration Duration (default 400 milliseconds, animDuration * 2 <= duration, conditions must be met for toast to display properly)
onDismiss VoidCallback (Invoked when toast dismiss)
dismissOtherOnShow bool (default true)
movingOnWindowChange bool (default true)
textDirection TextDirection (default TextDirection.ltr)
position StyledToastPosition (default )
animation StyledToastAnimation (default StyledToastAnimation.fade)
reverseAnimation StyledToastAnimation
alignment AlignmentGeometry (default Alignment.center)
axis Axis (default Axis.vertical)
startOffset Offset
endOffset Offset
reverseStartOffset Offset
reverseEndOffset Offset
curve Curve (default Curves.linear)
reverseCurve Curve (default Curves.linear)
isHideKeyboard bool (default false)(Is hide keyboard when toast show)
animationBuilder CustomAnimationBuilder (Builder method for custom animation)
reverseAnimBuilder CustomAnimationBuilder (Builder method for custom reverse animation)
isIgnoring bool (default true )(Is the input ignored for the toast)
onInitState OnInitStateCallback (When toast widget [initState], this callback will be called)

Example

example

Comments
  • Getting issue on flutter version 3.0.0

    Getting issue on flutter version 3.0.0

    /src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_styled_toast-2.0.0/lib/src/styled_toast.dart:1559:20: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.

    • 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/G:/AAAInstallation/src/flutter/packages/flutter/lib/src/widgets/binding.dart'). WidgetsBinding.instance!.removeObserver(this);
    opened by krButani 6
  • Without giving context getting error. But context is optional param.

    Without giving context getting error. But context is optional param.

    ======== Exception caught by gesture =============================================================== The following assertion was thrown while handling a gesture: 'package:flutter_styled_toast/src/styled_toast.dart': Failed assertion: line 73 pos 10: 'context != null': is not true.

    opened by saravananmnm 5
  • error when build in ios

    error when build in ios

    Showing All Messages ../../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_styled_toast-2.1.3/lib/src/styled_toast.dart:497:63: Error: Property 'window' cannot be accessed on 'WidgetsBinding?' because it is potentially null

    flutter 2.10.5 dart 2.16.2

    opened by eggysudianto 4
  • Button inside widget in showToastWidget is unclickable

    Button inside widget in showToastWidget is unclickable

    I already set isIgnoring to false and put a button inside the widget I create in showToastWidget, the button is work until I set endOffset with Offset(0, 1), seems the button is ignoring the pointer. any suggestion?

    opened by RakaAlrian 3
  • Toast was not dismissed after the show

    Toast was not dismissed after the show

    Thanks for your plugin! In a new plugin version, 1.5.2+1 has an issue, toast was not dismissed after the show On 1.5.1+1 all work fine!

    pubspec.yaml

    dependencies:
      flutter:
        sdk: flutter
      flutter_styled_toast: 1.5.2+1
    

    Material app:

      @override
      Widget build(BuildContext context) {
        return StyledToast(
          child: MaterialApp(
            title: _title,
            home: MyWidget(),
          ),
          locale: const Locale('en', 'US'),
          textStyle: const TextStyle(
            fontSize: 16.0,
            color: Colors.white,
            fontWeight: FontWeight.w800,
          ),
        );
      }
    

    Widget code:

      GestureDetector(
        onTap: () {
          showToast('Toast version flutter_styled_toast: 1.5.2+1');
        },
        child: Container(
          width: 100,
          color: Colors.blue,
        ),
      ),
    

    toast

    opened by ShelMax 3
  • Exception with newest Flutter version breaks TextFields context menu

    Exception with newest Flutter version breaks TextFields context menu

    How to reproduce:

    1. Add StyledToast at top of the Material Widget, but not inside of a Material Widget.
    2. Open context menu on a TextField to paste or copy something
    3. App crashes with:
    
    โ•โ•โ•โ•โ•โ•โ•โ• Exception caught by widgets library โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
    The following assertion was thrown building _OverlayEntryWidget-[LabeledGlobalKey<_OverlayEntryWidgetState>#39063](dirty, state: _OverlayEntryWidgetState#5b291):
    No MediaQuery widget found.
    
    _OverlayEntryWidget widgets require a MediaQuery widget ancestor.
    The specific widget that could not find a MediaQuery ancestor was: _OverlayEntryWidget-[LabeledGlobalKey<_OverlayEntryWidgetState>#39063]
        dirty
        state: _OverlayEntryWidgetState#5b291
    The ownership chain for the affected widget is: "_OverlayEntryWidget-[LabeledGlobalKey<_OverlayEntryWidgetState>#39063] โ† _Theatre โ† Overlay โ† Stack โ† Directionality โ† _StyledToastTheme โ† StyledToast โ† CookingPlannerApp โ† [root]"
    
    Typically, the MediaQuery widget is introduced by the MaterialApp or WidgetsApp widget at the top of your application widget tree.
    
    The relevant error-causing widget was
        StyledToast 
    lib/main.dart:30
    When the exception was thrown, this was the stack
    #0      debugCheckHasMediaQuery.<anonymous closure> 
    package:flutter/โ€ฆ/widgets/debug.dart:215
    #1      debugCheckHasMediaQuery 
    package:flutter/โ€ฆ/widgets/debug.dart:227
    #2      _MaterialTextSelectionControls.buildToolbar 
    package:flutter/โ€ฆ/material/text_selection.dart:645
    #3      TextSelectionOverlay._buildToolbar 
    package:flutter/โ€ฆ/widgets/text_selection.dart:556
    #4      _OverlayEntryWidgetState.build 
    package:flutter/โ€ฆ/widgets/overlay.dart:177
    ...
    โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
    Reloaded 1 of 764 libraries in 865ms.
    Reloaded 1 of 764 libraries in 914ms.
    W/IInputConnectionWrapper( 8055): getTextBeforeCursor on inactive InputConnection
    W/IInputConnectionWrapper( 8055): getSelectedText on inactive InputConnection
    W/IInputConnectionWrapper( 8055): getTextAfterCursor on inactive InputConnection
    W/IInputConnectionWrapper( 8055): beginBatchEdit on inactive InputConnection
    W/IInputConnectionWrapper( 8055): endBatchEdit on inactive InputConnection
    

    Flutter Doctor:

    [โœ“] Flutter (Channel stable, v1.17.0, on Linux, locale de_DE.UTF-8)
        โ€ข Flutter version 1.17.0 at /home/krille/Lokal/HADTF/flutter_linux_v1.2.1-stable/flutter
        โ€ข Framework revision e6b34c2b5c (vor 11 Tagen), 2020-05-02 11:39:18 -0700
        โ€ข Engine revision 540786dd51
        โ€ข Dart version 2.8.1
    
     
    [โœ“] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
        โ€ข Android SDK at /home/krille/Android/Sdk
        โ€ข Platform android-29, build-tools 29.0.2
        โ€ข Java binary at: /snap/android-studio/88/android-studio/jre/bin/java
        โ€ข Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
        โ€ข All Android licenses accepted.
    
    [โœ“] Android Studio (version 3.6)
        โ€ข Android Studio at /snap/android-studio/88/android-studio
        โ€ข Flutter plugin version 45.1.1
        โ€ข Dart plugin version 192.7761
        โ€ข Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    
    [โœ“] Connected device (1 available)
        โ€ข Android SDK built for x86 โ€ข emulator-5554 โ€ข android-x86 โ€ข Android 10 (API 29) (emulator)
    
    โ€ข No issues found!
    

    Workaround:

    Place another MaterialApp around StyledToast:

    Widget build(BuildContext context) {
        return MaterialApp(
          home: StyledToast(
            toastPositions: StyledToastPosition.top,
            child: MaterialApp(
        // ...
    

    But this doesn't look that great ... so it would be nice if we could get a fix for this :)

    opened by krillefear 3
  • The latest version (v1.5.x) prevents child widgets from getting updated

    The latest version (v1.5.x) prevents child widgets from getting updated

    Hi, thanks for the very helpful package!

    Since updating from v1.4.x to v1.5.x I'm no longer able to force the child widgets to update.

    This is the approach I'm using which could definitely be part of the problem:

    https://hillel.dev/2018/08/15/flutter-how-to-rebuild-the-entire-app-to-change-the-theme-or-locale/

    Any thoughts?

    opened by hillelcoren 2
  • Toast hides when keyboard is active.

    Toast hides when keyboard is active.

    Hi, I'm using this package, and it is working fine. The only issue I'm facing on both Android and iOS is that when its position is on the bottom and the keyboard is active, toast hides behind the keyboard but showing on the top position. For now, I'm using it on the top position but it doesn't look so good in my scenario. Kindly provide any solution to show it at the bottom of the screen without hiding it behind the keyboard. Thanks

    opened by imAunAbbas 2
  • Request: Allow widget to slide from the edge of the screen with no gap

    Request: Allow widget to slide from the edge of the screen with no gap

    It will be nice to be able to slide a toast from the edge of the screen, and keep it connected to that edge with no gap.

    In my design a toast takes full width of a screen, and it looks better with no gap, especially on devices with rounded corners, e.g. iPhone 11.

    opened by volgin 2
  • inheritFromWidgetOfExactType

    inheritFromWidgetOfExactType

    Hello at you , when i try to use flutter_styled_toast in flutter 2.0 i got

    /C:/Flutter%20v2.0/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_styled_toast-1.3.0/lib/src/styled_toast.dart:1880:15: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.
     - 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/Flutter%20v2.0/flutter/packages/flutter/lib/src/widgets/framework.dart').
    Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'.
          context.inheritFromWidgetOfExactType(_StyledToastTheme);
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    opened by aristidenholle 1
  • Replace future with timer so that timer can be cancelled on dismiss

    Replace future with timer so that timer can be cancelled on dismiss

    Hi @JackJonson, thanks for your plugin! Well done!

    As we want to improve on tests for it we wanted to create this PR that will allow us to cancel all timers on toast dismiss (if there are any pending timers after the test ends - it will fail). Please review.

    Also, are you considering adding any tests yourself?

    Thanks, Illia

    opened by illia-romanenko 1
  • Causing Error, Doesn't Run

    Causing Error, Doesn't Run

    /C:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_styled_toast-2.1.3/lib/src/styled_toast.dart:497:63: Error: Property 'window' cannot be accessed on 'WidgetsBinding?' because it is potentially null.

    • 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/C:/flutter/packages/flutter/lib/src/widgets/binding.dart'). Try accessing using ?. instead. data: MediaQueryData.fromWindow(WidgetsBinding.instance.window), ^^^^^^ /C:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_styled_toast-2.1.3/lib/src/styled_toast.dart:681:29: Error: Method 'addObserver' cannot be called on 'WidgetsBinding?' because it is potentially null.
    • 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/C:/flutter/packages/flutter/lib/src/widgets/binding.dart'). Try calling using ?. instead. WidgetsBinding.instance.addObserver(this); ^^^^^^^^^^^ /C:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_styled_toast-2.1.3/lib/src/styled_toast.dart:1559:29: Error: Method 'removeObserver' cannot be called on 'WidgetsBinding?' because it is potentially null.
    • 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/C:/flutter/packages/flutter/lib/src/widgets/binding.dart'). Try calling using ?. instead. WidgetsBinding.instance.removeObserver(this);
    opened by emondd4 0
  • Could you make StyledToastTheme visible outside of library?

    Could you make StyledToastTheme visible outside of library?

    Hi there! It would be very useful if I could access the StyledToastTheme outside of the lib. And it would be nice to have a public function for that, which would receive optional BuildContext (like showToast function which uses currentContext if an optional context is null).

    Thank you!

    opened by darkstarx 0
  • It is impossible to write independent reverse animation builder.

    It is impossible to write independent reverse animation builder.

    Now you apply both animation builders (forward and reverse) to show a toast and only reverse animation builder to dismiss a toast. What if I want to make on independent transition to show a toast and another independent transition to hide a toast?

    I wonder why did you decide to mix animationBuilder and reverseAnimationBuilder for showing? And why don't you mix them on dismiss? It is very unusual behavior. And it is very uncomfortable to live with such behavior.

    Here is my example. I want to animate scale and borderRadius of ClipRRect on showing, and fade out on dismissing. I have to use ClipRRect outside the toast widget and inside of animationBuilder because I use BackdropFilter which requires some clipping in a parent widget.

        toasts.showToast(text,
          context: context,
          animationBuilder: (context, controller, duration, child) {
            final scale = Tween<double>(begin: 1.3, end: 1.0).animate(
              CurvedAnimation(
                parent: controller,
                curve: Curves.easeInSine,
                reverseCurve: Curves.easeOutSine
              ),
            );
            final sigma = Tween<double>(begin: 0.0, end: 8.0).animate(
              CurvedAnimation(
                parent: controller,
                curve: Curves.easeInSine,
                reverseCurve: Curves.easeOutSine
              ),
            );
            final opacity = Tween<double>(begin: 0.0, end: 1.0).animate(
              CurvedAnimation(
                parent: controller,
                curve: Curves.easeInSine,
                reverseCurve: Curves.easeOutSine
              ),
            );
            return ScaleTransition(
              scale: scale,
              child: ClipRRect(
                borderRadius: borderRadius,
                child: BlurTransition(
                  sigma: sigma,
                  child: FadeTransition(
                    opacity: opacity,
                    child: child,
                  ),
                )
              )
            );
          },
          reverseAnimBuilder: (context, controller, duration, child) {
            final sigma = Tween<double>(begin: 8.0, end: 0.0).animate(
              CurvedAnimation(
                parent: controller,
                curve: Curves.easeOutSine,
                reverseCurve: Curves.easeInSine
              ),
            );
            final opacity = Tween<double>(begin: 1.0, end: 0.0).animate(
              CurvedAnimation(
                parent: controller,
                curve: Curves.easeOutSine,
                reverseCurve: Curves.easeInSine
              ),
            );
            return ClipRRect(
              borderRadius: borderRadius,
              child: BlurTransition(
                sigma: sigma,
                child: FadeTransition(
                  opacity: opacity,
                  child: child,
                ),
              ),
            );
          },
          animDuration: animDuration,
          duration: totalDuration,
        );
    

    So, while a toast is showing up, it contains inside of FadeTransition -> BlurTransition -> ClipRRect (scaled border radius) -> ScaleTransition -> FadeTransition -> BlurTransition -> ClipRRect (normal border radius crops the scaled!!!)

    Well, why don't you simply apply the only forward animationBuilder on showing and the only reverseAnimationBuilder (if exists) on dismissing? It would be a rather better idea, you simply would have to add some flag, say _dismissing, in the StyledToastWidgetState and check this flag in the build method while deciding in which animation builder to put the widget - in animationBuilder or in reverseAnimationBuilder and that's all. Why did you choose so strange approach with mixing animations?

    opened by darkstarx 0
Owner
null
pull_down_button is a rework of Flutter's PopupMenuButton to be styled like Pop-Up & Pull-Down Buttons from iOS 14+ with some additional customisation options.

pull_down_button is a rework of Flutter's PopupMenuButton to be styled like Pop-Up & Pull-Down Buttons from iOS 14+ with some additional customisation options.

ฤmฤrl 18 Dec 30, 2022
A package for flutter to use alert and toast within one line code.

easy_alert A package for flutter to use alert and toast within one line code. Getting Started Add easy_alert: to your pubspec.yaml, and run flutt

null 34 Jun 25, 2021
A really easy to use flutter toast library

BotToast ?? A really easy to use flutter toast library! Language: English | ไธญๆ–‡็ฎ€ไฝ“ ?? Overview ?? Online Demo ?? Example ?? Renderings ?? Getting starte

null 719 Dec 28, 2022
A pure flutter toast library

oktoast A library for flutter. A pure dart toast Library. You can completely customize the style of toast. ไธญๆ–‡ๅšๅฎขไป‹็ป Screenshot Default Custom GIF Versio

OpenFlutter 438 Dec 24, 2022
Provider support for overlay, make it easy to build toast and In-App notification.

overlay_support Provider support for overlay, make it easy to build toast and In-App notification. this library support ALL platform Interaction If yo

Bin 340 Jan 1, 2023
Flutter package: Assorted layout widgets that boldly go where no native Flutter widgets have gone before.

assorted_layout_widgets I will slowly but surely add interesting widgets, classes and methods to this package. Despite the package name, they are not

Marcelo Glasberg 122 Dec 22, 2022
Flutter UI Widgets Flutter Package

Flutter UI Widgets Flutter Package This package makes different Flutter UI widgets implementation easy for you. Flutter UI Widgets The list of widgets

Hassan Ur Rahman 0 May 6, 2022
Flutter Package for Easier Creation of Home Screen Widgets

Home Widget HomeWidget is a Plugin to make it easier to create HomeScreen Widgets on Android and iOS. HomeWidget does not allow writing Widgets with F

Anton Borries 405 Dec 31, 2022
A Flutter package which provides helper widgets for selecting single or multiple account/user from the given list.

account_selector A Flutter package which provides helper widgets for selecting single or multiple account/user from a list Supported Dart Versions Dar

Harpreet Singh 49 Oct 7, 2021
Flutter package: Similar to a ListView, but lets you programmatically jump to any item, by index.

indexed_list_view Similar to a ListView, but lets you programmatically jump to any item, by index. The index jump happens instantly, no matter if you

Marcelo Glasberg 244 Dec 27, 2022
A flutter package for displaying common picker dialogs.

Flutter Material Pickers A flutter package containing commonly used material design picker dialogs. Some are new, some wrap existing or built in picke

CodeGrue 89 Jan 2, 2023
Flutter package: Define a theme (colors, text styles etc.) as static const values which can be changed dynamically.

Flutter package: Define a theme (colors, text styles etc.) as static const values which can be changed dynamically. Also comes with useful extensions to create text styles by composition.

Marcelo Glasberg 21 Jan 2, 2023
flutter commons package

Commons Commons Flutter package can used for Flutter Android and IOS applications. https://pub.dev/packages/commons example/lib/main.dart Includes Ale

Arbaz Mateen 43 Dec 21, 2022
Fancy design of radio buttons in Flutter (package).

A Flutter package for new radio button design. With Elegant Animation. Features Usage TODO: Include short and useful examples for package users. Add l

Aymen Boucheffa 0 Nov 26, 2021
Flutter Package: When your desired layout or animation is too complex for Columns and Rows, this widget lets you position/size/rotate/transform its child in complex ways.

align_positioned Widgets in this package: AlignPositioned AnimatedAlignPositioned AnimChain Why are these widgets an indispensable tool? When your des

Marcelo Glasberg 69 Dec 12, 2022
A new flutter package for collection of common popular social media widgets

Social Media Widgets - package A new flutter package for collection of common popular social media widgets Currently available widgets Snapchat screen

theboringdeveloper 34 Nov 12, 2022
The flutter_otp_text_field package for flutter is a TextField widget that allows you to display different style pin.

flutter_otp_text_field flutter_otp_text_field The flutter_otp_text_field package for flutter is a TextField widget that allows you to display differen

David-Legend 30 Nov 8, 2022
An awesome Flutter package with widget extension.

jr_extension An awesome Flutter package with widget extension. Why do I want to create this lib? In SwiftUI framework created

WenJingRui 2 Sep 28, 2022
A vertical tabs package for flutter framework.

Vertical Tabs A vertical tabs package for flutter framework. Getting Started A simple example of usage. to get more examples see Examples directory. T

null 62 Dec 30, 2022