From 4eb11f8208ba16ba303e80ed8eaa13d11781afb8 Mon Sep 17 00:00:00 2001 From: TheEthicalBoy <98978078+ndonkoHenri@users.noreply.github.com> Date: Fri, 20 Dec 2024 00:48:43 +0100 Subject: [PATCH] Migrate to Flutter 3.27.0 (#4593) * 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 --- .appveyor.yml | 2 +- client/.gitignore | 3 + client/macos/Runner/AppDelegate.swift | 4 ++ client/pubspec.lock | 58 +++++++-------- packages/flet/lib/src/utils/theme.dart | 6 +- .../flet-cli/src/flet_cli/commands/build.py | 70 ++++++++++--------- 6 files changed, 77 insertions(+), 66 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index c952f9098..27c6070d2 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -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__ diff --git a/client/.gitignore b/client/.gitignore index c8b858145..b85a59419 100644 --- a/client/.gitignore +++ b/client/.gitignore @@ -46,3 +46,6 @@ app.*.map.json # Ruby vendor/ + +# FVM Version Cache +.fvm/ \ No newline at end of file diff --git a/client/macos/Runner/AppDelegate.swift b/client/macos/Runner/AppDelegate.swift index 8e02df288..b3c176141 100644 --- a/client/macos/Runner/AppDelegate.swift +++ b/client/macos/Runner/AppDelegate.swift @@ -6,4 +6,8 @@ class AppDelegate: FlutterAppDelegate { override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { return true } + + override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { + return true + } } diff --git a/client/pubspec.lock b/client/pubspec.lock index ef778ea56..2803dc720 100644 --- a/client/pubspec.lock +++ b/client/pubspec.lock @@ -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: @@ -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 @@ -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: @@ -1172,7 +1172,7 @@ packages: dependency: transitive description: flutter source: sdk - version: "0.0.99" + version: "0.0.0" source_span: dependency: transitive description: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: diff --git a/packages/flet/lib/src/utils/theme.dart b/packages/flet/lib/src/utils/theme.dart index b9850b94c..d0ee5eed0 100644 --- a/packages/flet/lib/src/utils/theme.dart +++ b/packages/flet/lib/src/utils/theme.dart @@ -346,7 +346,7 @@ ScrollbarThemeData? parseScrollBarTheme( ); } -TabBarTheme? parseTabBarTheme(ThemeData theme, Map? j) { +TabBarThemeData? parseTabBarTheme(ThemeData theme, Map? j) { if (j == null) { return null; } @@ -427,7 +427,7 @@ PageTransitionsTheme? parsePageTransitions(Map? json, }); } -DialogTheme? parseDialogTheme(ThemeData theme, Map? j) { +DialogThemeData? parseDialogTheme(ThemeData theme, Map? j) { if (j == null) { return null; } @@ -474,7 +474,7 @@ BottomSheetThemeData? parseBottomSheetTheme( ); } -CardTheme? parseCardTheme(ThemeData theme, Map? j) { +CardThemeData? parseCardTheme(ThemeData theme, Map? j) { if (j == null) { return null; } diff --git a/sdk/python/packages/flet-cli/src/flet_cli/commands/build.py b/sdk/python/packages/flet-cli/src/flet_cli/commands/build.py index 212157549..42139e455 100644 --- a/sdk/python/packages/flet-cli/src/flet_cli/commands/build.py +++ b/sdk/python/packages/flet-cli/src/flet_cli/commands/build.py @@ -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"})) @@ -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() @@ -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 @@ -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 @@ -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 @@ -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): @@ -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']}", ) @@ -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) @@ -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 (