-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6594cf1
commit 666dd48
Showing
2 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_clean_app_examples/core/manager/cache/user_cache_manager.dart'; | ||
import 'package:flutter_clean_app_examples/feature/user/model/user_model.dart'; | ||
|
||
|
||
class SearchView extends StatefulWidget { | ||
SearchView({Key? key, required this.model}) : super(key: key); | ||
final ICacheManager<User> model; | ||
@override | ||
State<SearchView> createState() => _SearchViewState(); | ||
} | ||
|
||
class _SearchViewState extends State<SearchView> { | ||
List<User> _items = []; | ||
|
||
void findAndSet(String key){ | ||
_items = widget.model.getValues()?.where((element) => element.name?.toLowerCase().contains(key.toLowerCase()) ?? false).toList() ?? []; | ||
setState(() { | ||
|
||
}); | ||
} | ||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: TextField( | ||
onChanged: (value){ | ||
findAndSet(value); | ||
}, | ||
), | ||
leading: InkWell( | ||
child: Icon(CupertinoIcons.back), | ||
onTap: (){ | ||
Navigator.pop(context); | ||
}, | ||
), | ||
), | ||
body: ListView.builder( | ||
itemCount:_items.length , | ||
itemBuilder: (((context, index) { | ||
return Card( | ||
child: ListTile( | ||
title: Text(_items.map((e) => '${e.name}').join('')), | ||
), | ||
); | ||
}) ) ), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters