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

套件詳情v3.2.0

flutter_zoom_drawer

一個帶有自定義側邊菜單(抽屜)實現的 Flutter 套件

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
5080
喜歡數
1100
Pub 分數
150

安裝套件

flutter pub add flutter_zoom_drawer

套件介紹

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

Flutter Zoom Drawer 是一個可自定義的側邊選單(抽屜)實作,適用於 Flutter 應用程式,提供流暢的縮放和滑動動畫。它支援多種螢幕尺寸和平台,為使用者提供增強的導航體驗。該套件允許開發者以最少的設定輕鬆整合響應式抽屜,非常適合現代應用程式介面。透過直覺的設定選項,它支援垂直和水平抽屜佈局,適用於各種設計需求。其輕量級特性確保在 Android、iOS、Web、macOS、Windows 和 Linux 上的效能表現。

適用情境

  • 移動應用導航
  • Web 儀表板佈局
  • 桌面應用程式選單
  • 可自定的側板
  • 互動式UI組件

主要特色

  • 平滑縮放和滑動動畫
  • 對多個平台的支援
  • 可自訂抽屜位置
  • 響應式設計整合
  • 易於使用的 API

適合對象

  • 尋求動畫抽屜的開發者
  • 需要現代導航模式的應用
  • 跨平台應用程式
  • UI 設計師想要靈活的抽屜選項
  • 具有複雜佈局要求的項目

使用建議

  • 可能需要為複雜主題添加額外的樣式
  • 在低階設備上使用大量內容時的效能影響
  • 對高級手勢的內建自訂功能有限
  • 不太適合簡單的靜態抽屜
  • 需要仔細處理嵌套導航器

原始 README

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

Flutter Zoom Drawer

pub package License: MIT

A Flutter package with custom implementation of the Side Menu (Drawer)

🌟 Getting Started

To start using this package, add flutter_zoom_drawer dependency to your pubspec.yaml

dependencies:
  flutter_zoom_drawer: "<latest_release>"

⚠ Version 3 Breaking Changes for Style

Old Style New Style
DrawerStyle.style1 DrawerStyle.defaultStyle
DrawerStyle.style2 DrawerStyle.defaultStyle
DrawerStyle.style3 DrawerStyle.defaultStyle
DrawerStyle.style4 DrawerStyle.style1
DrawerStyle.style5 DrawerStyle.style2
DrawerStyle.style6 DrawerStyle.style3
DrawerStyle.style7 DrawerStyle.style4

💪 Features

  • Simple sliding drawer
  • Sliding drawer with shadows
  • Sliding drawer with rotation
  • Sliding drawer with rotation and shadows
  • Support for both LTR & RTL

📌 Simple Example (Thanks to @JesusHdezWaterloo)

import 'package:flutter/material.dart';
import 'package:flutter_zoom_drawer/flutter_zoom_drawer.dart';
import 'package:get/get.dart';

void main() {
  Get.put<MyDrawerController>(MyDrawerController());

  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Zoom Drawer Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends GetView<MyDrawerController> {
  @override
  Widget build(BuildContext context) {
    return GetBuilder<MyDrawerController>(
      builder: (_) => ZoomDrawer(
        controller: _.zoomDrawerController,
        menuScreen: MenuScreen(),
        mainScreen: MainScreen(),
        borderRadius: 24.0,
        showShadow: true,
        angle: -12.0,
        drawerShadowsBackgroundColor: Colors.grey,
        slideWidth: MediaQuery.of(context).size.width * 0.65,
      ),
    );
  }
}

class MenuScreen extends GetView<MyDrawerController> {
  const MenuScreen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.yellow,
    );
  }
}

class MainScreen extends GetView<MyDrawerController> {
  const MainScreen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.pink,
      child: Center(
        child: ElevatedButton(
          onPressed: controller.toggleDrawer,
          child: Text("Toggle Drawer"),
        ),
      ),
    );
  }
}

class MyDrawerController extends GetxController {
  final zoomDrawerController = ZoomDrawerController();

  void toggleDrawer() {
    print("Toggle drawer");
    zoomDrawerController.toggle?.call();
    update();
  }
}

📝 Documentation

    ZoomDrawer(
      controller: ZoomDrawerController,
      style: DrawerStyle.defaultStyle,
      menuScreen: MenuScreen(),
      mainScreen: MainScreen(),
      borderRadius: 24.0,
      showShadow: true,
      angle: -12.0,
      drawerShadowsBackgroundColor: Colors.grey[300],
      slideWidth: MediaQuery.of(context).size.width*.65,
      openCurve: Curves.fastOutSlowIn,
      closeCurve: Curves.bounceIn,
    )
Parameters Value Required Docs
controller ZoomDrawerController No Controller to have access to the open/close/toggle function of the drawer
style DrawerStyle No the drawer style to be displayed (check the DrawerStyle enum)
mainScreen Widget Yes Screen containing the main content to display
menuScreen Widget Yes Screen containing the menu/bottom screen
slideWidth double No Sliding width of the drawer - defaults to 275.0
slideHeight double No Sliding height of the drawer - defaults to 0.0
mainScreenScale double No MainScreen scale - defaults to 0.3
borderRadius double No Border radius of the slided content - defaults to 16.0
angle double No Rotation angle of the drawer - defaults to -12.0 - should be 0.0 to -30.0
disableGesture bool No Disable the home page swipe to open drawer gesture - defaults to false
drawerShadowsBackgroundColor Color No Background color of the drawer shadows - defaults to white
showShadow bool No Boolean, whether to show the drawer shadows - defaults to false
openCurve Curve No open animation curve - defaults to Curves.easeOut
closeCurve Curve No close animation curve - defaults to Curves.easeOut
mainScreenTapClose bool No Close drawer when tapping mainScreen
mainScreenOverlayColor Color No Color of the main screen's cover overlay
overlayBlend BlendMode No The BlendMode of the mainScreenOverlayColor filter (default BlendMode.screen)
boxShadow BoxShadow No The Shadow of the mainScreenContent
overlayBlur double No The Blur amount of the mainScreen option
shrinkMainScreen bool No Shrinks the mainScreen by [slideWidth], good on desktop with Style2
drawerStyleBuilder DrawerStyleBuilder No Build custom animated style to override [DrawerStyle]

🕹️ Drawer Usage

To use the drawer, and be able to control it, there are 2 ways:

  • Using a ZoomDrawerController inside the main widget where you have the ZoomDrawer widget and providing it to the widget, which will allow you to trigger the open/close/toggle methods.
    final drawerController = ZoomDrawerController();

    drawerController.open();
    drawerController.close();
    drawerController.toggle();
    drawerController.isOpen();
    drawerController.stateNotifier;
  • Using the static method inside ancestor widgets to get access to the ZoomDrawer.
  ZoomDrawer.of(context).open();
  ZoomDrawer.of(context).close();
  ZoomDrawer.of(context).toggle();
  ZoomDrawer.of(context).isOpen();
  ZoomDrawer.of(context).stateNotifier;

Screens

Example app Demo

Example RTL Demo

  • Drawer Sliding
    ZoomDrawer(
      controller: ZoomDrawerController,
      menuScreen: MenuScreen(),
      mainScreen: MainScreen(),
      borderRadius: 24.0,
      showShadow: false,
      angle: 0.0,
      drawerShadowsBackgroundColor: Colors.grey[300],
      slideWidth: MediaQuery.of(context).size.width * 0.65,
    )

Drawer Sliding

  • Drawer Sliding with shadow
    ZoomDrawer(
      controller: ZoomDrawerController,
      menuScreen: MenuScreen(),
      mainScreen: MainScreen(),
      borderRadius: 24.0,
      showShadow: true,
      angle: 0.0,
      drawerShadowsBackgroundColor: Colors.grey[300],
      slideWidth: MediaQuery.of(context).size.width * 0.65,
    )

Drawer Sliding

  • Drawer Sliding with rotation
    ZoomDrawer(
      controller: ZoomDrawerController,
      menuScreen: MenuScreen(),
      mainScreen: MainScreen(),
      borderRadius: 24.0,
      showShadow: false,
      angle: -12.0,
      drawerShadowsBackgroundColor: Colors.grey[300],
      slideWidth: MediaQuery.of(context).size.width * 0.65,
    )

Drawer Sliding with rotation

  • Drawer Sliding with rotation and shadows
    ZoomDrawer(
      controller: ZoomDrawerController,
      menuScreen: MenuScreen(),
      mainScreen: MainScreen(),
      borderRadius: 24.0,
      showShadow: true,
      angle: -12.0,
      drawerShadowsBackgroundColor: Colors.grey[300],
      slideWidth: MediaQuery.of(context).size.width * 0.65,
    )

Drawer Sliding with rotation and shadows

Issues

Please file any issues, bugs or feature request as an issue on our GitHub page.

Want to contribute

If you would like to contribute to the plugin (e.g. by improving the documentation, solving a bug or adding a cool new feature), please carefully review our contribution guide and send us your pull request.

Credits

Credits goes to pedromassango as most of this package comes from his implementation.

所屬分類

原始碼儲存庫

使用此套件的專案