Use `onPressed: wasExpanded = ...` idiom
This is a common snippet of code in applets. It prevents applet from re-expanding again when user clicks on the compact representation when the applet is already expanded and located on a desktop containment.