title: Preserving the State of a Drawer in Flutter
body: <p>I have a stateful <code>Scaffold</code> widget, where the <code>body</code> contains a list of entities with various properties (e.g. shoes or cars) and <code>Drawer</code> widget, which is empty at first, except for two buttons at the bottom (&quot;Cancel&quot; and &quot;Filter&quot;) and a FAB. The user can add various filters with the FAB (e.g. the user can add a shoesize-filter, or a color-filter).</p>
  <p>The problem I have is the following: Let's say the user selects various filters and works with them (i.e. ticks checkboxes, enters a shoesize, changes sliders, etc.). When the user is ready to apply the filters, he can click the &quot;Filter&quot; button, which closes the <code>Drawer</code> (<code>onTap -&gt; callback -&gt; Navigator.of(context).pop()</code>). But when the user wants to go back, reopen the <code>Drawer</code>, and adjust one of the filters, it obviously doesn't work, since the widget is being rebuilt from scratch.</p>
  <p>Currently, the way the filtering works is, once the &quot;Filter&quot; Button is pressed, all the various values from the added filters are collected into an object <code>FilterPackage</code>, which is then passed via <code>callback</code> to the <code>Scaffold</code> widget, which then applies the values from the <code>FilterPackage</code> to the list of entities.
  One solution I came up with, would be feeding this <code>FilterPackage</code> object to the <code>Drawer</code> widget in its constructor, which would provide all the information necessary to rebuild the widget just how it has to be.</p>
  <p>Is that a reasonable solution? I have already made some research, but struggled finding a solution on what would clearly be the best and recommended way to preserve the drawer's state. Using <code>PageStorage</code> / <code>PageStorageBucket</code> seems overly complicated for this case. Or am I wrong?</p>
  <p>Thanks in advance for any guidance.</p>