问题
In Flutter, StatefulWidget has dispose() and deactivate(). How are they different?
回答1:
dispose is definitive. deactivate is not.
deactivate is called when a widget may be disposed. But that is not guaranteed.
A typical situation where deactivate is called but not dispose,is when moving widgets in the widget tree using a GlobalKey.
来源:https://stackoverflow.com/questions/56387243/difference-between-deactivate-and-dispose