Flutter not compiling error Error: The method 'CustomStyle.copyWith' has fewer named arguments than those of overridden method 'TextStyle.copyWith'
Flutter not compiling error Error: The method 'CustomStyle.copyWith' has fewer named arguments than those of overridden method 'TextStyle.copyWith'
当我托盘编译时(屏幕上没有编程错误)但在编译中显示这些错误日志:
*/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/styled_text-3.0.4+1/lib/custom_style.dart:17:13:
Error: The method 'CustomStyle.apply' has fewer named arguments than
those of overridden method 'TextStyle.apply'.
TextStyle apply({
^
这是我的pubspec.yaml
name: myprject description: A new Flutter project. publish_to: 'none'
version: 1.0.0+1 environment: sdk: ">=2.12.0 <3.0.0" dependencies:
flutter: sdk: flutter cupertino_icons: ^1.0.2
flutter_staggered_grid_view: ^0.4.1 rflutter_alert: ^2.0.4
connectivity: ^3.0.6 path_provider: ^2.0.6 dio: ^4.0.1
percent_indicator: ^3.4.0 flutter_archive: ^4.1.0
flutter_webview_plugin: ^0.4.0 flutter_inappwebview: ^5.3.2
flutter_staggered_animations: ^1.0.0 flutter_scale_tap: ^1.0.5
intl: ^0.17.0 shared_preferences: ^2.0.8 flutter_svg: ^0.23.0+1
styled_text: ^3.0.4+1 audio_service: ^0.18.1 just_audio: ^0.9.18
url_launcher: ^6.0.16 permission_handler: ^8.3.0 animations:
^2.0.2 transformer_page_view: ^0.1.6 chewie: ^1.2.2
video_player: ^2.2.7 flutter_colorpicker: ^1.0.3 vibration:
^1.7.4-nullsafety.0 flare_flutter: ^3.0.2 rive: ^0.8.1
screenshot: ^1.2.3 share_plus: ^3.0.4 external_path: ^1.0.1
flame: ^1.0.0 flutter_fortune_wheel: ^1.2.0 elliptic_text:
^1.0.1+9
dev_dependencies: flutter_test:
sdk: flutter sqflite: ^2.0.0+4
flutter_lints: ^1.0.0 http: ^0.13.3 provider: ^5.0.0
flutter: uses-material-design: true assets:
- assets/ fonts:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.10.5, on Microsoft Windows [Versión 10.0.19044.1645], locale es-MX)
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.6)
[√] Android Studio (version 2020.3)
[√] VS Code (version 1.66.2)
[√] Connected device (6 available)
[√] HTTP Host Availability
这看起来像是您的 Flutter 版本(相对较新)与 styled_text
软件包的(半年)旧版本之间的不匹配。据我了解,Style
类 中 copyWith
函数的函数签名发生了变化。只需更新依赖项就可以了。在您的 pubspec.yaml 文件中替换它:
styled_text: ^5.1.0
作为一般提示,您可以 运行 flutter pub outdated
识别可以更新的包。
当我托盘编译时(屏幕上没有编程错误)但在编译中显示这些错误日志:
*/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/styled_text-3.0.4+1/lib/custom_style.dart:17:13:
Error: The method 'CustomStyle.apply' has fewer named arguments than those of overridden method 'TextStyle.apply'. TextStyle apply({ ^
这是我的pubspec.yaml
name: myprject description: A new Flutter project. publish_to: 'none' version: 1.0.0+1 environment: sdk: ">=2.12.0 <3.0.0" dependencies:
flutter: sdk: flutter cupertino_icons: ^1.0.2
flutter_staggered_grid_view: ^0.4.1 rflutter_alert: ^2.0.4
connectivity: ^3.0.6 path_provider: ^2.0.6 dio: ^4.0.1
percent_indicator: ^3.4.0 flutter_archive: ^4.1.0
flutter_webview_plugin: ^0.4.0 flutter_inappwebview: ^5.3.2
flutter_staggered_animations: ^1.0.0 flutter_scale_tap: ^1.0.5
intl: ^0.17.0 shared_preferences: ^2.0.8 flutter_svg: ^0.23.0+1
styled_text: ^3.0.4+1 audio_service: ^0.18.1 just_audio: ^0.9.18
url_launcher: ^6.0.16 permission_handler: ^8.3.0 animations: ^2.0.2 transformer_page_view: ^0.1.6 chewie: ^1.2.2
video_player: ^2.2.7 flutter_colorpicker: ^1.0.3 vibration: ^1.7.4-nullsafety.0 flare_flutter: ^3.0.2 rive: ^0.8.1
screenshot: ^1.2.3 share_plus: ^3.0.4 external_path: ^1.0.1
flame: ^1.0.0 flutter_fortune_wheel: ^1.2.0 elliptic_text: ^1.0.1+9dev_dependencies: flutter_test: sdk: flutter sqflite: ^2.0.0+4
flutter_lints: ^1.0.0 http: ^0.13.3 provider: ^5.0.0
flutter: uses-material-design: true assets: - assets/ fonts:
Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 2.10.5, on Microsoft Windows [Versión 10.0.19044.1645], locale es-MX) [√] Android toolchain - develop for Android devices (Android SDK version 31.0.0) [√] Chrome - develop for the web [√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.6) [√] Android Studio (version 2020.3) [√] VS Code (version 1.66.2) [√] Connected device (6 available) [√] HTTP Host Availability
这看起来像是您的 Flutter 版本(相对较新)与 styled_text
软件包的(半年)旧版本之间的不匹配。据我了解,Style
类 中 copyWith
函数的函数签名发生了变化。只需更新依赖项就可以了。在您的 pubspec.yaml 文件中替换它:
styled_text: ^5.1.0
作为一般提示,您可以 运行 flutter pub outdated
识别可以更新的包。