🏠 Home

Zero Adaptive Link

One tap. Every platform does the right thing.

Adaptive navigation for Flutter: write one onTap and the plugin decides by window width whether to push a new page (mobile) or expand a sidebar pane (web and desktop). URL-addressable, deep-linkable, zero runtime dependencies.

一套 onTap,任意平台都做出正确行为。

Flutter 的自适应导航:只写一套 onTap,插件按窗口宽度决定移动端推入新页面、Web 与桌面端展开侧栏 pane。URL 可寻址、可深链、零运行时依赖。

✨ Features / 功能特性

FeatureDescription
One onTapZeroLink or ZeroNav — the same tap adapts per width / 同一套点击按宽度自适应
Window-width breakpoints600 / 840 by window width, not device type / 断点按窗口宽度而非设备类型
Master-detail panesSlide-in detail, parallax master, draggable resize handle / detail 右滑入、master 视差、可拖拽分割线
Idempotent focusTapping a visible pane focuses it / 点击已可见 pane 时聚焦而非重复展开
Deep linksHash strategy on web, browser back works / Web hash 策略,浏览器返回可用
Declarative route tableNested routes, :param, redirects, onExit, fullscreen / 嵌套路由、参数、重定向、退出钩子、全屏覆盖
Nested shellsA ZeroRoute hosts its own ZeroShell via shell + shellBuilder / 路由可通过 shell + shellBuilder 承载自己的 ZeroShell
Real web anchorsZeroAnchor renders a genuine DOM <a href>; canonicalHref shares it / ZeroAnchor 渲染真正的 DOM <a href>;canonicalHref 返回可分享链接
Scroll & focus restorationOffsets and focus survive breakpoint crossings and history / 滚动偏移与焦点跨断点、跨历史保留
Navigator-shaped verbspushNamed / pop / maybePop / popUntil / canPop / 与 Navigator 同名同签名
Zero runtime depsPure Dart, no platform channels / 纯 Dart,无 platform channel
Layout standaloneSlidingPanes / SlidingPane / Breadcrumbs usable alone / 布局组件可单独使用

🚀 Quick start / 快速开始

import 'package:flutter/material.dart';
import 'package:zero_adaptive_link/zero_adaptive_link.dart';
 
void main() => runApp(MaterialApp.router(routerConfig: myRouter));
 
// Declarative: wrap any tappable widget. / 声明式:包裹任意可点击组件。
final tile = ZeroLink(
  location: '/products/42',
  child: const ListTile(title: Text('Product 42')),
);
 
// Imperative: from any callback. / 命令式:任意回调中均可使用。
void open(BuildContext context) => ZeroNav.of(context).open('/products/42');

📚 Table of Contents / 目录

PageDescription
Getting Started60-second integration / 60 秒接入
Installationpub.dev & GitHub / 安装方式
UsageZeroLink / ZeroNav entry points / 两种入口
Adaptive BehaviorBehavior matrix, breakpoints, pane semantics / 行为矩阵、断点、pane 语义
Route TableZeroRoute / ZeroShell / ZeroTab / 路由表
NavigationVerbs, pop semantics, exit confirmation / 导航动词、pop 语义、退出确认
Layout Without RouterSlidingPanes standalone / 单独使用布局组件
FAQCross-breakpoint rebuilds, overlays, hash strategy / 跨断点重建、覆盖层、hash 策略

📄 License / 许可证

This project is licensed under the Mozilla Public License 2.0 (MPL-2.0).

本项目采用 Mozilla Public License 2.0 (MPL-2.0) 许可证。

This plugin is provided “as is”, without warranty of any kind. The author assumes no responsibility or liability for the functionality, security, or any consequences arising from the use of modified versions or derivative projects.

本插件按”原样”提供,不提供任何担保。作者不对修改版或衍生项目的功能、安全性及任何使用后果承担责任。