0

I have a long method in a State class which I want to use in any other state class. So How can I do such that ?

Filburt
  • 17,626
  • 12
  • 64
  • 115

2 Answers2

0

you can pass that method to the other class constructor. for example:

class ContainingMethod() {

MethodTaker(method)

method() {
...
}

}

// The class which method is passed to 

class MethodTaker {
final method;
MethodTaker(this.method)
}
Benyamin
  • 1,008
  • 11
  • 18
0

you probably want to understand state management. By reading a little further into your question, I'd say you want to study and implement the Provider package.

venir
  • 1,809
  • 7
  • 19