overlay_manager 0.0.2 copy "overlay_manager: ^0.0.2" to clipboard
overlay_manager: ^0.0.2 copied to clipboard

Group and manage easily flutter overlays: Create a new overlay, arrange it in z-index order, check, close, and capture the return value when closed.

Overlay Manager #

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.

Import #

import 'package:overlay_manager/overlay_manager.dart';

Create #

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);

Using #

  • 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.

5
likes
0
points
116
downloads

Publisher

unverified uploader

Weekly Downloads

Group and manage easily flutter overlays: Create a new overlay, arrange it in z-index order, check, close, and capture the return value when closed.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on overlay_manager