From fafafd73bf2eb3207b02270decc915484238eede Mon Sep 17 00:00:00 2001 From: Edouard Marquez Date: Mon, 21 Aug 2023 08:38:41 +0200 Subject: [PATCH 1/7] Migration to Flutter 3.13 --- flutter-version.txt | 2 +- .../app_store/apple_app_store/pubspec.yaml | 4 +- packages/app_store/google_play/pubspec.yaml | 4 +- packages/app_store/shared/pubspec.yaml | 4 +- packages/app_store/uri_store/pubspec.yaml | 4 +- packages/data_importer/pubspec.yaml | 2 +- packages/data_importer_shared/pubspec.yaml | 2 +- packages/scanner/ml_kit/pubspec.yaml | 4 +- packages/scanner/shared/pubspec.yaml | 2 +- packages/scanner/zxing/pubspec.yaml | 2 +- packages/smooth_app/android/app/build.gradle | 15 +++--- packages/smooth_app/android/build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- packages/smooth_app/android/settings.gradle | 25 +++++++--- .../ios/Runner.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- .../smooth_draggable_bottom_sheet.dart | 4 +- .../smooth_draggable_bottom_sheet_route.dart | 6 +-- .../knowledge_panel_group_card.dart | 2 +- .../knowledge_panel_table_card.dart | 2 +- .../pages/onboarding/country_selector.dart | 2 +- .../product/common/product_query_page.dart | 2 +- .../macos/Runner.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- packages/smooth_app/pubspec.lock | 50 +++++++++++-------- packages/smooth_app/pubspec.yaml | 18 +++---- 26 files changed, 91 insertions(+), 77 deletions(-) diff --git a/flutter-version.txt b/flutter-version.txt index c84ccce96a7..4eba2a62eb7 100644 --- a/flutter-version.txt +++ b/flutter-version.txt @@ -1 +1 @@ -3.10.5 +3.13.0 diff --git a/packages/app_store/apple_app_store/pubspec.yaml b/packages/app_store/apple_app_store/pubspec.yaml index f8ac8345eec..50c432f7131 100644 --- a/packages/app_store/apple_app_store/pubspec.yaml +++ b/packages/app_store/apple_app_store/pubspec.yaml @@ -4,7 +4,7 @@ version: 0.0.1 publish_to: "none" environment: - sdk: '>=3.0.0 <4.0.0' + sdk: '>=3.1.0 <4.0.0' dependencies: flutter: @@ -18,6 +18,6 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: 2.0.1 + flutter_lints: 2.0.2 openfoodfacts_flutter_lints: git: https://github.com/openfoodfacts/openfoodfacts_flutter_lints.git \ No newline at end of file diff --git a/packages/app_store/google_play/pubspec.yaml b/packages/app_store/google_play/pubspec.yaml index 460fbe51f26..239fe1da35e 100644 --- a/packages/app_store/google_play/pubspec.yaml +++ b/packages/app_store/google_play/pubspec.yaml @@ -4,7 +4,7 @@ version: 0.0.1 publish_to: "none" environment: - sdk: '>=3.0.0 <4.0.0' + sdk: '>=3.1.0 <4.0.0' dependencies: flutter: @@ -18,7 +18,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: 2.0.1 + flutter_lints: 2.0.2 openfoodfacts_flutter_lints: git: https://github.com/openfoodfacts/openfoodfacts_flutter_lints.git diff --git a/packages/app_store/shared/pubspec.yaml b/packages/app_store/shared/pubspec.yaml index 8b2d44ffb81..c42b9a63fc5 100644 --- a/packages/app_store/shared/pubspec.yaml +++ b/packages/app_store/shared/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.0.0 publish_to: "none" environment: - sdk: '>=3.0.0 <4.0.0' + sdk: '>=3.1.0 <4.0.0' dependencies: flutter: @@ -13,7 +13,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: 2.0.1 + flutter_lints: 2.0.2 openfoodfacts_flutter_lints: git: https://github.com/openfoodfacts/openfoodfacts_flutter_lints.git diff --git a/packages/app_store/uri_store/pubspec.yaml b/packages/app_store/uri_store/pubspec.yaml index 038ccf41562..0172c9b9637 100644 --- a/packages/app_store/uri_store/pubspec.yaml +++ b/packages/app_store/uri_store/pubspec.yaml @@ -4,7 +4,7 @@ version: 0.0.1 publish_to: "none" environment: - sdk: '>=3.0.0 <4.0.0' + sdk: '>=3.1.0 <4.0.0' dependencies: flutter: @@ -18,6 +18,6 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: 2.0.1 + flutter_lints: 2.0.2 openfoodfacts_flutter_lints: git: https://github.com/openfoodfacts/openfoodfacts_flutter_lints.git \ No newline at end of file diff --git a/packages/data_importer/pubspec.yaml b/packages/data_importer/pubspec.yaml index cf165e7af4e..7f143906102 100644 --- a/packages/data_importer/pubspec.yaml +++ b/packages/data_importer/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.0.0 publish_to: none environment: - sdk: '>=3.0.0 <4.0.0' + sdk: '>=3.1.0 <4.0.0' dependencies: flutter: diff --git a/packages/data_importer_shared/pubspec.yaml b/packages/data_importer_shared/pubspec.yaml index 71ac7c61736..1d9ca87f76e 100644 --- a/packages/data_importer_shared/pubspec.yaml +++ b/packages/data_importer_shared/pubspec.yaml @@ -3,7 +3,7 @@ description: A starting point for Dart libraries or applications. publish_to: none environment: - sdk: '>=3.0.0 <4.0.0' + sdk: '>=3.1.0 <4.0.0' dev_dependencies: flutter_driver: diff --git a/packages/scanner/ml_kit/pubspec.yaml b/packages/scanner/ml_kit/pubspec.yaml index 2a39eefe055..96f43a158b1 100644 --- a/packages/scanner/ml_kit/pubspec.yaml +++ b/packages/scanner/ml_kit/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.0.0 publish_to: "none" environment: - sdk: '>=3.0.0 <4.0.0' + sdk: '>=3.1.0 <4.0.0' dependencies: flutter: @@ -23,6 +23,6 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: 2.0.1 + flutter_lints: 2.0.2 openfoodfacts_flutter_lints: git: https://github.com/openfoodfacts/openfoodfacts_flutter_lints.git \ No newline at end of file diff --git a/packages/scanner/shared/pubspec.yaml b/packages/scanner/shared/pubspec.yaml index f6a4d1429c6..35b8ef0332c 100644 --- a/packages/scanner/shared/pubspec.yaml +++ b/packages/scanner/shared/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.0.0 publish_to: "none" environment: - sdk: '>=3.0.0 <4.0.0' + sdk: '>=3.1.0 <4.0.0' dependencies: flutter: diff --git a/packages/scanner/zxing/pubspec.yaml b/packages/scanner/zxing/pubspec.yaml index de0786a81a8..8404d158fd8 100644 --- a/packages/scanner/zxing/pubspec.yaml +++ b/packages/scanner/zxing/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.0.0 publish_to: "none" environment: - sdk: '>=3.0.0 <4.0.0' + sdk: '>=3.1.0 <4.0.0' dependencies: flutter: diff --git a/packages/smooth_app/android/app/build.gradle b/packages/smooth_app/android/app/build.gradle index 32e739346a4..cd932a381b6 100644 --- a/packages/smooth_app/android/app/build.gradle +++ b/packages/smooth_app/android/app/build.gradle @@ -1,3 +1,9 @@ +plugins { + id "com.android.application" + id "kotlin-android" + id "dev.flutter.flutter-gradle-plugin" +} + def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { @@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) { } } -def flutterRoot = localProperties.getProperty('flutter.sdk') -if (flutterRoot == null) { - throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") -} - def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' @@ -21,10 +22,6 @@ if (flutterVersionName == null) { flutterVersionName = '1.0' } -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - android { compileSdkVersion 33 ndkVersion "25.1.8937393" diff --git a/packages/smooth_app/android/build.gradle b/packages/smooth_app/android/build.gradle index e06c40a4131..77611697ef2 100644 --- a/packages/smooth_app/android/build.gradle +++ b/packages/smooth_app/android/build.gradle @@ -6,7 +6,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:7.1.2' + classpath 'com.android.tools.build:gradle:7.3.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/packages/smooth_app/android/gradle/wrapper/gradle-wrapper.properties b/packages/smooth_app/android/gradle/wrapper/gradle-wrapper.properties index cb24abda10a..3c472b99c6f 100644 --- a/packages/smooth_app/android/gradle/wrapper/gradle-wrapper.properties +++ b/packages/smooth_app/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip diff --git a/packages/smooth_app/android/settings.gradle b/packages/smooth_app/android/settings.gradle index 44e62bcf06a..55c4ca8b109 100644 --- a/packages/smooth_app/android/settings.gradle +++ b/packages/smooth_app/android/settings.gradle @@ -1,11 +1,20 @@ -include ':app' +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + } + settings.ext.flutterSdkPath = flutterSdkPath() -def localPropertiesFile = new File(rootProject.projectDir, "local.properties") -def properties = new Properties() + includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") -assert localPropertiesFile.exists() -localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + plugins { + id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false + } +} -def flutterSdkPath = properties.getProperty("flutter.sdk") -assert flutterSdkPath != null, "flutter.sdk not set in local.properties" -apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" +include ":app" + +apply from: "${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/packages/smooth_app/ios/Runner.xcodeproj/project.pbxproj b/packages/smooth_app/ios/Runner.xcodeproj/project.pbxproj index a0a53bd0216..fefc2df070d 100644 --- a/packages/smooth_app/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/smooth_app/ios/Runner.xcodeproj/project.pbxproj @@ -299,7 +299,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { diff --git a/packages/smooth_app/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/smooth_app/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index c87d15a3352..a6b826db27d 100644 --- a/packages/smooth_app/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/packages/smooth_app/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ 0.0 && maxHeightFraction <= 1.0), @@ -23,7 +23,7 @@ class SmoothDraggableBottomSheet extends StatefulWidget { final WidgetBuilder bodyBuilder; final DraggableScrollableController? draggableScrollableController; final AnimationController? animationController; - final BorderRadius? borderRadius; + final BorderRadiusGeometry borderRadius; final Color? bottomSheetColor; @override diff --git a/packages/smooth_app/lib/generic_lib/bottom_sheets/smooth_draggable_bottom_sheet_route.dart b/packages/smooth_app/lib/generic_lib/bottom_sheets/smooth_draggable_bottom_sheet_route.dart index 7e327b175d1..8a20253362e 100644 --- a/packages/smooth_app/lib/generic_lib/bottom_sheets/smooth_draggable_bottom_sheet_route.dart +++ b/packages/smooth_app/lib/generic_lib/bottom_sheets/smooth_draggable_bottom_sheet_route.dart @@ -7,9 +7,9 @@ Future showDraggableModalSheet({ required WidgetBuilder headerBuilder, required double headerHeight, required WidgetBuilder bodyBuilder, + required BorderRadiusGeometry borderRadius, double? initHeight, double? maxHeight, - BorderRadius? borderRadius, Color? bottomSheetColor, Color? barrierColor, }) { @@ -37,8 +37,8 @@ class _FlexibleBottomSheetRoute extends PopupRoute { required this.headerBuilder, required this.headerHeight, required this.bodyBuilder, + required this.borderRadius, this.barrierLabel, - this.borderRadius, this.bottomSheetBackgroundColor, RouteSettings? settings, }) : super(settings: settings); @@ -47,7 +47,7 @@ class _FlexibleBottomSheetRoute extends PopupRoute { final double headerHeight; final WidgetBuilder bodyBuilder; final double initHeight; - final BorderRadius? borderRadius; + final BorderRadiusGeometry borderRadius; final Color? bottomSheetBackgroundColor; @override diff --git a/packages/smooth_app/lib/knowledge_panel/knowledge_panels/knowledge_panel_group_card.dart b/packages/smooth_app/lib/knowledge_panel/knowledge_panels/knowledge_panel_group_card.dart index 4b3602cb84a..a08cd74844c 100644 --- a/packages/smooth_app/lib/knowledge_panel/knowledge_panels/knowledge_panel_group_card.dart +++ b/packages/smooth_app/lib/knowledge_panel/knowledge_panels/knowledge_panel_group_card.dart @@ -31,7 +31,7 @@ class KnowledgePanelGroupCard extends StatelessWidget { themeData.textTheme.titleSmall!.apply(color: Colors.grey), ), ), - for (String panelId in groupElement.panelIds) + for (final String panelId in groupElement.panelIds) KnowledgePanelCard( panelId: panelId, product: product, diff --git a/packages/smooth_app/lib/knowledge_panel/knowledge_panels/knowledge_panel_table_card.dart b/packages/smooth_app/lib/knowledge_panel/knowledge_panels/knowledge_panel_table_card.dart index b239bdcc49a..954a2bedd62 100644 --- a/packages/smooth_app/lib/knowledge_panel/knowledge_panels/knowledge_panel_table_card.dart +++ b/packages/smooth_app/lib/knowledge_panel/knowledge_panels/knowledge_panel_table_card.dart @@ -94,7 +94,7 @@ class _KnowledgePanelTableCardState extends State { _buildRowWidgets(_buildRowCells(), constraints); return Column( children: [ - for (List row in rowsWidgets) + for (final List row in rowsWidgets) Semantics( excludeSemantics: true, value: _buildSemanticsValue(row), diff --git a/packages/smooth_app/lib/pages/onboarding/country_selector.dart b/packages/smooth_app/lib/pages/onboarding/country_selector.dart index dae38d58822..0fc1c1cf574 100644 --- a/packages/smooth_app/lib/pages/onboarding/country_selector.dart +++ b/packages/smooth_app/lib/pages/onboarding/country_selector.dart @@ -46,7 +46,7 @@ class _CountrySelectorState extends State { try { localizedCountries = - await IsoCountries.iso_countries_for_locale(languageCode); + await IsoCountries.isoCountriesForLocale(languageCode); } on MissingPluginException catch (_) { // Locales are not implemented on desktop and web // TODO(g123k): Add a complete list diff --git a/packages/smooth_app/lib/pages/product/common/product_query_page.dart b/packages/smooth_app/lib/pages/product/common/product_query_page.dart index 95e230b6b7f..5f3b2a70bee 100644 --- a/packages/smooth_app/lib/pages/product/common/product_query_page.dart +++ b/packages/smooth_app/lib/pages/product/common/product_query_page.dart @@ -390,7 +390,7 @@ class _ProductQueryPageState extends State } final String locale = Localizations.localeOf(context).languageCode; final List localizedCountries = - await IsoCountries.iso_countries_for_locale(locale); + await IsoCountries.isoCountriesForLocale(locale); for (final Country country in localizedCountries) { if (country.countryCode.toLowerCase() == _country!.offTag.toLowerCase()) { return country.name; diff --git a/packages/smooth_app/macos/Runner.xcodeproj/project.pbxproj b/packages/smooth_app/macos/Runner.xcodeproj/project.pbxproj index 8cb1537fe77..427c25f523d 100644 --- a/packages/smooth_app/macos/Runner.xcodeproj/project.pbxproj +++ b/packages/smooth_app/macos/Runner.xcodeproj/project.pbxproj @@ -202,7 +202,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = ""; TargetAttributes = { 33CC10EC2044A3C60003C045 = { diff --git a/packages/smooth_app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/smooth_app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 2aba2321ea8..5ebb5d0af52 100644 --- a/packages/smooth_app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/packages/smooth_app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ =3.0.0 <4.0.0" + dart: ">=3.1.0 <4.0.0" flutter: ">=3.10.0" diff --git a/packages/smooth_app/pubspec.yaml b/packages/smooth_app/pubspec.yaml index 61774a767d3..d1b19781c4d 100644 --- a/packages/smooth_app/pubspec.yaml +++ b/packages/smooth_app/pubspec.yaml @@ -4,7 +4,7 @@ version: 0.0.0+734 publish_to: "none" environment: - sdk: '>=3.0.0 <4.0.0' + sdk: '>=3.1.0 <4.0.0' dependencies: flutter: @@ -26,8 +26,8 @@ dependencies: hive: 2.2.3 hive_flutter: 1.1.0 http: 0.13.5 - image_picker: ^1.0.1 - iso_countries: 2.1.0 + image_picker: 1.0.1 + iso_countries: 2.2.0 latlong2: 0.8.2 matomo_tracker: 3.1.0 package_info_plus: 3.0.3 @@ -47,14 +47,14 @@ dependencies: path: ../app_store/shared audioplayers: 5.0.0 percent_indicator: 4.2.3 - flutter_email_sender: ^6.0.0 + flutter_email_sender: 6.0.0 flutter_native_splash: 2.3.1 image: ^4.0.17 auto_size_text: 3.0.0 crop_image: 1.0.10 shared_preferences: 2.1.1 - intl: 0.18.0 - collection: 1.17.1 + intl: 0.18.1 + collection: 1.17.2 path: 1.8.3 path_provider: 2.0.15 data_importer_shared: @@ -68,9 +68,9 @@ dependencies: rive: 0.11.4 sensors_plus: 3.0.3 webview_flutter: 3.0.4 - flutter_custom_tabs: ^1.0.4 + flutter_custom_tabs: 1.0.4 flutter_image_compress: 2.0.4 - connectivity_plus: ^4.0.2 + connectivity_plus: 4.0.2 dart_ping: 9.0.0 dart_ping_ios: 4.0.0 @@ -115,7 +115,7 @@ dev_dependencies: mockito: 5.4.2 path_provider_platform_interface: 2.0.6 plugin_platform_interface: 2.1.4 - flutter_lints: 2.0.1 + flutter_lints: 2.0.2 openfoodfacts_flutter_lints: git: https://github.com/openfoodfacts/openfoodfacts_flutter_lints.git From 986b192bfc9a04b6861a79f71d0e0ed7cdbc5e38 Mon Sep 17 00:00:00 2001 From: Edouard Marquez Date: Mon, 21 Aug 2023 08:40:53 +0200 Subject: [PATCH 2/7] Let's prepare for the upcoming release --- packages/smooth_app/lib/main.dart | 17 +++++++++++++---- .../smooth_app/lib/themes/smooth_theme.dart | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/smooth_app/lib/main.dart b/packages/smooth_app/lib/main.dart index 9a533d9a500..67e989c1997 100644 --- a/packages/smooth_app/lib/main.dart +++ b/packages/smooth_app/lib/main.dart @@ -255,10 +255,18 @@ class _SmoothAppState extends State { localizationsDelegates: AppLocalizations.localizationsDelegates, supportedLocales: AppLocalizations.supportedLocales, debugShowCheckedModeBanner: !(kReleaseMode || _screenshots), - theme: SmoothTheme.getThemeData(Brightness.light, themeProvider, - colorProvider, textContrastProvider), - darkTheme: SmoothTheme.getThemeData(Brightness.dark, themeProvider, - colorProvider, textContrastProvider), + theme: SmoothTheme.getThemeData( + Brightness.light, + themeProvider, + colorProvider, + textContrastProvider, + ), + darkTheme: SmoothTheme.getThemeData( + Brightness.dark, + themeProvider, + colorProvider, + textContrastProvider, + ), themeMode: themeProvider.currentThemeMode, routerConfig: AppNavigator.of(context).router, ), @@ -267,6 +275,7 @@ class _SmoothAppState extends State { Widget _buildError(AsyncSnapshot snapshot) { return MaterialApp( + theme: ThemeData(useMaterial3: false), home: SmoothScaffold( body: Center( child: Text( diff --git a/packages/smooth_app/lib/themes/smooth_theme.dart b/packages/smooth_app/lib/themes/smooth_theme.dart index afdcdf1632f..46b4567a3d8 100644 --- a/packages/smooth_app/lib/themes/smooth_theme.dart +++ b/packages/smooth_app/lib/themes/smooth_theme.dart @@ -38,6 +38,7 @@ class SmoothTheme { } return ThemeData( + useMaterial3: false, primaryColor: const Color(0xFF341100), colorScheme: myColorScheme, canvasColor: themeProvider.currentTheme == THEME_AMOLED From 46a58e7a8e724ccdaba86cd8fb5a79c23ee66e77 Mon Sep 17 00:00:00 2001 From: Edouard Marquez Date: Mon, 21 Aug 2023 08:48:16 +0200 Subject: [PATCH 3/7] Fix build issues --- .../ml_kit/lib/src/scanner_ml_kit.dart | 4 +- .../scanner/zxing/lib/src/scanner_zxing.dart | 4 +- .../lib/background/background_task.dart | 24 +++++---- .../user_preferences_settings.dart | 50 ++++++++++--------- .../product/common/product_query_page.dart | 10 ++-- .../product/ordered_nutrients_cache.dart | 1 + 6 files changed, 54 insertions(+), 39 deletions(-) diff --git a/packages/scanner/ml_kit/lib/src/scanner_ml_kit.dart b/packages/scanner/ml_kit/lib/src/scanner_ml_kit.dart index 2b67d7fd0a8..d7d6d0244c4 100644 --- a/packages/scanner/ml_kit/lib/src/scanner_ml_kit.dart +++ b/packages/scanner/ml_kit/lib/src/scanner_ml_kit.dart @@ -304,7 +304,9 @@ class _SmoothBarcodeScannerMLKitState extends State<_SmoothBarcodeScannerMLKit> try { await _controller.toggleTorch(); } catch (err) { - widget.onCameraFlashError?.call(context); + if (context.mounted) { + widget.onCameraFlashError?.call(context); + } } }, child: ValueListenableBuilder( diff --git a/packages/scanner/zxing/lib/src/scanner_zxing.dart b/packages/scanner/zxing/lib/src/scanner_zxing.dart index 2a62a25e2e3..bafeca62d30 100644 --- a/packages/scanner/zxing/lib/src/scanner_zxing.dart +++ b/packages/scanner/zxing/lib/src/scanner_zxing.dart @@ -172,7 +172,9 @@ class _SmoothBarcodeScannerZXingState await _controller?.toggleFlash(); setState(() {}); } catch (err) { - widget.onCameraFlashError?.call(context); + if (context.mounted) { + widget.onCameraFlashError?.call(context); + } } }, child: Icon( diff --git a/packages/smooth_app/lib/background/background_task.dart b/packages/smooth_app/lib/background/background_task.dart index 558854da89c..e3a585d1288 100644 --- a/packages/smooth_app/lib/background/background_task.dart +++ b/packages/smooth_app/lib/background/background_task.dart @@ -121,16 +121,20 @@ abstract class BackgroundTask { return; } - if (getFloatingMessage(AppLocalizations.of(widget.context)) - case ( - final String message, - final AlignmentGeometry alignment, - )) { - SmoothFloatingMessage(message: message).show( - widget.context, - duration: SnackBarDuration.medium, - alignment: alignment, - ); + if (widget.context.mounted) { + // ignore: use_build_context_synchronously + if (getFloatingMessage(AppLocalizations.of(widget.context)) + case ( + final String message, + final AlignmentGeometry alignment, + )) { + // ignore: use_build_context_synchronously + SmoothFloatingMessage(message: message).show( + widget.context, + duration: SnackBarDuration.medium, + alignment: alignment, + ); + } } } diff --git a/packages/smooth_app/lib/pages/preferences/user_preferences_settings.dart b/packages/smooth_app/lib/pages/preferences/user_preferences_settings.dart index 6a129e69b0d..b64fd8b6a8d 100644 --- a/packages/smooth_app/lib/pages/preferences/user_preferences_settings.dart +++ b/packages/smooth_app/lib/pages/preferences/user_preferences_settings.dart @@ -75,19 +75,21 @@ class _RateUs extends StatelessWidget { try { await ApplicationStore.openAppDetails(); } on PlatformException { - final AppLocalizations appLocalizations = AppLocalizations.of(context); - final ThemeData themeData = Theme.of(context); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - appLocalizations.error_occurred, - textAlign: TextAlign.center, - style: TextStyle(color: themeData.colorScheme.background), + if (context.mounted) { + final AppLocalizations appLocalizations = AppLocalizations.of(context); + final ThemeData themeData = Theme.of(context); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + appLocalizations.error_occurred, + textAlign: TextAlign.center, + style: TextStyle(color: themeData.colorScheme.background), + ), + behavior: SnackBarBehavior.floating, + backgroundColor: themeData.colorScheme.onBackground, ), - behavior: SnackBarBehavior.floating, - backgroundColor: themeData.colorScheme.onBackground, - ), - ); + ); + } } } @@ -137,19 +139,21 @@ class _ShareWithFriends extends StatelessWidget { try { await Share.share(appLocalizations.contribute_share_content); } on PlatformException { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - appLocalizations.error, - textAlign: TextAlign.center, - style: TextStyle( - color: themeData.colorScheme.background, + if (context.mounted) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + appLocalizations.error, + textAlign: TextAlign.center, + style: TextStyle( + color: themeData.colorScheme.background, + ), ), + behavior: SnackBarBehavior.floating, + backgroundColor: themeData.colorScheme.onBackground, ), - behavior: SnackBarBehavior.floating, - backgroundColor: themeData.colorScheme.onBackground, - ), - ); + ); + } } } diff --git a/packages/smooth_app/lib/pages/product/common/product_query_page.dart b/packages/smooth_app/lib/pages/product/common/product_query_page.dart index 5f3b2a70bee..f59ce12020b 100644 --- a/packages/smooth_app/lib/pages/product/common/product_query_page.dart +++ b/packages/smooth_app/lib/pages/product/common/product_query_page.dart @@ -438,10 +438,12 @@ class _ProductQueryPageState extends State try { successfullyLoaded = await _model.loadFromTop(); } catch (e) { - await LoadingDialog.error( - context: context, - title: _model.loadingError, - ); + if (mounted) { + await LoadingDialog.error( + context: context, + title: _model.loadingError, + ); + } } finally { if (successfullyLoaded) { _scrollToTop(instant: true); diff --git a/packages/smooth_app/lib/pages/product/ordered_nutrients_cache.dart b/packages/smooth_app/lib/pages/product/ordered_nutrients_cache.dart index e5543fac587..7c1e2c638aa 100644 --- a/packages/smooth_app/lib/pages/product/ordered_nutrients_cache.dart +++ b/packages/smooth_app/lib/pages/product/ordered_nutrients_cache.dart @@ -22,6 +22,7 @@ class OrderedNutrientsCache { ) async { final OrderedNutrientsCache cache = OrderedNutrientsCache._(); cache._orderedNutrients = await cache._get() ?? + // ignore: use_build_context_synchronously await LoadingDialog.run( context: context, future: cache._download(), From 8d6af652c4f317c5d2d61290d4c96827022b2b93 Mon Sep 17 00:00:00 2001 From: Edouard Marquez Date: Mon, 21 Aug 2023 08:52:42 +0200 Subject: [PATCH 4/7] Use the compile SDK version from Flutter = 34 --- packages/smooth_app/android/app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/smooth_app/android/app/build.gradle b/packages/smooth_app/android/app/build.gradle index cd932a381b6..94f940dd194 100644 --- a/packages/smooth_app/android/app/build.gradle +++ b/packages/smooth_app/android/app/build.gradle @@ -23,7 +23,7 @@ if (flutterVersionName == null) { } android { - compileSdkVersion 33 + compileSdkVersion flutter.compileSdkVersion ndkVersion "25.1.8937393" compileOptions { From ea623739d6bf7243bf2590065b2ba871540fec52 Mon Sep 17 00:00:00 2001 From: Edouard Marquez Date: Fri, 25 Aug 2023 08:21:03 +0200 Subject: [PATCH 5/7] Migration to Flutter 3.13.1 --- README.md | 2 +- flutter-version.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1aefe803ac0..7fcb6890d24 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ Starting this April, we invite all users and contributors to build a vision for - Make sure you have installed flutter and all the requirements - [Official flutter installation guide](https://docs.flutter.dev/get-started/install) -- Currently, the app uses the previous version of Flutter (3.10). We plan to migrate soon. +- Currently, the app uses the latest stable version of Flutter (3.13). We have predefined run configurations for Android Studio and Visual Studio Code diff --git a/flutter-version.txt b/flutter-version.txt index 4eba2a62eb7..c10780c628a 100644 --- a/flutter-version.txt +++ b/flutter-version.txt @@ -1 +1 @@ -3.13.0 +3.13.1 From 10f0329b81e37c79534002141ebd172ae9e7a465 Mon Sep 17 00:00:00 2001 From: Edouard Marquez Date: Sat, 30 Sep 2023 10:19:01 +0200 Subject: [PATCH 6/7] Migrate to Flutter 3.13.6 --- flutter-version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flutter-version.txt b/flutter-version.txt index c10780c628a..64af02e6251 100644 --- a/flutter-version.txt +++ b/flutter-version.txt @@ -1 +1 @@ -3.13.1 +3.13.6 From 53acc5cab2442b41feffad32bd971d870ef76c33 Mon Sep 17 00:00:00 2001 From: Edouard Marquez Date: Sat, 30 Sep 2023 10:24:54 +0200 Subject: [PATCH 7/7] Fix 2 Lint issues --- .../lib/pages/preferences/user_preferences_rate_us.dart | 4 ++++ .../preferences/user_preferences_share_with_friends.dart | 3 +++ 2 files changed, 7 insertions(+) diff --git a/packages/smooth_app/lib/pages/preferences/user_preferences_rate_us.dart b/packages/smooth_app/lib/pages/preferences/user_preferences_rate_us.dart index 14aedf2055e..cba7fc5eefe 100644 --- a/packages/smooth_app/lib/pages/preferences/user_preferences_rate_us.dart +++ b/packages/smooth_app/lib/pages/preferences/user_preferences_rate_us.dart @@ -40,6 +40,10 @@ class UserPreferencesRateUs extends StatelessWidget { try { await ApplicationStore.openAppDetails(); } on PlatformException { + if (!context.mounted) { + return; + } + final ThemeData themeData = Theme.of(context); ScaffoldMessenger.of(context).showSnackBar( SnackBar( diff --git a/packages/smooth_app/lib/pages/preferences/user_preferences_share_with_friends.dart b/packages/smooth_app/lib/pages/preferences/user_preferences_share_with_friends.dart index c6d28ccb72c..6e9875ff5c3 100644 --- a/packages/smooth_app/lib/pages/preferences/user_preferences_share_with_friends.dart +++ b/packages/smooth_app/lib/pages/preferences/user_preferences_share_with_friends.dart @@ -35,6 +35,9 @@ class UserPreferencesShareWithFriends extends StatelessWidget { try { await Share.share(appLocalizations.contribute_share_content); } on PlatformException { + if (!context.mounted) { + return; + } ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text(