check null safety
This commit is contained in:
@@ -8,8 +8,8 @@ import 'package:provider/provider.dart';
|
||||
typedef OnUserSelect(User suer);
|
||||
typedef OnUserRowSelect(User suer);
|
||||
|
||||
Future<User> searchUser(BuildContext context,
|
||||
{OnUserSelect onUserSelect, bool popPage = false}) async =>
|
||||
Future<User?> searchUser(BuildContext context,
|
||||
{required OnUserSelect onUserSelect, bool popPage = false}) async =>
|
||||
await showSearch<User>(
|
||||
context: context,
|
||||
delegate:
|
||||
@@ -20,7 +20,7 @@ class UserSearchDelegate extends SearchDelegate<User> {
|
||||
final OnUserSelect onUserSelect;
|
||||
final bool popPage;
|
||||
|
||||
UserSearchDelegate({this.onUserSelect, this.popPage});
|
||||
UserSearchDelegate({required this.onUserSelect, required this.popPage});
|
||||
|
||||
@override
|
||||
String get searchFieldLabel => 'Search by FCS ID or Name';
|
||||
@@ -31,10 +31,10 @@ class UserSearchDelegate extends SearchDelegate<User> {
|
||||
return theme.copyWith(
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
hintStyle: TextStyle(
|
||||
color: theme.primaryTextTheme.caption.color, fontSize: 14)),
|
||||
color: theme.primaryTextTheme.caption?.color, fontSize: 14)),
|
||||
textTheme: theme.textTheme.copyWith(
|
||||
title: theme.textTheme.title.copyWith(
|
||||
color: theme.primaryTextTheme.title.color, fontSize: 16)),
|
||||
title: theme.textTheme.title?.copyWith(
|
||||
color: theme.primaryTextTheme.title?.color, fontSize: 16)),
|
||||
primaryColor: primaryColor,
|
||||
);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ class UserSearchDelegate extends SearchDelegate<User> {
|
||||
Widget buildLeading(BuildContext context) {
|
||||
return IconButton(
|
||||
icon: Icon(Icons.arrow_back),
|
||||
onPressed: () => close(context, null),
|
||||
onPressed: () => close(context, new User()),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ class UserSearchDelegate extends SearchDelegate<User> {
|
||||
future: packageModel.searchUser(query),
|
||||
builder: (context, AsyncSnapshot<List<User>> snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
if (snapshot.data.length == 0) {
|
||||
if (snapshot.data == null || snapshot.data!.length == 0) {
|
||||
return Container(
|
||||
child: Center(
|
||||
child: Text(
|
||||
@@ -77,7 +77,7 @@ class UserSearchDelegate extends SearchDelegate<User> {
|
||||
return Container(
|
||||
padding: EdgeInsets.only(top: 15),
|
||||
child: ListView(
|
||||
children: snapshot.data
|
||||
children: snapshot.data!
|
||||
.map((u) => UserListRow(
|
||||
user: u,
|
||||
onUserRowSelect: (u) => _onUserRowSelect(context, u),
|
||||
|
||||
Reference in New Issue
Block a user