Git Product home page Git Product logo

fluttertoast's Introduction

Toast Library for Flutter

Build Checks

Now this toast library supports two kinds of toast messages one which requires BuildContext other with No BuildContext

Toast with no context

Supported Platforms

This one has limited features and no control over UI

Toast Which requires BuildContext

Supported Platforms

  • ALL
  1. Full Control of the Toast
  2. Toasts will be queued
  3. Remove a toast
  4. Clear the queue

How to Use

# add this line to your dependencies
fluttertoast: ^8.2.6
import 'package:fluttertoast/fluttertoast.dart';

Toast with No Build Context (Android & iOS)

Fluttertoast.showToast(
        msg: "This is Center Short Toast",
        toastLength: Toast.LENGTH_SHORT,
        gravity: ToastGravity.CENTER,
        timeInSecForIosWeb: 1,
        backgroundColor: Colors.red,
        textColor: Colors.white,
        fontSize: 16.0
    );
property description default
msg String (Not Null)(required) required
toastLength Toast.LENGTH_SHORT or Toast.LENGTH_LONG (optional) Toast.LENGTH_SHORT
gravity ToastGravity.TOP (or) ToastGravity.CENTER (or) ToastGravity.BOTTOM (Web Only supports top, bottom) ToastGravity.BOTTOM
timeInSecForIosWeb int (for ios & web) 1 (sec)
backgroundColor Colors.red null
textcolor Colors.white null
fontSize 16.0 (float) null
webShowClose false (bool) false
webBgColor String (hex Color) linear-gradient(to right, #00b09b, #96c93d)
webPosition String (left, center or right) right

To cancel all the toasts call

Fluttertoast.cancel()

Note Android

Custom Toast will not work on android 11 and above, it will only use msg and toastLength remaining all properties are ignored

Custom Toast For Android

Create a file named toast_custom.xml in your project app/res/layout folder and do custom styling

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:layout_marginStart="50dp"
    android:background="@drawable/corner"
    android:layout_marginEnd="50dp">

    <TextView
        android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#CC000000"
        android:paddingStart="16dp"
        android:paddingTop="10dp"
        android:paddingEnd="16dp"
        android:paddingBottom="10dp"
        android:textStyle="bold"
        android:textColor="#FFFFFF"
        tools:text="Toast should be short." />
</FrameLayout>

Toast with BuildContext (All Platforms)

Update your MaterialApp with builder like below for the use of Context globally check doc section Use NavigatorKey for Context(to access context globally)

MaterialApp(
    builder: FToastBuilder(),
    home: MyApp(),
    navigatorKey: navigatorKey,
),
FToast fToast;

@override
void initState() {
    super.initState();
    fToast = FToast();
    // if you want to use context from globally instead of content we need to pass navigatorKey.currentContext!
    fToast.init(context);
}

_showToast() {
    Widget toast = Container(
        padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0),
        decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(25.0),
        color: Colors.greenAccent,
        ),
        child: Row(
        mainAxisSize: MainAxisSize.min,
        children: [
            Icon(Icons.check),
            SizedBox(
            width: 12.0,
            ),
            Text("This is a Custom Toast"),
        ],
        ),
    );


    fToast.showToast(
        child: toast,
        gravity: ToastGravity.BOTTOM,
        toastDuration: Duration(seconds: 2),
    );
    
    // Custom Toast Position
    fToast.showToast(
        child: toast,
        toastDuration: Duration(seconds: 2),
        positionedToastBuilder: (context, child) {
          return Positioned(
            child: child,
            top: 16.0,
            left: 16.0,
          );
        });
}

Now Call _showToast()

For more details check example project

property description default
child Widget (Not Null)(required) required
toastDuration Duration (optional)
gravity ToastGravity.*

Use NavigatorKey for Context(to access context globally)

To use NavigatorKey for Context first define the GlobalKey<NavigatorState> at top level in your main.dart file

GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();

At the time of initializing the FToast we need to use context from globally defined GlobalKey<NavigatorState>

FToast fToast = FToast();
fToast.init(yourNavKey.currentContext!);

To cancel all the toasts call

// To remove present shwoing toast
fToast.removeCustomToast()

// To clear the queue
fToast.removeQueuedCustomToasts();

Preview Images (No BuildContext)

Preview Images (BuildContext)

If you need any features suggest

...

Buy Me a Coffee

Buy Me A Coffee

fluttertoast's People

Contributors

alexseednov avatar alexteamx avatar asmh1989 avatar bgetsug avatar bilonik avatar boehrsi avatar caijinglong avatar cbahai avatar cdoky avatar cqhchan avatar dg76 avatar drown0315 avatar guozhiqiang avatar imyashadulkar avatar jackkang0401 avatar jgasparetti avatar mmdrez4 avatar ponnamkarthik avatar pvsvamsi avatar salihagic avatar sam-kym avatar shadabunique avatar shivbo96 avatar slowhand0309 avatar sputnikplop avatar vjpranay avatar werdnamax avatar xubillde avatar yoavrofe avatar zhaoya188 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fluttertoast's Issues

Build error iOS v.2.0.4

  1. Flutter doctor says everything is fine :D

If i try to build my app with flutter toast on iOS i get the following error message:
no visible @interface for 'FluttertoastPlugin' declares the selector 'intFromHexString:'
unsigned int hexint = [self intFromHexString:hexStr];

Any idea?
I already updated all pods and librarys.

Build error if AndroidX is used

If the library is used within a project which uses AndroidX in the native Android part of the Flutter app, FlutterToast won't compile. The following error appears:

Launching lib/main.dart on SM G930F in debug mode...
Initializing gradle...
Resolving dependencies...
Gradle task 'assembleDebug'...
/home/daniel/.pub-cache/hosted/pub.dartlang.org/fluttertoast-2.2.3/android/src/main/java/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.java:9: error: package android.support.v4.content does not exist
import android.support.v4.content.ContextCompat;
^
/home/daniel/.pub-cache/hosted/pub.dartlang.org/fluttertoast-2.2.3/android/src/main/java/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.java:70: error: cannot find symbol
Drawable shapeDrawable = ContextCompat.getDrawable(ctx, R.drawable.toast_bg);
^
symbol: variable ContextCompat
location: class FluttertoastPlugin
2 errors

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':fluttertoast:compileDebugJavaWithJavac'.
    Compilation failed; see the compiler error output for details.

The reason is that android.support.v4.content doesn't exists and androidx.core.content should get used instead. I changed the mentioned parts in this pull request (#45). Due to a lack of time I wasn't able to test if also non-AndroidX apps, so apps that still use the com.android.support:appcompat-vXYZ, work completely fine with the suggest changes.

Cannot build in Xcode throws ARC semantic issue

I was trying to do last time building before I create a release. It was all ok during debugging. But today I created new developer certificate with agent for provision, changed the bundle ID to match my App Store bundle id, then tried 'flutter run' or Xcode 'Runner', both throw the following issue.

No visible @interface for 'FlutterToastPlugin' declares the selector 'intFromHexString:' FlutterToastPlugin.m

Also in Xcode the file opens giving red highlight to line #67

library not found for -lfluttertoast

Ld /Users/deanguo/tanzi.flutter/build/ios/Debug-iphonesimulator/Runner.app/Runner normal x86_64
    cd /Users/deanguo/tanzi.flutter/ios
    export IPHONEOS_DEPLOYMENT_TARGET=8.0
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk -L/Users/deanguo/tanzi.flutter/build/ios/Debug-iphonesimulator -L/Users/deanguo/tanzi.flutter/build/ios/Debug-iphonesimulator/fluttertoast -L/Users/deanguo/tanzi.flutter/ios/Flutter -L/Users/deanguo/tanzi.flutter/ios/Runner/XGPush -F/Users/deanguo/tanzi.flutter/build/ios/Debug-iphonesimulator -F/Users/deanguo/tanzi.flutter/ios/Pods/../.symlinks/flutter/ios -F/Users/deanguo/tanzi.flutter/ios/Flutter -filelist /Users/deanguo/tanzi.flutter/build/ios/Runner.build/Debug-iphonesimulator/Runner.build/Objects-normal/x86_64/Runner.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -Xlinker -rpath -Xlinker @executable_path/Frameworks -mios-simulator-version-min=8.0 -dead_strip -Xlinker -object_path_lto -Xlinker /Users/deanguo/tanzi.flutter/build/ios/Runner.build/Debug-iphonesimulator/Runner.build/Objects-normal/x86_64/Runner_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -ObjC -lfluttertoast -framework Flutter -ObjC -lfluttertoast -framework Flutter -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/deanguo/tanzi.flutter/build/ios/Runner.build/Debug-iphonesimulator/Runner.build/Runner.app-Simulated.xcent -lsqlite3.0 -lz -framework UserNotifications -framework SystemConfiguration -framework CoreTelephony -lfluttertoast -framework Flutter -framework App -lPods-Runner -lXG-SDK -Xlinker -dependency_info -Xlinker /Users/deanguo/tanzi.flutter/build/ios/Runner.build/Debug-iphonesimulator/Runner.build/Objects-normal/x86_64/Runner_dependency_info.dat -o /Users/deanguo/tanzi.flutter/build/ios/Debug-iphonesimulator/Runner.app/Runner

ld: warning: directory not found for option '-L/Users/deanguo/tanzi.flutter/build/ios/Debug-iphonesimulator/fluttertoast'
ld: library not found for -lfluttertoast
clang: error: linker command failed with exit code 1 (use -v to see invocation)

the error is above, any idea?

Doesn't work after await code or Future.then

Response res = await Dio().post(BASEURL + submitFeedbackUrl, data: params);
    Fluttertoast.showToast(
      msg: 'Success',
      timeInSecForIos: 2,
      gravity: ToastGravity.CENTER,
    );

doesn't work!

getting error on android

Hi, I am using v2.2.5 and when I try to run my code I get error:(even when I only add the package pubspec.yaml and don't import that in code)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Android resource linking failed
  Output:  C:\Projects\Hamayesh\hamayesh\build\app\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
  C:\Projects\Hamayesh\hamayesh\build\app\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
  C:\Projects\Hamayesh\hamayesh\build\app\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:956: error: resource android:attr/fontVariationSettings not found.
  C:\Projects\Hamayesh\hamayesh\build\app\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:957: error: resource android:attr/ttcIndex not found.
  error: failed linking references.

  Command: C:\Users\Dell\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\451c100d8bf9a65f95ef6aa052d39f8f\aapt2-3.2.1-4818971-windows\aapt2.exe link -I\
          C:\Users\Dell\AppData\Local\Android\Sdk\platforms\android-27\android.jar\
          --manifest\
          C:\Projects\Hamayesh\hamayesh\build\app\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
          -o\
          C:\Projects\Hamayesh\hamayesh\build\app\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
          -R\
          @C:\Projects\Hamayesh\hamayesh\build\app\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
          --auto-add-overlay\
          --java\
          C:\Projects\Hamayesh\hamayesh\build\app\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
          --custom-package\
          com.example.hamayesh\
          -0\
          apk\
          --output-text-symbols\
          C:\Projects\Hamayesh\hamayesh\build\app\intermediates\symbols\debug\R.txt\
          --no-version-vectors
  Daemon:  AAPT2 aapt2-3.2.1-4818971-windows Daemon #0
  Output:  C:\Users\Dell\.gradle\caches\transforms-1\files-1.1\appcompat-1.0.2.aar\ecd6e2b9bb4b92916609cb0c2e58164c\res\values-v28\values-v28.xml:9:5-12:13: AAPT: error: resource android:attr/dialogCornerRadius not found.

  C:\Projects\Hamayesh\hamayesh\build\app\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:11: AAPT: error: resource android:attr/dialogCornerRadius not found.

  C:\Users\Dell\.gradle\caches\transforms-1\files-1.1\core-1.0.1.aar\00977c9949f24ec591bbf642eb5a1280\res\values\values.xml:89:5-125:25: AAPT: error: resource android:attr/fontVariationSettings not found.

  C:\Users\Dell\.gradle\caches\transforms-1\files-1.1\core-1.0.1.aar\00977c9949f24ec591bbf642eb5a1280\res\values\values.xml:89:5-125:25: AAPT: error: resource android:attr/ttcIndex not found.

  error: failed linking references.
  Command: C:\Users\Dell\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\451c100d8bf9a65f95ef6aa052d39f8f\aapt2-3.2.1-4818971-windows\aapt2.exe link -I\
          C:\Users\Dell\AppData\Local\Android\Sdk\platforms\android-27\android.jar\
          --manifest\
          C:\Projects\Hamayesh\hamayesh\build\app\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
          -o\
          C:\Projects\Hamayesh\hamayesh\build\app\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
          -R\
          @C:\Projects\Hamayesh\hamayesh\build\app\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
          --auto-add-overlay\
          --java\
          C:\Projects\Hamayesh\hamayesh\build\app\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
          --custom-package\
          com.example.hamayesh\
          -0\
          apk\
          --output-text-symbols\
          C:\Projects\Hamayesh\hamayesh\build\app\intermediates\symbols\debug\R.txt\
          --no-version-vectors
  Daemon:  AAPT2 aapt2-3.2.1-4818971-windows Daemon #0

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
Finished with error: Gradle task assembleDebug failed with exit code 1

[2.2.4] Cannot build because of dependency w/ v28

Everything works fine w/ 2.2.3, but since release of 2.2.4, build fails. Problem comes from the new dependency on v28.

I solved it by forcing 2.2.3 in pubspec.yaml, but is this something you can fix, or we have to make changes to our build.gradle (in that case, what exactly?)

Thanks,
Manuel.

Incomplete text display

I don't think it is necessary to set the maximum number of rows to 1, otherwise the message will be incomplete if it is too long.

      final TextView text = toast.getView().findViewById(android.R.id.message);
      text.setTextSize(textSize.floatValue());
      text.setMaxLines(1); // This line of code

Background color does not fill the whole Toast (ver 2.1.0)

As shown below, Background color does not fill the whole Toast.
image


ENV:

Google Pixel 2 XL running Android 9
fluttertoast:
    dependency: "direct main"
    description:
      name: fluttertoast
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.1.0"
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.11.3, on Mac OS X 10.14.1 18B75, locale en-CN)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
[✓] Android Studio (version 3.2)
[✓] VS Code (version 1.28.2)
[✓] Connected device (3 available)

• No issues found!

Add ToastGravity.only()

If there were options to put the toastgravity on a specific place like Top-left,top-right,bottom-right,bottom-left, center-left etc. anyways. that's just my feedback because I am using a FAB centered in my UI.

Error on flutter run due to Swift Language version

Getting this error today, but all worked on Thursday when I last built.

=== BUILD TARGET fluttertoast OF PROJECT Pods WITH CONFIGURATION Debug ===
The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a
supported value for targets which use Swift. Supported values are: 3.0, 4.0,
4.2. This setting can be set in the build settings editor.

Execution failed for task ':fluttertoast:compileDebugKotlin'.

`e: /Users/ice/flutter/.pub-cache/hosted/pub.flutter-io.cn/fluttertoast-2.0.8/android/src/main/kotlin/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.kt: (39, 36): Type inference failed. Expected type mismatch: inferred type is String? but String was expected
e: /Users/ice/flutter/.pub-cache/hosted/pub.flutter-io.cn/fluttertoast-2.0.8/android/src/main/kotlin/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.kt: (40, 39): Type inference failed. Expected type mismatch: inferred type is String? but String was expected
e: /Users/ice/flutter/.pub-cache/hosted/pub.flutter-io.cn/fluttertoast-2.0.8/android/src/main/kotlin/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.kt: (41, 40): Type inference failed. Expected type mismatch: inferred type is String? but String was expected
e: /Users/ice/flutter/.pub-cache/hosted/pub.flutter-io.cn/fluttertoast-2.0.8/android/src/main/kotlin/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.kt: (42, 40): Type inference failed. Expected type mismatch: inferred type is String? but String was expected
e: /Users/ice/flutter/.pub-cache/hosted/pub.flutter-io.cn/fluttertoast-2.0.8/android/src/main/kotlin/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.kt: (43, 42): Type inference failed. Expected type mismatch: inferred type is String? but String was expected

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':fluttertoast:compileDebugKotlin'.

Compilation error. See log for more details

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

  • Get more help at https://help.gradle.org

BUILD FAILED in 6s
Finished with error: Gradle task assembleDebug failed with exit code 1
`

Toast backgroung issue

Some additional background when add line "background Color: Colors.black12"

Fluttertoast.showToast(
msg: "loginSuccess",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
timeInSecForIos: 1,
backgroundColor: Colors.black12,
textColor: Colors.black54,
fontSize: 16.0
);
photo_2019-01-30_12-08-02

PlatformException(error, java.lang.Integer cannot be cast to java.lang.Long, null)

The error:

E/flutter (17884): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
E/flutter (17884): PlatformException(error, java.lang.Integer cannot be cast to java.lang.Long, null)
E/flutter (17884): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:551:7)
E/flutter (17884): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:292:18)
E/flutter (17884): <asynchronous suspension>
E/flutter (17884): #2      Fluttertoast.showToast (package:fluttertoast/fluttertoast.dart:45:33)
E/flutter (17884): <asynchronous suspension>
E/flutter (17884): #3      Helper.showToast (package:consumos_app/utils/helper.dart:199:18)
E/flutter (17884): #4      _ConsumosPageState.getConsumos.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:consumos_app/consumos.dart:66:30)
E/flutter (17884): #5      _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
E/flutter (17884): #6      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
E/flutter (17884): #7      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
E/flutter (17884): #8      _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:68:11)
E/flutter (17884): #9      _EventSinkWrapper.add (dart:async/stream_transformers.dart:15:11)
E/flutter (17884): #10     _StringAdapterSink.add (dart:convert/string_conversion.dart:268:11)
E/flutter (17884): #11     _StringAdapterSink.addSlice (dart:convert/string_conversion.dart:273:7)
E/flutter (17884): #12     _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:348:20)
E/flutter (17884): #13     _Utf8ConversionSink.add (dart:convert/string_conversion.dart:341:5)
E/flutter (17884): #14     _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:86:18)
E/flutter (17884): #15     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:120:24)
E/flutter (17884): #16     _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
E/flutter (17884): #17     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
E/flutter (17884): #18     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)
E/flutter (17884): #19     _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:132:11)
E/flutter (17884): #20     _ForwardingStream._handleData (dart:async/stream_pipe.dart:98:10)
E/flutter (17884): #21     _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:164:13)
E/flutter (17884): #22     _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)
E/flutter (17884): #23     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
E/flutter (17884): #24     _DelayedData.perform (dart:async/stream_impl.dart:591:14)
E/flutter (17884): #25     _StreamImplEvents.handleNext (dart:async/stream_impl.dart:707:11)
E/flutter (17884): #26     _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:667:7)
E/flutter (17884): #27     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (17884): #28     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)

Flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, v1.0.0, on Microsoft Windows [Versión 10.0.17134.407], locale es-AR)
[√] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[√] Android Studio (version 3.1)
[√] IntelliJ IDEA Ultimate Edition (version 2018.1)
[√] VS Code (version 1.26.1)
[√] VS Code, 64-bit edition (version 1.28.2)
[√] Connected device (1 available)

• No issues found!

The flutter call:

Fluttertoast.showToast(
        msg: message,
        toastLength: Toast.LENGTH_SHORT,
        gravity: ToastGravity.BOTTOM,
        timeInSecForIos: 1,
        backgroundColor: Colors.black45,
        textColor: Colors.white
    );

If i remove backgroundColor: Colors.black45, textColor: Colors.white, it works fine.

Background color does not fill the whole Toast

Hi,

first thanks for this great component. I just added it using your example code and the result looks like

image

Is that intended?

Something else, why can't I set a duration for Android?

All the best
Thomas

[Android] cannot compile because of type inference failed

Error logs:

e: /Users/hunghd/.pub-cache/hosted/pub.dartlang.org/fluttertoast-2.0.8/android/src/main/kotlin/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.kt: (39, 36): Type inference failed. Expected type mismatch: inferred type is String? but String was expected
e: /Users/hunghd/.pub-cache/hosted/pub.dartlang.org/fluttertoast-2.0.8/android/src/main/kotlin/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.kt: (40, 39): Type inference failed. Expected type mismatch: inferred type is String? but String was expected
e: /Users/hunghd/.pub-cache/hosted/pub.dartlang.org/fluttertoast-2.0.8/android/src/main/kotlin/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.kt: (41, 40): Type inference failed. Expected type mismatch: inferred type is String? but String was expected
e: /Users/hunghd/.pub-cache/hosted/pub.dartlang.org/fluttertoast-2.0.8/android/src/main/kotlin/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.kt: (42, 40): Type inference failed. Expected type mismatch: inferred type is String? but String was expected
e: /Users/hunghd/.pub-cache/hosted/pub.dartlang.org/fluttertoast-2.0.8/android/src/main/kotlin/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.kt: (43, 42): Type inference failed. Expected type mismatch: inferred type is String? but String was expected

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':fluttertoast:compileReleaseKotlin'.

Flutter doctor logs:

[✓] Flutter (Channel master, v0.9.7-pre.42, on Mac OS X 10.14 18A391, locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK 28.0.2)
    ✗ Android license status unknown.
[✓] iOS toolchain - develop for iOS devices (Xcode 10.0)
[✓] Android Studio (version 3.2)
[✓] Connected device (3 available)

A problem occurred configuring project ':fluttertoast'.

From @1420965446 on October 29, 2018 9:55

I just added a line : fluttertoast: ^2.0.9

  • Error running Gradle:
    Exit code 1 from: /Users/edz/Desktop/flutter_app/android/gradlew app:properties:

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ':fluttertoast'.

Failed to notify project evaluation listener.
java.lang.AbstractMethodError (no error message)

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1s

Finished with error: Please review your Gradle project setup in the android/ folder.

Copied from original issue: dart-lang/pub-dev#1731

It's not a good idea to make incompatible API changes

Today after I ran pub get, I got some error. And I found out that this lib had changed static method to single instance. However, the major version is still 2. According to semver.org, it's not recommended to change your api without a major version changed...

unable to build

=== BUILD TARGET fluttertoast OF PROJECT Pods WITH CONFIGURATION Debug ===
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "Headers/fluttertoast-umbrella.h"
        ^
/Users/huangyicheng1/Downloads/flutter_app/ios/Pods/Target Support Files/fluttertoast/fluttertoast-umbrella.h:13:9: note: in file included from /Users/huangyicheng1/Downloads/flutter_app/ios/Pods/Target Support Files/fluttertoast/fluttertoast-umbrella.h:13:
#import "FluttertoastPlugin.h"
        ^
/Users/huangyicheng1/.pub-cache/hosted/pub.flutter-io.cn/fluttertoast-2.0.1/ios/Classes/FluttertoastPlugin.h:1:9: error: 'Flutter/Flutter.h' file not found
#import <Flutter/Flutter.h>
        ^
<unknown>:0: error: could not build Objective-C module 'fluttertoast'

Still getting an error with the new release

This error shows up when i try to build my project
A problem occurred configuring project ':fluttertoast'.

Failed to notify project evaluation listener.
java.lang.AbstractMethodError (no error message)

bgcolor setting doesn't work for ios

bgcolor is not changed to setting on ios.

Fluttertoast.showToast(
      msg: "Favorite Added!",
      toastLength: Toast.LENGTH_SHORT,
      gravity: ToastGravity.BOTTOM,
      timeInSecForIos: 1,
      bgcolor: '#e74c3c',
    );

how to change font of toast?

Is there any way to change the font of toast? i changed the whole app font trough pubspec.yaml but not work in toast

iOS crash:-[NSNull unsignedIntegerValue]: unrecognized selector

I found This Problem on tag: 2.1.4, but not appear everytime, I'm fell unsure on that. it's initialization already. need your help.....

First ,notice that

        style.backgroundColor = [self colorWithHex:bgcolor.unsignedIntegerValue];
        style.messageColor = [self colorWithHex:textcolor.unsignedIntegerValue];

Second, notice That

    Color backgroundColor = const Color.fromARGB(255, 0, 0, 0),
    Color textColor = const Color.fromARGB(255, 255, 255, 255),

device Log:

-[NSNull unsignedIntegerValue]: unrecognized selector sent to instance 0x1c4d099b0
2
(null)
3
((
4
0 CoreFoundation 0x0000000194d5feb8 + 252
5
1 libobjc.A.dylib 0x0000000193f31a40 objc_exception_throw + 56
6
2 CoreFoundation 0x0000000194c78d04 + 0
7
3 CoreFoundation 0x0000000194d657b8 + 1412
8
4 CoreFoundation 0x0000000194d6745c _CF_forwarding_prep_0 + 92
9
5 Runner 0x0000000104a131a0 -[FluttertoastPlugin handleMethodCall:result:] + 564
10
6 Flutter 0x00000001050580d4 Flutter + 32980
11
7 Flutter 0x000000010507a0fc Flutter + 172284
12
8 Flutter 0x00000001050c1ae4 Flutter + 465636
13
9 Flutter 0x0000000105084e34 Flutter + 216628
14
10 Flutter 0x000000010508626c Flutter + 221804
15
11 CoreFoundation 0x0000000194cf0804 + 28
16
12 CoreFoundation 0x0000000194cf0534 + 864
17
13 CoreFoundation 0x0000000194cefd68 + 248
18
14 CoreFoundation 0x0000000194ceac44 + 1880
19
15 CoreFoundation 0x0000000194cea1cc CFRunLoopRunSpecific + 436
20
16 GraphicsServices 0x0000000196f61584 GSEventRunModal + 100
21
17 UIKitCore 0x00000001c1de5054 UIApplicationMain + 212
22
18 Runner 0x0000000104934d58 main + 88
23
19 libdyld.dylib 0x00000001947aabb4 + 4
24
)
25
26
dSYM UUID: CFD8EAF8-62B3-37F5-A81C-4519FA65E85C
27
CPU Type: arm64
28
Slide Address: 0x0000000100000000
29
Binary Image: Runner
30
Base Address: 0x0000000104930000

Build [ release ] failed with an exception ( fluttertoast:verifyReleaseResources )

setup

version: 1.0.0+1

environment:
  sdk: ">=2.0.0-dev.68.0 <3.0.0"

dependencies:
  ...
  fluttertoast: ^3.0.0
  ...

after running flutter clean and flutter build apk

Initializing gradle...                                       1,7s
Resolving dependencies...                                   16,1s
Gradle task 'assembleRelease'...
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Note: D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\connectivity-0.4.2\android\src\main\java\io\flutter\plugins\connectivity\ConnectivityPlugin.java uses or overrides a
 deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: D:\src\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-3.0.0\android\src\main\java\io\flutter\plugins\firebasemessaging\FlutterFirebaseInstanceIDService
.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

         *********************************************************
WARNING: This version of connectivity will break your Android build if it or its dependencies aren't compatible with AndroidX.
         See https://goo.gl/CP92wY for more information on the problem and how to fix it.
         This warning prints for all Android build failures. The real root cause of the error may be unrelated.
         *********************************************************
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':fluttertoast:verifyReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
  D:\codeLabs\algerien_lawyers\build\fluttertoast\intermediates\res\merged\release\values-v28\values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
  D:\codeLabs\algerien_lawyers\build\fluttertoast\intermediates\res\merged\release\values-v28\values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
  D:\codeLabs\algerien_lawyers\build\fluttertoast\intermediates\res\merged\release\values\values.xml:2601: error: resource android:attr/fontVariationSettings not found.
  D:\codeLabs\algerien_lawyers\build\fluttertoast\intermediates\res\merged\release\values\values.xml:2602: error: resource android:attr/ttcIndex not found.
  error: failed linking references.


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 55s
Gradle task 'assembleRelease'... Done                       116,0s
Gradle task assembleRelease failed with exit code 1

Build failed with an exception

Execution failed for task ':app:lintVitalRelease'.

Could not resolve all artifacts for configuration ':app:dynamicProfileRuntimeClasspath'.
Could not resolve project :fluttertoast.
Required by:
project :app
> java.lang.NullPointerException (no error message)

The plugin calls the build of the previous widget

I have two stateful widgets.

When I navigate from first to second and in the second I call Fluttertoast.showToast, then the build method of the first widget is being called.

Flutter 0.5.1.
fluttertoast: ^2.0.7

MissingPluginException

Exception while invoking

Fluttertoast.showToast(
  msg: _message,
  toastLength: Toast.LENGTH_LONG,
  gravity: ToastGravity.CENTER,
  timeInSecForIos: 1,
  bgcolor: "#e74c3c",
  textcolor: '#ffffff'
);
E/flutter (28857): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (28857): MissingPluginException(No implementation found for method showToast on channel PonnamKarthik/fluttertoast)
E/flutter (28857): #0      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:278:7)
E/flutter (28857): <asynchronous suspension>
E/flutter (28857): #1      Fluttertoast.showToast (package:fluttertoast/fluttertoast.dart:54:33)
E/flutter (28857): <asynchronous suspension>
E/flutter (28857): #2      AppUtils.refresh (package:grom.......

Doesnt work for sdk 28

Hello i was testing today with sdk 28 and it doest appear the toast. Flutter doctor no issues.

Running on android has errors

W/System.err(15667): java.lang.IllegalArgumentException: Unknown color
W/System.err(15667): at android.graphics.Color.parseColor(Color.java:235)
W/System.err(15667): at io.github.ponnamkarthik.toast.fluttertoast.FluttertoastPlugin.onMethodCall(FluttertoastPlugin.java:74)
W/System.err(15667): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:200)
W/System.err(15667): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163)
W/System.err(15667): at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err(15667): at android.os.MessageQueue.next(MessageQueue.java:323)
W/System.err(15667): at android.os.Looper.loop(Looper.java:135)
W/System.err(15667): at android.app.ActivityThread.main(ActivityThread.java:5417)
W/System.err(15667): at java.lang.reflect.Method.invoke(Native Method)
W/System.err(15667): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
W/System.err(15667): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
W/System.err(15667): java.lang.IllegalArgumentException: Unknown color
W/System.err(15667): at android.graphics.Color.parseColor(Color.java:226)
W/System.err(15667): at io.github.ponnamkarthik.toast.fluttertoast.FluttertoastPlugin.onMethodCall(FluttertoastPlugin.java:88)
W/System.err(15667): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:200)
W/System.err(15667): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163)
W/System.err(15667): at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err(15667): at android.os.MessageQueue.next(MessageQueue.java:323)
W/System.err(15667): at android.os.Looper.loop(Looper.java:135)
W/System.err(15667): at android.app.ActivityThread.main(ActivityThread.java:5417)
W/System.err(15667): at java.lang.reflect.Method.invoke(Native Method)
W/System.err(15667): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
W/System.err(15667): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
W/art (15667): Native thread exiting without having called DetachCurrentThread (maybe it's going to use a pthread_key_create destructor?): Thread[14,tid=17200,Native,Thread*=0x55ccc6f020,peer=0x22d0a0a0,"Thread-16091"]

Crash on iOS

Getting this error when attempt to toast

*** First throw call stack:
(
	0   CoreFoundation                      0x00000001182901bb __exceptionPreprocess + 331
	1   libobjc.A.dylib                     0x0000000117836735 objc_exception_throw + 48
	2   CoreFoundation                      0x00000001182aef44 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
	3   CoreFoundation                      0x0000000118294ed6 ___forwarding___ + 1446
	4   CoreFoundation                      0x0000000118296da8 _CF_forwarding_prep_0 + 120
	5   fluttertoast                        0x00000001156bf699 -[FluttertoastPlugin handleMethodCall:result:] + 873
	6   Flutter                             0x00000001123489a2 __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 115
	7   Flutter                             0x0000000112365616 _ZNK5shell21PlatformMessageRouter21HandlePlatformMessa<…>

Command `flutter build ios` failed with error when running in example folder

When running flutter build ios in example folder, the following errors occur:

FluttertoastPlugin.m:87:16: error: implicit conversion of 'int' to 'id _Nullable' is disallowed with ARC
            result(true);
                   ^~~~

FluttertoastPlugin.m:41:16: error: implicit conversion of 'int' to 'id _Nullable' is disallowed with ARC
            result(true);
                   ^~~~

FlutterToast version: 2.2.9

Xcode version: 10.1

Flutter version: 1.1.9

meet android.support.v4.content not exist

after i update to 2.2.8, i meet the following errors.
/Users/reply/flutter/.pub-cache/hosted/pub.flutter-io.cn/fluttertoast-2.2.8/android/src/main/java/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.java:14: 错误: 程序包android.support.v4.content不存在
import android.support.v4.content.ContextCompat;
^
/Users/reply/flutter/.pub-cache/hosted/pub.flutter-io.cn/fluttertoast-2.2.8/android/src/main/java/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.java:108: 错误: 找不到符号
Drawable shapeDrawable = ContextCompat.getDrawable(ctx, R.drawable.toast_bg);
^
符号: 变量 ContextCompat
位置: 类 FluttertoastPlugin
2 个错误

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':fluttertoast:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 5s
Finished with error: Gradle task assembleDebug failed with exit code 1

It's currently not possible to use the default Android Toast style

There's currently no way to use the default Android toast styles.
The dart interface forces default color values without the ability to pass in null (it'll throw a null-pointer).

It forces it to be black and white rather than default to whatever the device's toast style is.

Thanks for the extremely quick turn-around with the previous issue!

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.