首页 > 解决方案 > Flutter:使用当前 mp_chart 版本构建错误

问题描述

更新旧颤振项目中的所有包后,我无法摆脱关于 mp_charts 的最后两个构建错误

错误:

../../../AppData/Local/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' ('../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;
                                 ^^^^
../../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/mp_chart-0.3.1/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 'C:\Users\...\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1070

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\Users\...\flutter\bin\flutter.bat'' 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 18s
Exception: Gradle task assembleDebug failed with exit code 1

pubspec.yaml:

environment:


sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter


  http: ^0.13.4
  meta: ^1.7.0
  flutter_blue: ^0.8.0
  flutter_secure_storage: ^4.2.1
  path_provider: any
  equatable: ^2.0.3
  permission_handler: ^8.2.5
  url_launcher: ^6.0.12
  shared_preferences: ^2.0.8
  package_info: ^2.0.2
  floor: ^1.2.0
  mp_chart: ^0.3.1
  tuple: ^2.0.0

dev_dependencies:
  flutter_test:
    sdk: flutter
  floor_generator: ^1.2.0
  build_runner: ^2.1.4

flutter:
  uses-material-design: true

我找不到可能导致此问题的特定代码部分,最新的 mp_chart 版本一般有问题吗?

标签: flutterandroid-studiogradle

解决方案


推荐阅读