Flushbar plugin: Error: The method 'attach' isn't defined for the class 'FocusScopeNode'

Issue

my previous project I used flushbar plugin without any error. but my new project when try to use flushbar i got error..

Project is working well without flushbar.

full error message

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();

I tried these four version, but nothing change

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

and also I used,

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

Solution

I was facing the same problem after flutter upgrade.
Remove ^ from your pubspec.yaml for now. It should work.

 flushbar: 1.5.3

Reference : https://github.com/flutter/flutter/issues/33827

Answered By – Rahul Bagal

Answer Checked By – David Marino (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *