Advertisement
FahimHoque

search_Page.dart

Dec 13th, 2021
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 2.50 KB | None | 0 0
  1. class SearchPage extends StatefulWidget {
  2.   const SearchPage({Key? key}) : super(key: key);
  3.  
  4.   @override
  5.   _SearchPageState createState() => _SearchPageState();
  6. }
  7.  
  8. class _SearchPageState extends State<SearchPage> {
  9.   final controller = FloatingSearchBarController();
  10.  
  11.   @override
  12.   Widget build(BuildContext context) {
  13.     return SafeArea(
  14.       child: Scaffold(
  15.         body: Center(
  16.           child: buildFloatingSearchBar(),
  17.         ),
  18.       ),
  19.     );
  20.   }
  21.  
  22.   Widget buildFloatingSearchBar() {
  23.     final isPortrait =
  24.         MediaQuery.of(context).orientation == Orientation.portrait;
  25.  
  26.     return FloatingSearchBar(
  27.       hint: 'Search...',
  28.       scrollPadding: const EdgeInsets.only(top: 16, bottom: 56),
  29.       transitionDuration: const Duration(milliseconds: 800),
  30.       transitionCurve: Curves.easeInOut,
  31.       physics: const BouncingScrollPhysics(),
  32.       axisAlignment: isPortrait ? 0.0 : -1.0,
  33.       openAxisAlignment: 0.0,
  34.       width: isPortrait ? 600 : 500,
  35.       debounceDelay: const Duration(milliseconds: 500),
  36.       onQueryChanged: (query) {
  37.         print('Query changed: $query');
  38.       },
  39.       transition: CircularFloatingSearchBarTransition(),
  40.       actions: [
  41.         FloatingSearchBarAction(
  42.           showIfOpened: false,
  43.           child: CircularButton(
  44.             icon: const Icon(Icons.place),
  45.             onPressed: () {},
  46.           ),
  47.         ),
  48.         FloatingSearchBarAction.searchToClear(
  49.           showIfClosed: false,
  50.         ),
  51.       ],
  52.       builder: (context, transition) {
  53.         return ClipRRect(
  54.           borderRadius: BorderRadius.circular(8),
  55.           child: Material(
  56.             color: Colors.white,
  57.             elevation: 4.0,
  58.             child: _buildSearchHistoryContainer(),
  59.           ),
  60.         );
  61.       },
  62.     );
  63.   }
  64.  
  65.   Widget _buildSearchHistoryContainer() {
  66.     return Container(
  67.       padding: EdgeInsets.all(20),
  68.       height: 200,
  69.       child: Column(
  70.         children: [
  71.           const SizedBox(height: 8),
  72.           _buildSearchHistoryHeader(),
  73.         ],
  74.       ),
  75.     );
  76.   }
  77.  
  78.   Widget _buildSearchHistoryHeader() {
  79.     return Row(
  80.       mainAxisAlignment: MainAxisAlignment.spaceBetween,
  81.       children: [
  82.         Text(
  83.           'Search history',
  84.           style: TextStyle(
  85.             fontSize: 16,
  86.             fontWeight: FontWeight.w500,
  87.           ),
  88.         ),
  89.         const SizedBox(width: 8),
  90.         SvgPicture.asset(
  91.           "assets/icons/trash_small.svg",
  92.         ),
  93.       ],
  94.     );
  95.   }
  96. }
  97.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement