Flushbar 插件:错误:没有为类“FocusScopeNode”定义方法“附加”

Posted

技术标签:

【中文标题】Flushbar 插件:错误:没有为类“FocusScopeNode”定义方法“附加”【英文标题】:Flushbar plugin: Error: The method 'attach' isn't defined for the class 'FocusScopeNode' 【发布时间】:2019-11-14 19:34:48 【问题描述】:

我之前的项目我使用了flushbar插件,没有任何错误。但是我的新项目在尝试使用flushbar时出错了..

项目在没有flushbar的情况下运行良好。

完整的错误信息

Compiler message:
file:///Users/bhanukaisuru/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/flushbar-1.7.0/lib/flushbar.dart:207:3: Error: Type 'FocusAttachment' not found.
  FocusAttachment _focusAttachment;
  ^^^^^^^^^^^^^^^
file:///Users/bhanukaisuru/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/flushbar-1.7.0/lib/flushbar.dart:207:3: Error: 'FocusAttachment' isn't a type.
  FocusAttachment _focusAttachment;
  ^^^^^^^^^^^^^^^
file:///Users/bhanukaisuru/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/flushbar-1.7.0/lib/flushbar.dart:228:35: Error: The method 'attach' isn't defined for the class 'FocusScopeNode'.
 - 'FocusScopeNode' is from 'package:flutter/src/widgets/focus_manager.dart' ('file:///Users/bhanukaisuru/Documents/flutter/packages/flutter/lib/src/widgets/focus_manager.dart').
Try correcting the name to the name of an existing method, or defining a method named 'attach'.
    _focusAttachment = _focusNode.attach(context);
                                  ^^^^^^
file:///Users/bhanukaisuru/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/flushbar-1.7.0/lib/flushbar.dart:239:16: Error: The method 'dispose' isn't defined for the class 'FocusScopeNode'.
 - 'FocusScopeNode' is from 'package:flutter/src/widgets/focus_manager.dart' ('file:///Users/bhanukaisuru/Documents/flutter/packages/flutter/lib/src/widgets/focus_manager.dart').
Try correcting the name to the name of an existing method, or defining a method named 'dispose'.
    _focusNode.dispose();

我试过这四个版本,但没有任何变化

  flushbar: ^1.3.0
  flushbar: ^1.5.3
  flushbar: ^1.7.0
  flushbar: ^1.6.0

我也用过,

  FocusScope.of(context).requestFocus(FocusNode()),

【问题讨论】:

【参考方案1】:

flutter 升级后我也遇到了同样的问题。 暂时从您的 pubspec.yaml 中删除 ^。它应该可以工作。

 flushbar: 1.5.3

参考:https://github.com/flutter/flutter/issues/33827

【讨论】:

我会尽力让你知道...^是什么意思 插入符号 (^) 用于 Dart 中的 pub 依赖项,表示允许的版本号范围。具体来说,从指定版本到(但不包括)下一个非破坏版本的任何版本都可以。 So ^3.1.5 is the same as '>=3.1.5 <4.0.0'And ^1.2.3 would be the same as '>=1.2.3 <2.0.0'参考:***.com/questions/53563079/…

以上是关于Flushbar 插件:错误:没有为类“FocusScopeNode”定义方法“附加”的主要内容,如果未能解决你的问题,请参考以下文章

错误:没有为类“BuildContext”定义方法“ancestorInheritedElementForWidgetOfExactType”

Flutter 2 构建项目:错误:没有为类“_LoadingIndicatorState”定义方法“SpinKitPouringHourglass”

flutter-web: build_runner getter 'typeArguments' 没有为类 'Annotation' 错误定义

斯威夫特故事板中的“没有为类找到@implementation”错误

没有为类“对象”定义运算符“[]”。扑

没有为类定义 getter 'Timer'