Merge branch 'main' of https://github.com/vodemn/m3_lightmeter into bugfix/ML-111

This commit is contained in:
Vadim 2023-09-08 20:57:30 +02:00
commit 16c81a7116
7 changed files with 83 additions and 38 deletions

2
.gitignore vendored
View file

@ -57,6 +57,6 @@ keystore.properties
android/app/google-services.json android/app/google-services.json
ios/firebase_app_id_file.json ios/firebase_app_id_file.json
ios/Runner/GoogleService-Info.plist ios/Runner/GoogleService-Info.plist
lib/firebase_options.dart /lib/firebase_options.dart
coverage/ coverage/

66
.vscode/launch.json vendored
View file

@ -5,9 +5,10 @@
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "dev (android)", "name": "dev-debug (android)",
"request": "launch", "request": "launch",
"type": "dart", "type": "dart",
"flutterMode": "debug",
"args": [ "args": [
"--flavor", "--flavor",
"dev", "dev",
@ -17,9 +18,49 @@
"program": "${workspaceFolder}/lib/main_dev.dart", "program": "${workspaceFolder}/lib/main_dev.dart",
}, },
{ {
"name": "dev (ios)", "name": "dev-profile (android)",
"request": "launch", "request": "launch",
"type": "dart", "type": "dart",
"flutterMode": "profile",
"args": [
"--flavor",
"dev",
"--dart-define",
"cameraPreviewAspectRatio=240/320",
],
"program": "${workspaceFolder}/lib/main_dev.dart",
},
{
"name": "prod-debug (android)",
"request": "launch",
"type": "dart",
"flutterMode": "debug",
"args": [
"--flavor",
"prod",
"--dart-define",
"cameraPreviewAspectRatio=240/320",
],
"program": "${workspaceFolder}/lib/main_release.dart",
},
{
"name": "prod-profile (android)",
"request": "launch",
"type": "dart",
"flutterMode": "profile",
"args": [
"--flavor",
"prod",
"--dart-define",
"cameraPreviewAspectRatio=240/320",
],
"program": "${workspaceFolder}/lib/main_release.dart",
},
{
"name": "dev-debug (ios)",
"request": "launch",
"type": "dart",
"flutterMode": "debug",
"args": [ "args": [
"--flavor", "--flavor",
"dev", "dev",
@ -29,30 +70,17 @@
"program": "${workspaceFolder}/lib/main_dev.dart", "program": "${workspaceFolder}/lib/main_dev.dart",
}, },
{ {
"name": "prod (android)", "name": "dev-profile (ios)",
"request": "launch", "request": "launch",
//"flutterMode": "release", "flutterMode": "profile",
"type": "dart", "type": "dart",
"args": [ "args": [
"--flavor", "--flavor",
"prod", "dev",
"--dart-define",
"cameraPreviewAspectRatio=240/320",
],
"program": "${workspaceFolder}/lib/main_prod.dart",
},
{
"name": "prod (ios)",
"request": "launch",
//"flutterMode": "release",
"type": "dart",
"args": [
"--flavor",
"prod",
"--dart-define", "--dart-define",
"cameraPreviewAspectRatio=3/4", "cameraPreviewAspectRatio=3/4",
], ],
"program": "${workspaceFolder}/lib/main_prod.dart", "program": "${workspaceFolder}/lib/main_dev.dart",
}, },
], ],
} }

View file

@ -60,13 +60,18 @@ flutter pub get
flutter pub run intl_utils:generate flutter pub run intl_utils:generate
``` ```
### 4. Build (Android) ### 4. Build
#### Android
You can build an apk by running the following command from the root of the repository: You can build an apk by running the following command from the root of the repository:
```console ```console
flutter build apk --release --flavor $FLAVOR --dart-define cameraPreviewAspectRatio=240/320 -t lib/main_$FLAVOR.dart flutter build apk --release --flavor dev --dart-define cameraPreviewAspectRatio=240/320 -t lib/main_dev.dart
``` ```
Just replace `$FLAVOR` with `dev` or `prod`.
### iOS
TBD
# Contribution # Contribution

View file

@ -1,14 +1,22 @@
import 'dart:developer';
import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_crashlytics/firebase_crashlytics.dart'; import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:lightmeter/firebase_options.dart'; import 'package:lightmeter/firebase_options.dart';
Future<void> initializeFirebase() async { Future<void> initializeFirebase({required bool handleErrors}) async {
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); try {
FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterFatalError; await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
PlatformDispatcher.instance.onError = (error, stack) { if (handleErrors) {
FirebaseCrashlytics.instance.recordError(error, stack, fatal: true); FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterFatalError;
return true; PlatformDispatcher.instance.onError = (error, stack) {
}; FirebaseCrashlytics.instance.recordError(error, stack, fatal: true);
return true;
};
}
} catch (e) {
log(e.toString());
}
} }

View file

@ -1,5 +1,3 @@
import 'dart:developer';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:lightmeter/application.dart'; import 'package:lightmeter/application.dart';
import 'package:lightmeter/environment.dart'; import 'package:lightmeter/environment.dart';
@ -7,10 +5,6 @@ import 'package:lightmeter/firebase.dart';
Future<void> main() async { Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
try { await initializeFirebase(handleErrors: true);
await initializeFirebase();
} catch (e) {
log(e.toString());
}
runApp(const Application(Environment.prod())); runApp(const Application(Environment.prod()));
} }

10
lib/main_release.dart Normal file
View file

@ -0,0 +1,10 @@
import 'package:flutter/material.dart';
import 'package:lightmeter/application.dart';
import 'package:lightmeter/environment.dart';
import 'package:lightmeter/firebase.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await initializeFirebase(handleErrors: false);
runApp(const Application(Environment.prod()));
}

View file

@ -1,7 +1,7 @@
name: lightmeter name: lightmeter
description: Lightmeter app inspired by Material 3 design system. description: Lightmeter app inspired by Material 3 design system.
publish_to: "none" publish_to: "none"
version: 0.13.2+38 version: 0.14.0+39
environment: environment:
sdk: ">=3.0.0 <4.0.0" sdk: ">=3.0.0 <4.0.0"