Giter Site home page Giter Site logo

yako-dev / flutter-status-alert Goto Github PK

View Code? Open in Web Editor NEW
131.0 4.0 9.0 2.75 MB

Display Apple system-like self-hiding status alerts. It is well suited for notifying user without interrupting user flow.

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

License: Apache License 2.0

Kotlin 0.52% Swift 1.69% Objective-C 0.15% Dart 96.89% HTML 0.75%
flutter dart mobile android ios ui ui-components widget alert status

flutter-status-alert's Introduction

Status Alert for Flutter

Pub Version

Installing:

In your pubspec.yaml

dependencies:
  status_alert: ^1.0.1
import 'package:status_alert/status_alert.dart';

Basic Usage:

    StatusAlert.show(
      context,
      duration: Duration(seconds: 2),
      title: 'Title',
      subtitle: 'Subtitle',
      configuration: IconConfiguration(icon: Icons.done),
      maxWidth: 260,
    )


Apple Podcasts vs Status Alert:


License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details

flutter-status-alert's People

Contributors

m-ixai-l avatar sawel24 avatar yadaniyil 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

flutter-status-alert's Issues

Dismiss popup on touch

How do we make the popup dismiss itself on touch registered anywhere on the screen and at the same time make the rest of the screen inactive while the popup is alive?

Error: Cannot run with sound null safety, because the following dependencies

Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:

  • package:status_alert
  • package:flare_flutter
  • package:flare_dart

For solutions, see https://dart.dev/go/unsound-null-safety

FAILURE: Build failed with an exception.

  • Where:
    Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1005

  • What went wrong:
    Execution failed for task ':app:compileFlutterBuildDebug'.

Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1

  • 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 47s
Exception: Gradle task assembleDebug failed with exit code 1

How to run StatusAlert.show() in background

I want to display a alert notification using StatusAlert.show(.........) in Flutter.The problem is I can run it foreground(it can be shown only over the current build context) but I want to run the StatusAlert's notification in background.The Alert is actually called when a countdown timer reaches zero.Can anyone suggest me how.

import 'package:android_alarm_manager/android_alarm_manager.dart';
import 'package:flutter/material.dart';
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:intl/intl.dart';
import 'package:flushbar/flushbar.dart';
import 'package:status_alert/status_alert.dart';
import 'CommonPicker.dart';
import 'fileUtils.dart';
import 'package:firebase_messaging/firebase_messaging.dart';

Future myBackgroundMessageHandler(Map<String, dynamic> message) {
if (message.containsKey('data')) {
// Handle data message
final dynamic data = message['data'];
}

if (message.containsKey('notification')) {
// Handle notification message
final dynamic notification = message['notification'];
}

// Or do other work.
}

void status_bar() {

StatusAlert.show(
context,
blurPower: 0.1,
duration: Duration(seconds: 5),
title: 'Hey',
subtitle: 'Message:XXXXXXXXXXXXXXXXXXXXXXXXXX ',
configuration: IconConfiguration(icon: Icons.warning),
);
}
//
//FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
//
//initializeNotification()async {
// var initializeAndroid = AndroidInitializationSettings(
// 'ic_launcher');
// var initializeIOS = IOSInitializationSettings();
// var initSettings = InitializationSettings(initializeAndroid, initializeIOS);
// await flutterLocalNotificationsPlugin.initialize(initSettings);
//}
//
//Future singleNotification(DateTime dateTime,String message,String subtext,int hashcode,{String sound}) async {
// var androidChannel = AndroidNotificationDetails(
// 'channel-id', 'channel-name', 'channel-description',
// importance: Importance.Max, priority: Priority.Max,enableVibration: true,visibility:NotificationVisibility.Public );
// var iosChannel = IOSNotificationDetails();
// var platformChannelSpecifics = NotificationDetails(androidChannel, iosChannel);
// await flutterLocalNotificationsPlugin.show(0, message, subtext, platformChannelSpecifics,);
//}

Future callback() async {
print("I am in the isolate");

// DateTime now=DateTime.now().toLocal();

status_bar();

// await singleNotification(now, "notification" , "This is the message", 98123871);
print("last line of Isolate");
}

class AlertTime2 extends StatefulWidget {
static const routeName = '/alertTime2';

@OverRide
_AlertTime2State createState() => _AlertTime2State();
}

class _AlertTime2State extends State {
String mm = "00";
String ss = "00";
var mmValue;
var ssValue;
var totalTimeInSec;
Flushbar flush;
String _selectedTime;

final FirebaseMessaging _messaging = FirebaseMessaging();

@OverRide
void initState() {
super.initState();

//initializeNotification();

_messaging.getToken().then((token) {
  print("token is :" + token);
});

FileUtils().readFromFile().then((String value) {
  setState(() {
    _selectedTime = value;
  });
});

}

// ignore: non_constant_identifier_names
void display_flush_bar() {
Future.delayed(Duration(seconds: totalTimeInSec), () {
setState(() {
flush = Flushbar(
title: "Hey",
message:
"XXXXXXXXXXXXXXXXXXXXxx",
duration: Duration(seconds: 5),
isDismissible: true,
icon: Icon(
Icons.warning,
color: Colors.red,
),
dismissDirection: FlushbarDismissDirection.HORIZONTAL,
mainButton: FlatButton(
onPressed: () {
flush.dismiss(true);
},
child: Text(
"CANCEL",
style: TextStyle(color: Colors.amber),
),
),
)..show(context);
});
});
}

void alarm_managing_function(int t) async {
await AndroidAlarmManager.initialize();
await AndroidAlarmManager.periodic(Duration(seconds: t), 0, callback);
}

@OverRide
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
Padding(
padding: const EdgeInsets.fromLTRB(30, 70, 0, 0),
child: Text(
"Timer for Notification",
style: TextStyle(
fontSize: 50,
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(0, 150, 0, 0),
child: Text(
"MM-SS",
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.bold,
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
child: Text(
"${_selectedTime ?? 'Selected Time'}",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 38),
),
),
RaisedButton(
onPressed: () {
DatePicker.showPicker(context,
showTitleActions: true,
pickerModel:
CustomPicker(currentTime: DateTime.tryParse(_selectedTime)),
onConfirm: (time) {
setState(() {
print(time);
_selectedTime = DateFormat("mm-ss").format(time);
FileUtils().saveToFile(_selectedTime);

            mm = _selectedTime.substring(0, 2);
            ss = _selectedTime.substring(3, 5);
            print(mm);
            print(ss);
            mmValue = int.parse(mm);
            ssValue = int.parse(ss);
            totalTimeInSec = mmValue * 60 + ssValue;
            print(totalTimeInSec);

            display_flush_bar();
            alarm_managing_function(totalTimeInSec);
          });
        }, locale: LocaleType.en);
      },
      child: Text("Show Time picker"),
    ),
  ],
));

}
}

Screen Actions Blocked

Hi, I'm currently using package v. ^1.0.1

At this moment, on alert spawn, if it's not touched, it blocks screen's gestures as soon as the screen gets clicked.

Any idea about?

type 'Color' is not a subtype of type 'bool'

I had to fix this by putting brackets around the ternary operator - not sure but it looks like the ternary operator has higher precedence than the ?? operator causing this error

widget.subtitleOptions.style.color ?? Theme.of(context).brightness == Brightness.light ? lightAccent : darkAccent

Should read

widget.subtitleOptions.style.color ?? (Theme.of(context).brightness == Brightness.light ? lightAccent : darkAccent)

Notice the brackets added to the ternary operator to fix the 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.