Code Monkey home page Code Monkey logo

fluttertoast's Introduction

fluttertoast's People

Contributors

appdev avatar jankolancer avatar moda20 avatar peterhijma avatar renatfakhrutdinov avatar uslashvlad avatar wtoalabi 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

fluttertoast's Issues

null safe support

This is already null safe as far as I can tell. Can you please release this with a null safe tag on pub.dev?

Looking up a deactivated widget's ancestor is unsafe. At this point the state of the widget's element tree is no longer stable

兄弟,使用过程报了这个错,请问有解决方案吗:
image

Exception has occurred.
FlutterError (Looking up a deactivated widget's ancestor is unsafe.
At this point the state of the widget's element tree is no longer stable. To safely refer to a widget's ancestor in its dispose() method, save a reference to the ancestor by calling inheritFromWidgetOfExactType() in the widget's didChangeDependencies() method.
)

Keyboard is over Toast

Hi there! Thanks for this awesome Flutter plugin. I am actually facing an issue while using it, when I am using Toast.Bottom as gravity value the Keyboard hide the Toast when it is active. can you make the Toast move just above it. I am actually using the center mode but it is not what I initially wanted. Thanks

Not work in GetMaterialApp?

Init in GetMaterialApp

GetMaterialApp(
      debugShowCheckedModeBanner: false,
      onInit: () async {
        ToastContext().init(context);
      },
      home: HomePage(),
      routes: {
          PAGE_BACKUP: (context) => BackupPage(),
      },
      navigatorObservers: [firebase],
    );

show:
Toast.show('subtype_name_repeated', gravity: Toast.top);

error:

I/flutter ( 9542): #0      Overlay.of.<anonymous closure> (package:flutter/src/widgets/overlay.dart:476:9)
I/flutter ( 9542): #1      Overlay.of (package:flutter/src/widgets/overlay.dart:479:6)
I/flutter ( 9542): #2      ToastView.createView (package:toast/toast.dart:97:28)
I/flutter ( 9542): #3      Toast.show (package:toast/toast.dart:68:17)
I/flutter ( 9542): #4      CreatePatternSheet._checkIntegrity (package:easy_table/pages/sheet/create_pattern_sheet.dart:86:15)
I/flutter ( 9542): #5      CreatePatternSheet.onActionClick (package:easy_table/pages/sheet/create_pattern_sheet.dart:65:15)
I/flutter ( 9542): #6      ShellController.onInit.<anonymous closure> (package:easy_table/widget/bottom_sheet/bottom_sheet_shell.dart:201:34)
I/flutter ( 9542): #7      EventBus.emit (package:easy_table/event/event_bus.dart:37:14)
I/flutter ( 9542): #8      _BottomSheetShellState.buildTitleBar.<anonymous closure> (package:easy_table/widget/bottom_sheet/bottom_sheet_shell.dart:172:41)
I/flutter ( 9542): #9      _InkResponseState.handleTap (package:flutter/src/material/ink_well.dart:1154:21)
I/flutter ( 9542): #10     GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:275:24)
I/flutter ( 9542): #11     TapGestureRecogni

About eg

ToastContext().init(context);
but init Function is not static Function,I will report an error if I write like this.
error:Instance member 'init' can't be accessed using static access.
I only
var toastContext = ToastContext(); toastContext.init(context);
why u can do that?

Wrong after installation

`Failed to build iOS app
Error output from Xcode build:

** BUILD FAILED **

Xcode's output:

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.`

NoSuchMethodError: The method 'insert' was called on null.

My code is very simple and I'm still getting an error :

void initState() {
super.initState();
Toast.show("Toast plugin app", context, duration: Toast.LENGTH_SHORT, gravity: Toast.BOTTOM);
}

error :

[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The method 'insert' was called on null. E/flutter ( 2653): Receiver: null E/flutter ( 2653): Tried calling: insert(Instance of 'OverlayEntry')

Don't Work in Web

I got this error in web

ReferenceError: Toastify is not defined
%3Canonymous%3E 1:30
dart-sdk/lib/html/dart2js/html_dart2js.dart 23474:33 append]
dart-sdk/lib/html/dart2js/html_dart2js.dart 11768:14 add
packages/toast/toast_web.dart 70:24 showWebToast
packages/toast/toast_web.dart 42:5 showToast
packages/toast/toast_web.dart 23:9 handleMethodCall
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async
packages/toast/toast_web.dart 20:35 handleMethodCall
packages/flutter/src/services/platform_channel.dart 547:55 _handleAsMethodCall
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async
packages/flutter/src/services/platform_channel.dart 544:40 [_handleAsMethodCall]
packages/flutter/src/services/platform_channel.dart 540:34
packages/flutter_web_plugins/src/plugin_registry.dart 115:33 handleFrameworkMessage
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async
packages/flutter_web_plugins/src/plugin_registry.dart 106:38 handleFrameworkMessage
lib/_engine/engine/platform_dispatcher.dart 607:7 [_sendPlatformMessage]
lib/_engine/engine/platform_dispatcher.dart 350:5 sendPlatformMessage
packages/flutter/src/services/binding.dart 456:36 send
packages/flutter/src/services/platform_channel.dart 303:31 _invokeMethod
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54 runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 123:5 _async
packages/flutter/src/services/platform_channel.dart 298:30 [_invokeMethod]
packages/flutter/src/services/platform_channel.dart 483:12 invokeMethod
packages/toast/toast.dart 65:32 show
packages/orang_tracker/views/about/about_screen.dart 35:27
dart-sdk/lib/async/zone.dart 1661:54 runUnary
dart-sdk/lib/async/future_impl.dart 147:18 handleValue
dart-sdk/lib/async/future_impl.dart 784:44 handleValueCallback
dart-sdk/lib/async/future_impl.dart 813:13 _propagateToListeners
dart-sdk/lib/async/future_impl.dart 584:5 [_completeWithValue]
dart-sdk/lib/async/future_impl.dart 657:7 callback
dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 177:15
Error: PlatformException(error, Unexpected null value., null, null)
dart-sdk/lib/internal/js_dev_runtime/private/ddc_runtime/errors.dart 288:49 throw
packages/flutter/src/services/message_codecs.dart 652:7 decodeEnvelope
packages/flutter/src/services/platform_channel.dart 310:18 _invokeMethod
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50
dart-sdk/lib/async/zone.dart 1661:54 runUnary
dart-sdk/lib/async/future_impl.dart 147:18 handleValue
dart-sdk/lib/async/future_impl.dart 784:44 handleValueCallback
dart-sdk/lib/async/future_impl.dart 813:13 _propagateToListeners
dart-sdk/lib/async/future_impl.dart 584:5 [_completeWithValue]
dart-sdk/lib/async/future_impl.dart 657:7 callback
dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 177:15

Not incompatibilities androidX

when ues androidx ,import this lib build failed with error info :

/Users/Carl/dev_soft/flutter/.pub-cache/hosted/pub.flutter-io.cn/fluttertoast-2.2.11/android/src/main/java/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.java:14: 错误: 程序包android.support.v4.content不存在
import android.support.v4.content.ContextCompat;
                                 ^
/Users/Carl/dev_soft/flutter/.pub-cache/hosted/pub.flutter-io.cn/fluttertoast-2.2.11/android/src/main/java/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.java:107: 错误: 找不到符号
          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 15s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                        15.9s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool
is about to try using Jetfier to solve the incompatibility.

Adding more customization options

I needed this component, much better than the default material toast, thanks. I just needed to customize it further to fit the style of my app. Found it really easy to do, wanted to offer my changes. I added new properties for textSize, boxShadow and border and it looks much better to me now. Here's the blocks of code in toast.dart that I changed:

  static void show(String msg, BuildContext context,
      {int duration = 1,
      int gravity = 0,
      Color backgroundColor = const Color(0xAA000000),
      Color textColor = Colors.white,
      double textSize = 15.0,
      double backgroundRadius = 20,
      BoxShadow boxShadow,
      Border border,
      }) {
    ToastView.dismiss();
    ToastView.createView(
        msg, context, duration, gravity, backgroundColor, textColor, textSize, backgroundRadius, boxShadow, border);
  }
}

Then mixed those in below:

  static void createView(String msg, BuildContext context, int duration, int gravity,
      Color background, Color textColor, double textSize, double backgroundRadius, BoxShadow boxShadow, Border border) async {
    overlayState = Overlay.of(context);
    overlayEntry = new OverlayEntry(
      builder: (BuildContext context) => ToastWidget(
          widget: Container(
            width: MediaQuery.of(context).size.width,
            child: FittedBox(
                alignment: Alignment.center,
                fit: BoxFit.none,
                child: ConstrainedBox(
                  constraints: BoxConstraints(minHeight: 32),
                  child: Container(
                    decoration: BoxDecoration(
                      color: background,
                      border: border,
                      borderRadius: BorderRadius.circular(backgroundRadius),
                      boxShadow: boxShadow == null ? null : <BoxShadow>[boxShadow],
                    ),
                    margin: EdgeInsets.symmetric(horizontal: 20),
                    padding: EdgeInsets.symmetric(horizontal: 16.0),
                    child: Center(
                      child: new Text(msg,
                          softWrap: true, style: TextStyle(fontSize: textSize, color: textColor)),
                    ),
                  ),
                )),
          ),
          gravity: gravity),
    );

Very easy, but makes a difference in giving it a unique style, and I can think of a few more fixed properties that could be made accessible like the margin and padding, but this did it for me. Now the only missing feature I'd love to see added is to animate the toast coming in and out. Would be nice to have option to fade in/out or to slide in/out based on gravity direction. Probably not that difficult to do, and would make it look much more native. Thanks, now my toast has extra jam..

Toast iOS Error

Hi, I got this error after running this line:
Toast.show("Toast plugin app", duration: Toast.LENGTH_SHORT, gravity: Toast.BOTTOM);

flutter/.pub-cache/hosted/pub.dartlang.org/toast-0.0.6/ios/Classes/ToastReference.swift:325:37: error: 'init(style:)' has been renamed to 'init(activityIndicatorStyle:)'
let activityIndicatorView = UIActivityIndicatorView(style: .whiteLarge)
^ ~~~~~
activityIndicatorStyle
UIKit.UIActivityIndicatorView:6:12: note: 'init(style:)' was introduced in Swift 4.2
public init(style: UIActivityIndicatorViewStyle)
^
/Users/rlecheta/Dev/flutter/.pub-cache/hosted/pub.dartlang.org/toast-0.0.6/ios/Classes/ToastReference.swift:354:47: error: 'common' has been renamed to 'RunLoopMode.commonModes'
RunLoop.main.add(timer, forMode: .common)
^~~~~~
RunLoopMode.commonModes
Foundation.RunLoop.Mode:9:23: note: 'common' was introduced in Swift 4.2
public static let common: RunLoopMode
^
/Users/rlecheta/Dev/flutter/.pub-cache/hosted/pub.dartlang.org/toast-0.0.6/ios/Classes/ToastReference.swift:354:47: error: 'common' has been renamed to 'RunLoopMode.commonModes'
RunLoop.main.add(timer, forMode: .common)
^~~~~~
RunLoopMode.commonModes
Foundation.RunLoop.Mode:9:23: note: 'common' was introduced in Swift 4.2
public static let common: RunLoopMode

Contribute

Why not open the project so we can contribute?

I have a customization ready here but I can not push the branch in order to create the pull request.

Target of URI doesn't exist: 'package:toast/toast.dart'.

After Add import 'package:toast/toast.dart'; this line into my main.dart file, not run to my app and show this error message..Please give me a solution how to solve it..

Error message : Target of URI doesn't exist: 'package:toast/toast.dart'.
Try creating the file referenced by the URI, or Try using a URI for a file that does exist.

Showing a second toast before the previous one disappears makes it disappear too soon

If I show a first toast for 5 seconds, then after 4 seconds show a second toast, then the second message gets shown only one second. Seems like there are two ways one could fix that:

not work in WillPopScope (onWillPop)

WillPopScope(
//
onWillPop: () async{
Toast.show("test",context);
}
)

E/flutter ( 2193): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: NoSuchMethodError: The method 'insert' was called on null.
E/flutter ( 2193): Receiver: null
E/flutter ( 2193): Tried calling: insert(Instance of 'OverlayEntry')
E/flutter ( 2193): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:50:5)
E/flutter ( 2193): #1 ToastView.createView (package:toast/toast.dart:67:18)
E/flutter ( 2193):
E/flutter ( 2193): #2 Toast.show (package:toast/toast.dart:19:15)
E/flutter ( 2193): #3 AppState.build. (package:mama_call/main.dart:145:25)
E/flutter ( 2193): #4 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:49:6)
E/flutter ( 2193): #5 AppState.build. (package:mama_call/main.dart:141:26)
E/flutter ( 2193): #6 ModalRoute.willPop (package:flutter/src/widgets/routes.dart:1083:26)
E/flutter ( 2193): #7 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:49:6)
E/flutter ( 2193): #8 ModalRoute.willPop (package:flutter/src/widgets/routes.dart:1079:38)
E/flutter ( 2193): #9 NavigatorState.maybePop (package:flutter/src/widgets/navigator.dart:2004:57)
E/flutter ( 2193): #10 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:49:6)
E/flutter ( 2193): #11 NavigatorState.maybePop (package:flutter/src/widgets/navigator.dart:2001:42)
E/flutter ( 2193): #12 _WidgetsAppState.didPopRoute (package:flutter/src/widgets/app.dart:808:28)
E/flutter ( 2193): #13 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:49:6)
E/flutter ( 2193): #14 _WidgetsAppState.didPopRoute (package:flutter/src/widgets/app.dart:803:27)
E/flutter ( 2193): #15 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.handlePopRoute (package:flutter/src/widgets/binding.dart:482:26)
E/flutter ( 2193): #16 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:49:6)
E/flutter ( 2193): #17 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.handlePopRoute (package:flutter/src/widgets/binding.dart:480:30)
E/flutter ( 2193): #18 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding._handleNavigationInvocation (package:flutter/src/widgets/binding.dart:510:16)
E/flutter ( 2193): #19 MethodChannel._handleAsMethodCall (package:flutter/src/services/platform_channel.dart:397:55)
E/flutter ( 2193): #20 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:49:6)
E/flutter ( 2193): #21 MethodChannel._handleAsMethodCall (package:flutter/src/services/platform_channel.dart:394:39)
E/flutter ( 2193): #22 MethodChannel.setMethodCallHandler. (package:flutter/src/services/platform_channel.dart:365:54)
E/flutter ( 2193): #23 _DefaultBinaryMessenger.handlePlatformMessage (package:flutter/src/services/binary_messenger.dart:110:33)
E/flutter ( 2193): #24 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:49:6)
E/flutter ( 2193): #25 _DefaultBinaryMessenger.handlePlatformMessage (package:flutter/src/services/binary_messenger.dart:101:37)
E/flutter ( 2193): #26 _invoke3. (dart:ui/hooks.dart:280:15)
E/flutter ( 2193): #27 _rootRun (dart:async/zone.dart:1124:13)
E/flutter ( 2193): #28 _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter ( 2193): #29 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
E/flutter ( 2193): #30 _invoke3 (dart:ui/hooks.dart:279:10)
E/flutter ( 2193): #31 _dispatchPlatformMessage (dart:ui/hooks.dart:141:5)

This should has more optional customization

Since flutter do the same and offering tuns of different things to do.. every other widget should has the same approach..
I recently worked with this Toast and I couldn't set the property of TextAlign because there is no options to do that..
So what I did is I open the source code and changed them my self and set an options parameters to do that as well.

I hope you guys develop this more efficiently and usefully for other developers.
Thank you.

ssss

package com.android.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.fragment.MenuFragment;
//import com.special.ResideMenu.ResideMenu;
//import com.special.ResideMenu.ResideMenuInfo;
//import com.special.ResideMenu.ResideMenuItem;

public class MainActivity extends FragmentActivity {

    public Fragment mContent;
    public TextView maintitle;
    public ImageView logo;

    private MenuFragment fragment;

    MyApplication myApp;

    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        maintitle = (TextView) findViewById(R.id.main_txt);
        logo = (ImageView) findViewById(R.id.logo);

        myApp = (MyApplication) getApplication();

        // changeFragment(new HuDongFragment());
        initView();// 初始化页面信息
    }


    // 监听手机上的BACK键
    //public boolean onKeyDown(int keyCode, KeyEvent event) {
    //    if (keyCode == KeyEvent.KEYCODE_BACK) {
    //        // 判断菜单是否关闭
    //        if (is_closed) {
    //            // 判断两次点击的时间间隔(默认设置为2秒)ime) > 2000) {
    //                Toast.makeText(this, "再按一次退出程
    //            if ((System.currentTimeMillis() - mExitT序", Toast.LENGTH_SHORT).show();

    //                mExitTime = System.currentTimeMillis();
    //            } else {
    //                finish();
    //                System.exit(0);
    //                super.onBackPressed();
    //            }
    //        } else {
    //            resideMenu.closeMenu();
    //        }
    //        return true;
    //    }
    //    return super.onKeyDown(keyCode, event);
    //}

    private void initView() {

        maintitle.setText("今日签到");
        fragment =  new MenuFragment();
        mContent = fragment;

        // 显示主页面
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.content_frame, mContent).commit();

    }

    public void switchContent(Fragment fragment) {
        fragment.getClass().getSimpleName() == fragment.getClass().getSimpleName()

        mContent = fragment;

        getSupportFragmentManager().beginTransaction()
                .replace(R.id.content_frame, fragment).commit();

    }

    @Override
    public void onBackPressed() {
        switchContent(fragment);
        //  super.onBackPressed();
    }
}


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.