We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Error: The argument type 'String?' can't be assigned to the parameter type 'Object' because 'String?' is nullable and 'Object' isn't.

Example from pub dev returns this mensage:

Error: The argument type 'String?' can't be assigned to the parameter type 'Object' because 'String?' is nullable and 'Object' isn't.
../…/forms/pdf_xfdf_document.dart:38
- 'Object' is from 'dart:core'.

builder.attribute('rel='nofollow' href', _pdfFilePath);


class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('PDF Viewer'),
      ),
      body: Center(
        child: SfPdfViewer.network(
            'https://cdn.syncfusion.com/content/PDFViewer/flutter-succinctly.pdf'),
      ),
    );
  }
}


Somebody save me :)












9 Replies

DR Deepika Ravi Syncfusion Team February 2, 2023 06:30 AM UTC

Hi CLAUDIO DIEGO SOUSA RAMOS,

We tried to replicate the issue with provided details, but the PDF is loaded properly on our end. For your reference we have prepared the sample and it can be downloaded from the attachment. Kindly share the modified issue reproducing in sample and also share the following details,

  • syncfusion_flutter_pdfviewer version

  • Flutter SDK version

  • Issue reproducing document

  • Issue reproducing steps


This information will be helpful for us to provide the prompt solution at earliest.

Regards,

Deepika R


Attachment: fourm_180301_10bf3050.zip


SH Shan February 7, 2023 01:58 AM UTC

I am having similart issue.


BUILD FAILED in 2m 28s
Retrying Gradle Build: #1, wait time: 100ms
[!] Gradle threw an error while downloading artifacts from the network.
Running Gradle task 'assembleOneAppProductionDebug'...
../../../../.pub-cache/hosted/pub.dartlang.org/syncfusion_flutter_core-20.4.48/lib/src/widgets/interactive_scroll_viewer.dart:59:9: Error: Type 'PanAxis' not found.
  final PanAxis panAxis;
        ^^^^^^^
../../../../.pub-cache/hosted/pub.dartlang.org/syncfusion_flutter_core-20.4.48/lib/src/widgets/interactive_scroll_viewer.dart:15:22: Error: Undefined name 'PanAxis'.
      this.panAxis = PanAxis.free,
                     ^^^^^^^
../../../../.pub-cache/hosted/pub.dartlang.org/syncfusion_flutter_pdfviewer-20.4.48/lib/src/pdfviewer.dart:1016:54: Error: Method 'readState' cannot be called on 'PageStorageBucket?' because it is potentially null.
 - 'PageStorageBucket' is from 'package:flutter/src/widgets/page_storage.dart' ('../../../../fvm/versions/3.3.3/packages/flutter/lib/src/widgets/page_storage.dart').
Try calling using ?. instead.
      final dynamic offset = PageStorage.of(context).readState(context);
                                                     ^^^^^^^^^
../../../../.pub-cache/hosted/pub.dartlang.org/syncfusion_flutter_pdfviewer-20.4.48/lib/src/pdfviewer.dart:1020:12: Error: Method 'readState' cannot be called on 'PageStorageBucket?' because it is potentially null.
 - 'PageStorageBucket' is from 'package:flutter/src/widgets/page_storage.dart' ('../../../../fvm/versions/3.3.3/packages/flutter/lib/src/widgets/page_storage.dart').
Try calling using ?. instead.
          .readState(context, identifier: 'zoomLevel_${widget.key}');
           ^^^^^^^^^
../../../../.pub-cache/hosted/pub.dartlang.org/syncfusion_flutter_pdfviewer-20.4.48/lib/src/pdfviewer.dart:3244:35: Error: Method 'writeState' cannot be called on 'PageStorageBucket?' because it is potentially null.
 - 'PageStorageBucket' is from 'package:flutter/src/widgets/page_storage.dart' ('../../../../fvm/versions/3.3.3/packages/flutter/lib/src/widgets/page_storage.dart').
Try calling using ?. instead.
          PageStorage.of(context).writeState(
                                  ^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dartlang.org/syncfusion_flutter_pdfviewer-20.4.48/lib/src/pdfviewer.dart:3272:35: Error: Method 'writeState' cannot be called on 'PageStorageBucket?' because it is potentially null.
 - 'PageStorageBucket' is from 'package:flutter/src/widgets/page_storage.dart' ('../../../../fvm/versions/3.3.3/packages/flutter/lib/src/widgets/page_storage.dart').
Try calling using ?. instead.
          PageStorage.of(context).writeState(
                                  ^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dartlang.org/syncfusion_flutter_core-20.4.48/lib/src/widgets/interactive_scroll_viewer.dart:59:9: Error: 'PanAxis' isn't a type.
  final PanAxis panAxis;
        ^^^^^^^
../../../../.pub-cache/hosted/pub.dartlang.org/syncfusion_flutter_core-20.4.48/lib/src/widgets/interactive_scroll_viewer.dart:299:9: Error: No named parameter with the name 'panAxis'.
        panAxis: widget.panAxis,
        ^^^^^^^
../../../../fvm/versions/3.3.3/packages/flutter/lib/src/widgets/interactive_viewer.dart:61:3: Context: Found this candidate, but the arguments don't match.
  InteractiveViewer({
  ^^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dartlang.org/syncfusion_flutter_pdf-20.4.48/lib/src/pdf/implementation/forms/pdf_xfdf_document.dart:38:35: Error: The argument type 'String?' can't be assigned to the parameter type 'Object' because 'String?' is nullable and 'Object' isn't.
 - 'Object' is from 'dart:core'.
        builder.attribute('rel='nofollow' href', _pdfFilePath);



DR Deepika Ravi Syncfusion Team February 7, 2023 06:04 AM UTC

Hi CLAUDIO DIEGO SOUSA RAMOS, The reported issue is caused by a recent upgrade to the Flutter version. In previous versions, the alignPanAxis property was a Boolean, but in version 3.7.0, it was changed to an Enum type. To resolve this issue, upgrade the Flutter SDK to the latest version [3.7.0] and also upgrade the latest Syncfusion package version [20.4.48].


PdfViewer package: https://pub.dev/packages/syncfusion_flutter_pdfviewer/versions/20.4.48

FlutterSDK: https://storage.googleapis.com/flutter_infra_release/releases/stable/windows/flutter_windows_3.7.0-stable.zip



UT usama Tahir February 10, 2023 09:59 AM UTC

I'm having the following problem:

Error: The argument type 'String?' can't be assigned to the parameter type 'Object' because 'String?' is nullable and 'Object' isn't.
 - 'Object' is from 'dart:core'.

        builder.attribute('rel='nofollow' href', _pdfFilePath);


I have flutter version 3.7.2 and using the latest version of syncfusion flutter pdfviewer that is 20.4.49.

I think it is having the compatibility issue with the latest version of flutter.

Kindly brief me on this.



MB Matt Booth February 13, 2023 05:19 AM UTC

Hi. I am also having the same issue. All my Syncfusion is at 20.4.49 and my flutter is on 3.7.3.


../../../../../AppData/Local/Pub/Cache/hosted/pub.dev/syncfusion_flutter_pdf-20.4.49/lib/src/pdf/implementation/forms/pdf_xfdf_document.dart:38:35: Error: The argument type 'String?' can't be assigned to the parameter type 'Object' because 'String?' is nullable and 'Object' isn't.

 - 'Object' is from 'dart:core'.

        builder.attribute('rel='nofollow' href', _pdfFilePath);



DA Daniel Ardison February 13, 2023 02:53 PM UTC

I have the same problem.

Syncfusion is at 20.4.49 and Flutter is on 3.7.3


Error: The argument type 'String?' can't be assigned to the parameter type 'Object' because 'String?' is nullable and 'Object' isn't.
../…/forms/pdf_xfdf_document.dart:38
- 'Object' is from 'dart:core'.
builder.attribute('rel='nofollow' href', _pdfFilePath);


DR Deepika Ravi Syncfusion Team February 13, 2023 03:26 PM UTC

Hi Matt Booth ,Kindly run the flutter clean command to clear the cache, then check the reported issue and let us know if the issue is resolved or not.



DA Daniel Ardison February 13, 2023 06:53 PM UTC

Hi,


I try:

flutter clean

Flutter pub get


but the issue was not resolved. 



DR Deepika Ravi Syncfusion Team February 14, 2023 06:33 AM UTC

Hi Daniel Ardison,

We found that the problem is due to the older version of the xml package being referred to in your project. Recently, the XmlBuilder attribute value API has been updated from non-nullable to nullable type; you can refer to the following API reference for further details.


Xml package version 6.2.0

Xml package version 6.2.2

https://pub.dev/documentation/xml/6.2.0/xml/XmlBuilder/attribute.html

 

https://pub.dev/documentation/xml/latest/xml/XmlBuilder/attribute.html


So, we request you to update your pub cache by using the following command to resolve the issue. 

dart pub cache add xml --version "6.2.2"


You can refer to https://dart.dev/tools/pub/cmd/pub-cache for more details.


Loader.
Up arrow icon