Searching through all kinds of various content in your Flutter app is something you’ll likely have to implement one day. A successful search implementation needs basically two things - a usable search history and also the search bar widget. Now, we’re going to take a look at the most extensible and good-looking way to do this.
We’re going to build a simple project that will contain all of the basic building blocks of a good search implementation. The package that we’re going to use for the UI part is called material_floating_search_bar. There are many other packages and even the built-in showSearch function, but the package we’re using is one of the best ones out there in terms of customizability and it also looks really good out of the box.
When it comes to the search history part, we’re going to keep it simple. We could introduce all kinds of third-party dependencies like different state management packages and all kinds of persistent databases. However, we’re going to implement the history only inside a StatefulWidget and as an in-memory List. Yet, as you’ll see in a little while, the code will be easily applicable to any state management and database solution you like.
#flutter #dart #mobile-apps