Git Product home page Git Product logo

belovance / quickalert Goto Github PK

View Code? Open in Web Editor NEW
46.0 1.0 42.0 12.12 MB

An instantly ready, full-featured alerts for development on any platform with flutter. Enabling you to complete projects and deploy quickly. With QuickAlert, you can display animated alert dialogs such as success, error, warning, confirm, loading or even a custom dialog.

Home Page: https://pub.dev/packages/quickalert

License: MIT License

Kotlin 0.19% Swift 1.60% Objective-C 0.05% Dart 39.65% CMake 25.09% C++ 28.92% C 1.97% HTML 2.54%
android dart flutter flutter-package ios linux macos package web windows

quickalert's Issues

Showing dialogs can be easy and better

QuickAlert.success(context: context);

// or

QuickAlert.success(context); // context as positional parameter

QuickAlert.success(context, message: "File downloaded successfully!");

instead of

QuickAlert.show(
  context: context,
  type: QuickAlertType.success,
);

How to custom image size on custom asset field ?

extension AlertExtension on BuildContext { void showQuickAlertFeatureNotYetAvailable() { QuickAlert.show( context: this, type: QuickAlertType.warning, text: 'This feature is not yet available.', customAsset: 'assets/images/coming_soon.jpg' ); }
image

How to manually close the dialog box?

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Add option to dismiss alert with keyboard "Enter/Cancel" pressed

Hi, i've noticed that either if the keyboard is opened on the screen or if i'm using an external keyboard (or another input device) or I'm on flutter web, it's not possible to dismiss the alert with a button press from the keyboard.

The solution would be:

  • with a single button alert the dismiss will happen when pressing Enter key;
  • if the alert has two buttons by pressing Cancel it will do the onCancelBtnTap and with Enter the onConfirmBtnTap.

I think it would be useful as the user hasn't to pass between the keyboard and the tap each time an alert is showed.
Thanks.

Header size

How could I change this? It looks way to big, especially for small devices:

image

Sometimes, buttons are not even displayed at all

Popping context pops current screen not alert

This is the 3rd time I am reporting this issue and 2 times I have given pull request for same but I don't know why this issue is always supressed.

The issue is so intermittent that it's very hard to catch.
The context we are passing and the context we are popping is same which pops screen behind the alert.
I gave solution to simply return context alert is using in onConfirmBtnTap function . onConfirmBtnTap(context)

We are always popping parent context in onConfirmBtnTap if we are defining that function , if function is null it pops context that alert widget has defined (child context of what we have passed)

see quickalert_buttons.dart

// quickalert_buttons.dart
@override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.only(top: 10.0),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          cancelBtn(context),
          okayBtn(context), // the alert context not the parent which was passed
        ],
      ),
    );
  }

  Widget okayBtn(context) { // the alert context not the parent which was passed
    if (!options!.showConfirmBtn!) {
      return const SizedBox();
    }
    final showCancelBtn = options!.type == QuickAlertType.confirm
        ? true
        : options!.showCancelBtn!;

    final okayBtn = buildButton(
        context: context,
        isOkayBtn: true,
        text: options!.confirmBtnText!,
        onTap: () {
          options!.timer?.cancel();
// the alert context not the parent which was passed
// if options!.onConfirmBtnTap != null then user will use the parent context to pop which will pop current screen not alert
          options!.onConfirmBtnTap != null
              ? options!.onConfirmBtnTap!()
              : Navigator.pop(context);
        });

    if (showCancelBtn) {
      return Expanded(child: okayBtn);
    } else {
      return okayBtn;
    }
  }
var res = await QuickAlert.show(
      context: context,
      width: width,
      type: QuickAlertType.error,
      title: 'Delete record',
      widget: const Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Text(
            'Are you sure to remove this ?',
            textAlign: TextAlign.center,
            style: TextStyle(
              color: Colors.grey,
              fontSize: 13,
            ),
          ),
        ],
      ),
      showCancelBtn: true,
      showConfirmBtn: true,
      onConfirmBtnTap: () {
        Navigator.pop(context);
      },
    );

Title Style & Hide Animated Asset

Describe the solution you'd like

  1. Editable Title Style: I need the ability to control the title's appearance. This includes functions like:
    Font size adjustment: Allow me to make the title font smaller or larger. Potentially other style options (depending on the context): Font style (bold, italic), color changes, etc.

  2. Conditional Display of Animated GIF/Asset: I want the option to show or hide the animated GIF or asset based on specific situations.

Cancel button with QuickAlertType.loading

Hello,

Thanks for the wonderful library. I rarely see such a clean and well maintained library ! 🥇

if (options!.type == QuickAlertType.loading) {

According to the code line above, no button is shown when the alert type is QuickAlertType.loading

Please provide a way to show the cancel button even for QuickAlertType.loading.

Why ? sometimes you want to give the user the possibility to cancel a loading process. Sure the user can still tap outside of the dialog to dismiss or "cancel" but that is not a clean way from the UX perspective.

Thanks in advance and HAPPY CODING :)

How to remove the Success trext from QuickAlertType.success

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Title Color not working

Describe the bug
The usage of titleColor does not color the title

To Reproduce
QuickAlert.show(
context: context,
type: QuickAlertType.success,
title: "My Title",
titleColor: Colors.red,
text: 'Some text',
barrierDismissible: false,
showConfirmBtn: false,
customAsset: "some asset",
autoCloseDuration: const Duration(seconds: 5))
;

Expected behavior
Title should turn red

Desktop (please complete the following information):

  • Android

Smartphone (please complete the following information):

  • Pixel 3a

Factory constructors should be provided for each event

Hi @ItsAkashS22 ,

Thanks for amazing package anyway, I really love it :) I would like to suggest the following improvements to this package.

Currently, an Enum corresponding to each dialog is passed when instantiating a QuickAlert object, but this should be eliminated and a factory constructor corresponding to each dialog should be provided.

So it's currently initialized as follows:

QuickAlert.show(
 context: context,
 type: QuickAlertType.success,
 text: 'Transaction Completed Successfully!',
);
QuickAlert.show(
 context: context,
 type: QuickAlertType.error,
 title: 'Oops...',
 text: 'Sorry, something went wrong',
);

But I suggest like:

QuickAlert.success(
 context: context,
 text: 'Transaction Completed Successfully!',
);
QuickAlert.error(
 context: context,
 title: 'Oops...',
 text: 'Sorry, something went wrong',
);

There are many advantages to having a factory constructor for each event. Currently, the developer must tailor the options depending on the type of dialog used, but providing a factory constructor would eliminate the need to be actively aware of the options required for each dialog :)

Thank you.

tap OK button make a blank screen after AutoClose elapsed time

Describe the bug
In flutter, when user tap Quick Alert´s OK button, the quickAlert dialog is closed, but after the time specified in the autoCloseDuration property, the screen became black.

To test the bug I wrote a very simple project based on counter project.

pubspec.yaml looks like this:

name: debug01
description: A new Flutter project.
publish_to: 'none' 
version: 1.0.0+1

environment:
  sdk: '>=3.1.0-128.0.dev <4.0.0'

dependencies:
  flutter:
    sdk: flutter
  quickalert: ^1.0.1
  cupertino_icons: ^1.0.2

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^2.0.0

flutter:
  uses-material-design: true

I´ve added a sucess quickAlert after _counter++; on _incrementCounter() method, with 5 seconds autoCloseDuration

  void _incrementCounter() {
    setState(() {
      _counter++;
      // quick alert added for debug
      QuickAlert.show(
        context: context,
        type: QuickAlertType.success,
        text: 'Transaction Completed Successfully!',
        autoCloseDuration: const Duration(seconds: 5),
      );
    });
  }

The problem is that when user tap Quick Alert´s OK button, the quickAlert dialog is closed, but after the time specified in the autoCloseDuration property, the screen became black.
No debug console message was shown.
Tested on:

  • windows desktop
  • chrome web
  • edge web
  • android emulator
  • android device

To Reproduce
Steps to reproduce the behavior:

  1. set autoCloseDuration property of a quickAlert dialog with n seconds
  2. show the quickAlert dialog
  3. click OK button
  4. Screen became black after n seconds

Expected behavior
OK button should close the quickAlert Dialog and interrupt autoClose

Desktop ():

  • OS: windows 10
  • Browser edge
  • Version 113.0.1774.50

**Android emulator

  • Device Pixel 6 Pro API 33
  • OS: android 13

Smartphone :

  • Device: redmi 6
  • OS: android 9

Screenshots
video attached

2023-05-21.21-11-00.mp4

Localization

Is there a way to localize the default actions and titles instead of changing them every time from code?
like ( Are you sure ? ) , ( Okay ) , ( Cancel ) ... etc

alert stacked without an option to dismiss

this demo will explain it better, when the user try and fail again to reconnect , a new alert pops before dismissing the old one ? I'm not sure what's happening
the confirm button doesn't dismiss the alert because it's creating a new alert ?

gdm_bloc_3OQHX8rfa1.mp4

QuickAlert.cancel() must have been added since day 1

i'm navigating a user into another page in which when i get back to the main page the dialog is still existing which is super annoying.

there should have been a 'cancelation' to fix the issue, note that i tried Navigator.pop() but it crushes the app.

Close Dialog programatically

Hello, first of all. Thank you for this amazing package. It has helped me provide an elegant and beautiful alerts to my app.

I have faced a situation where I need to close the dialog dynamically, after certain action. For example, when fetching data from an API is complete, I would want to close the "loading" dialog. I have seen the 'autoCloseDuration' option but there's really no way of knowing how much time such an action would take.

Kindly add the feature to close the dialog after an action. For example:

var alert = QuickAlert(options);
if(condition) {
alert.show();
} else {
if(alert.isOpen){
alert.close();
}
}

Remove confirm button

I don't want the user to dismiss the quick alert dialog. It should dismiss only with autoCloseDuration.
I think that should exist a parameter just like showCancelButton, but for confirmation button.

Option To Set Barrier Color

I want the alert to be non dismissible but still able to see the app in the background, it's too dark especially in a dark mode app
I'm talking about barrierColor: Colors.black.withOpacity(0.5),

Function that handle click when using attributes : onConfirmBtnTap and onCancelBtnTap don't work and the alert window does not dispose or close

I try to use QuickAlert.confirm on a drawer. When I use function that handle click when using attributes : onConfirmBtnTap and onCancelBtnTap, it's doesn't work and the alert window does not dispose or close
I use
QuickAlert.show(
context: context,
type: QuickAlertType.confirm,
title: "Confirm action",
text: 'Do you want to log out?',
confirmBtnText: 'oui',
cancelBtnText: 'Non',
confirmBtnColor: Colors.green,
onConfirmBtnTap: (){
print("Yes");
logout();
Navigator.pop(context);

              });

Expected behavior
I want the function set to attribute onConfirmBtnTap to be executed and to dispose of the QuickAlert window.

Smartphone

  • Device: [pixel]
  • OS: [Android 11]

Navigator inside QuickAlert Dialog does not work

https://stackoverflow.com/questions/74840292/navigator-inside-quickalert-dialog-does-not-work

In flutter, I have this Screen deep down in my MaterialApp's widget tree:

class ItemDetailsScreen extends StatefulWidget {
  ItemDetailsScreen();

  @override
  State<ItemDetailsScreen> createState() => _ItemDetailsScreenState();
}

class _ItemDetailsScreenState extends State<ItemDetailsScreen> {

 @override
  Widget build(BuildContext context) {

    bleController.onBleStatusChange('box_is_open', context);
    
    return Scaffold(....
} 

Future<void> onBleStatusChange() async {
...
QuickAlert.show(
        context: context,
        type: QuickAlertType.success,
        title: 'Box geöffnet!',
        text: 'Bitte entnimm jetzt das Item',
        confirmBtnText: 'Weiter',
        onConfirmBtnTap: () {
          Navigator.of(context).push(
              MaterialPageRoute(
                  builder: (context) => const MyNextScreen())); // ERROR
        }
      );
  }
}

I get this error meassage after apping on the confirm button in the QuickAlert dialog onConfirmBtnTap:

======== Exception caught by scheduler library =====================================================
The following assertion was thrown during a scheduler callback:
'package:flutter/src/widgets/navigator.dart': Failed assertion: line 4475 pos 12: '!_debugLocked': is not true.


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.md

When the exception was thrown, this was the stack: 
#2      NavigatorState._pushEntry (package:flutter/src/widgets/navigator.dart:4475:12)
#3      NavigatorState.push (package:flutter/src/widgets/navigator.dart:4412:5)
#4      GetNavigation.to (package:get/get_navigation/src/extension_navigation.dart:522:37)
#5      BleController._navigateToTestDeviceUI.<anonymous closure> (package:flutter_starter/controllers/ble_controller.dart:177:61)
#6      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1175:15)
#7      SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1113:9)
#8      SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1015:5)
#9      _invoke (dart:ui/hooks.dart:148:13)
#10     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:318:5)
#11     _drawFrame (dart:ui/hooks.dart:115:31)
(elided 2 frames from class _AssertionError)
====================================================================================================

I also tried to add a small delay and to move the Navigation to a separate function:

onConfirmBtnTap: () async {
      await Future.delayed(Duration.zero);
      _navigateToMyNextScreen();
    },

...

void _navigateToMyNextScreen() {
        Navigator.of(Get.context!)
            .push(MaterialPageRoute(builder: (Get.context!) => MyNextScreen())));

  }

But the error was the exact same. I also tried passing the BuildContext into that new separate Method instead of getting it from GetX, but it's the same error. I also tried to navigate with GetX Get.to(() => MyNextScreen()) instead of using the Navigator, but that made no difference.

I also asked ChatGPT3, it gave a good looking response that I should separate it into a separate function, but I think that makes no sense and the error stayed the same.

ChatGPT
ChatGPT_answer

On hover color on web

Is your feature request related to a problem? Please describe.
I noticed that the hover color on flutter web is not customizable (screen attached)

  QuickAlert.show(
    context: context,
    type: QuickAlertType.error,
    title: title,
    text: desc,
    confirmBtnText: "OK",
    confirmBtnColor: Color.blue,
  );

Describe the solution you'd like

  QuickAlert.show(
    context: context,
    type: QuickAlertType.error,
    title: title,
    text: desc,
    confirmBtnText: "OK",
    confirmBtnHoverColor: Color.red,
    confirmBtnColor: Color.blue,
  );

Additional context

image image

dark theme support

Is your feature request related to a problem? Please describe.
add dark theme support

Describe the solution you'd like
Can use dark theme when application switched to dark mode

Describe alternatives you've considered
NONE

Additional context
NONE

Unable to load asset

Try in expample app

Another exception was thrown: Unable to load asset: packages/quickalert/assets/error.gif
Error while trying to load an asset: Failed to load asset at "assets/assets/error.gif" (404)
Another exception was thrown: Unable to load asset: assets/error.gif
Error while trying to load an asset: Failed to load asset at "assets/assets/confirm.gif" (404)
Another exception was thrown: Unable to load asset: assets/confirm.gif
Error while trying to load an asset: Failed to load asset at "assets/assets/loading.gif" (404)
Another exception was thrown: Unable to load asset: assets/loading.gif
Error while trying to load an asset: Failed to load asset at "assets/assets/loading.gif" (404)
Another exception was thrown: Unable to load asset: assets/loading.gif

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.