I have created the Search bar, I need to add a functionality to it so that whenever the user scrolls down, the search bar turns into an icon in the appbar which can be clicked again to expand.
This is the appbar container
Container(
height: 122,
color: AppColors.kDefaultPink,
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
//Location text
SizedBox(height: 10.0,),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.location_on,
color: Colors.white,
),
SizedBox(width: 12.0),
Text("Delhi NCR",style: TextStyle(color: Colors.white, fontSize: 18.0),),
],
),
SizedBox(height: 20.0,),
//SearchBOX
SearchBox(onChanged: (value) {}),
],
),
),
),
This is the code for the search bar that would be present in the appbar
import 'package:flutter/material.dart';
import 'package:zattireuserapp/views/AppColors.dart';
class SearchBox extends StatelessWidget {
final ValueChanged onChanged;
const SearchBox({Key key, this.onChanged}) : super(key: key);
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 5),
child: Container(
width: 390,
height: 45,
margin: EdgeInsets.symmetric(horizontal: 22.0),
decoration: BoxDecoration(
color: Colors.white.withOpacity(1),
borderRadius: BorderRadius.circular(12),
),
child: TextField(
onChanged: onChanged,
style: TextStyle(color: AppColors.blackColor),
decoration: InputDecoration(
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
prefixIcon: Icon(Icons.search),
hintText: 'Search for anything',
hintStyle: TextStyle(fontSize: 15),
),
),
),
);
}
}