//Simple to use, no global configurationshowToast("hello styled toast",context:context);
//Customize toast content widget, no global configurationshowToastWidget(Text('hello styled toast'),context:context);
StyledToast(
locale:constLocale('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 animationreturnSlideTransition(
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 animationreturnSlideTransition(
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) {
returnMyHomePage(
title: appTitle,
onSetting: onSettingCallback,
);
},
),
),
);
```dart
```dart
//After global configuration, use in a single line.showToast("hello styled toast");
//After global configuration, Customize toast content widgetshowToastWidget(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)
/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);
======== 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.
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
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?
Add StyledToast at top of the Material Widget, but not inside of a Material Widget.
Open context menu on a TextField to paste or copy something
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!
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 topposition. 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
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);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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?
/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);
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).
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.
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?
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.
oktoast A library for flutter. A pure dart toast Library. You can completely customize the style of toast. ไธญๆๅๅฎขไป็ป Screenshot Default Custom GIF Versio
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.