All checks were successful
Flutter APK Build / Build Flutter APK (push) Successful in 6m38s
35 lines
895 B
Dart
35 lines
895 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
class SearchBarWidget extends StatelessWidget {
|
|
const SearchBarWidget({
|
|
super.key,
|
|
required this.onEditingComplete,
|
|
required this.onResetSearch,
|
|
});
|
|
|
|
final Function(String searchString) onEditingComplete;
|
|
final Function() onResetSearch;
|
|
|
|
void onChanged(String text, BuildContext context) {
|
|
if (context.mounted) onEditingComplete(text);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final searchTextController = TextEditingController();
|
|
return TextField(
|
|
controller: searchTextController,
|
|
onChanged: (text) => onChanged(text, context),
|
|
decoration: InputDecoration(
|
|
suffixIcon: IconButton(
|
|
onPressed: () {
|
|
searchTextController.clear();
|
|
onResetSearch();
|
|
},
|
|
icon: Icon(Icons.delete_outline_outlined),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|