-
Notifications
You must be signed in to change notification settings - Fork 694
Expand file tree
/
Copy pathmain.dart
More file actions
162 lines (146 loc) · 5.1 KB
/
Copy pathmain.dart
File metadata and controls
162 lines (146 loc) · 5.1 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import 'package:flet/flet.dart';
import 'package:flet_ads/flet_ads.dart' as flet_ads;
// --FAT_CLIENT_START--
import 'package:flet_audio/flet_audio.dart' as flet_audio;
// --FAT_CLIENT_END--
import 'package:flet_audio_recorder/flet_audio_recorder.dart'
as flet_audio_recorder;
import 'package:flet_camera/flet_camera.dart' as flet_camera;
import 'package:flet_charts/flet_charts.dart' as flet_charts;
import 'package:flet_code_editor/flet_code_editor.dart' as flet_code_editor;
import 'package:flet_color_pickers/flet_color_pickers.dart'
as flet_color_picker;
import 'package:flet_datatable2/flet_datatable2.dart' as flet_datatable2;
import "package:flet_flashlight/flet_flashlight.dart" as flet_flashlight;
import 'package:flet_geolocator/flet_geolocator.dart' as flet_geolocator;
import 'package:flet_lottie/flet_lottie.dart' as flet_lottie;
import 'package:flet_local_auth/flet_local_auth.dart' as flet_local_auth;
import 'package:flet_map/flet_map.dart' as flet_map;
import 'package:flet_permission_handler/flet_permission_handler.dart'
as flet_permission_handler;
// --FAT_CLIENT_START--
// --RIVE_IMPORT_START--
import 'package:flet_rive/flet_rive.dart' as flet_rive;
// --RIVE_IMPORT_END--
// --FAT_CLIENT_END--
import 'package:flet_secure_storage/flet_secure_storage.dart'
as flet_secure_storage;
import 'package:flet_spinkit/flet_spinkit.dart' as flet_spinkit;
// --FAT_CLIENT_START--
import 'package:flet_video/flet_video.dart' as flet_video;
// --FAT_CLIENT_END--
import 'package:flet_webview/flet_webview.dart' as flet_webview;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_web_plugins/url_strategy.dart';
const bool isProduction = bool.fromEnvironment('dart.vm.product');
Tester? tester;
void main([List<String>? args]) async {
if (isProduction) {
// ignore: avoid_returning_null_for_void
debugPrint = (String? message, {int? wrapWidth}) => null;
}
await setupDesktop();
WidgetsFlutterBinding.ensureInitialized();
List<FletExtension> extensions = [
flet_ads.Extension(),
flet_audio_recorder.Extension(),
flet_camera.Extension(),
flet_charts.Extension(),
flet_code_editor.Extension(),
flet_color_picker.Extension(),
flet_datatable2.Extension(),
flet_flashlight.Extension(),
flet_geolocator.Extension(),
flet_lottie.Extension(),
flet_local_auth.Extension(),
flet_map.Extension(),
flet_permission_handler.Extension(),
flet_secure_storage.Extension(),
flet_spinkit.Extension(),
flet_webview.Extension(),
// --FAT_CLIENT_START--
// --RIVE_EXTENSION_START--
flet_rive.Extension(),
// --RIVE_EXTENSION_END--
flet_audio.Extension(),
flet_video.Extension(),
// --FAT_CLIENT_END--
];
// initialize extensions
for (var extension in extensions) {
extension.ensureInitialized();
}
var pageUrl = Uri.base.toString();
var assetsDir = "";
//debugPrint("Uri.base: ${Uri.base}");
if (kDebugMode) {
// The Android emulator reaches the host machine via 10.0.2.2, not
// localhost (which points at the emulator itself). Everywhere else
// (desktop, iOS simulator, web) localhost is correct.
var debugHost =
!kIsWeb && defaultTargetPlatform == TargetPlatform.android
? "10.0.2.2"
: "localhost";
pageUrl = "http://$debugHost:8550";
}
if (kIsWeb) {
debugPrint("Flet View is running in Web mode");
var routeUrlStrategy = getFletRouteUrlStrategy();
debugPrint("URL Strategy: $routeUrlStrategy");
if (routeUrlStrategy == "path") {
usePathUrlStrategy();
}
assetsDir = getAssetsDir();
} else {
if (args!.isNotEmpty) {
pageUrl = args[0];
if (args.length > 1) {
var pidFilePath = args[1];
debugPrint("Args contain a path to PID file: $pidFilePath}");
var pidFile = await File(pidFilePath).create();
await pidFile.writeAsString("$pid");
}
if (args.length > 2) {
assetsDir = args[2];
debugPrint("Args contain a path assets directory: $assetsDir}");
}
} else if (!kDebugMode &&
(Platform.isWindows || Platform.isMacOS || Platform.isLinux)) {
throw Exception(
'In desktop mode Flet app URL must be provided as a first argument.');
}
}
debugPrint("Page URL: $pageUrl");
FletAppErrorsHandler errorsHandler = FletAppErrorsHandler();
if (!kDebugMode) {
FlutterError.onError = (details) {
errorsHandler.onError(details.exceptionAsString());
};
PlatformDispatcher.instance.onError = (error, stack) {
errorsHandler.onError(error.toString());
return true;
};
}
var app = FletApp(
title: 'Flet',
pageUrl: pageUrl,
assetsDir: assetsDir,
errorsHandler: errorsHandler,
bootScreenName: "flet",
bootScreenOptions: const {
"spinner_size": 30,
"startup_message": "Working..."
},
appErrorMessage: "The application encountered an error: {message}",
extensions: extensions,
multiView: isMultiView(),
tester: tester,
);
if (app.multiView) {
debugPrint("Flet Web Multi-View mode");
runWidget(app);
} else {
runApp(app);
}
}