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

套件詳情v0.3.0

custom_navigator

一個 Flutter 套件,讓您輕鬆在小部件樹中的任何位置建立自己的導航器。

近 30 天下載
107
喜歡數
51
Pub 分數
40

安裝套件

flutter pub add custom_navigator

套件介紹

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

一個 Flutter 套件,可簡化在 widget 樹的任何部分建立自訂導航器的過程。它允許開發人員獨立於應用程式主要導航器定義和管理導航邏輯,從而實現模組化和可重複使用的導航元件。適用於具有巢狀或動態導航流程的複雜 UI,有助於實現關注點分離並提升可測試性。此套件輕量且設計靈活,無需深入整合至應用程式的核心結構中。

適用情境

  • 在大型應用中構建模組化導航
  • 在小部件中建立巢狀導航
  • 實現動態路由管理
  • 啟用可重複使用的導航組件
  • 測試導航邏輯的獨立性

主要特色

  • 輕鬆整合到小部件樹中的任何位置
  • 支援自訂路由定義
  • 促進可重用的導航邏輯
  • 最小化樣板
  • 獨立於主導航器工作

適合對象

  • 開發複雜導航模式的開發者
  • 需要模組化UI架構的團隊
  • 具有動態或嵌套導航的應用程式
  • 測試驅動開發工作流程
  • 需要內部導航的自定義 UI 組件

使用建議

  • 不打算作為 MaterialApp.router 的替代品
  • 在多個上下文中使用時需要仔細管理狀態
  • 如果在簡單應用中過度使用,可能會增加複雜性
  • 與內建導航器相比,平台特定功能較少

原始 README

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

Custom navigator

A flutter package that makes it easy to create your own navigator anywhere in the widget tree.

A common use for such widget is when you need to implement an "Always presenting bottom navigation bar"

Getting Started

First you need to add the package to your pubspec.yaml file.

Custom scaffold

CustomScaffold is a stateful widget that uses the CustomNavigator to to handle item transition of [BottomNavigationBar] with nested navigation while keeping the [BottomNavigationBar] visible!

Usage
// Here's the custom scaffold widget
// It takes a normal scaffold with mandatory bottom navigation bar
// and children who are your pages
CustomScaffold(
      scaffold: Scaffold(
        bottomNavigationBar: BottomNavigationBar(
          items: _items,
        ),
      ),

      // Children are the pages that will be shown by every click
      // They should placed in order such as
      // `page 0` will be presented when `item 0` in the [BottomNavigationBar] clicked.
      children: <Widget>[
        Page('0'),
        Page('1'),
        Page('2'),
      ],

      // Called when one of the [items] is tapped.
      onItemTap: (index) {},
    );

See the custom_scaffold_example for more details


Custom navigator

The CustomNavigator is fairly easy to use

Usage

CustomNavigator(
        home: YourChildWidget(),
        //Specify your page route [PageRoutes.materialPageRoute] or [PageRoutes.cupertinoPageRoute]
        pageRoute: PageRoutes.materialPageRoute,
      );

Then you can call it using the same old Navigator.of(context)

Options
  • you can specify Named routes exactly like in MaterialApp.

if you want to use the default [Navigator] you need to specify a [GlobalKey] to your [MaterialApp] and use it navigatorKey.currentState

See the example for more details.

所屬分類

原始碼儲存庫

使用此套件的專案