Adds flight,battery models and image file managment
This commit is contained in:
33
lib/models/battery.dart
Normal file
33
lib/models/battery.dart
Normal file
@ -0,0 +1,33 @@
|
||||
class Battery {
|
||||
int? id;
|
||||
String name;
|
||||
String type;
|
||||
double voltage;
|
||||
String? imageUuid;
|
||||
|
||||
Battery({
|
||||
this.id,
|
||||
required this.name,
|
||||
required this.type,
|
||||
required this.voltage,
|
||||
this.imageUuid,
|
||||
});
|
||||
|
||||
factory Battery.fromMap(Map<String, dynamic> map) => Battery(
|
||||
id: map["id"],
|
||||
name: map["name"],
|
||||
type: map["type"],
|
||||
voltage: map["voltage"],
|
||||
imageUuid: map["image_uuid"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"type": type,
|
||||
"voltage": voltage,
|
||||
"image_uuid": imageUuid,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -1,24 +1,14 @@
|
||||
import 'package:image/image.dart' as img;
|
||||
class Drone {
|
||||
int? id;
|
||||
String name;
|
||||
String? imageUuid;
|
||||
|
||||
class Drone
|
||||
{
|
||||
final int? id;
|
||||
final String name;
|
||||
//final img.Image image;
|
||||
Drone({this.id, required this.name, this.imageUuid});
|
||||
|
||||
Drone ({this.id, required this.name}); //required this.image});
|
||||
factory Drone.fromMap(Map<String, dynamic> map) =>
|
||||
Drone(id: map["id"], name: map["name"], imageUuid: map["image_uuid"]);
|
||||
|
||||
factory Drone.fromMap(Map<String, dynamic> map) => Drone
|
||||
(
|
||||
id: map["id"],
|
||||
name: map["name"],
|
||||
//image: img.decodeJpg(map["image"])!,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() =>
|
||||
{
|
||||
"id": id,
|
||||
"name": name,
|
||||
//"image": img.encodeJpg(image),
|
||||
};
|
||||
Map<String, dynamic> toMap() {
|
||||
return {"id": id, "name": name, "image_uuid": imageUuid};
|
||||
}
|
||||
}
|
||||
|
||||
51
lib/models/flight.dart
Normal file
51
lib/models/flight.dart
Normal file
@ -0,0 +1,51 @@
|
||||
class Flight {
|
||||
int? id;
|
||||
String name;
|
||||
|
||||
// Timestamp in seconds since epoch
|
||||
int startTimestamp;
|
||||
int endTimestamp;
|
||||
|
||||
// Foreign keys
|
||||
int droneId;
|
||||
int batteryId;
|
||||
|
||||
// Location
|
||||
double? locationLat;
|
||||
double? locationLong;
|
||||
|
||||
Flight({
|
||||
this.id,
|
||||
required this.name,
|
||||
required this.startTimestamp,
|
||||
required this.endTimestamp,
|
||||
required this.droneId,
|
||||
required this.batteryId,
|
||||
this.locationLat,
|
||||
this.locationLong,
|
||||
});
|
||||
|
||||
factory Flight.fromMap(Map<String, dynamic> map) => Flight(
|
||||
id: map["id"],
|
||||
name: map["name"],
|
||||
startTimestamp: map["start_timestamp"],
|
||||
endTimestamp: map["end_timestamp"],
|
||||
droneId: map["drone_id"],
|
||||
batteryId: map["batteryId"],
|
||||
locationLat: map["location_lat"],
|
||||
locationLong: map["location_long"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"start_timestamp": startTimestamp,
|
||||
"end_timestamp": endTimestamp,
|
||||
"drone_id": droneId,
|
||||
"battery_id": batteryId,
|
||||
"location_lat": locationLat,
|
||||
"location_long": locationLong,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user