sososdk / flash

⚡️A highly customizable, powerful and easy-to-use alerting library for Flutter.

Home Page:https://sososdk.github.io/flash

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Expected a value of type 'FutureOr<Flash<dynamic>>', but got one of type 'Null'

devj3ns opened this issue · comments

When I run my Flutter web app with sound null safety I get this warning when the Flashbar disappears:

======== Exception caught by animation library =====================================================
The following TypeErrorImpl was thrown while notifying status listeners for AnimationController:
Expected a value of type 'FutureOr<Flash<dynamic>>', but got one of type 'Null'

When the exception was thrown, this was the stack: 
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 236:49      throw_
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 84:3        castError
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 442:10  cast
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/classes.dart 192:14     as_FutureOr
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 46:41                                         complete
...
The AnimationController notifying status listeners was: AnimationController#c75ed(⏮ 0.000; paused; DISPOSED; for FlashController<Flash<dynamic>>)
====================================================================================================

This is my code:

void showFlashbar(
    BuildContext context,
    String message, {
    required Color iconColor,
    required IconData icon,
    int duration = 3,
  }) {
    showFlash<Flash>(
      context: context,
      duration: Duration(seconds: duration),
      transitionDuration: const Duration(milliseconds: 750),
      builder: (context, controller) {
        return Flash<Flash>.bar(
          controller: controller,
          backgroundColor: const Color(0xFF303030),
          borderRadius: BorderRadius.circular(10),
          margin: const EdgeInsets.all(10),
          child: FlashBar(
            message: Text(
              message,
              style: const TextStyle(fontSize: 14.0, color: Colors.white),
            ),
            icon: Icon(
              icon,
              color: iconColor,
              size: 28,
            ),
          ),
        );
      },
    );
  }

I'm using flash: ^1.5.0 and Flutter v2.0.3 (stable)

Thanks @sososdk, for fixing it that quickly 💙

Could you please upload the new version to pub.dev as well?

The git dependency does not work:

Error on line 2, column 19: Unexpected character.
  ╷
2 │ description: âš¡ï¸�A highly customizable, powerful and easy-to-use alerting library for Flutter. 
  │                   ^
  ╵
pub get failed (65;   ╵)

Hi @devj3ns, It was published: pub