MPFlutterChart icon indicating copy to clipboard operation
MPFlutterChart copied to clipboard

The method 'then' isn't defined for the class 'FutureOr<dynamic>'

Open safu2011 opened this issue 4 years ago • 5 comments

Try correcting the name to the name of an existing method, or defining a method named 'then'. .then((value) { ^^^^ /C:/flutter/.pub-cache/hosted/pub.dartlang.org/mp_chart-0.3.1/lib/mp/core/utils/painter_utils.dart:15:34: Error: The getter 'text' isn't defined for the class 'InlineSpan'.

  • 'InlineSpan' is from 'package:flutter/src/painting/inline_span.dart' ('/C:/flutter/packages/flutter/lib/src/painting/inline_span.dart'). Try correcting the name to the name of an existing getter, or defining a getter or field named 'text'. var preText = painter.text.text;

safu2011 avatar Oct 14 '21 13:10 safu2011

I am facing the same error.

../../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/mp_chart-0.2.2/lib/mp/core/utils/painter_utils.dart:15:34: Error: The getter 'text' isn't defined for the class 'InlineSpan'.
 - 'InlineSpan' is from 'package:flutter/src/painting/inline_span.dart' ('../../../snap/flutter/common/flutter/packages/flutter/lib/src/painting/inline_span.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'text'.
      var preText = painter.text.text;                                  
                                 ^^^^                                   
../../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/mp_chart-0.2.2/lib/mp/chart/chart.dart:51:12: Error: The method 'then' isn't defined for the class 'FutureOr<dynamic>'.
Try correcting the name to the name of an existing method, or defining a method named 'then'.
          .then((value) {                                               
           ^^^^                                                         
                                                                        
                                                                        
FAILURE: Build failed with an exception.                                
                                                                        
* Where:                                                                
Script '/home/bmabir/snap/flutter/common/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1035
                                                                        
* What went wrong:                                                      
Execution failed for task ':app:compileFlutterBuildDebug'.              
> Process 'command '/home/bmabir/snap/flutter/common/flutter/bin/flutter'' 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 25s

flutter doctor -v output

[✓] Flutter (Channel stable, 2.2.1, on Linux, locale en_US.UTF-8)
    • Flutter version 2.2.1 at /home/bmabir/snap/flutter/common/flutter
    • Framework revision 02c026b03c (5 months ago), 2021-05-27 12:24:44 -0700
    • Engine revision 0fdb562ac8
    • Dart version 2.13.1

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /home/bmabir/Android
    • Platform android-30, build-tools 29.0.3
    • Java binary at: /usr/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_292-8u292-b10-0ubuntu1~20.04-b10)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).

[✓] VS Code (version 1.61.1)
    • VS Code at /usr/share/code
    • Flutter extension version 3.27.0

[✓] Connected device (2 available)
    • Mi A2 Lite (mobile) • 28d9cc140205 • android-arm64  • Android 10 (API 29)
    • Chrome (web)        • chrome       • web-javascript • Google Chrome 94.0.4606.8

And my pubspec.yaml

environment:
  sdk: ">=2.7.0 <3.0.0"
  flutter: 1.17.5

dependencies:
  flutter:
    sdk: flutter

  rxdart: ^0.23.0
  flutter_bloc: ^5.0.1
  provider: ^4.3.1
  fluttertoast: ^7.0.1
  math_expressions: ^2.0.0
  moor_flutter: ^3.1.0
  sqlite3_flutter_libs: ^0.5.0
  path_provider: ^1.6.11
  path: ^1.6.4
  table_calendar: ^2.2.3
  intl: ^0.16.1
  percent_indicator: ^2.1.5
  date_range_picker: ^1.0.5
  mp_chart: ^0.2.2
  shared_preferences: 0.5.8
  csv: ^4.0.3
  moor_generator: ^3.2.0
  build_runner: ^1.10.0

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.3

bmabir17 avatar Oct 26 '21 16:10 bmabir17

https://github.com/SunPointed/MPFlutterChart/issues/155#issuecomment-773995265 this solution solves the following error temporarily.

Try correcting the name to the name of an existing getter, or defining a getter or field named 'text'.
      var preText = painter.text.text;                                  
                                 ^^^^ 

But the other one remains

Try correcting the name to the name of an existing method, or defining a method named 'then'.
          .then((value) {                                               
           ^^^^            

bmabir17 avatar Oct 26 '21 19:10 bmabir17

@bmabir17 this seems to solve the other error for me.

 _screenshotController
        .capture(path: path, pixelRatio: 3.0)
        .then((imgFile) async {
      await ImageGallerySaver.saveImage(
          Uint8List.fromList(imgFile.readAsBytesSync()));
      imgFile.delete();

      isCapturing = false;
    }).catchError((error) {
      isCapturing = false;
    });

qwales1 avatar Oct 28 '21 14:10 qwales1

same issue on flutter 2.8.1

lyf571321556 avatar Dec 24 '21 11:12 lyf571321556

This appears to be the result of a change with the image_gallery_saver library and its change of ImageGallerySaver.saveImage now returning a FutureOr instead of a Future. If you don't want to deal with editing the pub cache (a PR would be great for the project), you can add to your pubspec.yaml file the following:

mp_chart: ^0.3.1
image_gallery_saver: <1.7.1

Didn't play around with the versioning too much, but the above seems to get the latest "compatible" versions.

Still have to fix the cast to painter.text to TextSpan, so not sure what this buys you.

andymeadows avatar Mar 31 '22 05:03 andymeadows