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

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

Open
KalybosPro opened this issue Jan 16, 2025 · 3 comments
Open
Labels
pdf viewer PDF viewer component solved Solved the query using existing solutions

Comments

@KalybosPro
Copy link

Bug description

error: ../../../.pub-cache/hosted/pub.dev/syncfusion_flutter_pdfviewer-28.1.39/lib/src/pdfviewer.dart:2242:39: Error: The method 'withValues' isn't defined for the class 'Color'.

  • 'Color' is from 'dart:ui'.
    Try correcting the name to the name of an existing method, or defining a method named 'withValues'.
    color: Colors.black.withValues(alpha: 0.3),
    ^^^^^^^^^^
    ../../../.pub-cache/hosted/pub.dev/syncfusion_flutter_pdfviewer-28.1.39/lib/src/pdfviewer.dart:2289:58: Error: The method 'withValues' isn't defined for the class 'Color'.
  • 'Color' is from 'dart:ui'.
    Try correcting the name to the name of an existing method, or defining a method named 'withValues'.
    ? Colors.black.withValues(alpha: 0.87)
    ^^^^^^^^^^
    ../../../.pub-cache/hosted/pub.dev/syncfusion_flutter_pdfviewer-28.1.39/lib/src/pdfviewer.dart:2290:58: Error: The method 'withValues' isn't defined for the class 'Color'.
  • 'Color' is from 'dart:ui'.
    Try correcting the name to the name of an existing method, or defining a method named 'withValues'.
    : Colors.white.withValues(alpha: 0.87)
    ^^^^^^^^^^
    ../../../.pub-cache/hosted/pub.dev/syncfusion_flutter_pdfviewer-28.1.39/lib/src/pdfviewer.dart:2325:38: Error: The method 'withValues' isn't defined for the class 'Color'.
  • 'Color' is from 'dart:ui'.
    Try correcting the name to the name of an existing method, or defining a method named 'withValues'.
    .withValues(alpha: 0.6),
    ^^^^^^^^^^
    ../../../.pub-cache/hosted/pub.dev/syncfusion_flutter_pdfviewer-28.1.39/lib/src/pdfviewer.dart:2347:52: Error: The method 'withValues' isn't defined for the class 'Color'.
  • 'Color' is from 'dart:ui'.
    Try correcting the name to the name of an existing method, or defining a method named 'withValues'.
    ? Colors.black.withValues(alpha: 0.6)
    ^^^^^^^^^^
    ../../../.pub-cache/hosted/pub.dev/syncfusion_flutter_pdfviewer-28.1.39/lib/src/pdfviewer.dart:2348:52: Error: The method 'withValues' isn't defined for the class 'Color'.
  • 'Color' is from 'dart:ui'.
    Try correcting the name to the name of an existing method, or defining a method named 'withValues'.
    : Colors.white.withValues(alpha: 0.6),
    ^^^^^^^^^^
    ../../../.pub-cache/hosted/pub.dev/syncfusion_flutter_pdfviewer-28.1.39/lib/src/pdfviewer.dart:2431:50: Error: The method 'withValues' isn't defined for the class 'Color'.
  • 'Color' is from 'dart:ui'.
    Try correcting the name to the name of an existing method, or defining a method named 'withValues'.
    .withValues(alpha: 0.38)
    ^^^^^^^^^^
    ../../../.pub-cache/hosted/pub.dev/syncfusion_flutter_pdfviewer-28.1.39/lib/src/pdfviewer.dart:2434:50: Error: The method 'withValues' isn't defined for the class 'Color'.
  • 'Color' is from 'dart:ui'.
    Try correcting the name to the name of an existing method, or defining a method named 'withValues'.
    .withValues(alpha: 0.38))
    ^^^^^^^^^^

Steps to reproduce

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

Code sample

Code sample
import 'package:dm_app/utils/icons/custom_icon.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';

class WebViewPage extends StatelessWidget {
  final String url;
  final bool fromAsset;
  const WebViewPage({
    super.key,
    required this.url,
    this.fromAsset = true,
  });

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        height: ScreenUtil().screenHeight,
        width: ScreenUtil().screenWidth,
        padding: EdgeInsets.only(top: 20.h),
        child: Stack(
          children: [
            if (fromAsset) ...{
              SfPdfViewer.asset(url)
            } else ...{
              SfPdfViewer.network(url)
            },
            Positioned(
              top: 20.h,
              left: 15.w,
              child: const CustomIcon(),
            ),
          ],
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

error: ../../../.pub-cache/hosted/pub.dev/syncfusion_flutter_pdfviewer-28.1.39/lib/src/pdfviewer.dart:2242:39: Error: The method 'withValues' isn't defined for the class 'Color'.

  • 'Color' is from 'dart:ui'.
    Try correcting the name to the name of an existing method, or defining a method named 'withValues'.
    color: Colors.black.withValues(alpha: 0.3),
    ^^^^^^^^^^
    ../../../.pub-cache/hosted/pub.dev/syncfusion_flutter_pdfviewer-28.1.39/lib/src/pdfviewer.dart:2289:58: Error: The method 'withValues' isn't defined for the class 'Color'.
  • 'Color' is from 'dart:ui'.
    Try correcting the name to the name of an existing method, or defining a method named 'withValues'.
    ? Colors.black.withValues(alpha: 0.87)
    ^^^^^^^^^^
    ../../../.pub-cache/hosted/pub.dev/syncfusion_flutter_pdfviewer-28.1.39/lib/src/pdfviewer.dart:2290:58: Error: The method 'withValues' isn't defined for the class 'Color'.
  • 'Color' is from 'dart:ui'.
    Try correcting the name to the name of an existing method, or defining a method named 'withValues'.
    : Colors.white.withValues(alpha: 0.87)
    ^^^^^^^^^^

Stack Traces

Stack Traces
none

On which target platforms have you observed this bug?

iOS

Flutter Doctor output

Doctor output
none
@RamiroNoronha
Copy link

RamiroNoronha commented Jan 16, 2025

I had the same problem, but in mobile development (Android) and using the SfcartesianChart. I solved this by updating my Flutter SDK. I think you are using an incompatible version between the package and Flutter

@VijayakumarMariappan VijayakumarMariappan added pdf viewer PDF viewer component open Open labels Jan 17, 2025
@immankumarsync
Copy link
Contributor

Hi @KalybosPro,
We have migrated our source to Flutter SDK 3.27. In this version, there are breaking changes in the Color class.
Breaking change: https://docs.flutter.dev/release/breaking-changes/wide-gamut-framework#migrate-withopacity

So, kindly upgrade the Flutter SDK to 3.27 and rebuild your application to resolve this issue.
If you are not willing to upgrade the Flutter SDK, please use syncfusion_flutter_pdfviewer package version 28.1.35 or below.

Please find the Flutter SDK compatibility table from the link,
https://help.syncfusion.com/flutter/system-requirements#sdk-version-compatibility

@Deepak1799 Deepak1799 added solved Solved the query using existing solutions and removed open Open labels Jan 17, 2025
@KalybosPro
Copy link
Author

It worked after upgrading Flutter version from 3.5.6 to 3.27.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pdf viewer PDF viewer component solved Solved the query using existing solutions
Projects
None yet
Development

No branches or pull requests

5 participants