I'm sure this is going to be a simple and easy one, but I'm still too new, and have zero clue as to how to resolve.
I was having an issue with my program, in that I needed to run a method/function in my class, but couldn't merely add the class that contains it as a final variable into the class that needed it, because I couldn't be certain that the particular copy of the class that needed it would be active in the hierarchy.
So my solution (Thanks to Stack Overflow) was to separate the logic out, thanks to the suggestion on How to call method from another class in Flutter(Dart)?
There proved to be a few errors though in trying to implement it.
I was able to separate off the functions/methods into a separate logic class, and add the logic class alone as a final, not a problem.
going from:
class MyClass extends StatefulWidget {
// Random code that is unimportant to the question
void myMethod(){}
}
to:
class Logic {
void myMethod(){}
}
class MyClass extends StatefulWidget {
final Logic logic;
MyClass(this.logic);
// Random code that is unimportant to the question
}
and using this.myMethod(); to call the function is perfectly fine, no issues.
My issue however, is that there are several times in the program where I'm creating an instance of MyClass(); and it's apparently missing a "positional argument" now, where it didn't need it previously. I tried adding a positional argument for Logic: but that wasn't an available option, so... what is needed? I know I just need to pass something in through to them, but I don't know what.