FLUTTER ECOSYSTEM

shirne/shirne_dialog

一个可自定义主题的对话框(警告、确认、提示、Toast 等)Flutter 包

shirne_dialog 项目封面
Stars
18
Forks
2
最近推送(UTC)
2025年12月31日
项目状态
未归档
shirne GitHub avatar
GITHUB User

shirne ↗

Flutter/PHP/Java/.NET/Vue

语辰软件中国广东惠州官方网站 ↗
语言DartC++CMakeSwiftHTMLCKotlinObjective-C

技术话题

此仓库发布的插件

使用的依赖

依赖清单 4 项
  • flutter{"sdk":"flutter"}
  • combined_animation>=0.3.1 <1.0.0
  • flutter_test开发依赖{"sdk":"flutter"}
  • flutter_lints开发依赖

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

展开 / 收起项目 README

Shirne Dialog

A flutter package to use alert, confirm, prompt, toast, popup, snack, imagePreview, loading etc. with customizable style in anywhere.

pub package

Features

  • ✅ toast

  • ✅ alert

  • ✅ confirm

  • ✅ prompt [new]

  • ✅ modal

  • ✅ popup

  • ✅ imagePreview

  • ✅ snack

  • ✅ loading

  • ✅ dropdown [new]

  • 🚧 imagePreview support hero

  • 🚧 modal adaptive & more style

  • 🚧 guide

Notice

You must initialize ShirneDialogTheme on theme.extensions between flutter version 3.0.0 - 3.0.4

Above 3.0.5 dialog will use default theme when not provide in ThemeData.extends

Preview

Online Demo

Toast Dialog ImagePreview
toast dialog imagePreview
Loading Popup Snackbar
loading popup snack
Dropdown Dropdown Customize
loading popup snack

Usage

add localizations

dependencies:
    #...
  flutter_localizations:
    sdk: flutter
    #...

Recommanded usage


// Use Mydialog.navigatorKey with MaterialApp
// and set theme for dialog
MaterialApp(
    // ...
    navigatorKey: MyDialog.navigatorKey,
    localizationsDelegates:[
        ShirneDialogLocalizations.delegate,

        // flutter locals see [https://docs.flutter.dev/development/accessibility-and-localization/internationalization]
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
    ],
    theme: ThemeData.light().copyWith(extensions: [const ShirneDialogTheme()]);
    // ...
);

// Use with MaterialApp.router
MaterialApp.router(
    routerDelegate: AppRouterDelegate(),
);
class AppRouterDelegate<T> extends RouterDelegate<T> with PopNavigatorRouterDelegateMixin{
  
  @override
  GlobalKey<NavigatorState>? get navigatorKey => MyDialog.navigatorKey;

  // ...
}

// Use with Getx
MyDialog.navigatorKey = Get.key;
 

// call in anywhere
MyDialog.confirm('aaa');
MyDialog.alert('test');
MyDialog.toast('test');

In 2.x and earlier


MyDialog.of(context).toast('tip message');

MyDialog.of(context).alert(Text('alert message'));

MyDialog.of(context).confirm(Text('alert message')).then((v){

});

MyDialog.of(context).popup(Text('popup contents'));

MyDialog.of(context).snack('tip');


// initialize in MaterialApp
 MaterialApp(
    //...
    navigatorKey: MyDialog.navigatorKey,
    //...
);

// and then call in anywhere
MyDialog.confirm('aaa');
MyDialog.alert('test');
MyDialog.toase('test');