flet icon indicating copy to clipboard operation
flet copied to clipboard

Support Flutter 3.27

Open Sameri11 opened this issue 1 year ago • 10 comments

Duplicate Check

  • [X] I have searched the opened issues and there are no duplicates

Describe the bug

In Flutter 3.27, API breaking change introduced, as a part of attempt to "normalize" Material's theme API. Reference is here for TabBarTheme – ThemeData's tabBarTheme property is now TabBarThemeData instead of TabBarTheme.

These changes breaks flet because theme utils now have incompatible types. Consider this example:

This method returns TabBarTheme? because it returns result of copyWith method. But this method now returns TabBarThemeData. Thus errors like this:

../../../../../.pub-cache/hosted/pub.dev/flet-0.25.1/lib/src/utils/theme.dart:356:28: Error: A
           value of type 'TabBarThemeData' can't be returned from a function with return type 'TabBarTheme?'.
            - 'TabBarThemeData' is from 'package:flutter/src/material/tab_bar_theme.dart'
           ('/opt/homebrew/Caskroom/flutter/3.27.0/flutter/packages/flutter/lib/src/material/tab_bar_theme.da
           rt').
            - 'TabBarTheme' is from 'package:flutter/src/material/tab_bar_theme.dart'
           ('/opt/homebrew/Caskroom/flutter/3.27.0/flutter/packages/flutter/lib/src/material/tab_bar_theme.da
           rt').
             return theme.tabBarTheme.copyWith(
                                      ^

Sadly, there is already questions on SO on this matter, for example: https://stackoverflow.com/questions/79273727/materialtheme-normalization-breaks-tabbartheme-cardtheme-dialogtheme-api/79273907#79273907

Same for other API apart from TabBarTheme, such as DialogTheme, CardTheme, etc ....

Code sample

Code Considerr this code:
// Current TabBarTheme API in stable channel version: 3.24.5
final TabBarTheme tabTheme = Theme.of(context).tabBarTheme;

This will works on 3.24.5, but breaks on 3.27

To reproduce

See code sample

Expected behavior

No response

Screenshots / Videos

Captures

[Upload media here]

Operating System

macOS

Operating system details

Sonoma 14.7

Flet version

0.25.1

Regression

No, it isn't

Suggestions

Hard to say. Since it's hard breakage of public API of Flutter itself, maybe it'll require to set minimal flutter version for 3.27 for flet package and update usages accordingly in new version of flet

Logs

Logs
❯ flet build macos
[22:01:43] Created Flutter bootstrap project from gh:flet-dev/flet-build-template with ref 0.25.1 ✅
           Customized app icons and splash images ✅
[22:01:45] Generated app icons ✅
[22:01:51] Packaged Python app ✅
[22:02:13]
           Updating project for Xcode compatibility.
           Upgrading project.pbxproj
           Upgrading Runner.xcscheme
           Running pod install...                                              4.3s
           Building macOS application...

           macos/Runner/AppDelegate.swift uses the deprecated @NSApplicationMain attribute, updating.
           macos/Runner/AppDelegate.swift does not override applicationSupportsSecureRestorableState.
           Updating.
           .gitignore does not ignore Swift Package Manager build directories, updating.
           --- xcodebuild: WARNING: Using the first of multiple matching destinations:
           { platform:macOS, arch:arm64, id:00008103-001C55920A33001E, name:My Mac }
           { platform:macOS, arch:x86_64, id:00008103-001C55920A33001E, name:My Mac }
           ../../../../../.pub-cache/hosted/pub.dev/flet-0.25.1/lib/src/utils/theme.dart:356:28: Error: A
           value of type 'TabBarThemeData' can't be returned from a function with return type 'TabBarTheme?'.
            - 'TabBarThemeData' is from 'package:flutter/src/material/tab_bar_theme.dart'
           ('/opt/homebrew/Caskroom/flutter/3.27.0/flutter/packages/flutter/lib/src/material/tab_bar_theme.da
           rt').
            - 'TabBarTheme' is from 'package:flutter/src/material/tab_bar_theme.dart'
           ('/opt/homebrew/Caskroom/flutter/3.27.0/flutter/packages/flutter/lib/src/material/tab_bar_theme.da
           rt').
             return theme.tabBarTheme.copyWith(
                                      ^
           ../../../../../.pub-cache/hosted/pub.dev/flet-0.25.1/lib/src/utils/theme.dart:438:28: Error: A
           value of type 'DialogThemeData' can't be returned from a function with return type 'DialogTheme?'.
            - 'DialogThemeData' is from 'package:flutter/src/material/dialog_theme.dart'
           ('/opt/homebrew/Caskroom/flutter/3.27.0/flutter/packages/flutter/lib/src/material/dialog_theme.dar
           t').
            - 'DialogTheme' is from 'package:flutter/src/material/dialog_theme.dart'
           ('/opt/homebrew/Caskroom/flutter/3.27.0/flutter/packages/flutter/lib/src/material/dialog_theme.dar
           t').
             return theme.dialogTheme.copyWith(
                                      ^
           ../../../../../.pub-cache/hosted/pub.dev/flet-0.25.1/lib/src/utils/theme.dart:482:26: Error: A
           value of type 'CardThemeData' can't be returned from a function with return type 'CardTheme?'.
            - 'CardThemeData' is from 'package:flutter/src/material/card_theme.dart'
           ('/opt/homebrew/Caskroom/flutter/3.27.0/flutter/packages/flutter/lib/src/material/card_theme.dart'
           ).
            - 'CardTheme' is from 'package:flutter/src/material/card_theme.dart'
           ('/opt/homebrew/Caskroom/flutter/3.27.0/flutter/packages/flutter/lib/src/material/card_theme.dart'
           ).
             return theme.cardTheme.copyWith(
                                    ^
           Target kernel_snapshot_program failed: Exception

           Command PhaseScriptExecution failed with a nonzero exit code




           warning: Run script build phase 'Run Script' will be run during every build because it does not
           specify any outputs. To address this issue, either add output dependencies to the script phase, or
           configure it to run in every build by unchecking "Based on dependency analysis" in the script
           phase. (in target 'Flutter Assemble' from project 'Runner')
           ** BUILD FAILED **

           Build process failed

           Error building Flet app - see the log of failed command above.
[22:02:26] Doctor summary (to see all details, run flutter doctor -v):
           [✓] Flutter (Channel stable, 3.27.0, on macOS 15.1.1 24B91 darwin-arm64, locale en-US)
           [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0-rc4)
           [✓] Xcode - develop for iOS and macOS (Xcode 16.1)
           [✓] Chrome - develop for the web
           [✓] Android Studio (version 2024.2)
           [✓] Connected device (3 available)
           [✓] Network resources

           • No issues found!

Additional details

No response

Sameri11 avatar Dec 12 '24 05:12 Sameri11

Thanks for letting know. Flet is not yet 3.27-ready. We will work on that.

For now, please make use of Flitter 3.24

ndonkoHenri avatar Dec 12 '24 08:12 ndonkoHenri

I can confirm this behaviour, i had to downgrade flutter to successfully build windows and apk targets:

cd \flutter\flutter\
git checkout 3.24.5
flutter doctor -v

Franky1 avatar Dec 14 '24 21:12 Franky1

How can I benefit from this update (Flutter 3.27) because I still have this error when converting to apk?

Youssef3082004 avatar Dec 21 '24 11:12 Youssef3082004

  • Upgrade to the latest prerelease: pip install 'flet[all]' --upgrade --pre
  • In your requirements/pyproject file: flet==0.26.0.dev3957

ndonkoHenri avatar Dec 21 '24 11:12 ndonkoHenri

@ndonkoHenri pip install flet --upgrade --pre update to the last flet 0.26.0.dev3912 [√] Flutter (Channel stable, 3.27.1 still not work It hasn't helped me.

catg0tfish avatar Dec 22 '24 07:12 catg0tfish

@ndonkoHenri pip install flet --upgrade --pre update to the last flet 0.26.0.dev3912 [√] Flutter (Channel stable, 3.27.1 still not work It hasn't helped me.

Yes , I have the Same also with the Same error

Youssef3082004 avatar Dec 22 '24 11:12 Youssef3082004

Bump

jowolf avatar Dec 26 '24 18:12 jowolf

The same error. Need to add flutter install instructions on flet install page.

alr888rav avatar Dec 29 '24 14:12 alr888rav

TabBarTheme? DialogTheme? CardTheme?

there are error in these types. Please update flet package.

semiromest avatar Jan 12 '25 09:01 semiromest

If the solution shared above doesnt work, downgrade your Flutter version to Flutter 3.24.x

ndonkoHenri avatar Jan 12 '25 15:01 ndonkoHenri