androidflutterdartbuild.gradleflutter-doctor

Flutter: Try correcting the name to the name of an existing getter, or defining a getter or field named 'caption'. Failed to compile application


I'm trying to run my Flutter app on Android after a long time and it won't run successfully because of the below error:

  • 'TextTheme' is from 'package:flutter/src/material/text_theme.dart' ('../../Dev/flutter/packages/flutter/lib/src/material/text_theme.dart').

Try correcting the name to the name of an existing getter, or defining a getter or field named 'caption'. .caption! ^^^^^^^ Target kernel_snapshot failed: Exception FAILURE: Build failed with an exception.

What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'. Process 'command '/Users/iman/Documents/Dev/flutter/bin/flutter'' finished with non-zero exit value 1

And this is the result of my Flutter Doctor which I think there shouldn't be a problem for running on Android:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.22.2, on macOS 13.3 22E252 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✗] Xcode - develop for iOS and macOS
    ✗ Xcode installation is incomplete; a full installation is necessary for iOS and macOS development.
      Download at: https://developer.apple.com/xcode/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -runFirstLaunch
    ✗ CocoaPods not installed.
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your
        plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] VS Code (version 1.91.1)
[✓] Connected device (3 available)
[✓] Network resources

Solution

  • This property in TextTheme was deprecated since 3.19 and removed in 3.22. See breaking changes. It was made for the sake of support new stylings from Material design specifications.

    There are some suggestions that you can use instead removed APIs. In case of caption, it is recommended to use bodySmall