搜尋套件、儲存庫與 APP 分類

sweetsheet 封面
套件詳情v0.4.0

sweetsheet

快速輕鬆地顯示漂亮的底部彈出式對話框作為確認對話框。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
50
喜歡數
231
Pub 分數
140

安裝套件

flutter pub add sweetsheet

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Sweetsheet 是一個 Flutter 套件,讓開發者能快速且輕鬆地顯示吸引人的底部彈窗作為確認對話框。它透過最少的程式碼簡化了建立模態底部彈窗的過程,開箱即用提供乾淨現代的使用者介面。此套件專為跨多個平台的無縫整合而設計,支援 Android、iOS、Web、macOS、Windows 與 Linux。該套件透過提供順暢的動畫與可自訂的版面來增強使用者體驗,同時維持設計上的簡潔與一致性。

適用情境

  • 快速確認對話方塊
  • 用戶操作提示
  • 表單提交確認
  • 模態導航
  • 簡單的彈出式介面

主要特色

  • 易於使用的 API
  • 漂亮的預設樣式
  • 跨平台支援
  • 可自訂內容
  • 平滑動畫
  • 最小化樣板程式碼

適合對象

  • 尋求快速底部抽屜實作的開發者
  • 需要輕量級確認對話方塊的專案
  • 具有一致 UI 範式之應用程式
  • 重視開發速度的團隊
  • Flutter 初學者探索底部表單

使用建議

  • 超出基本樣式之外的自訂功能有限
  • 不適合複雜的互動式表單
  • 依賴外部相依性以實現完整功能
  • 最適合簡單使用案例,而非進階對話方塊

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

sweetsheet

Show beautiful bottom sheet as confirmation dialog quickly and easily.

nice warning
nice warning
success danger
success danger

and since version 0.2.0 , it is fully customizable.

custom dark custom light
success danger

Getting Started

With increasingly large smartphones, it has become almost impossible to have good ergonomics in an application using confirmation dialogs. The SweetSheet package allows you to show beautiful bottoms sheets to replace your confirmation dialogs and maintain a good user experience.

How to use?

Add this to your package's pubspec.yaml file:

dependencies:
  sweetsheet: ^0.4.0

And import it:

import 'package:sweetsheet/sweetsheet.dart';

to start using the sheets, you have to create the instance of the SweetSheet class first.

final SweetSheet _sweetSheet = SweetSheet();

Now you can show the bottom sheet by calling the method show() on the instance. This is the signature of the show method

  show({
    required BuildContext context,
    Text? title,
    required Text description,
    required CustomSheetColor color,
    required SweetSheetAction positive,
    EdgeInsets? contentPadding = const EdgeInsets.symmetric(horizontal: 24.0, vertical: 24.0),
    EdgeInsets? actionPadding = const EdgeInsets.all(8.0),
    SweetSheetAction? negative,
    IconData? icon,
    bool useRootNavigator = false,
    bool isDismissible = true,
  }) {}

This is the signature of the SweetSheetAction widget.

class SweetSheetAction extends StatelessWidget {
  final String title;
  final VoidCallback onPressed;
  final IconData icon;
  final Color color;

  SweetSheetAction({
    @required this.title,
    @required this.onPressed,
    this.icon,
    this.color = Colors.white,
  });  
}

Attention : At least one action is required and the icons are IconData for uniformity purpose.

The SweetSheetColor is a class which have four static values and it determine the color of the sheet by creating a CustomSheetColor:

  • SweetSheetColor.SUCCESS (green)
  • SweetSheetColor.DANGER (red)
  • SweetSheetColor.WARNING (orange)
  • SweetSheetColor.NICE (blue)

Customisation

To customise, create a new instance of CustomSheetColor and pass it to the argument color when calling the method show. signature of CustomSheetColor:

class CustomSheetColor {
  Color main;
  Color accent;
  Color icon;

  CustomSheetColor({@required this.main, @required this.accent, this.icon});
}

To customise the action, pass a new color to color argument of SweetSheetAction.

Example:

Warning
_sweetSheet.show(
    context: context,
    title: Text("Attention"),
    description: Text(
        'Your app is not connected to internet actually, please turn on Wifi/Celullar data.'),
    color: SweetSheetColor.WARNING,
    icon: Icons.portable_wifi_off,
    positive: SweetSheetAction(
      onPressed: () {
        Navigator.of(context).pop();
      },
      title: 'OPEN SETTING',
      icon: Icons.open_in_new,
    ),
    negative: SweetSheetAction(
      onPressed: () {
        Navigator.of(context).pop();
      },
      title: 'CANCEL',
    ),
);
Custom Light
_sweetSheet.show(
    context: context,
    description: Text(
      'Place your order. Please confirm the placement of your order : Iphone X 128GB',
      style: TextStyle(color: Color(0xff2D3748)),
    ),
    color: CustomSheetColor(
      main: Colors.white,
      accent: Color(0xff5A67D8),
      icon: Color(0xff5A67D8),
    ),
    icon: Icons.local_shipping,
    positive: SweetSheetAction(
      onPressed: () {
        Navigator.of(context).pop();
      },
      title: 'CONTINUE',
    ),
    negative: SweetSheetAction(
      onPressed: () {
        Navigator.of(context).pop();
      },
      title: 'CANCEL',
  ),
);
That is all. Have fun!

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。