I want to know how to build a search bar where it filters the users search input into groups or tabs such as people, tags, places just like what instagram has but I don't know how to do this!


Solution 1: Butzlabben

It could look like this:

import 'package:flutter/material.dart';

main() => runApp(
      MaterialApp(
//          home: Scaffold(
//        body: Container(child: SearchButton()),
          home: Body()),
    );

class Body extends StatefulWidget {
  @override
  _BodyState createState() => _BodyState();
}

class _BodyState extends State<Body> {
  TextEditingController controller;

  @override
  void initState() {
    super.initState();
    controller = TextEditingController();
  }

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: 2,
      child: Scaffold(
        appBar: AppBar(
          leading: Icon(Icons.search),
          title: TextField(
            controller: controller,
            cursorColor: Colors.white,
            style: TextStyle(color: Colors.white),
          ),
          bottom: TabBar(tabs: [
            Tab(icon: Icon(Icons.people)),
            Tab(icon: Icon(Icons.location_city)),
          ]),
        ),
        body: TabBarView(children: [Container(), Container()]),
      ),
    );
  }
}

Wanted result:enter image description here

Result from Code: enter image description here