0

I am trying to call the following hideOverlay function from a separate class

  hideOverlay() {
    overlayEntry?.remove();
    overlayEntry = null;

    if (overlayEntry != null) {
      overlayEntry.remove();
      overlayEntry = null;
    }
  }

In a separate class, I have imported the file containing the function and attempted to call the file by using.

hideOverlay();

I am a super newbie please advise what I am doing wrong :-(

1 Answer 1

1

Put hideOverlay() as a method in a Class, lets call that class 'FirstClass' and from a separate class call an object of the FirstClass class and call that hideOverlay() method like this.

import 'first_class.dart';

class SecondClass {
 FirstClass firstClass;
//call function like this when needed.
 firstClass.hiveOverlay()
}
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks @Fahmida, seems so simple when you know how!
yes, but you have to know first

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.