OpenFlutter / flutter_screenutil

Flutter screen adaptation, font adaptation, get screen information
https://pub.dartlang.org/packages/flutter_screenutil
Apache License 2.0
3.83k stars 485 forks source link

Provide a concise title for your issue, e.g., "Error: The getter 'backgroundColor' isn't defined for the class 'ThemeData'". #577

Open aliabdelmoaty opened 4 days ago

aliabdelmoaty commented 4 days ago

Description

I encountered an error when using the persistent_bottom_nav_bar package. The error message is as follows:

/C:/Users/username/AppData/Local/Pub/Cache/hosted/pub.dev/persistent_bottom_nav_bar-5.0.2/lib/neumorphic_package_by_serge_software/neumorphic_card.dart:57:57: Error: The getter 'backgroundColor' isn't defined for the class 'ThemeData'.
 - 'ThemeData' is from 'package:flutter/src/material/theme_data.dart' ('../../flutter%20system/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'.
    final color = decoration.color ?? Theme.of(context).backgroundColor;
                                                        ^^^^^^^^^^^^^^^

Steps to Reproduce

  1. Add persistent_bottom_nav_bar version 5.0.2 to your pubspec.yaml.
  2. Run the application on an Android or iOS device.
  3. Observe the error during the build process.

Suggested Fix

The issue is due to the use of the backgroundColor property, which does not exist in the ThemeData class. Instead, scaffoldBackgroundColor should be used.

In the neumorphic_card.dart file, replace:

final color = decoration.color ?? Theme.of(context).backgroundColor;

with:

final color = decoration.color ?? Theme.of(context).scaffoldBackgroundColor;

Environment

Thank you!