Added package_info to get the package version
This commit is contained in:
parent
ef932f84e6
commit
aa496b0ed2
3 changed files with 52 additions and 42 deletions
|
|
@ -1,10 +1,11 @@
|
||||||
library fires.globals;
|
library fires.globals;
|
||||||
|
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'dart:async';
|
|
||||||
|
|
||||||
final String appVersion = '1.6';
|
String appVersion;
|
||||||
|
|
||||||
final Widget appMediumIcon =
|
final Widget appMediumIcon =
|
||||||
Image.asset('images/logo-200.png', width: 60.0, height: 60.0);
|
Image.asset('images/logo-200.png', width: 60.0, height: 60.0);
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,12 @@ import 'models/appState.dart';
|
||||||
import 'models/firesApi.dart';
|
import 'models/firesApi.dart';
|
||||||
import 'redux/fetchDataMiddleware.dart';
|
import 'redux/fetchDataMiddleware.dart';
|
||||||
import 'redux/reducers.dart';
|
import 'redux/reducers.dart';
|
||||||
|
import 'package:package_info/package_info.dart';
|
||||||
|
|
||||||
|
Future<PackageInfo> loadPackageInfo() async {
|
||||||
|
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||||
|
return packageInfo;
|
||||||
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>> loadSecrets() async {
|
Future<Map<String, dynamic>> loadSecrets() async {
|
||||||
return await SecretLoader(secretPath: 'assets/private-settings.json').load();
|
return await SecretLoader(secretPath: 'assets/private-settings.json').load();
|
||||||
|
|
@ -20,49 +26,54 @@ Future<Map<String, dynamic>> loadSecrets() async {
|
||||||
void mainCommon(List<Middleware<AppState>> otherMiddleware) {
|
void mainCommon(List<Middleware<AppState>> otherMiddleware) {
|
||||||
final injector = Injector.getInjector();
|
final injector = Injector.getInjector();
|
||||||
injector.map<FiresApi>((i) => new FiresApi(), isSingleton: true);
|
injector.map<FiresApi>((i) => new FiresApi(), isSingleton: true);
|
||||||
loadSecrets().then((secrets) {
|
loadPackageInfo().then((packageInfo) {
|
||||||
final store = new Store<AppState>(appStateReducer,
|
globals.appVersion = packageInfo.version;
|
||||||
|
print('Running version ${packageInfo.version}');
|
||||||
|
loadSecrets().then((secrets) {
|
||||||
|
final store = new Store<AppState>(appStateReducer,
|
||||||
initialState: new AppState(
|
initialState: new AppState(
|
||||||
gmapKey: secrets['gmapKey'],
|
gmapKey: secrets['gmapKey'],
|
||||||
firesApiKey: secrets['firesApiKey'],
|
firesApiKey: secrets['firesApiKey'],
|
||||||
serverUrl: secrets['firesApiUrl'],
|
serverUrl: secrets['firesApiUrl'],
|
||||||
firesApiUrl: secrets['firesApiUrl'] + "api/v1/"),
|
firesApiUrl: secrets['firesApiUrl'] + "api/v1/"),
|
||||||
middleware: List.from(otherMiddleware)..add(fetchDataMiddleware));
|
middleware: List.from(otherMiddleware)
|
||||||
|
..add(fetchDataMiddleware));
|
||||||
|
|
||||||
injector.map<Store<AppState>>((i) => store);
|
injector.map<Store<AppState>>((i) => store);
|
||||||
injector.map<String>((i) => store.state.firesApiUrl, key: "firesApiUrl");
|
injector.map<String>((i) => store.state.firesApiUrl, key: "firesApiUrl");
|
||||||
injector.map<String>((i) => store.state.firesApiKey, key: "firesApiKey");
|
injector.map<String>((i) => store.state.firesApiKey, key: "firesApiKey");
|
||||||
injector.map<String>((i) => store.state.serverUrl, key: "serverUrl");
|
injector.map<String>((i) => store.state.serverUrl, key: "serverUrl");
|
||||||
injector.map<String>((i) => store.state.gmapKey, key: "gmapKey");
|
injector.map<String>((i) => store.state.gmapKey, key: "gmapKey");
|
||||||
|
|
||||||
var useSentry = !globals.isDevelopment;
|
var useSentry = !globals.isDevelopment;
|
||||||
|
|
||||||
SentryClient _sentry;
|
SentryClient _sentry;
|
||||||
if (useSentry) _sentry = SentryClient(dsn: secrets['sentryDSN']);
|
if (useSentry) _sentry = SentryClient(dsn: secrets['sentryDSN']);
|
||||||
|
|
||||||
// https://flutter.io/cookbook/maintenance/error-reporting/
|
// https://flutter.io/cookbook/maintenance/error-reporting/
|
||||||
runZoned<Future<Null>>(() async {
|
runZoned<Future<Null>>(() async {
|
||||||
runApp(new FiresApp(store));
|
runApp(new FiresApp(store));
|
||||||
}, onError: (error, stackTrace) {
|
}, onError: (error, stackTrace) {
|
||||||
// Whenever an error occurs, call the `_reportError` function. This will send
|
// Whenever an error occurs, call the `_reportError` function. This will send
|
||||||
// Dart errors to our dev console or Sentry depending on the environment.
|
// Dart errors to our dev console or Sentry depending on the environment.
|
||||||
_reportError(useSentry, _sentry, error, stackTrace);
|
_reportError(useSentry, _sentry, error, stackTrace);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Listen to store changes, and re-render when the state is updated
|
||||||
|
store.onChange.listen((state) {
|
||||||
|
// print('Store onChange');
|
||||||
|
});
|
||||||
|
FlutterError.onError = (FlutterErrorDetails details) {
|
||||||
|
if (!useSentry) {
|
||||||
|
// In development mode simply print to console.
|
||||||
|
FlutterError.dumpErrorToConsole(details);
|
||||||
|
} else {
|
||||||
|
// In production mode report to the application zone to report to
|
||||||
|
// Sentry.
|
||||||
|
Zone.current.handleUncaughtError(details.exception, details.stack);
|
||||||
|
}
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// Listen to store changes, and re-render when the state is updated
|
|
||||||
store.onChange.listen((state) {
|
|
||||||
// print('Store onChange');
|
|
||||||
});
|
|
||||||
FlutterError.onError = (FlutterErrorDetails details) {
|
|
||||||
if (!useSentry) {
|
|
||||||
// In development mode simply print to console.
|
|
||||||
FlutterError.dumpErrorToConsole(details);
|
|
||||||
} else {
|
|
||||||
// In production mode report to the application zone to report to
|
|
||||||
// Sentry.
|
|
||||||
Zone.current.handleUncaughtError(details.exception, details.stack);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ dependencies:
|
||||||
sentry: "^2.0.2"
|
sentry: "^2.0.2"
|
||||||
flutter_markdown: "^0.1.5"
|
flutter_markdown: "^0.1.5"
|
||||||
url_launcher: "^3.0.2"
|
url_launcher: "^3.0.2"
|
||||||
|
package_info: "^0.3.2"
|
||||||
|
|
||||||
# net
|
# net
|
||||||
http: "^0.11.3+16"
|
http: "^0.11.3+16"
|
||||||
|
|
@ -62,9 +63,6 @@ dependencies:
|
||||||
cupertino_icons: "^0.1.2"
|
cupertino_icons: "^0.1.2"
|
||||||
community_material_icon: "^0.1.2"
|
community_material_icon: "^0.1.2"
|
||||||
|
|
||||||
# not using yet
|
|
||||||
# package_info: "^0.3.2"
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue