Skip to content

Commit

Permalink
Upgrade flutter version from 3.13.9 to 3.19.6 (#183)
Browse files Browse the repository at this point in the history
- upgrade flutter sub module to 3.13.9.
- migrate breaking changes from 3.13 to 3.19 release. 
    - migrate `TextScaleFactor` to `TextScaler`.
    - migrate `WillPopScope` to `PopScope`.
    - migrate Android build plugin to `Plugin DSL`.
- fix all mounted checking in async code block.
- bump ios/macos's locked dependencies.
- fix some `Scrollbar` crashed during widget building on desktop platform.
- update some building files.
  • Loading branch information
FriesI23 authored Jun 9, 2024
1 parent 427c422 commit 97f2a14
Show file tree
Hide file tree
Showing 45 changed files with 386 additions and 329 deletions.
2 changes: 1 addition & 1 deletion .flutter
Submodule .flutter updated 2886 files
4 changes: 2 additions & 2 deletions .fvm/fvm_config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"flutterSdkVersion": "3.13.9",
"flutterSdkVersion": "3.19.6",
"flavors": {
"release": "3.13.9"
"release": "3.19.6"
}
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ coverage/html/

# fvm
.fvm/flutter_sdk
.fvm/release
.fvm/version
.fvm/versions/

# coverage
coverage/
3 changes: 1 addition & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[submodule "flutter"]
path = .flutter
url = https://github.com/flutter/flutter.git
tag = 3.13.9

tag = 3.19.6
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"**/.flutter": true
},
"files.associations": {
"*.arb": "json"
"*.arb": "json",
"*.gradle": "groovy"
},
"[dart]": {
"editor.formatOnSave": true,
Expand Down
2 changes: 1 addition & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ linter:
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# FIXME: ignore with 3.13.x's linter bug.
# see https://github.com/dart-lang/linter/issues/4753
use_build_context_synchronously: false
# use_build_context_synchronously: false
# Prefer relative imports for files in lib/.
# see: https://dart.dev/tools/linter-rules/prefer_relative_imports
prefer_relative_imports: true
Expand Down
25 changes: 13 additions & 12 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/* groovylint-disable CompileStatic, DuplicateStringLiteral, NoDef, VariableTypeRequired */

plugins {
id 'com.android.application'
id 'kotlin-android'
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id 'dev.flutter.flutter-gradle-plugin'
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
Expand All @@ -6,11 +15,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,10 +25,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"

def customCompileSdkVersion = localProperties.getProperty('flutter.compileSdkVersion')
if (customCompileSdkVersion == null) {
// FIXME: url_launcher_android 6.3.0 bump compileSdk version to 34.
Expand Down Expand Up @@ -62,15 +62,16 @@ android {

defaultConfig {
multiDexEnabled true
/* groovylint-disable-next-line LineLength */
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "io.github.friesi23.mhabit"
applicationId 'io.github.friesi23.mhabit'
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
resourceConfigurations += ["en", "ar", "de", "es", "fa", "fr", "it", "nb-rNO", "pt-rBR", "ru", "vi", "zh"]
resourceConfigurations += ['en', 'ar', 'de', 'es', 'fa', 'fr', 'it', 'nb-rNO', 'pt-rBR', 'ru', 'vi', 'zh']
}

signingConfigs {
Expand All @@ -87,6 +88,7 @@ android {
signingConfig keystoreProperties['storeFile'] ? signingConfigs.release : signingConfigs.debug
}
}

namespace 'io.github.friesi23.mhabit'
}

Expand All @@ -95,7 +97,6 @@ flutter {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.window:window:1.0.0'
implementation 'androidx.window:window-java:1.0.0'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2'
Expand Down
15 changes: 2 additions & 13 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
buildscript {
ext.kotlin_version = '1.8.22'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:8.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
/* groovylint-disable CompileStatic */

allprojects {
repositories {
Expand All @@ -24,6 +13,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
tasks.register('clean', Delete) {
delete rootProject.buildDir
}
32 changes: 24 additions & 8 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
include ':app'
/* groovylint-disable CompileStatic, ImplicitClosureParameter, NoDef, VariableTypeRequired */

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
}()

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

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"
plugins {
id 'dev.flutter.flutter-plugin-loader' version '1.0.0'
id 'com.android.application' version '8.1.3' apply false
id 'org.jetbrains.kotlin.android' version '1.8.22' apply false
}

include ':app'
1 change: 1 addition & 0 deletions devtools_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extensions:
2 changes: 1 addition & 1 deletion ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
# platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
10 changes: 5 additions & 5 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,19 @@ SPEC CHECKSUMS:
DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac
DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179
file_picker: 15fd9539e4eb735dc54bae8c0534a7a9511a03de
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_local_notifications: 4cde75091f6327eb8517fa068a0a5950212d2086
flutter_timezone: ffb07bdad3c6276af8dada0f11978d8a1f8a20bb
open_file_plus: 05737718530c14cf02868e3b7754d7fe4df76d8b
package_info_plus: 115f4ad11e0698c8c1c5d8a689390df880f47e85
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
SDWebImage: fd7e1a22f00303e058058278639bf6196ee431fe
share_plus: c3fef564749587fc939ef86ffb283ceac0baf9f5
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
SwiftyGif: 93a1cc87bf3a51916001cf8f3d63835fb64c819f
url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe

PODFILE CHECKSUM: ed11bcbce7d892a5cf6ce26330e9d4aa9739ddff
PODFILE CHECKSUM: 38a5d5ec463a50cc13d7630ab79f450537b24db1

COCOAPODS: 1.14.2
2 changes: 1 addition & 1 deletion ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
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 = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
26 changes: 13 additions & 13 deletions lib/component/widgets/date_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
//
// Copy source code from flutter: flutter/lib/src/material/date_picker.dart
// Flutter license place at LICENSE_THIRDPARTY.md
import 'dart:math' as math;

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:intl/intl.dart';

import '../../extension/textscale_extensions.dart';
import '../../l10n/localizations.dart';
import '../../logging/helper.dart';
import 'chip_list.dart';
Expand Down Expand Up @@ -53,8 +53,8 @@ class HabitDatetimePickerDialog extends DatePickerDialog {

class _HabitDatetimePickerDialog extends State<HabitDatetimePickerDialog>
with RestorationMixin {
late final RestorableDateTime _selectedDate =
RestorableDateTime(widget.initialDate);
late final RestorableDateTimeN _selectedDate =
RestorableDateTimeN(widget.initialDate);
late final _RestorableDatePickerEntryMode _entryMode =
_RestorableDatePickerEntryMode(widget.initialEntryMode);
final _RestorableAutovalidateMode _autovalidateMode =
Expand Down Expand Up @@ -97,9 +97,9 @@ class _HabitDatetimePickerDialog extends State<HabitDatetimePickerDialog>
Navigator.pop(
context,
widget.currentDateTime.copyWith(
year: _selectedDate.value.year,
month: _selectedDate.value.month,
day: _selectedDate.value.day,
year: _selectedDate.value?.year,
month: _selectedDate.value?.month,
day: _selectedDate.value?.day,
));
}

Expand Down Expand Up @@ -177,12 +177,14 @@ class _HabitDatetimePickerDialog extends State<HabitDatetimePickerDialog>
final TextTheme textTheme = theme.textTheme;
// Constrain the textScaleFactor to the largest supported value to prevent
// layout issues.
final double textScaleFactor =
math.min(MediaQuery.textScaleFactorOf(context), 1.3);
final TextScaler textScale =
MediaQuery.textScalerOf(context).clamp(maxScaleFactor: 1.3);

final l10n = L10n.of(context);

final String dateText = localizations.formatMediumDate(_selectedDate.value);
final String dateText = _selectedDate.value == null
? ""
: localizations.formatMediumDate(_selectedDate.value!);
final Color onPrimarySurface = colorScheme.brightness == Brightness.light
? colorScheme.onPrimary
: colorScheme.onSurface;
Expand Down Expand Up @@ -390,7 +392,7 @@ class _HabitDatetimePickerDialog extends State<HabitDatetimePickerDialog>
nextDateChip: nextDateChip,
));

final Size dialogSize = _dialogSize(context) * textScaleFactor;
final Size dialogSize = textScale.scaleForSize(_dialogSize(context));
return Dialog(
insetPadding:
const EdgeInsets.symmetric(horizontal: 16.0, vertical: 24.0),
Expand All @@ -401,9 +403,7 @@ class _HabitDatetimePickerDialog extends State<HabitDatetimePickerDialog>
duration: _dialogSizeAnimationDuration,
curve: Curves.easeIn,
child: MediaQuery(
data: MediaQuery.of(context).copyWith(
textScaleFactor: textScaleFactor,
),
data: MediaQuery.of(context).copyWith(textScaler: textScale),
child: Builder(builder: (context) {
switch (orientation) {
case Orientation.portrait:
Expand Down
6 changes: 3 additions & 3 deletions lib/component/widgets/habit_score_chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ class HabitScoreChart extends StatelessWidget {

@override
Widget build(BuildContext context) {
final double textScaleFactor =
math.min(MediaQuery.textScaleFactorOf(context), 1.3);
final TextScaler textScaler =
MediaQuery.textScalerOf(context).clamp(maxScaleFactor: 1.3);

appLog.build.debug(context);
final double maxX = (data.length - 1).toDouble();
Expand All @@ -274,7 +274,7 @@ class HabitScoreChart extends StatelessWidget {
showTitles: true,
getTitlesWidget: _buildRightTitle,
reservedSize:
protoLeftWidgetSize.width * textScaleFactor + leftTipsSpace,
textScaler.scale(protoLeftWidgetSize.width) + leftTipsSpace,
interval: 20,
),
),
Expand Down
11 changes: 3 additions & 8 deletions lib/component/widgets/markdown_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import 'dart:math' as math;

import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';

Expand All @@ -24,26 +22,23 @@ import '../widget.dart';
class ThematicMarkdownBody extends StatelessWidget {
final String data;
final HabitColorType? colorType;
final double? textScaleFactor;
final TextScaler? textScaler;
final MarkdownImageBuilder? imageBuilder;
final MarkdownTapLinkCallback? onTapLink;

const ThematicMarkdownBody({
super.key,
required this.data,
this.colorType,
this.textScaleFactor,
this.textScaler,
this.imageBuilder,
this.onTapLink,
});

double _getDefaultTextScaleFactor(BuildContext context) =>
math.min(MediaQuery.textScaleFactorOf(context), 1.3);

MarkdownStyleSheet _getStyleSheet(BuildContext context) {
final themeData = Theme.of(context);
return MarkdownStyleSheet.fromTheme(themeData).copyWith(
textScaleFactor: textScaleFactor ?? _getDefaultTextScaleFactor(context),
textScaler: textScaler ?? MediaQuery.textScalerOf(context),
a: TextStyle(color: themeData.colorScheme.primary),
blockquote: themeData.textTheme.bodyMedium!
.copyWith(color: themeData.colorScheme.primary),
Expand Down
20 changes: 20 additions & 0 deletions lib/extension/textscale_extensions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2024 Fries_I23
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import 'package:flutter/material.dart';

extension TextScaleExtension on TextScaler {
Size scaleForSize<T extends Size>(T size) =>
Size(scale(size.width), scale(size.height));
}
Loading

0 comments on commit 97f2a14

Please sign in to comment.