flutter通用Widget混入AutomaticKeepAl
2021-04-15 本文已影响0人
Janise001
当通用场景在不同地方调用要求其切换时不得重建,即要求该通用场景不得调用initState方法,这个时候需要对class混入AutomaticKeepAliveClientMixin,并设置wantKeepAlive为true,这样在不同场景中调用切换时都不会相互影响且不会调用initState方法
当通用场景在不同地方调用要求其切换时不得重建,即要求该通用场景不得调用initState方法,这个时候需要对class混入AutomaticKeepAliveClientMixin,并设置wantKeepAlive为true,这样在不同场景中调用切换时都不会相互影响且不会调用initState方法