63 lines
1.3 KiB
Dart
63 lines
1.3 KiB
Dart
import "package:flutter/material.dart";
|
|
|
|
class Destination {
|
|
final double latitude;
|
|
final double longitude;
|
|
final String name;
|
|
final String description;
|
|
// final DestinationType type;
|
|
final Duration duration;
|
|
final bool visited;
|
|
|
|
const Destination({
|
|
required this.latitude,
|
|
required this.longitude,
|
|
required this.name,
|
|
required this.description,
|
|
// required this.type,
|
|
required this.duration,
|
|
required this.visited,
|
|
});
|
|
|
|
factory Destination.fromJson(Map<String, dynamic> json) {
|
|
return switch (json) {
|
|
{
|
|
'lat': double latitude,
|
|
'lon': double longitude,
|
|
'name': String name,
|
|
'description': String description,
|
|
// 'type': String type,
|
|
'duration': int duration,
|
|
'visited': bool visited
|
|
|
|
} =>
|
|
Destination(
|
|
latitude: latitude,
|
|
longitude: longitude,
|
|
name: name,
|
|
description: description,
|
|
// type: "DestinationType.values.firstWhere((element) => element.name == type)",
|
|
duration: Duration(minutes: duration),
|
|
visited: visited
|
|
),
|
|
_ => throw const FormatException('Failed to load destination.'),
|
|
};
|
|
}
|
|
|
|
}
|
|
|
|
|
|
class DestinationType {
|
|
final String name;
|
|
final String description;
|
|
final Icon icon;
|
|
|
|
const DestinationType({
|
|
required this.name,
|
|
required this.description,
|
|
required this.icon,
|
|
});
|
|
}
|
|
|
|
|