title: How to provide a BLoC (with flutter_bloc) to `showSearch`
body: <p>I am using the package <code>flutter_bloc</code> for state management. I want to create a search screen, and found the <code>showSearch</code> Flutter function, and have been having issues providing a <code>BLoC</code> instance to the <code>ListView</code> my <code>SearchDelegate</code> implementation creates. I finally made it work, but would like to ask what the best way of doing this is. Here is the code (excerpts, starting from a button that is placed in an <code>AppBar</code> within a <code>Scaffold</code>):</p>
  
  <pre class="lang-dart prettyprint-override"><code>class ItemSearchButton extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return IconButton(
        icon: Icon(Icons.search),
        onPressed: () {
          final itemListBloc = context.bloc&lt;ItemListBloc&gt;();
          showSearch(
            context: context,
            delegate: _ItemSearchDelegate(itemListBloc),
          );
        },
      );
    }
  }
  
  class _ItemSearchDelegate extends SearchDelegate&lt;String&gt; {
    final ItemListBloc itemListBloc;
  
    _ItemSearchDelegate(this.itemListBloc);
  
    // other overridden methods
  
    @override
    Widget buildSuggestions(BuildContext context) {
      return BlocProvider.value(
        value: itemListBloc,
        child: ItemListWidget(),
      );
    }
  }
  </code></pre>
  
  <p>Basically, the context that invokes the <code>showSearch</code> method has the correct BLoC instance, but it is not available within my <code>SearchDelegate</code> implementation, unless I re-provide it again explicitly in <code>buildSuggestions</code>.</p>
  
  <p>Why is the BLoC not available by default? The <code>showSearch</code> function internally pushes a new <code>Navigator</code> <code>Route</code>, is this the issue?</p>
  
  <p>What is the canonical way of dealing with things like this?</p>