A Flutter package that allows you to display custom pop-up elements through the Overlay
without needing to wrap your Scaffold
. It can be controlled through a custom controller, making it easy to show and hide overlay popups dynamically.
- Display custom popups on top of your current screen via
Overlay
. - No need to wrap
Scaffold
, the popups can be shown independently. - Controlled through a custom controller, enabling dynamic visibility and interactions.
To use overlay_popup_entry
, add it to your pubspec.yaml
file:
dependencies:
overlay_popup_entry: ^1.0.0
Then run flutter pub get
to install the package.
- Import the package in your Dart file:
import 'package:overlay_popup_entry/overlay_popup_entry.dart';
- Create an instance of
OverlayPopupController
:
final overlayController = OverlayPopupController();
- Use the controller to show or hide the popup:
overlayController.show(
child: YourContent()
); // Show the popup
overlayController.hide(); // Hide the popup
- Create your custom popup widget and pass it to the controller as needed.
Here's a simple example of how to use the OverlayPopup
in your app:
import 'package:flutter/material.dart';
import 'package:overlay_popup_entry/overlay_popup_entry.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
final OverlayPopupController _popupController = OverlayPopupController();
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('Overlay Popup Example')),
body: Center(
child: ElevatedButton(
onPressed: () {
_popupController.show(
child: YourContent()
); // Show the popup
},
child: Text('Show Popup'),
),
),
),
);
}
}
In this example, tapping the "Show Popup" button will display the popup, which can be controlled through the OverlayPopupController
.
- For detailed documentation, check the official Flutter documentation.
- To contribute, fork the repository, create a branch, and submit a pull request.
- For any issues or feature requests, open an issue on the repository's GitHub page.
Happy coding!