Skip to content

Commit

Permalink
chore: Migration to Flutter 3.13 (#4579)
Browse files Browse the repository at this point in the history
Co-authored-by: monsieurtanuki <fabrice_fontaine@hotmail.com>
  • Loading branch information
g123k and monsieurtanuki committed Sep 30, 2023
1 parent da78240 commit c31e458
Show file tree
Hide file tree
Showing 35 changed files with 141 additions and 99 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion flutter-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.10.5
3.13.6
4 changes: 2 additions & 2 deletions packages/app_store/apple_app_store/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
4 changes: 2 additions & 2 deletions packages/app_store/google_play/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions packages/app_store/shared/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions packages/app_store/uri_store/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
2 changes: 1 addition & 1 deletion packages/data_importer/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion packages/data_importer_shared/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion packages/scanner/ml_kit/lib/src/scanner_ml_kit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<TorchState>(
Expand Down
4 changes: 2 additions & 2 deletions packages/scanner/ml_kit/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
2 changes: 1 addition & 1 deletion packages/scanner/shared/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion packages/scanner/zxing/lib/src/scanner_zxing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion packages/scanner/zxing/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
17 changes: 7 additions & 10 deletions packages/smooth_app/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -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()) {
Expand All @@ -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'
Expand All @@ -21,12 +22,8 @@ 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
compileSdkVersion flutter.compileSdkVersion
ndkVersion "25.1.8937393"

compileOptions {
Expand Down
2 changes: 1 addition & 1 deletion packages/smooth_app/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
25 changes: 17 additions & 8 deletions packages/smooth_app/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion packages/smooth_app/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
24 changes: 14 additions & 10 deletions packages/smooth_app/lib/background/background_task.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class SmoothDraggableBottomSheet extends StatefulWidget {
required this.headerBuilder,
required this.headerHeight,
required this.bodyBuilder,
required this.borderRadius,
this.initHeightFraction = 0.5,
this.maxHeightFraction = 1.0,
this.animationController,
this.borderRadius,
this.bottomSheetColor,
this.draggableScrollableController,
}) : assert(maxHeightFraction > 0.0 && maxHeightFraction <= 1.0),
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Future<T?> showDraggableModalSheet<T>({
required WidgetBuilder headerBuilder,
required double headerHeight,
required WidgetBuilder bodyBuilder,
required BorderRadiusGeometry borderRadius,
double? initHeight,
double? maxHeight,
BorderRadius? borderRadius,
Color? bottomSheetColor,
Color? barrierColor,
}) {
Expand Down Expand Up @@ -37,8 +37,8 @@ class _FlexibleBottomSheetRoute<T> extends PopupRoute<T> {
required this.headerBuilder,
required this.headerHeight,
required this.bodyBuilder,
required this.borderRadius,
this.barrierLabel,
this.borderRadius,
this.bottomSheetBackgroundColor,
RouteSettings? settings,
}) : super(settings: settings);
Expand All @@ -47,7 +47,7 @@ class _FlexibleBottomSheetRoute<T> extends PopupRoute<T> {
final double headerHeight;
final WidgetBuilder bodyBuilder;
final double initHeight;
final BorderRadius? borderRadius;
final BorderRadiusGeometry borderRadius;
final Color? bottomSheetBackgroundColor;

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class _KnowledgePanelTableCardState extends State<KnowledgePanelTableCard> {
_buildRowWidgets(_buildRowCells(), constraints);
return Column(
children: <Widget>[
for (List<Widget> row in rowsWidgets)
for (final List<Widget> row in rowsWidgets)
Semantics(
excludeSemantics: true,
value: _buildSemanticsValue(row),
Expand Down
17 changes: 13 additions & 4 deletions packages/smooth_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,18 @@ class _SmoothAppState extends State<SmoothApp> {
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,
),
Expand All @@ -267,6 +275,7 @@ class _SmoothAppState extends State<SmoothApp> {

Widget _buildError(AsyncSnapshot<void> snapshot) {
return MaterialApp(
theme: ThemeData(useMaterial3: false),
home: SmoothScaffold(
body: Center(
child: Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class _CountrySelectorState extends State<CountrySelector> {

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
Expand Down
Loading

0 comments on commit c31e458

Please sign in to comment.