Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The method 'withValues' isn't defined for the class 'Color'. #2231

Open
mehuldadlani opened this issue Dec 27, 2024 · 8 comments
Open

The method 'withValues' isn't defined for the class 'Color'. #2231

mehuldadlani opened this issue Dec 27, 2024 · 8 comments
Labels
charts Charts component open Open

Comments

@mehuldadlani
Copy link

Bug description

I am using syncfusion_flutter_charts 28.1.36 for my App and I get this error whenever I try to build.
Here I am using Riverpod for state management in my app.

Error : The method 'withValues' isn't defined for the class 'Color'.

SDK Version :-

Flutter 3.24.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 603104015d (9 weeks ago) • 2024-10-24 08:01:25 -0700
Engine • revision db49896cf2
Tools • Dart 3.5.4 • DevTools 2.37.3

Steps to reproduce

  1. Added the code to my chart widget .
  2. Run The App
  3. Getting the error while building the app

Code sample

Code sample
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_charts/charts.dart';

class LiveStockChart extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Basic Line Chart')),
      body: SfCartesianChart(
        primaryXAxis: NumericAxis(),
        primaryYAxis: NumericAxis(),
        series: <CartesianSeries>[
          LineSeries<ChartData, int>(
            dataSource: [
              ChartData(0, 35),
              ChartData(1, 28),
              ChartData(2, 34),
              ChartData(3, 32),
              ChartData(4, 40)
            ],
            xValueMapper: (ChartData data, _) => data.x,
            yValueMapper: (ChartData data, _) => data.y,
          )
        ],
      ),
    );
  }
}

class ChartData {
  ChartData(this.x, this.y);
  final int x;
  final double y;
}

Screenshots or Video

Screenshots / Video demonstration Screenshot 2024-12-28 at 12 34 19 AM

Stack Traces

Stack Traces
Launching lib/main.dart on iPhone 15 Pro in debug mode...
Xcode build done.                                           97.8s
Failed to build iOS app
Error (Xcode): /Users/mehuldadlani/.pub-cache/hosted/pub.dev/syncfusion_flutter_charts-28.1.36/lib/src/charts/axis/axis.dart:3817:42: Error: The method 'withValues' isn't defined for the class 'Color'.

Could not build the application for the simulator.
Error launching application on iPhone 15 Pro.

On which target platforms have you observed this bug?

iOS

Flutter Doctor output

Doctor output
mehuldadlani@Mehuls-MacBook-Pro defy-mobile % flutter doctor -v
[✓] Flutter (Channel stable, 3.24.4, on macOS 14.4 23E214 darwin-arm64, locale en-IN)
    • Flutter version 3.24.4 on channel stable at /Users/mehuldadlani/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 603104015d (9 weeks ago), 2024-10-24 08:01:25 -0700
    • Engine revision db49896cf2
    • Dart version 3.5.4
    • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/mehuldadlani/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Android Studio (version 2022.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)

[✓] VS Code (version 1.96.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.102.0

[✓] Connected device (3 available)
    • iPhone 15 Pro (mobile)          • 51264C57-DEDD-4AE6-B74B-932ACE06215A • ios          • com.apple.CoreSimulator.SimRuntime.iOS-17-5
      (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64 • macOS 14.4 23E214 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin       • macOS 14.4 23E214 darwin-arm64
    ! Error: Browsing on the local area network for iPhone 13 Pro Max. Ensure the device is unlocked and attached with a cable or associated
      with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
@RickZzDev
Copy link

I got the same error, and I think that is something wrong with the syncfusion_flutter_core that is imported by the syncfusion_flutter_charts package.

Until we have this fix, I will post here what I did to build my app normally.

Just set the past version on your pubspec.yaml to:

  syncfusion_flutter_charts: 28.1.35

And, on your pubspec.lock, set the same version to syncfusion_flutter_core, it will force you flutter pub get to use this version instead of 28.1.36

  syncfusion_flutter_core:
    dependency: transitive
    description:
      name: syncfusion_flutter_core
      sha256: f6d1e8c08361aed6fb7f7b6f327cbd190464e1c717c6152d59866b2f0bb90ffd
      url: "https://pub.dev"
    source: hosted
    version: "28.1.35"

@mehuldadlani
Copy link
Author

mehuldadlani commented Dec 29, 2024

I got the same error, and I think that is something wrong with the syncfusion_flutter_core that is imported by the syncfusion_flutter_charts package.

Until we have this fix, I will post here what I did to build my app normally.

Just set the past version on your pubspec.yaml to:

  syncfusion_flutter_charts: 28.1.35

And, on your pubspec.lock, set the same version to syncfusion_flutter_core, it will force you flutter pub get to use this version instead of 28.1.36

  syncfusion_flutter_core:
    dependency: transitive
    description:
      name: syncfusion_flutter_core
      sha256: f6d1e8c08361aed6fb7f7b6f327cbd190464e1c717c6152d59866b2f0bb90ffd
      url: "https://pub.dev"
    source: hosted
    version: "28.1.35"

This one just lets you build the app. Here, the chart is not visible yet.

@LavanyaGowtham2021 LavanyaGowtham2021 added charts Charts component open Open labels Dec 30, 2024
@hiteshgarg002
Copy link

+1

1 similar comment
@hazimOmar
Copy link

+1

@NgoTruongThanh
Copy link

In my case, upgrading Flutter resolved the issue.

@mehuldadlani
Copy link
Author

Can't upgrade the flutter version due to version constraints on my app but using one or 2 version older solved it

@dohyxx
Copy link

dohyxx commented Jan 7, 2025

I got this error in only github actions.
How to fix this error?

Error : The method 'withValues' isn't defined for the class 'Color'.

  • upgrading Flutter resolved the issue. (3.220 -> 3.27.1)

@mehuldadlani
Copy link
Author

Yes upgrading flutter will solve this error or else you can downgrade your syncfusion package and use that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
charts Charts component open Open
Projects
None yet
Development

No branches or pull requests

7 participants