initial upload
This commit is contained in:
40
lib/models/project.dart
Normal file
40
lib/models/project.dart
Normal file
@ -0,0 +1,40 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'udp_package.dart';
|
||||
|
||||
part 'project.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class Project {
|
||||
final String id;
|
||||
final String name;
|
||||
final int port;
|
||||
final List<UdpPackage> packages;
|
||||
|
||||
Project({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.port,
|
||||
required this.packages,
|
||||
});
|
||||
|
||||
factory Project.fromJson(Map<String, dynamic> json) =>
|
||||
_$ProjectFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$ProjectToJson(this);
|
||||
|
||||
Project copyWith({
|
||||
String? id,
|
||||
String? name,
|
||||
int? port,
|
||||
List<UdpPackage>? packages,
|
||||
}) {
|
||||
return Project(
|
||||
id: id ?? this.id,
|
||||
name: name ?? this.name,
|
||||
port: port ?? this.port,
|
||||
packages: packages ?? this.packages,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
23
lib/models/project.g.dart
Normal file
23
lib/models/project.g.dart
Normal file
@ -0,0 +1,23 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'project.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Project _$ProjectFromJson(Map<String, dynamic> json) => Project(
|
||||
id: json['id'] as String,
|
||||
name: json['name'] as String,
|
||||
port: (json['port'] as num).toInt(),
|
||||
packages: (json['packages'] as List<dynamic>)
|
||||
.map((e) => UdpPackage.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ProjectToJson(Project instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
'port': instance.port,
|
||||
'packages': instance.packages,
|
||||
};
|
||||
39
lib/models/udp_package.dart
Normal file
39
lib/models/udp_package.dart
Normal file
@ -0,0 +1,39 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'udp_package.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class UdpPackage {
|
||||
final String id;
|
||||
final String name;
|
||||
final String data;
|
||||
final String ipAddress;
|
||||
|
||||
UdpPackage({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.data,
|
||||
required this.ipAddress,
|
||||
});
|
||||
|
||||
factory UdpPackage.fromJson(Map<String, dynamic> json) =>
|
||||
_$UdpPackageFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$UdpPackageToJson(this);
|
||||
|
||||
UdpPackage copyWith({
|
||||
String? id,
|
||||
String? name,
|
||||
String? data,
|
||||
String? ipAddress,
|
||||
}) {
|
||||
return UdpPackage(
|
||||
id: id ?? this.id,
|
||||
name: name ?? this.name,
|
||||
data: data ?? this.data,
|
||||
ipAddress: ipAddress ?? this.ipAddress,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
22
lib/models/udp_package.g.dart
Normal file
22
lib/models/udp_package.g.dart
Normal file
@ -0,0 +1,22 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'udp_package.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
UdpPackage _$UdpPackageFromJson(Map<String, dynamic> json) => UdpPackage(
|
||||
id: json['id'] as String,
|
||||
name: json['name'] as String,
|
||||
data: json['data'] as String,
|
||||
ipAddress: json['ipAddress'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$UdpPackageToJson(UdpPackage instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
'data': instance.data,
|
||||
'ipAddress': instance.ipAddress,
|
||||
};
|
||||
Reference in New Issue
Block a user