AppBarWidget<T> constructor
const
AppBarWidget<T> ({
- Key? key,
- required String title,
- SearchBarConfig<
T> ? isShowSearchBar()?, - bool isShowSearchIcon = true,
- Color backgroundColor = Colors.blue,
- Color iconColor = Colors.white,
- TextStyle? titleStyle,
- double height = kToolbarHeight,
- Widget? loadingWidget,
- BorderRadiusGeometry borderRadius = const BorderRadius.all(Radius.circular(0)),
- EdgeInsetsGeometry padding = const EdgeInsets.all(0),
A highly customizable SearchBar widget with overlay results.
Example usage:
AppBarWidget<User>(
title: "Users",
isShowSearchBar: () => SearchBarConfig<User>(
url: "https://jsonplaceholder.typicode.com/users",
fromJson: User.fromJson,
searchBackgroundColor: Colors.white,
searchBy: (user) => user.name,
itemBuilder: (user) => ListTile(
leading: CircleAvatar(child: Text(user.name[0])),
title: Text(user.name),
subtitle: Text(user.email),
onTap: () => debugPrint("Selected: ${user.name}"),
),
),
)
class User {
final int id;
final String name;
final String email;
User({required this.id, required this.name, required this.email});
factory User.fromJson(Map<String, dynamic> json) {
return User(
id: json['id'],
name: json['name'],
email: json['email'],
);
}
}
Implementation
const AppBarWidget({
super.key,
required this.title,
this.isShowSearchBar,
this.isShowSearchIcon = true,
this.backgroundColor = Colors.blue,
this.iconColor = Colors.white,
this.titleStyle,
this.height = kToolbarHeight,
this.loadingWidget,
this.borderRadius = const BorderRadius.all(Radius.circular(0))
, this.padding=const EdgeInsets.all(0),
});