-
Notifications
You must be signed in to change notification settings - Fork 11
/
main.dart
80 lines (72 loc) · 2.76 KB
/
main.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
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
import 'package:appspector/appspector.dart';
import 'package:flutter/material.dart';
import 'package:flutter_appspector_example/metadata_page.dart';
import 'package:flutter_appspector_example/utils.dart';
import 'package:logging/logging.dart' as logger;
import 'color.dart';
import 'http_page.dart';
import 'main_page.dart';
import 'routes.dart';
import 'sqlite_page.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
var globalSessionUrlObserver = DataObservable<String>();
runAppSpector(globalSessionUrlObserver);
runApp(MyApp(globalSessionUrlObserver));
logger.Logger.root.level = logger.Level.ALL;
logger.Logger.root.onRecord.listen((logger.LogRecord rec) {
Logger.log(
LogLevel.DEBUG, rec.loggerName, "(${rec.level.name}) ${rec.message}");
print('${rec.level.name}: ${rec.time}: ${rec.message}');
});
}
void runAppSpector(DataObservable<String> sessionObserver) {
final config = Config()
..iosApiKey = "YjU1NDVkZGEtN2U3Zi00MDM3LTk5ZGQtNzdkNzY3YmUzZGY2"
..androidApiKey = "MWM1YTZlOTItMmU4OS00NGI2LWJiNGQtYjdhZDljNjBhYjcz"
..monitors = [
Monitors.http,
Monitors.logs,
Monitors.fileSystem,
Monitors.screenshot,
Monitors.environment,
Monitors.location,
Monitors.performance,
Monitors.sqLite,
Monitors.sharedPreferences,
Monitors.analytics,
Monitors.notification,
Monitors.userDefaults,
Monitors.coreData
];
AppSpectorPlugin.run(config);
AppSpectorPlugin.shared().sessionUrlListener =
(sessionUrl) => {sessionObserver.setValue(sessionUrl)};
}
class MyApp extends StatelessWidget {
final DataObservable<String> _sessionUrlObserver;
MyApp(this._sessionUrlObserver);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or press Run > Flutter Hot Reload in IntelliJ). Notice that the
// counter didn't reset back to zero; the application is not restarted.
primarySwatch: appSpectorPrimary,
highlightColor: appSpectorAccent),
home: MyHomePage(_sessionUrlObserver, title: 'Flutter Demo Home Page'),
routes: {
Routes.SQLiteMonitorPage: (BuildContext context) => SQLitePage(),
Routes.HttpMonitorPage: (BuildContext context) => HttpMonitorPage(),
Routes.MetadataPage: (BuildContext context) => MetadataPage(),
},
);
}
}