Remove unnecessary code in dispose method and if widget is disposed