  
import 'dart:typed_data';

import 'package:google_maps_flutter/google_maps_flutter.dart';

/// The result returned after completing location selection.
class LocationResult {
  /// The human readable name of the location. This is primarily the
  /// name of the road. But in cases where the place was selected from Nearby
  /// places list, we use the <b>name</b> provided on the list item.
  String address; // or road

  /// Latitude/Longitude of the selected location.
  LatLng latLng;

  List<int> screen;

  LocationResult({this.latLng, this.address,this.screen});

  LocationResult.fromJson(Map<String, dynamic> json) {
    address = json['address'];
  
    var latlngJson = json['latLng'];
    if (latlngJson != null) {
       latLng = LatLng(latlngJson[0], latlngJson[1]);
    }
    screen = Uint8List.fromList(List<int>.from(json['screen']));
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['address'] = this.address??'';
    data['latLng'] = [this.latLng.latitude,this.latLng.longitude];
    data['screen'] = this.screen.toList();
    return data;
  }

  @override
  String toString() {
    return 'LocationResult{address: $address, latLng: $latLng,screen:$screen}';
  }
}