Giter Club home page Giter Club logo

flutter_styled_toast's Introduction

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

Null safety

dependencies:
  flutter_styled_toast: ^2.2.1

Getting Started

dependencies:
  flutter_styled_toast: ^1.5.2+3
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)
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)
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)
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

flutter_styled_toast's People

Contributors

agordn52 avatar darkstarx avatar jackjonson avatar jeuler avatar solid-maxim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

flutter_styled_toast's Issues

Selection Handle Color

I'm having an issue that using styled toast globally, this widget changing selection handle (droplet-like shape cursor under selected text) color that does not match with app theme. Yet StyledToast does not have option to changing its theme.

return StyledToast(
      locale: const Locale('en', 'US'),
      toastAnimation: StyledToastAnimation.slideFromTopFade,
      reverseAnimation: StyledToastAnimation.slideToTopFade,
      animDuration: const Duration(milliseconds: 350),
      duration: const Duration(milliseconds: 2500),
      child: MaterialApp(
      // ...
);

While changing textSelectionTheme or cupertinoOverrideTheme in ThemeData.textSelectionTheme will not fix this issue.

theme: ThemeData(
          colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
          textSelectionTheme: TextSelectionThemeData(
            // ...
            selectionHandleColor: Colors.red,
          ),
          cupertinoOverrideTheme: CupertinoThemeData(
            primaryColor: Colors.red,
          ),
        ),
        // ...

Expected Output

Color of the selection handle match with app theme color. (Dark blue)

Actual Output

Color of the selection handle changed to purple.
image

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

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?

Very difficult to use

No proper example of how to use, seems to be tied to one class MyHomePage ? Looks great but I cannot figure out how to use it.

Should the BuildContext parameter in showToast really exist?

We've been using this library in multiple ways without knowing (I wasn't a part in setup of the project), here's what I mean:

  • Wrapped the whole app in StyledToast widget (StyledToast(child: MaterialApp(..)))
  • Calling showToast using context parameter (showToast and showToastWidget)

We had an issue where the provided context could be disposed while the toast was showing (and/or was trying to dismiss), causing the following error:

Null check operator used on a null value
#0      OverlayEntry.remove (package:flutter/src/widgets/overlay.dart:170)
#1      ToastFuture.dismiss (package:flutter_styled_toast/src/styled_toast_manage.dart:74)
#2      new ToastFuture.create.<anonymous closure> (package:flutter_styled_toast/src/styled_toast_manage.dart:51)
#3      Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18)
#4      _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398)
#5      _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429)
#6      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184)
/// in a widget under the same widget tree
/// `context` is from the widget
showToast(..., context: context, ...);
// or
showToastWidget(Text(...), context: context, ..);

At least that's the reason we think it's happening, since it stops happening when we set context parameter to null or don't use context parameter at all.

Why be able to do both?

One way this could be avoided would be to have showToast that doesn't have context parameter, and another called showToastOn with a context parameter.

Let me know if I can help.

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);

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);
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

Repeated "Null check operator used on a null value. Error thrown null" error

Hi, I am unable to reproduce this issue locally myself on any devices or simulators, Android or iOS, but in Crashlytics I am repeatedly seeing this reported crash in production:

Null check operator used on a null value. Error thrown null.
at OverlayEntry.remove(overlay.dart:163)
at ToastFuture.dismiss(styled_toast_manage.dart:73)
at new ToastFuture.create.(styled_toast_manage.dart:50)

It seems that this call in your code to remove an OverlayEntry is called on a null entry, which causes the issue in the Flutter SDK:

styled_toast_manage.dart:73 _entry.remove();

It is being reported from both iOS and Android devices, on a range of operating system versions too. Flutter version is 3.3.10. Any pointers or workarounds would be appreciated, as I'm at a loss how to control this, and this is now my most common crash.

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!

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?

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);

Upgrade dependencies to intl 0.18.0

The dependencies need to be upgraded as per sdk requirements?

Because no versions of flutter_styled_toast match >2.1.3 <3.0.0 and flutter_styled_toast 2.1.3 depends on flutter_localizations from sdk, flutter_styled_toast ^2.1.3 requires flutter_ localizations from sdk.
And because every version of flutter_localizations from sdk depends on intl 0.18.0, flutter_styled_toast ^2.1.3 requires intl 0.18.0
flutter_styled_ toast ^2.1.3 is incompatible with health ^6.0.0.

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.

Dismiss with a gesture.

Is there any way to dismiss the toast with a swipe gesture, or at least by tapping on it?
Thanks.

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

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 :)

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.