Giter Site home page Giter Site logo

sososdk / flash Goto Github PK

View Code? Open in Web Editor NEW
467.0 467.0 69.0 18.83 MB

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

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

License: Apache License 2.0

Objective-C 0.04% Dart 96.63% HTML 1.31% Kotlin 0.15% Swift 0.43% Ruby 1.44%
dialog flashbar flutter snackbar toast

flash's People

Contributors

devj3ns avatar sidrao2006 avatar sososdk avatar vesuvi88 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

flash's Issues

How can I show a flash on top of an alert dialog?

Currently the flash is shown behind the dialog

import 'package:flash/flash.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: Home(),
    );
  }
}

class Home extends StatelessWidget {
  const Home({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: RaisedButton(
          onPressed: () {
            showDialog(
              context: context,
              builder: (_) => AlertDialog(
                content: RaisedButton(
                  onPressed: () {
                    showFlash(
                      context: context,
                      duration: Duration(seconds: 3),
                      persistent: true,
                      builder: (_, controller) {
                        return Flash(
                          controller: controller,
                          child: FlashBar(
                            message: Text('Hello Flash'),
                          ),
                        );
                      },
                    );
                  },
                  child: Text('Show Flash'),
                ),
              ),
            );
          },
          child: Text('Show Dialog'),
        ),
      ),
    );
  }
}

flash

Shadow of the dialog is not rounded

I want my Dialog to be rounded and it works fine, however when I set boxShadows, the shadow turns out to be rectangular.

Flash.dialog(
borderRadius: const BorderRadius.all(Radius.circular(30)),
boxShadows: [
            BoxShadow(
              color: Color.fromRGBO(0, 0, 0, 0.25),
              blurRadius: 4.0,
              offset: Offset(0, 4),
            ),
          ],

The result is a rounded Dialog with NOT rounded shadow.

Overlay is null when using a GlobalKey<NavigatorState>

I'm trying to call showFlash with a navigatorState:

showFlash(context: _navigator.currentState.context, persistent: false, builder: (context, controller) {

But the overlay is null.

I already tried to add an Overlay when generating a route:

Route<dynamic> _generateRoute(RouteSettings settings) {
    return MaterialPageRoute(settings: settings, builder: (_) => Overlay(
          initialEntries: [OverlayEntry(builder: (context) => view )]
    ));
  }

Stacked Flashbars

Is it possible to have stacked flashbars for cases when you want to give the user more than one alert via a flashbar?

[ISSUE] Flash dialogs are stacked when the Android native back button is clicked multi times

Hi!

I need to show dialog when the Android native back button is clicked. So I am using WillPopScope widget.
Problem is that when the Flash dialog is shown and the user clicks on the Android native back button the dialog will not close, but a new dialog will appear above the existing dialog.

What I need is that when the Flash dialog is already shown and the user clicks on the Android native back button the dialog should be closed. Like it this example of using Flutter dialog: https://www.flutterclutter.dev/flutter/tutorials/prevent-back-button-from-closing-the-app/2021/14074/

Please use the code below to reproduce the issue.

import 'package:flash/flash.dart';
import 'package:flutter/material.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  runApp(
    MaterialApp(
      home: HomePage(),
    ),
  );
}

class HomePage extends StatelessWidget {
  Future<bool> _onWillPopFlashController(BuildContext context) async {
    final controller = FlashController<bool>(
      context,
      builder: (context, controller) {
        return Flash.dialog(
          controller: controller,
          alignment: const Alignment(0, 0.5),
          margin: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
          borderRadius: const BorderRadius.all(Radius.circular(8.0)),
          backgroundColor: Colors.black87,
          child: DefaultTextStyle(
            style: const TextStyle(fontSize: 16.0, color: Colors.white),
            child: Padding(
              padding:
                  const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
              child: Text('TEXT'),
            ),
          ),
        );
      },
    );

    final result = await controller.show();

    return result ?? false;
  }

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: () => _onWillPopFlashController(context),
      child: Scaffold(
        appBar: AppBar(
          title: const Text("Exit app warning"),
        ),
        body: Container(),
      ),
    );
  }
}

FocusScopeNode Error

FocusScopeNode FocusScopeNode#ea86b(_FlashState Focus Scope [PRIMARY FOCUS])(context: FocusScope, PRIMARY FOCUS) must be a child of FocusScopeNode#6ff27(Navigator Scope)(context: FocusScope, focusedChildren: [FocusScopeNode#bac68(_ModalScopeState Focus Scope)]) to set it as first focus.
'package:flutter/src/widgets/focus_manager.dart':
Failed assertion: line 1272 pos 12: 'scope.ancestors.contains(this)'

Is there way to inject overlay to context of GlobalKey<NavigatorState>?

Thanks you for making a good package.

In the previous version, after injecting the context of GlobalKey<NavigatorState> once, it was using flash well as if there was no dependency on the context. However, in the latest version, this method cannot be used because it has been updated so that the flash can be displayed only by using the context with overlay.

#21 is very similar to my situation. I wonder is it possible to inject an overlay into context of GlobalKey<NavigatorState>? if it possible, can you write some sample code?

Add FlashBar blur

Please provide blur effect for flashbar. This can be very nice when customized.

Cannot reuse a FlashController<dynamic> after disposing it.

Usecase:
Make a dialog dismissible so the user can dismiss it, but at the same time I want to dismiss the dialog after a delay if the user hasn't already dismissed it.

Problem:
There an assertion in the dismiss function that throws if we try to dismiss something that is already dismissed.

  Future<void> dismiss([T? result]) {
    assert(!_transitionCompleter.isCompleted,
        'Cannot reuse a $runtimeType after disposing it.'); // <---------- here
    _dismissed = true;
    _result = result;
    if (onWillPop != null) route?.removeScopedWillPopCallback(onWillPop!);
    _removeLocalHistory();
    _cancelTimer();
    return _controller.reverse();
  }

Possible solution:
Changing the assertion line to an if statement that return if the transition completed.

  Future<void> dismiss([T? result]) async {
    // assert(!_transitionCompleter.isCompleted,
    //     'Cannot reuse a $runtimeType after disposing it.');
    if (_transitionCompleter.isCompleted) {
      return;
    }
    _dismissed = true;
    _result = result;
    if (onWillPop != null) route?.removeScopedWillPopCallback(onWillPop!);
    _removeLocalHistory();
    _cancelTimer();
    return _controller.reverse();
  }

Screen does not detect gestures when Flash.dialog is shown.

Every time when I call the showFlash function and a Flash.dialog is displayed the screen below the Flash does not detect gestures anymore, only when the flash is dismissed again. Is this behaviour intendet or is it a bug?
This is my flash which I call all over the app to visualize a successfull action:

void showSuccessNoti({
  required String message,
  required BuildContext context,
}) {
  showFlash(
    context: context,
    duration: const Duration(seconds: 2),
    builder: (context, controller) {
      return Flash.dialog(
        barrierColor: Colors.transparent,
        controller: controller,
        alignment: Alignment.topCenter,
        borderRadius: const BorderRadius.all(Radius.circular(4)),
        backgroundColor: Theme.of(context).backgroundColor,
        boxShadows: [
          BoxShadow(
            color: Colors.black.withOpacity(0.12),
            offset: const Offset(3.0, 3.0),
            blurRadius: 6,
          )
        ],
        margin: const EdgeInsets.only(top: kMediumPadding),
        child: Padding(
          padding: const EdgeInsets.symmetric(
            horizontal: kMediumPadding,
            vertical: kSmallPadding,
          ),
          child: Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
            const Icon(
              Icons.check_circle,
              color: Color(0xFF52C41A),
              size: 18.0,
            ),
            const SizedBox(
              width: 8,
            ),
            Text(
              message,
              style: Theme.of(context).textTheme.bodyText2,
            )
          ]),
        ),
      );
    },
  );
}

This is how I then call the flash inside of my app when the state changes:

BlocConsumer<Bloc, State>(
  listener: (context, state) {
    if (state.formStatus is SubmissionSuccess) {
      showSuccessNoti(
          message: L.of(context).updateSuccessAddress,
          context: context);
      Navigator.pop(context);
    } else if (state.formStatus is SubmissionFailed) {
      showErrorNoti(
          message: L.of(context).updateErrorMessage,
          context: context);
    }
  },
  builder: (context, state) {
...

UIFreeze: Tried to remove a willPop callback from a route that is not currently in the tree.

I noticed that, after i call this:

context.showSuccessBar(content: Text('Authentication verified!'));

It is displaying properly on the UI, but on the log, i can see this trace. And during that, my UI is freezen, i have to restart my app to use my app. Why is that?

======== Exception caught by animation library =====================================================
The following assertion was thrown while notifying status listeners for AnimationController:
Tried to remove a willPop callback from a route that is not currently in the tree.
'package:flutter/src/widgets/routes.dart':
Failed assertion: line 1508 pos 12: '_scopeKey.currentState != null'

When the exception was thrown, this was the stack: 
#2      ModalRoute.removeScopedWillPopCallback (package:flutter/src/widgets/routes.dart:1508:12)
#3      FlashController.dismissInternal (package:flash/flash.dart:224:35)
#4      FlashController.dispose (package:flash/flash.dart:244:5)
#5      FlashController._handleStatusChanged (package:flash/flash.dart:159:9)
#6      AnimationLocalStatusListenersMixin.notifyStatusListeners (package:flutter/src/animation/listener_helpers.dart:233:19)
#7      AnimationController._checkStatusChanged (package:flutter/src/animation/animation_controller.dart:815:7)
#8      AnimationController._tick (package:flutter/src/animation/animation_controller.dart:831:5)
#9      Ticker._tick (package:flutter/src/scheduler/ticker.dart:238:12)
#10     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1146:15)
#11     SchedulerBinding.handleBeginFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:1059:11)
#12     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:614:13)
#13     SchedulerBinding.handleBeginFrame (package:flutter/src/scheduler/binding.dart:1057:17)
#14     SchedulerBinding._handleBeginFrame (package:flutter/src/scheduler/binding.dart:976:5)
#18     _invoke1 (dart:ui/hooks.dart:170:10)
#19     PlatformDispatcher._beginFrame (dart:ui/platform_dispatcher.dart:286:5)
#20     _beginFrame (dart:ui/hooks.dart:104:31)
(elided 5 frames from class _AssertionError and dart:async)
The AnimationController notifying status listeners was: AnimationController#a3606(⏮ 0.000; paused; for FlashController<dynamic>)

(showBlockDialog not dismissing) - Completer not completes when using it in Helper

I have this class, and initiated the showBlockDialog functionality in model.

PageLoader.dart

import 'dart:async';

import 'package:flash/flash.dart';
import 'package:flutter/material.dart';

class PageLoader {
  final _completer = Completer();
  final BuildContext context;

  PageLoader(this.context);

  void init() {
    context.showBlockDialog(dismissCompleter: _completer);
  }

  void complete() {
    _completer.complete();
    print("is completed");
  }
}

And using it like MyUI.dart

try {
  PageLoader(context).init(); // init 

  await provider.login(
      emailController.text, passwordController.text, deviceName);

  PageLoader(context).complete(); // triggering to completer to complete the job to dismiss the dialog

  Navigator.of(context).push(MaterialPageRoute(
      builder: (context) => VerificationPage(email: emailController.text)));
} catch (exception) {
  setState(() {
    errorMessage = exception.toString().replaceAll('Exception: ', '');
  });

  PageLoader(context).complete();  // triggering to completer to complete the job to dismiss the dialog

While respective actions, the showBlockDialog is displaying, but the complete is not completing.

Allow TextFields inside of Flash?

Maybe I'm using this in a less conventional way, but I have a couple form fields I'm trying to put in the flash. Is there any way to activate them?

image

StatusBar color

on Android show flash warning changes statusBar color.

screen-20220808-123626.mp4

Is there any solution to fix this issue?

It works when I try the package normally with a button, but it doesn't work from my own class.

Hello, as I mentioned, I checked the package with a button to try it, normally it works fine with the context of that widget, but when I try to run it in my Notification Handler class. I get the message from the top like the usage in this package when it is open. I think the problem is the context in the messaging page and the contex in my class are different so I can't see anything how can I solve this.

My Notification Handler

class NotificationHandler {
  String userId;

  FirebaseMessaging _fcm = FirebaseMessaging();

  static final NotificationHandler _singelton = NotificationHandler._internal();

  factory NotificationHandler() {
    return _singelton;
  }

  NotificationHandler._internal();

  BuildContext myContext;

  initializeFCMNotification(BuildContext context) async {


    myContext = context;

    final _tumKullanicilarViewModel =
    Provider.of<AllUserViewModel>(context, listen: false);
    var initializationSettingsAndroid = AndroidInitializationSettings("yeni");
    var initializatioonSettingsIOS = IOSInitializationSettings(
        onDidReceiveLocalNotification: onDidReceiveLocalNotification);
    var initializationSettings = InitializationSettings(
        initializationSettingsAndroid, initializatioonSettingsIOS);
    flutterLocalNotificationsPlugin.initialize(initializationSettings,
        onSelectNotification: onSelectNotification);
    //_fcm.subscribeToTopic("all");
    // String token= await _fcm.getToken();
    //  print("token : $token");
    _fcm.onTokenRefresh.listen((newToken) async {
      FirebaseUser _currentUser = await FirebaseAuth.instance.currentUser();
      Firestore.instance
          .document("tokens/" + _currentUser.uid)
          .setData({"token": newToken});
    });

    _fcm.configure(
      onMessage: (Map<String, dynamic> message) async {
        print("onmessage ");

        var notificationData = message['notification'];

        //If currently user is there, do not show notification
        var data = message['data'];
        var view;
        if (data != null) {
          view = data['view'];
          print(message['data']);
        }
        print("root gosterirmi //*/0" +
            MyNavigatorObserver.routeStack.toString());

        if (MyNavigatorObserver.routeStack.last == message['data']['view'] &&
            _tumKullanicilarViewModel.tiklaninanUserID ==
                message['data']['gonderenUserID']) {
          print("chat page deyiz");

          //show in app notification 
        } if( _tumKullanicilarViewModel.tiklaninanUserID !=
            message['data']['gonderenUserID']) {
          print("baska birinin sayfasındayım");

         showFlash(
            context: context,
            duration: const Duration(milliseconds: 1500),
            persistent: false,
            builder: (_, controller) {
              return Flash(
                backgroundGradient: RadialGradient(
                  colors: [Colors.red, Colors.white],
                  center: Alignment.topLeft,
                  radius: 2,
                ),
                controller: controller,
                backgroundColor: Colors.white,
                brightness: Brightness.light,
                boxShadows: [BoxShadow(blurRadius: 4)],
                barrierBlur: 2.0,
                barrierColor: Colors.black38,
                barrierDismissible: true,
                style: FlashStyle.floating,
                position: FlashPosition.top,
                child: FlashBar(
                  title: Text('Title'),
                  message: Text('Hello world!'),
                  showProgressIndicator: true,
                  progressIndicatorValueColor:
                  AlwaysStoppedAnimation<Color>(Colors.green),
                  primaryAction: FlatButton(
                    onPressed: () => controller.dismiss(),
                    child: Text('Kapat',
                        style: TextStyle(color: Colors.red, fontSize: 18)),
                  ),
                ),
              );
            },
          );

          

         /* PdyALertDialog(
            baslik: message['data']['title'],
            kapatAlert: "tamam",
            kapatAlertColor: Colors.blue, //89hjb5Qaqg4rYTD48cbjo5kusx2//
            icerik: message['data']['message'],
          ).goster(context);*/
        }

        if (_tumKullanicilarViewModel.tiklaninanUserID ==
            message['data']['gonderenUserID']) {
          print("chat page deyiz ve konustugumuz userdayız");
        } else {
          print("konustugumuz userda değiliiz");
        }
      },
      onLaunch: (Map<String, dynamic> message) async {
        print("onlaunch tetiklendi");
      },
      onResume: (Map<String, dynamic> message) async {
        print("onresume tetiklendi");
      },
      onBackgroundMessage: myBackgroundMessageHandler,
    );
  }}

My Overlay

 Navigator.of(context, rootNavigator: true).push(
          MaterialPageRoute(
            settings:
                RouteSettings(arguments: oankiUser.userID, name: "/chatpage"),
            builder: (context) {
              return ChangeNotifierProvider(
                create: (context) => ChatViewModel(
                  chatUser: oankiUser,
                  currentUser: _userModel.user,
                ),
                child: Overlay(
                  initialEntries: [
                    OverlayEntry(builder: (context) {
                      return KonusmaPage();
                    })
                  ],
                ),
              );
            },
          ),
        );

One more question, in this package, dialogs are shown according to the context value of the page required to do them?

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

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)

Bug: Android back button leaves dialog open

Load up the example app on Android. Go to the examples page and open any of the dialogs. Click the Android back button. The page navigates back, but the dialog is still open. The user can close it from there, but that's pretty awful UX.

overlay can't be the root overlay when persistent is false

I'm calling the sample showTopFlash() inside my app and get following error:

overlay can't be the root overlay when persistent is false
'package:flash/flash.dart':
Failed assertion: line 99 pos 14: 'overlay != rootOverlay'

This is my simple code to reproduce:

class _TestScreenState extends State<TestScreen> {
  int which = 0;

  @override
  Widget build(BuildContext context) {
    GlobalKey<ScaffoldState> _key = GlobalKey<ScaffoldState>();
    FlashHelper.init(context);
    return Scaffold(
      key: _key,
      body: Center(child: FlatButton(onPressed: (){
        _showTopFlash();
      }, child: Text('show Flash')),),
    );
  }
  void _showTopFlash({FlashStyle style = FlashStyle.floating}) {
    showFlash(
      context: context,
      duration: const Duration(seconds: 5),
      persistent: false,
      builder: (_, controller) {
        return Flash(
          controller: controller,
          backgroundColor: Colors.white,
          brightness: Brightness.light,
          boxShadows: [BoxShadow(blurRadius: 4)],
          barrierBlur: 3.0,
          barrierColor: Colors.black38,
          barrierDismissible: true,
          style: style,
          position: FlashPosition.bottom,
          child: FlashBar(
            title: Text('Title'),
            message: Text('Hello world!'),
            showProgressIndicator: true,
            primaryAction: FlatButton(
              onPressed: () => controller.dismiss(),
              child: Text('DISMISS', style: TextStyle(color: Colors.amber)),
            ),
          ),
        );
      },
    );
  }

}

When I set the persistent:true it works without Blur effect.
Thanks for your nice lib.

Drag direction

Would it be possible to set the drag direction ?
So the user can dismiss it with horizontal drag instead of vertical (because when the message is thin height and is shown at bottom, it is very hard to dismiss with a vertical drag gesture).
Even better : to be able to set both : user can dismiss using vertical or horizontal drag.

Thnaks.
Truly awesome plugin !

Error: No named parameter with the name 'foregroundColor'

[+7199 ms] [+7168 ms] ../Development/flutter/.pub-cache/hosted/pub.dartlang.org/flash-2.0.5/lib/src/flash_helper.dart:337:45: Error: No named
parameter with the name 'foregroundColor'.
[ +2 ms] [ +8 ms] style: TextButton.styleFrom(foregroundColor: $actionColor),
[ ] [ ] ^^^^^^^^^^^^^^^
[ ] [ ] ../Development/flutter/packages/flutter/lib/src/material/text_button.dart:145:22: Context: Found this candidate, but the
arguments don't match.
[ ] [ ] static ButtonStyle styleFrom({
[ ] [ ] ^^^^^^^^^
[ ] [ +1 ms] ../Development/flutter/.pub-cache/hosted/pub.dartlang.org/flash-2.0.5/lib/src/flash_helper.dart:555:45: Error: No named
parameter with the name 'foregroundColor'.
[ ] [ ] style: TextButton.styleFrom(foregroundColor: $actionColor),
[ ] [ ] ^^^^^^^^^^^^^^^
[ ] [ ] ../Development/flutter/packages/flutter/lib/src/material/text_button.dart:145:22: Context: Found this candidate, but the
arguments don't match.
[ ] [ ] static ButtonStyle styleFrom({

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.10.5, on macOS 12.6 21G115 darwin-arm, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.71.2)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

**iOS & Android not working. Not able to run or build.

Commenting out the plugin code is working. Please look into this.**

Flash Dialog and SafeArea

Hello. Is there a way to disable the SafeArea in dialogs similar to Flutter's showDialog and its useSafeArea parameter? If there is not, would you consider adding such a feature and/or accepting PR's?

The useSafeArea argument is used to indicate if the dialog should only display in 'safe' areas of the screen not used by the operating system (see SafeArea for more details). It is true by default, which means the dialog will not overlap operating system areas. If it is set to false the dialog will only be constrained by the screen size. It can not be null.

Popup widgets are behind the flash widget

Hi @sososdk ,

Thank you for building such great tool. When I am using it (version ^2.0.3+1), I find that the popup widgets are behind the flash widget.

For example, I try to add a dropdown button in a context.showFlashDialog<T>, but the dropdown list is behind the dialog. I also use a date time picker in a bottom sheet, but the popup date time picker also behind the bottom sheet.

image

Here is the example code I am using

await showFlash(
      context: context,
      builder: (_, controller) {
        return Flash(
          controller: controller,
          behavior: FlashBehavior.fixed,
          position: FlashPosition.bottom,
          onTap: () => controller.dismiss(),
          forwardAnimationCurve: Curves.easeInCirc,
          reverseAnimationCurve: Curves.bounceIn,
          child: SomeWidgetIncludingTheDateTimePicker(),
        );

Can you please take a look and see if there is anything I missed.

Thank you

Question: show flash behind the bottom navigation bar

Hey,
thanks for the great package!

As the title says is it possible to show the flash behind the bottom navigation bar? While the flash is sliding-in it hides/overlaps the bottom nav bar. We want to have our nav bar visible at all times.

Is this possible? Is there something against it (technically or UX)?

Thanks in advance and keep on rocking! ;-)

[flash-1.4.0-nullsafety] Warning: Operand of null-aware operation '?.' has type 'NavigatorState' which excludes null.

I am getting this warning when running my Flutter app (Flutter 2.0.1, stable channel).

/C:/flutter/.pub-cache/hosted/pub.dartlang.org/flash-1.4.0-nullsafety/lib/flash.dart:91:33: Warning: Operand of null-aware operation '?.' has type 'NavigatorState' which excludes null.
 - 'NavigatorState' is from 'package:flutter/src/widgets/navigator.dart' ('/C:/flutter/packages/flutter/lib/src/widgets/navigator.dart').
    var rootOverlay = Navigator.of(context)?.overlay;

Flutter web dialog size

Hello,

We use this package extensively in our projects.

Is there a way to specify the size of the Dialog window? We are running blockers in Flutter web when we do not have a way to limit the size of the dialog width.

Any existing settings that we can use to adjust it? (context.showFlashDialog)

Thanks

Setting FlashTheme ignores fontStyle, fontSize, fontWeight of contentStyle

When I set a FlashTheme I expect it to be applied to the FlashBars down the widget tree.

But when I set the contentStyle, only the color is respected. Other attributes like fontStyle, fontSize and fontWeight are ignored.

See the following example:

class FlashTest extends StatelessWidget {
  const FlashTest({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return FlashTheme(
      flashBarTheme: const FlashBarThemeData(
        contentStyle: TextStyle(
          color: Colors.green,
          fontStyle: FontStyle.italic,
          fontSize: 8,
          fontWeight: FontWeight.bold,
        ),
      ),
      child: Builder(
        builder: (context) {
          return TextButton(
            child: const Text('show flashbar'),
            onPressed: () => context.showFlashBar(
              content: const Text('content'),
            ),
          );
        },
      ),
    );
  }
}

This produces the following FlashBar. As you can see, only the green color is set:
WhatsApp Image 2022-07-18 at 17 29 52

However, when I set the same contentStyle directly in the showFlashBarmethod, it works as expected:

            onPressed: () => context.showFlashBar(
              content: const Text('content'),
              contentStyle: const TextStyle(
                color: Colors.green,
                fontStyle: FontStyle.italic,
                fontSize: 8,
                fontWeight: FontWeight.bold,
              ),
            ),

WhatsApp Image 2022-07-18 at 17 29 52 (1)

Any idea?

Null check operator used on a null value

After updating to v1.5.2+1, I am now receiving this error when attempting to show any flash.

{
    "timestamp": "2021-05-06T03:03:26.535",
    "type": "Critical",
    "class_name": "package:flash/flash.dart",
    "method_name": "FlashController.createAnimationController",
    "message": "Null check operator used on a null value",
    "error": "Null check operator used on a null value",
    "stack_trace": [
        "package:flash/flash.dart 138                                                                    FlashController.createAnimationController",
        "package:flash/flash.dart 100                                                                    new FlashController",
        "package:flash/flash.dart 23                                                                     showFlash",
        "dart:async/zone.dart 1378                                                                       _rootRunBinary",
        "dart:async/zone.dart 1272                                                                       _CustomZone.runBinary",
        "dart:async/future_impl.dart 169                                                                 _FutureListener.handleError",
        "dart:async/future_impl.dart 719                                                                 Future._propagateToListeners.handleError",
        "dart:async/future_impl.dart 740                                                                 Future._propagateToListeners",
        "dart:async/future_impl.dart 550                                                                 Future._completeError",
        "dart:async/future_impl.dart 606                                                                 Future._asyncCompleteError.<fn>",
        "dart:async/zone.dart 1354                                                                       _rootRun",
        "dart:async/zone.dart 1258                                                                       _CustomZone.run",
        "dart:async/zone.dart 1162                                                                       _CustomZone.runGuarded",
        "dart:async/zone.dart 1202                                                                       _CustomZone.bindCallbackGuarded.<fn>",
        "dart:async/schedule_microtask.dart 40                                                           _microtaskLoop",
        "dart:async/schedule_microtask.dart 49                                                           _startMicrotaskLoop"
    ]
}

Worked without any issue with 1.5.2 and previous releases. When stepping through, this line returns null:

L91: final rootOverlay = Overlay.of(context, rootOverlay: true);

So does this line:

L95: overlay = Overlay.of(context);

My assumption is because I have a singleton GlobalKey<NavigatorState> that I attach to the MaterialApp and I use for all flashes (via key.currentContext.

showToast in center or any other location

How do you showToast in any other location?

Currently context.showToast() places the toast at a weird between center to bottom location.

edit:
Okay found a way to adjust the alignment with:

// Wrap with toast.
    child = Toast(
      child: child,
      navigatorKey: navigatorKey,
      alignment: Alignment.topCenter,
    );

but this works only on the init, so it is currently not possible to change the alignment on showToast. maybe add optional argument in showToast to specify the location of toast?

If this sounds good, I can send a PR

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.