0
votes

My flutter app uses different classes and needs to refresh and rebuild items, but the refresh is only called in initState, so it only refreshes at the start. Is there an overrideable function?

  @override
  void initState() {
    super.initState();
    refresh();
  }

  void refresh() {
    question = new Question(_raw);
  }
1

1 Answers

0
votes

There are two potential candidates:

  • didUpdateWidget. Which is called right before a state is build a second time. Whether it's from a setState or a parent update.

  • didChangeDependencies. This one is specific to InheritedWidget and will be called only when one of the InheritedWidget you subscribed to changed.