From 53202b9ea48fe2691d17891a391f25452859fd37 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Beno=C3=AEt=20Harrault?= <benoit@harrault.fr>
Date: Wed, 28 Feb 2024 16:26:13 +0100
Subject: [PATCH] Avoid print calls in production code

---
 android/gradle.properties                        |  4 ++--
 fastlane/metadata/android/en-US/changelogs/6.txt |  1 +
 fastlane/metadata/android/fr-FR/changelogs/6.txt |  1 +
 lib/ui/widgets/take_picture_widget.dart          |  9 +++++----
 lib/utils/picture_storage.dart                   |  4 +++-
 lib/utils/tools.dart                             |  7 +++++++
 pubspec.lock                                     | 12 ++++++------
 pubspec.yaml                                     |  2 +-
 8 files changed, 26 insertions(+), 14 deletions(-)
 create mode 100644 fastlane/metadata/android/en-US/changelogs/6.txt
 create mode 100644 fastlane/metadata/android/fr-FR/changelogs/6.txt
 create mode 100644 lib/utils/tools.dart

diff --git a/android/gradle.properties b/android/gradle.properties
index aa51064..135006f 100644
--- a/android/gradle.properties
+++ b/android/gradle.properties
@@ -1,5 +1,5 @@
 org.gradle.jvmargs=-Xmx1536M
 android.useAndroidX=true
 android.enableJetifier=true
-app.versionName=0.0.5
-app.versionCode=5
+app.versionName=0.0.6
+app.versionCode=6
diff --git a/fastlane/metadata/android/en-US/changelogs/6.txt b/fastlane/metadata/android/en-US/changelogs/6.txt
new file mode 100644
index 0000000..52f2179
--- /dev/null
+++ b/fastlane/metadata/android/en-US/changelogs/6.txt
@@ -0,0 +1 @@
+Avoid print calls in production code.
diff --git a/fastlane/metadata/android/fr-FR/changelogs/6.txt b/fastlane/metadata/android/fr-FR/changelogs/6.txt
new file mode 100644
index 0000000..8537dac
--- /dev/null
+++ b/fastlane/metadata/android/fr-FR/changelogs/6.txt
@@ -0,0 +1 @@
+Supprime les appels à print dans le code de production.
diff --git a/lib/ui/widgets/take_picture_widget.dart b/lib/ui/widgets/take_picture_widget.dart
index d817f13..573bc52 100644
--- a/lib/ui/widgets/take_picture_widget.dart
+++ b/lib/ui/widgets/take_picture_widget.dart
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
 import 'package:unicons/unicons.dart';
 
 import 'package:stopmotion/utils/picture_storage.dart';
+import 'package:stopmotion/utils/tools.dart';
 
 class TakePictureWidget extends StatefulWidget {
   const TakePictureWidget({super.key});
@@ -41,7 +42,7 @@ class TakePictureWidgetState extends State<TakePictureWidget> {
       }
       setState(() {});
     });
-    }
+  }
 
   @override
   void dispose() {
@@ -71,14 +72,14 @@ class TakePictureWidgetState extends State<TakePictureWidget> {
               try {
                 if ((controller != null) && (controller!.value.isInitialized)) {
                   final XFile image = await controller!.takePicture();
-                  print('image.path: ${image.path}');
+                  printlog('image.path: ${image.path}');
                   debug.add('image.path: ${image.path}');
 
                   File savedFile = await storage!.writeCounter(File(image.path));
                   debug.add('image.path: ${image.path}');
 
                   String imagePath = savedFile.path;
-                  print('imagePath: $imagePath');
+                  printlog('imagePath: $imagePath');
                   debug.add('imagePath: $imagePath');
 
                   previousImages.add(imagePath);
@@ -88,7 +89,7 @@ class TakePictureWidgetState extends State<TakePictureWidget> {
                 debug.add('error: $e');
                 setState(() {});
 
-                print(e);
+                printlog(e.toString());
               }
             },
           ),
diff --git a/lib/utils/picture_storage.dart b/lib/utils/picture_storage.dart
index ebf663b..5fc0d54 100644
--- a/lib/utils/picture_storage.dart
+++ b/lib/utils/picture_storage.dart
@@ -3,6 +3,8 @@ import 'dart:io';
 import 'package:path/path.dart';
 import 'package:path_provider/path_provider.dart';
 
+import 'package:stopmotion/utils/tools.dart';
+
 class PictureStorage {
   Future<String> get _localPath async {
     final directory = await getApplicationDocumentsDirectory();
@@ -20,7 +22,7 @@ class PictureStorage {
     try {
       return await sourceFile.rename(newPath);
     } on FileSystemException catch (e) {
-      print('Found exception while moving file: $e');
+      printlog('Found exception while moving file: $e');
       final newFile = await sourceFile.copy(newPath);
       await sourceFile.delete();
       return newFile;
diff --git a/lib/utils/tools.dart b/lib/utils/tools.dart
new file mode 100644
index 0000000..fd48b2b
--- /dev/null
+++ b/lib/utils/tools.dart
@@ -0,0 +1,7 @@
+import 'package:flutter/foundation.dart';
+
+void printlog(String message) {
+  if (!kReleaseMode) {
+    debugPrint(message);
+  }
+}
diff --git a/pubspec.lock b/pubspec.lock
index dd587f2..d3313f3 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -45,10 +45,10 @@ packages:
     dependency: transitive
     description:
       name: camera_platform_interface
-      sha256: fceb2c36038b6392317b1d5790c6ba9e6ca9f1da3031181b8bea03882bf9387a
+      sha256: a250314a48ea337b35909a4c9d5416a208d736dcb01d0b02c6af122be66660b0
       url: "https://pub.dev"
     source: hosted
-    version: "2.7.3"
+    version: "2.7.4"
   camera_web:
     dependency: transitive
     description:
@@ -85,10 +85,10 @@ packages:
     dependency: transitive
     description:
       name: cross_file
-      sha256: "74a4727e030347edff3b6e5256b7fb0c3de8af8ed278e6c56718760786a1fa40"
+      sha256: "55d7b444feb71301ef6b8838dbc1ae02e63dd48c8773f3810ff53bb1e2945b32"
       url: "https://pub.dev"
     source: hosted
-    version: "0.3.4"
+    version: "0.3.4+1"
   crypto:
     dependency: transitive
     description:
@@ -308,10 +308,10 @@ packages:
     dependency: transitive
     description:
       name: provider
-      sha256: "9a96a0a19b594dbc5bf0f1f27d2bc67d5f95957359b461cd9feb44ed6ae75096"
+      sha256: c8a055ee5ce3fd98d6fc872478b03823ffdb448699c6ebdbbc71d59b596fd48c
       url: "https://pub.dev"
     source: hosted
-    version: "6.1.1"
+    version: "6.1.2"
   shared_preferences:
     dependency: transitive
     description:
diff --git a/pubspec.yaml b/pubspec.yaml
index a93f08f..04f16ce 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -3,7 +3,7 @@ description: stop motion assistant
 
 publish_to: 'none'
 
-version: 0.0.5+5
+version: 0.0.6+6
 
 environment:
   sdk: '^3.0.0'
-- 
GitLab