| 1234567891011121314151617181920212223242526272829303132 |
- import 'package:flutter/material.dart';
- import 'package:flutter_riverpod/flutter_riverpod.dart';
- /// 页面覆盖导航栏返回按钮的 Provider。
- /// 页面在 build 中设置:`ref.read(pageBackProvider.notifier).state = () => _doPop();`
- final pageBackProvider = StateProvider<VoidCallback?>((ref) => null);
- /// NavBar 配置——纯数据类,由路由层在 AppScaffold.navConfig 中声明式传入。
- ///
- /// 不再需要 Provider 中转:AppScaffold 直接消费,同步渲染,无延迟。
- class NavBarConfig {
- final String title;
- final bool showBack;
- final bool showRight;
- final Widget? rightWidget;
- final VoidCallback? onBack;
- final IconData? leadingIcon;
- const NavBarConfig({
- this.title = '',
- this.showBack = false,
- this.showRight = false,
- this.rightWidget,
- this.onBack,
- this.leadingIcon,
- });
- /// 根页面默认配置(无返回按钮)
- static const home = NavBarConfig(title: '', showBack: false);
- static const messages = NavBarConfig(title: '', showBack: false);
- static const profile = NavBarConfig(title: '', showBack: false);
- }
|