Code Monkey home page Code Monkey logo

overlay_support's Introduction

overlay_support

Pub Pub CI codecov

Provider support for overlay, make it easy to build toast and In-App notification.

this library support ALL platform

Interaction

If you want to see the ui effect of this library, just click here https://boyan01.github.io/overlay_support/#/

How To Use

  1. add dependencies into you project pubspec.yaml file

    dependencies:
        overlay_support: latest_version
    • the latest version is Pub
    • For project without migrate to null safety, please use version overlay_support: 1.0.5-hotfix1
  2. wrap your AppWidget with OverlaySupport

  return OverlaySupport.global(child: MaterialApp());
  1. show toast or simple notifications
import 'package:overlay_support/overlay_support.dart';

void onClick() {
    // popup a toast.
    toast('Hello world!');

    // show a notification at top of screen.
    showSimpleNotification(
        Text("this is a message from simple notification"),
        background: Colors.green);
}

more instructions check here : example/README.md

License

see License File

End

if you have some suggestion or advice, please open an issue to let me known. This will greatly help the improvement of the usability of this project. Thanks.

overlay_support's People

Contributors

boyan01 avatar elvisun avatar guillempuche avatar houdayec avatar ilyamax avatar leonidveremchuk avatar petro-i 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

overlay_support's Issues

Notifications are overlapping each other

I think by default, notifications should wait for an active notification to be dismissed before displaying the next one.

I can't see a case where someone would want to have a notification removed by another one without it running its course, honestly, so this behavior is a must!

notification not dismiss

有时候,顶部通知显示之后就不消失了,导致无法操作appbar上的按钮。希望能解决一下,我观察在ios上出现的概率比较高, 并且我在通知上加了手势监听也消失不小,应该是通知实例泄露了。

NotificationEntry showSimpleNotification2(BuildContext context, Widget content,
    {Widget leading,
    Widget subtitle,
    Widget trailing,
    EdgeInsetsGeometry contentPadding,
    Color background,
    Color foreground,
    bool autoDismiss = true}) {
  NotificationEntry entry;
  entry = showOverlayNotification(context, (context) {
    return Material(
      color: background ?? Theme.of(context)?.accentColor,
      elevation: 2,
      child: SafeArea(
          bottom: false,
          child: GestureDetector(
              onTap: () {
                entry?.dismiss();
              },
              child: ListTileTheme(
                textColor: foreground ?? Theme.of(context)?.accentTextTheme?.title?.color,
                iconColor: foreground ?? Theme.of(context)?.accentTextTheme?.title?.color,
                child: ListTile(
                  leading: leading,
                  title: content,
                  subtitle: subtitle,
                  trailing: trailing,
                  contentPadding: contentPadding,
                ),
              ))),
    );
  }, duration: Duration(milliseconds: 1000));
  return entry;
}

Add valid copyright information

Currently, in the LICENSE file, the copyright information is not correct. It literally reads (in line 189):

Copyright [yyyy] [name of copyright owner]

Could you please add a valid year and name?

implementing back pressed

is any solution for overlay support to implementing back pressed to close or dismiss notifications?

thanks

Migrate example to Android embedding v2

Description

The example of overlay_support isn't migrated to Android embedding v2 yet.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Warning
──────────────────────────────────────────────────────────────────────────────
Your Flutter application is created using an older version of the Android
embedding. It's being deprecated in favor of Android embedding v2. Follow the
steps at

https://flutter.dev/go/android-project-migration

to migrate your project.

Steps to reproduce

  1. Open example
  2. Run flutter pub get

set animate direction

in current implementation on library, animation control is top to bottom. how can i set direction to animate from bottom to top?

Thanks

getting The method 'ancestorWidgetOfExactType' isn't defined for the class 'BuildContext'.

Describe the bug
Running "flutter pub get" in safehandsfordoc... Launching lib\main.dart on Chrome in debug mode... lib\main.dart /D:/flutter/.pub-cache/hosted/pub.dartlang.org/overlay_support-1.0.5/lib/src/overlay.dart:156:19: Error: The method 'ancestorWidgetOfExactType' isn't defined for the class 'BuildContext'.

'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/D:/flutter/packages/flutter/lib/src/widgets/framework.dart'). Try correcting the name to the name of an existing method, or defining a method named 'ancestorWidgetOfExactType'. if (context.ancestorWidgetOfExactType(OverlaySupport) != null) { ^^^^^^^^^^^^^^^^^^^^^^^^^
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/overlay_support-1.0.5/lib/src/overlay_entry.dart:17:37: Error: The method 'ancestorWidgetOfExactType' isn't defined for the class 'BuildContext'.

'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/D:/flutter/packages/flutter/lib/src/widgets/framework.dart'). Try correcting the name to the name of an existing method, or defining a method named 'ancestorWidgetOfExactType'. final animatedOverlay = context.ancestorWidgetOfExactType(_AnimatedOverlay);

                         ^^^^^^^^^^^^^^^^^^^^^^^^^

/D:/flutter/.pub-cache/hosted/pub.dartlang.org/overlay_support-1.0.5/lib/src/theme.dart:53:20: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.

'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/D:/flutter/packages/flutter/lib/src/widgets/framework.dart'). Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'. return context.inheritFromWidgetOfExactType(OverlaySupportTheme) as OverlaySupportTheme;

        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Failed to compile application. Exited (sigterm)

To Reproduce
Steps to reproduce the behavior:

  1. just added in pubyaml
  2. returned OverlaySupport
  3. used showSimpleNotification

Version (please complete the following information):

  • Flutter Version: Flutter 1.26.0-17.2
  • OS: WEB
  • OverlaySupport Version : ^1.0.5

get callback from notification

you suppose i have textformfield on notification to get some information fro user, how can i get typed text from that?

Suggestion - duration

Add Duration parameter to showSimpleNotification method, so that it can be a chosen value instead of a fixed duration.

Is it possible to dismiss any pending previous overlay before firing a new one?

Is it possible to dismiss any pending previous overlay before firing a new one?

Sometimes I fire a loading overlay and then the operation gets completed fast and shows a new overlay stating success, but the previous overlay (the one with the loading label) is still there behind the new one has shown up.

I want to be able to dismiss any pending or any other overlay is present in screen before showing the new one. is this possible? How can this be achieved based on a main context.

[Feature Request] Swipe to dismiss

I was wondering if you have any plan to add a feature that can swipe an overlayed notification to dismiss.

Thank you for this awesome plugin.

The getter 'key' was called on null when trying to dismiss Notification

void _showDeletedSnackBar(String message, String itemCode, index,
      Map deletedItem, BuildContext context) {
    showSimpleNotification(Text(message),
        autoDismiss: true,
        position: NotificationPosition.bottom,
        leading: Icon(Icons.delete),
        background: Colors.redAccent,
        foreground: Colors.white,
        trailing: FlatButton(
          child: Text(
            'Recuperar',
            style: TextStyle(color: Colors.yellow),
          ),
          onPressed: () {
            OverlaySupportEntry.of(context).dismiss();
            context
                .read<CartDataProvider>()
                .addDeletedItemToCart(index, deletedItem);
          },
        ));
  }

Am I doing something wrong here?

OverlaySupport.local is not used on showSimpleNotification

It looks like OverlaySupport.global is always used even when there is a parent OverlaySupport.local widget.

I want to show a notification with showSimpleNotification under AppBar, so I wrap the Scaffold's body into OverlaySupport.local, but when calling showSimpleNotification from the body, the notification is showed over the AppBar.
I want to show it only over the body.

flutter android overlay_support doens't work on foreground

Describe the bug
I've an android app with flutter_webview_plugin (so a webapp), and if it is in foreground, every overlay widget (toast or showOverlayNotification) used doesn't show anything.
But on IOS all works perfectly.
I'm using firebase for notifications, and the onMessage event was called correctly. Inside the onMessage i would like to show the notification.

To Reproduce
Go to firebase console and send a notify to the token associated to the installed app

Expected behavior
on foreground, it should show a toast or similar widget for view the notification text

Screenshots

Version (please complete the following information):
Flutter 1.17.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f7a6a7906b (9 weeks ago) • 2020-05-12 18:39:00 -0700
Engine • revision 6bc433c6b6
Tools • Dart 2.8.2
OverlaySupport Version: 1.0.4
Android OS: 6.0

Additional context
I've tried to show a toast in other events also, but nothing works on foreground

Provide modal parameter to showSimpleNotification

Currently, in its simplest form - the quickest way to show a notification at the top of the screen is via showSimpleNotification. Without resorting to writing custom notification overlay, can we extend the showSimpleNotification to include an optional parameter

bool modal=true

This way - if Notifications are tied to (say) button taps - then repeated Notifications will not be shown because the first Notification at the top of the screen being MODAL will prevent this.

how can i showMessage inside view without clicking on button?

══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞══
The following assertion was thrown building Consumer<ConnectivityStatus>(dirty, dependencies:
[InheritedProvider<ConnectivityStatus>]):
visitChildElements() called during build.
The BuildContext.visitChildElements() method can't be called during build because the child list is
still being updated at that point, so the children might not be constructed yet, or might be old
children that are going to be replaced.

in this below code i'm trying to show message when internet connection is dissconnected:

 return Consumer<ConnectivityStatus>(
   builder: (context,isOnline,_){
     if (isOnline == ConnectivityStatus.Disconnected) {
       showSimpleNotification( Text( "$isOnline" ), background: Colors.green );
     }

but i get error

Add duration parameter

Add Duration parameter to showSimpleNotification method, so that it can be a chosen value instead of a fixed duration.

Dismiss showOverlayNotification Programmatically

How can I dismiss an OverlayNotification before showing another one?

I tried OverlaySupportEntry.of(context)?.dismiss(); before showing the notification but it doesn't show anything!

I tried to await OverlaySupportEntry.of(context)?.dismissed; but it gives an error, probably because there isn't any notification when calling it.

Is there any way to check if there's a notification showing before I call OverlaySupportEntry.of(context).dismiss(); ?

Thanks

Overlay Support Plugin not working in InitState Method

Describe the bug
When I tried to implement your plugin in initstate or start build state then occur error like VisitChildElements() called during build.

Expected behavior
I need show Notification on start the app or screen

Screenshots
Click to See the Error :
https://ibb.co/VptmtjM

Version (please complete the following information):

  • Flutter Version: [e.g. v2.2.3]
  • OS: Android
  • OverlaySupport Version : 1.2.1

disable autoDismiss for showOverlayNotification

how can i disable? it doesn't have any property to set that

showOverlayNotification((context) {
  return MessageNotification(
    message: messages[3],
    onReplay: () {
      OverlaySupportEntry.of(context).dismiss();
      toast('you checked this message');
    },
  );
}, duration: Duration(hours: 10));

dismiss notification on press

hello,

wonderful package and thank you.

Can you tell me please how i can dismiss the notification as soon as i press on it? I'm using the complex notification, not the simple one.

showOverlayNotification

Thanks.

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

Thank you for such a fantastic package. I spot an exception:

NoSuchMethodError: The method 'hide' was called on null.
Receiver: null
Tried calling: hide()
#0 NotificationEntry.dismiss (package:overlay_support/src/overlay_entry.dart:22)
#1 showOverlay.. (package:overlay_support/src/overlay.dart:43)
#2 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:988)
#3 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleBeginFrame. (package:flutter/src/scheduler/binding.dart:904)

Issue with RestartWidget.

Hi,
I use RestartWidget or PhoenixWidget with MaterialApp. I try to implement overlaysupport.global by following your guide and after that my restart function not work anymore.
Env:

  • Flutter channel master
  • overlay_support: 1.2.1

Please help!

Prevent simple notification from being displayed on specific pages

I am using the simple notification widget to present push notifications while the app is open. naturally, I do not want to present simple notifications notifying the user that they have a new chat message if the current active screen is displaying that chat message.

Because the simple notification function is a global function housed in the main.dart file outside of the material app widget, I have no access to context. How do I determine the current page before firing the simple notification?

Is it possible to dismiss notification without using context?

Is it possible to dismiss notifications without using context? I can show the notification just fine without context but i'm unsure how to dismiss it without context, is this possible?

Here is my code but as you can see its requiring context which at the point of calling this i don't have:

`showSimpleNotification(
Text("this is a message from simple notification"),
background: Colors.green,
autoDismiss: false,
trailing: FlatButton(onPressed: (){

        OverlaySupportEntry.of(context).dismiss();
      }, child: Text('dismiss')))`

calling showOverlayNotification from outside the widget tree

when combining overlay_support with packages like Firebase messaging to handle in app notifications you can run into the situation where you have a listener somewhere outside the widget tree, and you want to show a notification every time the listener fires. example:

_firebaseMessaging.configure(
    onBackgroundMessage: myBackgroundMessageHandler,
    onMessage: (Map<String, dynamic> message) async {
      myBackgroundMessageHandler(message);
    },
    onResume: (Map<String, dynamic> message) async {
      handleNotification(message, navigatorKey);
    },
    onLaunch: (Map<String, dynamic> message) async {
      handleNotification(message, navigatorKey);
    },
  );


Future<dynamic> myBackgroundMessageHandler(Map<String, dynamic> message) async {
  print('background message received');
  Map<String, dynamic> data = Map<String, dynamic>.from(message['data'] ?? message);

  if (data['type'] == 'chat') {
    if (user.isOnChatPage != data['id']) {
      print('popup');
      DocumentSnapshot chatRef = await db.collection('Chats').document(data['id']).get();
      showOverlayNotification(
        (BuildContext context) {
          return ChatNotification(
            document: chatRef,
          );
        },
        duration: Duration(milliseconds: 4000),
      );
    }
  }
}

in this case you get the error:
overlay not avaliable, dispose this call : null

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.