location_convert_marker_util.dart 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. import 'package:flutter_map/flutter_map.dart';
  2. import 'package:location/data/bean/user_info.dart';
  3. class Location2MarkerUtil {
  4. Location2MarkerUtil._();
  5. static Marker userInfo2Marker(UserInfo e, bool isSelected) {
  6. return Marker(
  7. id: e.id,
  8. markerName: e.getUserNickName(),
  9. longitude: e.lastLocation.value?.longitude,
  10. latitude: e.lastLocation.value?.latitude,
  11. markerType: MarkerType.friend,
  12. isSelected: isSelected,
  13. );
  14. }
  15. static List<Marker> userInfoList2MarkerList(
  16. List<UserInfo> list, UserInfo? selectedFriend) {
  17. List<Marker> markers = [];
  18. for (var e in list) {
  19. if ((e.isMine == true || e.blockedMe != true) &&
  20. e.lastLocation.value?.longitude != null &&
  21. e.lastLocation.value?.latitude != null) {
  22. markers.add(userInfo2Marker(e, e.id == selectedFriend?.id));
  23. }
  24. }
  25. return markers;
  26. // return list
  27. // .where((e) => e.blockedHim != true)
  28. // .map((e) => userInfo2Marker(e, e.id == selectedFriend?.id))
  29. // .toList();
  30. }
  31. }