46 lines
1.3 KiB
Dart
46 lines
1.3 KiB
Dart
import 'package:cutdex/l10n/l10n.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
|
|
|
import '../../features/projects/projects_page.dart';
|
|
import '../../features/settings/settings_page.dart';
|
|
|
|
part 'app_router.g.dart';
|
|
|
|
// The router is an application resource, independent of editor state changes.
|
|
@Riverpod(keepAlive: true)
|
|
GoRouter appRouter(Ref ref) {
|
|
final router = GoRouter(
|
|
routes: [
|
|
GoRoute(
|
|
path: '/',
|
|
builder: (context, state) => const EditingPage(),
|
|
routes: [
|
|
GoRoute(
|
|
path: 'settings',
|
|
builder: (context, state) => SettingsPage(
|
|
initialTab:
|
|
(int.tryParse(state.uri.queryParameters['tab'] ?? '') ?? 0)
|
|
.clamp(0, 2),
|
|
workspace: state.extra is (String, String)
|
|
? state.extra as (String, String)
|
|
: null,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
errorBuilder: (context, state) => Scaffold(
|
|
body: Center(
|
|
child: FilledButton(
|
|
onPressed: () => context.go('/'),
|
|
child: Text(context.l10n.backToProjects),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
ref.onDispose(router.dispose);
|
|
return router;
|
|
}
|