Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter Build Error: Undefined Getters in TextTheme and ThemeData

I cloned a repository from GitHub, and when trying to run the app, I got the following errors in my Debugging console:

../../../../AppData/Local/Pub/Cache/hosted/pub.dev/device_preview-1.1.0/lib/src/views/tool_panel/sections/section.dart:39:40: Error: The getter 'subtitle2' isn't defined for the class 'TextTheme'.
 - 'TextTheme' is from 'package:flutter/src/material/text_theme.dart' ('/C:/flutter/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 'subtitle2'.
                style: theme.textTheme.subtitle2?.copyWith(
                                       ^^^^^^^^^
../../../../AppData/Local/Pub/Cache/hosted/pub.dev/device_preview-1.1.0/lib/src/views/tool_panel/sections/settings.dart:56:34: Error: The getter 'backgroundColor' isn't defined for the class 'ThemeData'.
 - 'ThemeData' is from 'package:flutter/src/material/theme_data.dart' ('/C:/flutter/flutter/packages/flutter/lib/src/material/theme_data.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'backgroundColor'.
                  color: toolbar.backgroundColor,
                                 ^^^^^^^^^^^^^^^
../../../../AppData/Local/Pub/Cache/hosted/pub.dev/device_preview-1.1.0/lib/src/views/tool_panel/sections/settings.dart:87:34: Error: The getter 'backgroundColor' isn't defined for the class 'ThemeData'.
 - 'ThemeData' is from 'package:flutter/src/material/theme_data.dart' ('/C:/flutter/flutter/packages/flutter/lib/src/material/theme_data.dart').

Try correcting the name to the name of an existing getter, or defining a getter or field named 'backgroundColor'.
                  color: toolbar.backgroundColor,
                                 ^^^^^^^^^^^^^^^
../../../../AppData/Local/Pub/Cache/hosted/pub.dev/device_preview-1.1.0/lib/src/views/theme.dart:31:11: Error: No named parameter with the name 'toggleableActiveColor'.
          toggleableActiveColor: accentColor,
          ^^^^^^^^^^^^^^^^^^^^^
../../../../AppData/Local/Pub/Cache/hosted/pub.dev/device_preview-1.1.0/lib/src/views/theme.dart:54:11: Error: No named parameter with the name 'toggleableActiveColor'.
          toggleableActiveColor: accentColor,
          ^^^^^^^^^^^^^^^^^^^^^
../../../../AppData/Local/Pub/Cache/hosted/pub.dev/device_preview-1.1.0/lib/src/views/tool_panel/sections/subsections/device_model.dart:175:32: Error: The getter 'subtitle2' isn't defined for the class 'TextTheme'.
 - 'TextTheme' is from 'package:flutter/src/material/text_theme.dart' ('/C:/flutter/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 'subtitle2'.
        style: theme.textTheme.subtitle2?.copyWith(

                               ^^^^^^^^^
../../../../AppData/Local/Pub/Cache/hosted/pub.dev/device_preview-1.1.0/lib/src/views/tool_panel/tool_panel.dart:83:34: Error: The getter 'headline6' isn't defined for the class 'TextTheme'.
 - 'TextTheme' is from 'package:flutter/src/material/text_theme.dart' ('/C:/flutter/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 'headline6'.
          style: theme.textTheme.headline6?.copyWith(
                                 ^^^^^^^^^
Target kernel_snapshot_program failed: Exception
2

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\flutter\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 11s
Error: Gradle task assembleDebug failed with exit code 1

Exited (1).

The app works perfectly on other team members' devices, and I've tried different solutions like running flutter clean, flutter pub get, and updating Flutter SDK, but the error persists.

pubspec.yaml Snippet

name: myapp
description: "A new Flutter project."
publish_to: 'none'
version: 0.1.0

environment:
  sdk: '>=3.3.4 <4.0.0'

dependencies:
  flutter:
    sdk: flutter
  device_preview: ^1.1.0
  onboarding: ^4.0.2
  apoapps_onboarding_screen: ^1.0.4
  page_transition: ^2.1.0
  pinput: ^4.0.0
  flutter_bloc: ^8.1.5  
  tab_container: ^3.5.3
  dropdown_button2: ^2.3.8
  get_storage: ^2.1.1
  get_it: ^7.7.0
  geolocator: ^11.0.0
  google_maps_flutter: ^2.6.1
  geocoding: ^3.0.0
  flutter_config: ^2.0.2
  flutter_styled_toast: ^2.2.1
  bloc: ^8.1.4
  cached_network_image: ^3.3.1
  animated_toggle_switch: ^0.8.2
  iconify_flutter: ^0.0.5
  image_picker: ^1.1.1
  flutter_custom_clippers: ^2.1.0
  proste_bezier_curve: ^2.0.2







  
dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^3.0.0



flutter:
  uses-material-design: true
  assets:
    - assets/images/
  fonts:
    - family: Inria_Serif_Italic
      fonts:
        - asset: assets/fonts/InriaSerif-Italic.ttf

    - family: Inria_Serif_BoldItalic
      fonts:
        - asset: assets/fonts/InriaSerif-BoldItalic.ttf

    - family: Inria_Serif_LightItalic
      fonts:
        - asset: assets/fonts/InriaSerif-LightItalic.ttf

    - family: Inria_Serif_Regular
      fonts:
        - asset: assets/fonts/InriaSerif-Regular.ttf

    - family: Inria_Serif_Light
      fonts:
        - asset: assets/fonts/InriaSerif-Light.ttf


    - family: Inria_Serif_Bold
      fonts:
        - asset: assets/fonts/InriaSerif-Bold.ttf

Also, I attempted to include these parts from a solution I found in my pubspec.yaml:

dependency_overrides:
  intl: ^0.18.0

with this too:

dependencies:
   charts_flutter:
    git:
      url: git://github.com/google/charts.git
      path: charts_flutter

Running Flutter doctor result:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, 3.22.0-36.0.pre.39, on Microsoft Windows [Version
    10.0.22631.3593], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[X] Visual Studio - develop Windows apps
    X Visual Studio not installed; this is necessary to develop Windows apps.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its
      default components
[√] Android Studio (version 2022.2)
[√] VS Code (version 1.89.1)
[√] Connected device (4 available)
[√] Network resources

! Doctor found issues in 1 category.

How can I resolve these errors and run the app successfully? Any help would be appreciated!

like image 336
MJ HH Avatar asked Oct 20 '25 15:10

MJ HH


1 Answers

The new version of flutter sdk comes with some changes in those attributes :

Deprecation New API

headline1   displayLarge
headline2   displayMedium
headline3   displaySmall
headline4   headlineMedium
headline5   headlineSmall
headline6   titleLarge
subtitle1   titleMedium
subtitle2   titleSmall
bodyText1   bodyLarge
bodyText2   bodyMedium
caption     bodySmall
button      labelLarge
overline    labelSmall

you can refere to the changelog for more details

like image 69
Ayoub Arroub Avatar answered Oct 22 '25 05:10

Ayoub Arroub



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!