3

I wanted to allow a class that have a callback that passes back data to the main class.

So there is two class: First class contain the body of another widget from other class and a save button. The second class is the widget class stores in another file.

How to I save the value that had been inputted in the second class after i click the save button?

1 Answer 1

2

Can't you just do:

class WidgetWithCallback {
  VoidCallback onButtonPressed;
  ClassWithCallback(this.onButtonPressed);
  ...
}

If you want to apply a name to the callback then you could use:

ClassWithCallback({@required this.onButtonPressed});

Then within that widget just call the callback whenever the button is pressed or files selected, etc?

If you need to pass data back you can use a typedef.

Sign up to request clarification or add additional context in comments.

Comments

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.