ArcticZeroo / flutter-search-bar

(mostly) Automatic search-enabled appBar for flutter
BSD 3-Clause "New" or "Revised" License
266 stars 69 forks source link

Unable to show search bar #44

Open Switernal opened 3 years ago

Switernal commented 3 years ago

When I try to tap on the search button, the search bar doesn't open and just throws an error:

The method 'addLocalHistoryEntry' was called on null. Receiver: null Tried calling: addLocalHistoryEntry(Instance of 'LocalHistoryEntry')

What's the matter with it?

ArcticZeroo commented 3 years ago

I am unable to reproduce this in the example from the latest pr #46 . Can you show some code?

juvanjan commented 3 years ago

@ArcticZeroo The issue was on my side. I was able to fix it.

SteMMo33 commented 3 years ago

Hello, flutter_search_bar: ^2.1.0

I'm having the same problem: at the beginning I see the 'default' appbar with title and the lens icon. If I press the icon I see nothing but in the debug/run window I note that the 'build' function is recalled (setstate() ?) - no errors.

The code I used is basically the one from the example:

 searchBar = new SearchBar(
        inBar: true,
        buildDefaultAppBar: buildAppBar,
        setState: setState,
        hintText: "Filter",
        onSubmitted: onSearchSubmitted,
        onCleared: () {
          print("cleared");
        },
        onClosed: () {
          print("closed");
        }
    );

AppBar buildAppBar(BuildContext context) {
    return new AppBar(
        title: new Text(widget.title),
        actions: [searchBar.getSearchAction(context)]);
  }

  @override
  Widget build(BuildContext context) {
    //
    return Scaffold(
      appBar: buildAppBar(context),
...
SteMMo33 commented 3 years ago

Solved, I re-checked the code. The error was in the appbar: row.

@override
  Widget build(BuildContext context) {
    //
    return Scaffold(
      appBar: searchBar.build(context),

Thanks