overlayment
आसानी से एक डायलॉग, नोटिफिकेशन, विंडो या पैनल दिखाएं। सहायक विजेट्स जैसे ऑटो कंप्लीट, एक्सपेंडर (ड्रॉपडाउन) का उपयोग करें।
इस पैकेज की सहायता से आप अपने प्रोजेक्ट में ओवरले का प्रबंधन कर सकते हैं। डायलॉग, नोटिफिकेशन, विंडो या पैनल आसानी से दिखाएं। या ऑटो-कम्पलीट, एक्सपेंडर (ड्रॉपडाउन) जैसे सहायक विजेट का उपयोग करें।
{"sdk":"flutter"}{"sdk":"flutter"}^2.0.0यह अंग्रेज़ी मूल स्नैपशॉट है। नवीनतम सामग्री GitHub पर देखें।
Logo
likes popularity pub points Online Example
This package will help you to manage the overlays in your projects. Show a dialog, notification, window, or a panel easily. or use one of the helping widgets like AutoComplete, Expander(Dropdown).
To start working with overlayment you need to give to it the NavigationKey at the application start or you need to give it the context every time you want to create a new overlayment.
@override
Widget build(BuildContext context) {
final key = GlobalKey<NavigatorState>();
Overlayment.navigationKey = key;
return MaterialApp(
navigatorKey: key,
...
);
}
Note: if you are using qlevar_router you can use the key property of the router to set the NavigationKey.
final router = QRouterDelegate(routes);
Overlayment.navigationKey = router.key;
return MaterialApp.router(
routeInformationParser: const QRouteInformationParser(),
routerDelegate: router,
);
To show an overlay you can use Overlayment.show(OverlayType()) or OverlayType().show() .
To dismiss an overlay you can use:
All these methods can take a result parameter if you want the overlay to return some value.
| Overlay | Example | Properties |
|---|---|---|
| OverDialog | example | properties |
| OverPanel | example | properties |
| OverNotification | example | properties |
| OverWindow | example | properties |
| OverAutoComplete | example | properties |
| OverExpander | example | properties |
and there is Common properties between all overlays.
Overlayment.show(
OverDialog(
child: Text('Hello world'),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Colors.white,
),
),
);
Overlayment.show(
OverPanel(
child: Text('This is a panel'),
alignment: Alignment.bottomCenter,
)
)
Overlayment.show(OverNotification(
child: Text('This is a notification'),
alignment: Alignment.topCenter,
color: Colors.blue.shade200,
));
OverNotification.simple(
title: 'User logged in',
).show();
OverNotification.simple(
title: 'Simple notification',
message: 'This is a simple notification',
icon: const Icon(Icons.info, color: Colors.green)
).show();
Overlayment.show(OverWindow(
position: Offset(50, 50),
canMove: true,
child: Text('This is a window'),
));
final result = await OverWindow.simple(message: 'Are you sure?').show<bool?>()
OverWindow.simple:
The widget is used to suggest options to the user based on the input.
OverAutoComplete<String>(
loadSuggestions: (q) async => store.where((element) => element.contains(q)).take(5).toList(),
suggestionsBuilder: (value) => Padding(
padding: const EdgeInsets.all(8.0),
child: Text(value),
),
initialValue: "5",
onSelect: (value) => print(value),
inputDecoration: const InputDecoration(labelText: 'Enter a number up to 100'),
),
Create a widget that can be expanded and collapsed as an overlay. This widget can be used for example to create a dropdown list.
OverExpander<int>(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Selected Index: $_index',
style: const TextStyle(fontSize: 18, decoration: TextDecoration.underline),
),
),
onSelect: (i) {
if (i != null) {
setState(() {
_index = i;
});
}
},
expandChild: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: List.generate(
10,
(index) => Padding(
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
onPressed: () {
Overlayment.dismissName<int>(_name, result: index);
},
child: Text(index.toString()),
),
),
),
),
),
)
A unique name for the overlay. If you don't set a name, the overlay will be named with the class name. You can use this name to close the overlay later
set custom actions to the overlay events.
The animation that will be used to show the overlay. You can use TODO
The overlay container decoration
The overlay background color. If the [decoration] is set, this property will be ignored.
the overlay margin
the time to keep the overlay open. When the time is over, the overlay will be closed automatically.If the value is null, the overlay will not be closed automatically.
You can use this class to set the background color and the background blur of the layer behind the overlay. if you set the dismissOnClick to true, the overlay will be dismissed when you on the background layer.