listeners = {};
8 |
9 | static void addListener(void onFunc(dynamic data)) {
10 | listeners[onFunc] = _appManageListener.stream.listen(onFunc);
11 | }
12 |
13 | static void removeListener(void onFunc(dynamic data)) {
14 | StreamSubscription? listener = listeners[onFunc];
15 | if(listener == null) return;
16 | listener.cancel();
17 | listeners.remove(onFunc);
18 | }
19 |
20 | static void close() {
21 | _appManageListener.close();
22 | }
23 |
24 |
25 |
26 | ///
27 | //登录成功广播
28 | static void test(dynamic data){
29 | _appManageListener.add(data);
30 | }
31 |
32 | }
--------------------------------------------------------------------------------
/lib/app/app_resources.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | class AppIcons {
4 | AppIcons._();
5 |
6 | static const IconData cameraFront = Icons.camera_front;
7 | static const IconData cameraBack = Icons.camera_rear;
8 | static const IconData linkOption = Icons.format_quote;
9 | static const IconData option = Icons.more_vert;
10 | static const IconData plus = Icons.add;
11 | }
12 |
13 | class AppColors {
14 | AppColors._();
15 |
16 | static const Color black = Colors.black;
17 | static const Color white = Colors.white;
18 | static const Color blue = Colors.blue;
19 | static const Color grey = Colors.grey;
20 | }
21 |
22 | class AppFonts {
23 | AppFonts._();
24 |
25 | static const String fontRoboto = 'Roboto';
26 | }
27 |
28 | class AppFontSizes {
29 | AppFontSizes._();
30 |
31 | static const double extraExtraSmall = 10.0;
32 | static const double extraSmall = 12.0;
33 | static const double small = 14.0;
34 | static const double medium = 16.0;
35 | static const double large = 18.0;
36 | }
37 |
38 | class AppTextStyles {
39 | AppTextStyles._();
40 |
41 | //Regular
42 | static TextStyle regularTextStyle(
43 | {double? fontSize, Color? color, double? height, Color? backgroundColor}) =>
44 | TextStyle(
45 | fontFamily: AppFonts.fontRoboto,
46 | fontWeight: FontWeight.w300,
47 | fontSize: fontSize ?? AppFontSizes.medium,
48 | color: color ?? AppColors.black,
49 | backgroundColor: backgroundColor ?? null,
50 | height: height);
51 |
52 | //Medium
53 | static TextStyle mediumTextStyle(
54 | {double? fontSize, Color? color, double? height, Color? backgroundColor}) =>
55 | TextStyle(
56 | fontFamily: AppFonts.fontRoboto,
57 | fontSize: fontSize ?? AppFontSizes.medium,
58 | fontWeight: FontWeight.w500,
59 | color: color ?? AppColors.black,
60 | backgroundColor: backgroundColor ?? null,
61 | height: height);
62 |
63 | //Bold
64 | static TextStyle boldTextStyle(
65 | {double? fontSize, Color? color, double? height, Color? backgroundColor}) =>
66 | TextStyle(
67 | fontFamily: AppFonts.fontRoboto,
68 | fontSize: fontSize ?? AppFontSizes.medium,
69 | fontWeight: FontWeight.w700,
70 | color: color ?? AppColors.black,
71 | backgroundColor: backgroundColor ?? null,
72 | height: height);
73 | }
74 |
75 | class AppImages {
76 | AppImages._();
77 |
78 | //
79 | }
80 |
81 | class AppStrings {
82 | AppStrings._();
83 |
84 | static const title = 'Realtime Object Detection';
85 | static const urlRepo = 'https://github.com/hiennguyen92/flutter_realtime_object_detection';
86 | }
87 |
--------------------------------------------------------------------------------
/lib/app/app_router.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_realtime_object_detection/pages/home_screen.dart';
3 | import 'package:flutter_realtime_object_detection/pages/local_screen.dart';
4 | import 'package:flutter_realtime_object_detection/pages/splash_screen.dart';
5 | import 'package:flutter_realtime_object_detection/services/navigation_service.dart';
6 | import 'package:flutter_realtime_object_detection/services/tensorflow_service.dart';
7 | import 'package:flutter_realtime_object_detection/view_models/home_view_model.dart';
8 | import 'package:flutter_realtime_object_detection/view_models/local_view_model.dart';
9 | import 'package:provider/provider.dart';
10 |
11 | class AppRoute {
12 | static const splashScreen = '/splashScreen';
13 | static const homeScreen = '/homeScreen';
14 | static const localScreen = '/localScreen';
15 |
16 | static final AppRoute _instance = AppRoute._private();
17 | factory AppRoute() {
18 | return _instance;
19 | }
20 | AppRoute._private();
21 |
22 | static AppRoute get instance => _instance;
23 |
24 | static Widget createProvider(
25 | P Function(BuildContext context) provider,
26 | Widget child,
27 | ) {
28 | return ChangeNotifierProvider
(
29 | create: provider,
30 | builder: (_, __) {
31 | return child;
32 | },
33 | );
34 | }
35 |
36 | Route