-
-
Notifications
You must be signed in to change notification settings - Fork 171
/
Copy pathroute.dart
50 lines (37 loc) · 1.16 KB
/
route.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import 'package:flutter/material.dart';
import 'package:namida/controller/navigator_controller.dart';
import 'package:namida/core/enums.dart';
class NamidaDummyPage extends StatelessWidget with NamidaRouteWidget {
@override
RouteType get route => RouteType.UNKNOWN;
const NamidaDummyPage({super.key});
@override
Widget build(BuildContext context) => const SizedBox();
}
mixin NamidaRouteWidget on Widget implements NamidaRoute {
@override
String? get name => null;
@override
bool isSameRouteAs(NamidaRoute r) => this.name == r.name && this.route == r.route;
}
abstract class NamidaRoute {
final RouteType route;
final String? name;
const NamidaRoute(
this.route,
this.name,
);
@override
String toString() => '(route: $route, name: $name)';
bool isSameRouteAs(NamidaRoute r);
@override
bool operator ==(covariant NamidaRoute other) {
if (identical(this, other)) return true;
return other.route == route && other.name == name;
}
@override
int get hashCode => route.hashCode ^ name.hashCode;
}
extension NamidaRouteWidgetUtils on NamidaRouteWidget {
Future<void> navigate() => NamidaNavigator.inst.navigateTo(this);
}