Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/crazelu/dialog-manager
A Flutter package that allows for neater declaration, abstraction and use of customisable dialogs.
https://github.com/crazelu/dialog-manager
Last synced: 25 days ago
JSON representation
A Flutter package that allows for neater declaration, abstraction and use of customisable dialogs.
- Host: GitHub
- URL: https://github.com/crazelu/dialog-manager
- Owner: Crazelu
- License: mit
- Created: 2022-01-19T22:32:24.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-31T21:50:29.000Z (over 2 years ago)
- Last Synced: 2024-10-03T07:22:20.701Z (about 1 month ago)
- Language: Dart
- Homepage:
- Size: 216 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## flutter_dialog_manager
A Flutter package that allows for neater declaration, abstraction and use of customisable dialogs.
## Install
In the `pubspec.yaml` of your flutter project, add the following dependency:
```yaml
dependencies:
flutter_dialog_manager: ^1.0.0+4
```Import the package in your project:
```dart
import 'package:flutter_dialog_manager/flutter_dialog_manager.dart';
```## Getting started
Wrap your MaterialApp widget with a `DialogManager`
and pass the required `GlobalKey navigatorKey` parameter.
Also pass the navigator key to `MaterialApp`.```dart
@override
Widget build(BuildContext context) {
return DialogManager(
navigatorKey: _navigatorKey,
child: MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
navigatorKey: _navigatorKey,
home: const MyHomePage(title: 'Flutter Demo Home Page'),
),
)
```## Usage
Declare dialog UI implementations and their associated route names with `onGenerateDialog` or `dialogRoutes`
```dart
onGenerateDialog: (settings) {
switch (settings.name) {
case "/counter":
if (settings.arguments != null) {
return CounterDialog(
counter: settings.arguments as int,
);
}
break;
}}
``````dart
dialogRoutes: {
"/": (context) => DefaultDialog(),
"/home": (context) => HomeDialog(),
}
```Show dialog in your UI
```dart
DialogManager.of(context).showDialog(
routeName: "/counter",
arguments: _counter,
);
```Explore detailed examples [here](https://github.com/Crazelu/dialog-manager/tree/main/example).
## Contributions
Feel free to contribute to this project.
If you find a bug or want a feature, but don't know how to fix/implement it, please fill an [issue](https://github.com/Crazelu/dialog-manager/issues).
If you fixed a bug or implemented a feature, please send a [pull request](https://github.com/Crazelu/dialog-manager/pulls).