overlay_support 1.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 97

overlay_support #

Pub CI codecov

provider support for overlay, easy to build toast and internal notification.

this library support platform Android、iOS 、Linux、macOS、Windows and Web

Interation #

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
  1. wrap your AppWidget with OverlaySupport
  return OverlaySupport(child: MaterialApp());
  1. show toast or simple notifications
//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.

[1.0.2] - 2019/10/23

  • fix Toast hidden behind ime #20

[1.0.1] - 2019/7/26

  • swipe to dismiss #16
  • adjust default toast background #18

[1.0.0] - 2019/6/16

  • do not need pass context parameter to popup overlay

[0.3.0] - 2019/5/22

  • add key parameter for showOverlay

[0.2.0] - 2019/5/15

  • fix: call NotificationEntry#dismiss immediately when we showNotification cause an exception

[0.1.0] - 2019/3/5

  • expose showOverlay method to help build custom overlay
  • mark autoDismiss param as Deprecate, replace by duration param

[0.0.4] - 2019/3/2

  • bug fix

[0.0.3] - 2019/2/18

  • bug fix

[0.0.2] - 2019/2/17

  • remove line limit of toast

[0.0.1] - 2019/2/16

  • support notification
  • support toast

example/README.md

overlay_support_example #

example for overlay_support

Simple Usage #

popup a notification or toast:

showSimpleNotification(Text("this is a message from simple notification"),
                      background: Colors.green);

toast('this is a message from toast');

you can custom your notification widget to popup, for example:

showOverlayNotification((context) {
  return MessageNotification(
    message: 'i love you',
    onReplay: () {
      OverlaySupportEntry.of(context).dismiss(); //use OverlaySupportEntry to dismiss overlay
      toast(context, 'you checked this message');
    },
  );
class MessageNotification extends StatelessWidget {
  final VoidCallback onReplay;

  const MessageNotification({Key key, this.onReplay}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Card(
      margin: const EdgeInsets.symmetric(horizontal: 4),
      child: SafeArea(
        child: ListTile(
          leading: SizedBox.fromSize(
              size: const Size(40, 40),
              child: ClipOval(child: Image.asset('assets/avatar.png'))),
          title: Text('Lily MacDonald'),
          subtitle: Text('Do you want to see a movie?'),
          trailing: IconButton(
              icon: Icon(Icons.reply),
              onPressed: () {
                ///TODO i'm not sure it should be use this widget' BuildContext to create a Dialog
                ///maybe i will give the answer in the future
                if (onReplay != null) onReplay();
              }),
        ),
      ),
    );
  }
}

for example, we need create a iOS Style Toast.

  showOverlay((context, t) {
    return Opacity(
      opacity: t,
      child: IosStyleToast(),
    );
  });
class IosStyleToast extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: DefaultTextStyle(
        style: Theme.of(context).textTheme.body1.copyWith(color: Colors.white),
        child: Padding(
          padding: const EdgeInsets.all(16),
          child: Center(
            child: ClipRRect(
              borderRadius: BorderRadius.circular(10),
              child: Container(
                color: Colors.black87,
                padding: const EdgeInsets.symmetric(
                  vertical: 8,
                  horizontal: 16,
                ),
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  children: <Widget>[
                    Icon(
                      Icons.check,
                      color: Colors.white,
                    ),
                    Text('Succeed')
                  ],
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}

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.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  overlay_support: ^1.0.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:overlay_support/overlay_support.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
95
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
97
Learn more about scoring.

We analyzed this package on Dec 10, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.1+4
  • Flutter: 1.12.13+hotfix.4

Health suggestions

Fix lib/src/overlay.dart. (-0.50 points)

Analysis of lib/src/overlay.dart reported 1 hint:

line 156 col 19: 'ancestorWidgetOfExactType' is deprecated and shouldn't be used. Use findAncestorWidgetOfExactType instead. This feature was deprecated after v1.12.1..

Fix lib/src/overlay_entry.dart. (-0.50 points)

Analysis of lib/src/overlay_entry.dart reported 1 hint:

line 17 col 37: 'ancestorWidgetOfExactType' is deprecated and shouldn't be used. Use findAncestorWidgetOfExactType instead. This feature was deprecated after v1.12.1..

Fix lib/src/theme.dart. (-0.50 points)

Analysis of lib/src/theme.dart reported 1 hint:

line 53 col 20: 'inheritFromWidgetOfExactType' is deprecated and shouldn't be used. Use dependOnInheritedWidgetOfExactType instead. This feature was deprecated after v1.12.1..

Fix additional 4 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/notification/notification.dart (Run flutter format to format lib/src/notification/notification.dart.)
  • lib/src/notification/overlay_notification.dart (Run flutter format to format lib/src/notification/overlay_notification.dart.)
  • lib/src/overlay_animation.dart (Run flutter format to format lib/src/overlay_animation.dart.)
  • lib/src/toast/toast.dart (Run flutter format to format lib/src/toast/toast.dart.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
async ^2.1.0 2.4.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test