location_convert_marker_util.dart 687 B

123456789101112131415161718192021222324
  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.remark ?? e.phoneNumber,
  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. return list
  18. .map((e) => userInfo2Marker(e, e.id == selectedFriend?.id))
  19. .toList();
  20. }
  21. }