flutter_cupertino_date_picker插件 提示 Error: Type 'DiagnosticableMixin' not found解决方案

发布于 3 年前 作者 phonegap100 2307 次浏览 最后一次编辑是 3 年前 来自 分享

在Flutter 1.22.4中使用 flutter_cupertino_date_picker的时候提示下面错误, Error: Type ‘DiagnosticableMixin’ not found解决方案

解决方案参考https://github.com/dylanwuzh/flutter-cupertino-date-picker/issues/126

55.png

:/flutter_windows/flutter/.pub-cache/hosted/pub.flutter-io.cn/flutter_cupertino_date_picker-1.0.26+2/lib/src/date_picker_theme.dart:23:32: Error: Type 'DiagnosticableMixin' not found.
class DateTimePickerTheme with DiagnosticableMixin {
                               ^^^^^^^^^^^^^^^^^^^
/F:/flutter_windows/flutter/.pub-cache/hosted/pub.flutter-io.cn/flutter_cupertino_date_picker-1.0.26+2/lib/src/date_picker_theme.dart:23:7: Error: The 
type 'DiagnosticableMixin' can't be mixed in.
class DateTimePickerTheme with DiagnosticableMixin {
      ^                                                                        
                                                                        
FAILURE: Build failed with an exception.

解决方案

pubspec.yaml中引入日期插件的方式:

flutter_cupertino_date_picker: ^1.0.26+2

替换为

	flutter_cupertino_date_picker:
   		git: https://github.com/yasseralsamman/flutter-cupertino-date-picker.git

替换完成的效果


dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter  
  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.0
  date_format: ^1.0.9  
  flutter_cupertino_date_picker:
    git: https://github.com/yasseralsamman/flutter-cupertino-date-picker.git

回到顶部