Template
chore: 初始化脚手架 — sunny_mochi 企业级 Flutter 模板
Core 基础设施:Flavor 三包体系、Drift+SQLCipher 加密数据库 7 拦截器 Dio 网络栈、CrashReporter 崩溃日志、Sealed Failure 错误体系 5 色板主题系统、Auth 认证骨架(Clean Architecture)、Dev Panel、Mock Adapter 通过验证:flutter analyze(0 errors)、flutter test(全绿)、staging APK 74.8MB
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:sunny_mochi/core/widgets/shell_scaffold.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sunny_mochi/features/auth/presentation/pages/login_page.dart';
|
||||
import 'package:sunny_mochi/features/dev_panel/presentation/pages/dev_panel_page.dart';
|
||||
import 'package:sunny_mochi/features/error_report/presentation/error_report_page.dart';
|
||||
|
||||
part 'routes.g.dart';
|
||||
|
||||
// ── StatefulShellRoute(底部导航 2 Tab)─────────────────────────────────────
|
||||
|
||||
@TypedStatefulShellRoute<ShellRouteData>(
|
||||
branches: [
|
||||
TypedStatefulShellBranch<HomeBranch>(
|
||||
routes: [TypedGoRoute<HomeRoute>(path: '/home')],
|
||||
),
|
||||
TypedStatefulShellBranch<MineBranch>(
|
||||
routes: [TypedGoRoute<MineRoute>(path: '/mine')],
|
||||
),
|
||||
],
|
||||
)
|
||||
class ShellRouteData extends StatefulShellRouteData {
|
||||
const ShellRouteData();
|
||||
|
||||
@override
|
||||
Widget builder(
|
||||
BuildContext context,
|
||||
GoRouterState state,
|
||||
StatefulNavigationShell shell,
|
||||
) =>
|
||||
ShellScaffold(shell: shell);
|
||||
}
|
||||
|
||||
class HomeBranch extends StatefulShellBranchData {
|
||||
const HomeBranch();
|
||||
}
|
||||
|
||||
class MineBranch extends StatefulShellBranchData {
|
||||
const MineBranch();
|
||||
}
|
||||
|
||||
// ── Shell 叶子路由(TODO: 业务项目替换为真实页面)───────────────────────────
|
||||
|
||||
class HomeRoute extends GoRouteData with $HomeRoute {
|
||||
const HomeRoute();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) => const Scaffold(
|
||||
body: Center(child: Text('Home — TODO: Replace with HomePage')),
|
||||
);
|
||||
}
|
||||
|
||||
class MineRoute extends GoRouteData with $MineRoute {
|
||||
const MineRoute();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) => const Scaffold(
|
||||
body: Center(child: Text('Mine — TODO: Replace with MinePage')),
|
||||
);
|
||||
}
|
||||
|
||||
// ── 独立路由(Shell 之外)────────────────────────────────────────────────────
|
||||
|
||||
@TypedGoRoute<LoginRoute>(path: '/login')
|
||||
class LoginRoute extends GoRouteData with $LoginRoute {
|
||||
const LoginRoute();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) =>
|
||||
const LoginPage();
|
||||
}
|
||||
|
||||
@TypedGoRoute<DevPanelRoute>(path: '/dev')
|
||||
class DevPanelRoute extends GoRouteData with $DevPanelRoute {
|
||||
const DevPanelRoute();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) =>
|
||||
const DevPanelPage();
|
||||
}
|
||||
|
||||
@TypedGoRoute<ErrorReportRoute>(path: '/error-report')
|
||||
class ErrorReportRoute extends GoRouteData with $ErrorReportRoute {
|
||||
const ErrorReportRoute();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) =>
|
||||
const ErrorReportPage();
|
||||
}
|
||||
Reference in New Issue
Block a user