Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overlay Manager

version license

Group and manage easily flutter overlays:

  • Create a new overlay with the barrier options
  • Arrange it in z-index order.
  • Check, close, and capture the return value when closed.

Getting started

dependencies:
  overlay_manager: '0.0.3'

Usage

import 'package:overlay_manager/overlay_manager.dart';

The GlobalOverlayManager helps you create and manage your overlay without context:

final navKey = GlobalKey<NavigatorState>();
final manager = GlobalOverlayManager(navigatorKey: navKey);
// ...

@override
Widget build(BuildContext context) {
  return MaterialApp(
    navigatorKey: navKey,
    // ...
  );
}

or uses the ContextOverlayManager:

final manager = ContextOverlayManager(context: context);

Show an overlay

  • For show an overlay:
final myEntry = manager.show(
  barrierColor: Colors.red.shade500.withOpacity(0.2),
  onDismiss: print,
  isDismissible: false,
  builder: (context, entry) => AlertMessage(
    onClose: () => entry.close(0),
  ),
);

call myEntry.close(0) to close this overlay with the returns value

  • If you want to close all overlay when the screen is disposed, let's try:
@override
void dispose() {
    manager.closeAll();
    super.dispose();
}

Rearrange

All the overlay entries in the OverlayManager will be arranged z-index by elevation value. Create a new entry with it's elevation:

final myEntry = manager.show(
    elevation: 1
    // ...
);

Or rearrange it (after create):

myEntry.rearrange(newElevation);

// or

myEntry.elevation = 1;
manager.rearrange();

Features and bugs

Please file feature requests and bugs at the issue tracker.

About

Group and Manage easily flutter overlays.

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages