flutter_suggestion_searchbar 1.0.0 flutter_suggestion_searchbar: ^1.0.0 copied to clipboard
A Flutter Package for a SearchBar-Widget with suggestions. It is a full customizable SearchBar with a SuggestionsBar for mainly iOS and Android Apps.
A full customizable SearchBar-Widget with suggestions for iOS & Android.
Features #
The Suggestion-SearchBar can be used with or without suggestions. Style is full customizable.
Getting started #
-
Import the package: import 'package:suggestion_searchbar/suggestion_searchbar.dart';
-
Add "SearchBar" in Build-Method
-
Enter all values and data which are required by the widget
-
Play around with styles and enjoy using
Usage #
import 'package:flutter/material.dart';
import 'package:suggestion_searchbar/suggestion_searchbar.dart';
class SearchBarExample extends StatelessWidget {
SearchBarExample({Key? key}) : super(key: key);
final controller = TextEditingController();
final List<String> sugList = [
//Put suggestion data here
"Apple",
"Android",
"Flutter",
"Dart",
//...
];
@override
Widget build(BuildContext context) {
//Responsive Design Vars
const mockupWidth = 375;
const mockupHeight = 812;
final width = MediaQuery.of(context).size.width;
final height = MediaQuery.of(context).size.height;
final scale = mockupWidth / width;
final textScaleFactor = width / mockupWidth;
return SearchBar(
//Enables Suggestions
enableSuggestions: true,
textScaleFactor: textScaleFactor, //For responsive text size
textFieldController: controller, //TextEditingController
//Coloring
cursorColor: Colors.white,
enabledBorderColor: Colors.blue,
focusedBorderColor: Colors.blue.withAlpha(100),
labelColor: Colors.white.withAlpha(180),
textColor: Colors.white,
prefixIconColor: Colors.white,
suffixIconColor: Colors.white.withAlpha(100),
//Your suggestion-data
suggestionsList: sugList,
//Is added to the hint text (Search *optionalLabel*)
optionalLabel: "Categories",
gap: 12, //Gap between search- and suggestion bar
itemHeight: 60, //Height of the single items
itemTextSize: 18, //Size of suggestion-item
itemBGColor: const Color(0xFF252525), //BG Color of the single items
itemTextColor: Colors.white,
itemBorderRadius: 25, //BorderRadius of the single items
itemPadding: const EdgeInsets.only(bottom: 2.0),
enableSuggestionsFieldBorder: true,
suggestionsFieldHeigth: height / 6,
suggestionsFieldBGColor: const Color(0xFF181818), //BG Color for the whole suggestion bar
suggestionsFieldBorderRadius: 25, //BorderRadius for the whole suggestion bar
suggestionsFieldBorderWidth: 1,
suggestionsFieldBorderColor: Colors.blue,
onSelected: () {
//Call function
},
);
}
}
Additional information #
For more information or any bugs and problems. Please contact: cedno.official@gmail.com