Skip to content

Commit

Permalink
Migrate to Flutter 3.27.0 (#4593)
Browse files Browse the repository at this point in the history
* move to flutter 3.27

* Bump CI Flutter version from 3.24 to 3.27

* Bump minimum Flutter version for `flet build` from 3.24 to 3.27

* enhance flutter version validation
  • Loading branch information
ndonkoHenri authored Dec 19, 2024
1 parent 27ba3b5 commit 4eb11f8
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ skip_commits:

environment:
python_stack: python 3.12
FLUTTER_VERSION: 3.24.4
FLUTTER_VERSION: 3.27.0
GITHUB_TOKEN:
secure: 9SKIwc3VSfYJ5IChvNR74hQprJ0DRmcV9pPX+8KyE6IXIdfMsX6ikeUmMhJGRu3ztkZaF45jmU7Xn/6tauXQXhDBxK1N8kFHFSAnq6LjUXyhS0TZKX/H+jDozBeVbCXp
TWINE_USERNAME: __token__
Expand Down
3 changes: 3 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ app.*.map.json

# Ruby
vendor/

# FVM Version Cache
.fvm/
4 changes: 4 additions & 0 deletions client/macos/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ class AppDelegate: FlutterAppDelegate {
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true
}

override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
return true
}
}
58 changes: 29 additions & 29 deletions client/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ packages:
dependency: transitive
description:
name: collection
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf
url: "https://pub.dev"
source: hosted
version: "1.18.0"
version: "1.19.0"
cross_file:
dependency: transitive
description:
Expand Down Expand Up @@ -247,84 +247,84 @@ packages:
path: "../packages/flet"
relative: true
source: path
version: "0.25.1"
version: "0.25.2"
flet_ads:
dependency: "direct main"
description:
path: "../packages/flet_ads"
relative: true
source: path
version: "0.25.1"
version: "0.25.2"
flet_audio:
dependency: "direct main"
description:
path: "../packages/flet_audio"
relative: true
source: path
version: "0.25.1"
version: "0.25.2"
flet_audio_recorder:
dependency: "direct main"
description:
path: "../packages/flet_audio_recorder"
relative: true
source: path
version: "0.25.1"
version: "0.25.2"
flet_flashlight:
dependency: "direct main"
description:
path: "../packages/flet_flashlight"
relative: true
source: path
version: "0.25.1"
version: "0.25.2"
flet_geolocator:
dependency: "direct main"
description:
path: "../packages/flet_geolocator"
relative: true
source: path
version: "0.25.1"
version: "0.25.2"
flet_lottie:
dependency: "direct main"
description:
path: "../packages/flet_lottie"
relative: true
source: path
version: "0.25.1"
version: "0.25.2"
flet_map:
dependency: "direct main"
description:
path: "../packages/flet_map"
relative: true
source: path
version: "0.25.1"
version: "0.25.2"
flet_permission_handler:
dependency: "direct main"
description:
path: "../packages/flet_permission_handler"
relative: true
source: path
version: "0.25.1"
version: "0.25.2"
flet_rive:
dependency: "direct main"
description:
path: "../packages/flet_rive"
relative: true
source: path
version: "0.25.1"
version: "0.25.2"
flet_video:
dependency: "direct main"
description:
path: "../packages/flet_video"
relative: true
source: path
version: "0.25.1"
version: "0.25.2"
flet_webview:
dependency: "direct main"
description:
path: "../packages/flet_webview"
relative: true
source: path
version: "0.25.1"
version: "0.25.2"
flutter:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -572,18 +572,18 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06"
url: "https://pub.dev"
source: hosted
version: "10.0.5"
version: "10.0.7"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379"
url: "https://pub.dev"
source: hosted
version: "3.0.5"
version: "3.0.8"
leak_tracker_testing:
dependency: transitive
description:
Expand Down Expand Up @@ -1172,7 +1172,7 @@ packages:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
version: "0.0.0"
source_span:
dependency: transitive
description:
Expand All @@ -1193,10 +1193,10 @@ packages:
dependency: transitive
description:
name: stack_trace
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377"
url: "https://pub.dev"
source: hosted
version: "1.11.1"
version: "1.12.0"
stream_channel:
dependency: transitive
description:
Expand All @@ -1209,10 +1209,10 @@ packages:
dependency: transitive
description:
name: string_scanner
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
version: "1.3.0"
sync_http:
dependency: transitive
description:
Expand Down Expand Up @@ -1241,10 +1241,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c"
url: "https://pub.dev"
source: hosted
version: "0.7.2"
version: "0.7.3"
torch_light:
dependency: transitive
description:
Expand Down Expand Up @@ -1401,10 +1401,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b
url: "https://pub.dev"
source: hosted
version: "14.2.5"
version: "14.3.0"
volume_controller:
dependency: transitive
description:
Expand Down Expand Up @@ -1449,10 +1449,10 @@ packages:
dependency: transitive
description:
name: webdriver
sha256: "003d7da9519e1e5f329422b36c4dcdf18d7d2978d1ba099ea4e45ba490ed845e"
sha256: "3d773670966f02a646319410766d3b5e1037efb7f07cc68f844d5e06cd4d61c8"
url: "https://pub.dev"
source: hosted
version: "3.0.3"
version: "3.0.4"
webview_flutter:
dependency: transitive
description:
Expand Down
6 changes: 3 additions & 3 deletions packages/flet/lib/src/utils/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ ScrollbarThemeData? parseScrollBarTheme(
);
}

TabBarTheme? parseTabBarTheme(ThemeData theme, Map<String, dynamic>? j) {
TabBarThemeData? parseTabBarTheme(ThemeData theme, Map<String, dynamic>? j) {
if (j == null) {
return null;
}
Expand Down Expand Up @@ -427,7 +427,7 @@ PageTransitionsTheme? parsePageTransitions(Map<String, dynamic>? json,
});
}

DialogTheme? parseDialogTheme(ThemeData theme, Map<String, dynamic>? j) {
DialogThemeData? parseDialogTheme(ThemeData theme, Map<String, dynamic>? j) {
if (j == null) {
return null;
}
Expand Down Expand Up @@ -474,7 +474,7 @@ BottomSheetThemeData? parseBottomSheetTheme(
);
}

CardTheme? parseCardTheme(ThemeData theme, Map<String, dynamic>? j) {
CardThemeData? parseCardTheme(ThemeData theme, Map<String, dynamic>? j) {
if (j == null) {
return null;
}
Expand Down
70 changes: 37 additions & 33 deletions sdk/python/packages/flet-cli/src/flet_cli/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@

PYODIDE_ROOT_URL = "https://cdn.jsdelivr.net/pyodide/v0.25.0/full"
DEFAULT_TEMPLATE_URL = "gh:flet-dev/flet-build-template"
MINIMAL_FLUTTER_VERSION = "3.24.0"

MINIMAL_FLUTTER_VERSION = version.Version("3.27.0")

error_style = Style(color="red", bold=True)
console = Console(log_path=False, theme=Theme({"log.message": "green bold"}))
Expand Down Expand Up @@ -547,6 +548,7 @@ def handle(self, options: argparse.Namespace) -> None:
spinner="bouncingBall",
) as self.status:
self.initialize_build()
self.validate_flutter_version()
self.validate_target_platform()
self.validate_entry_point()
self.setup_template_data()
Expand Down Expand Up @@ -621,9 +623,35 @@ def initialize_build(self):
self.pubspec_path = str(self.flutter_dir.joinpath("pubspec.yaml"))
self.get_pyproject = load_pyproject_toml(self.python_app_path)

def validate_target_platform(
self,
):
def validate_flutter_version(self):
version_results = self.run(
[self.flutter_exe, "--version"],
cwd=os.getcwd(),
capture_output=True,
)
if version_results.returncode == 0 and version_results.stdout:
match = re.search(r"Flutter (\d+\.\d+\.\d+)", version_results.stdout)
if match:
flutter_version = version.parse(match.group(1))
min_major = MINIMAL_FLUTTER_VERSION.major
min_minor = MINIMAL_FLUTTER_VERSION.minor

# validate installed Flutter version
if not (
flutter_version.major == min_major
and flutter_version.minor == min_minor
):
flutter_msg = (
f"You are using an unsupported Flutter SDK version: {flutter_version}\n"
+ f"Flet build requires Flutter {min_major}.{min_minor}.x, where x "
+ f"is any patch version (ex: {min_major}.{min_minor}.0, {min_major}.{min_minor}.1, etc)."
)
self.skip_flutter_doctor = True
self.cleanup(1, flutter_msg)
else:
console.log(1, "Failed to validate Flutter version.")

def validate_target_platform(self):
assert self.options
if (
self.current_platform
Expand Down Expand Up @@ -673,9 +701,7 @@ def validate_entry_point(self):
f"Use --module-name option to specify an entry point for your Flet app.",
)

def setup_template_data(
self,
):
def setup_template_data(self):
assert self.options
assert self.python_app_path
assert self.get_pyproject
Expand Down Expand Up @@ -1246,7 +1272,7 @@ def generate_icons_and_splash_screens(self):
console.log(icons_result.stdout)
if icons_result.stderr:
console.log(icons_result.stderr, style=error_style)
self.cleanup(icons_result.returncode, check_flutter_version=True)
self.cleanup(icons_result.returncode)
console.log(f"Generated app icons {self.emojis['checkmark']}")

# splash screens
Expand All @@ -1264,7 +1290,7 @@ def generate_icons_and_splash_screens(self):
console.log(splash_result.stdout)
if splash_result.stderr:
console.log(splash_result.stderr, style=error_style)
self.cleanup(splash_result.returncode, check_flutter_version=True)
self.cleanup(splash_result.returncode)
console.log(f"Generated splash screens {self.emojis['checkmark']}")

def package_python_app(self):
Expand Down Expand Up @@ -1492,7 +1518,7 @@ def flutter_build(self):
console.log(build_result.stdout)
if build_result.stderr:
console.log(build_result.stderr, style=error_style)
self.cleanup(build_result.returncode, check_flutter_version=True)
self.cleanup(build_result.returncode)
console.log(
f"Built [cyan]{self.platforms[self.options.target_platform]['status_text']}[/cyan] {self.emojis['checkmark']}",
)
Expand Down Expand Up @@ -1601,9 +1627,7 @@ def run(self, args, cwd, env: Optional[dict] = None, capture_output=True):

return r

def cleanup(
self, exit_code: int, message: Optional[str] = None, check_flutter_version=False
):
def cleanup(self, exit_code: int, message: Optional[str] = None):
if exit_code == 0:
msg = message or f"Success! {self.emojis['success']}"
console.log(msg)
Expand All @@ -1615,26 +1639,6 @@ def cleanup(
)
console.log(msg, style=error_style)

if check_flutter_version:
version_results = self.run(
[self.flutter_exe, "--version"],
cwd=os.getcwd(),
capture_output=True,
)
if version_results.returncode == 0 and version_results.stdout:
match = re.search(
r"Flutter (\d+\.\d+\.\d+)", version_results.stdout
)
if match:
flutter_version = version.parse(match.group(1))
if flutter_version < version.parse(MINIMAL_FLUTTER_VERSION):
flutter_msg = (
"Incorrect version of Flutter SDK installed. "
+ f"Flet build requires Flutter {MINIMAL_FLUTTER_VERSION} or above. "
+ f"You have {flutter_version}."
)
console.log(flutter_msg, style=error_style)

# windows has been reported to raise encoding errors when running `flutter doctor`
# so skip running `flutter doctor` if no_rich_output is True and platform is Windows
if not (
Expand Down

0 comments on commit 4eb11f8

Please sign in to comment.