how to create toolbar searchview in flutter

前端 未结 6 1302
不思量自难忘°
不思量自难忘° 2020-12-02 13:19

i need to implement searchview in toolbar my app to achieve list view list filter. like below image, i searched lot still not get proper answer. Any help will be appreciated

6条回答
  •  误落风尘
    2020-12-02 14:09

    If you want a simple search bar, you can do it with a customized TextField

    import 'package:flutter/material.dart';
    
    class SearchBar extends StatelessWidget {
      final void Function(String) onTextChange;
    
      SearchBar({ this.onTextChange });
    
      @override
      Widget build(BuildContext context) {
        return Container(
          height: 50,
          padding: EdgeInsets.all(8),
          child: TextField(
            onChanged: onTextChange,
            decoration: InputDecoration(
              fillColor: Colors.black.withOpacity(0.1),
              filled: true,
              prefixIcon: Icon(Icons.search),
              hintText: 'Search something ...',
              border: OutlineInputBorder(borderRadius: BorderRadius.circular(10), borderSide: BorderSide.none),
              contentPadding: EdgeInsets.zero
            )
          )
        );
      }
    }
    

提交回复
热议问题