EcpUserPicker constructor
EcpUserPicker({
- Key? key,
- int limitNum = noLimit,
- bool allowEmpty = false,
- List<
User> ? selectUserList, - bool appBarVisible = true,
- bool? clickWithoutConfirm = true,
- String? title,
- List<
String> ? indexList, - bool? showIndex = false,
- String? searchHint = '请输入人员名称进行搜索',
- OnSelected<
User> ? onSelected, - bool showSearch = true,
- bool? showSelectedList,
- bool refreshEnable = true,
- bool loadMoreEnable = true,
- bool isAutoLeading = true,
- List<
User> ? frozenList, - bool showCharacter = false,
- UserSelectorBuilder<
User, Department> ? userSelectorBuilder, - SelectedBuilder<
User> ? userSelectedBuilder, - UserRepo<
User, Department> ? userRepo, - SearchRepo<
User, Department> ? userSearchRepo, - IndexPredicate<
User, Department> ? indexPredicate, - EcpDepartmentRange? range,
- List<
String> ? deptIds, - int? hideLeaderFlag,
- int? queryHeadshipName,
Implementation
EcpUserPicker({
super.key,
super.limitNum,
super.allowEmpty,
super.selectUserList,
super.appBarVisible,
super.clickWithoutConfirm = true,
super.title,
super.indexList,
super.showIndex = false,
super.searchHint = '请输入人员名称进行搜索',
super.onSelected,
bool showSearch = true,
super.showSelectedList,
super.refreshEnable,
super.loadMoreEnable,
super.isAutoLeading = true,
super.frozenList,
bool showCharacter = false,
UserSelectorBuilder<User, Department>? userSelectorBuilder,
SelectedBuilder<User>? userSelectedBuilder,
UserRepo<User, Department>? userRepo,
SearchRepo<User, Department>? userSearchRepo,
IndexPredicate<User, Department>? indexPredicate,
EcpDepartmentRange? range,
List<String>? deptIds,
int? hideLeaderFlag,
int? queryHeadshipName,
}) : super(
userSelectorBuilder: userSelectorBuilder ??
(ctx, proxy, user) {
var list = proxy.currentUserList;
int index = list.indexOf(user);
String? current = user.origin.pinYin.firstOrNull;
String? pre =
list.getElementOrNull(index - 1)?.origin.pinYin.firstOrNull;
bool showChar = current != null && current != pre;
return UserPickerItem(
wrapper: user,
showCheckBox: !(clickWithoutConfirm ?? limitNum == 1),
showCharacter: showCharacter && showChar,
);
},
userSelectedBuilder: userSelectedBuilder ??
(ctx, user) => UserPickerItem(wrapper: user),
userRepo: userRepo ??
(d, index) {
return defaultUserRepo(
d,
index,
hideLeaderFlag: hideLeaderFlag,
queryHeadshipName: queryHeadshipName,
);
},
searchRepo: showSearch
? userSearchRepo ??
(proxy, key, index) {
bool designated = range != EcpDepartmentRange.designated;
var deptId = designated ? null : proxy.rootDept?.deptId;
return defaultUserSearchRepo(
proxy,
key,
index,
deptId: deptId,
deptIds: deptIds,
hideLeaderFlag: hideLeaderFlag,
);
}
: null,
indexPredicate: indexPredicate ??
(c, index, proxy) {
var list = proxy.currentUserList.where((element) =>
element.origin.pinYin.firstOrNull?.toUpperCase() == c);
if (list.isNotEmpty) {
var index = proxy.currentUserList.indexOf(list.first);
return index >= 0 ? index : null;
}
return null;
},
);