Initial Commit : Network Map
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import 'package:brick_offline_first_with_supabase/brick_offline_first_with_supabase.dart';
|
||||
import 'package:brick_supabase/brick_supabase.dart';
|
||||
|
||||
@ConnectOfflineFirstWithSupabase(
|
||||
supabaseConfig: SupabaseSerializable(tableName: 'network_vlans'),
|
||||
)
|
||||
class NetworkVlan extends OfflineFirstWithSupabaseModel {
|
||||
final String id;
|
||||
final int vlanId;
|
||||
final String name;
|
||||
final String? description;
|
||||
final String? color;
|
||||
|
||||
NetworkVlan({
|
||||
required this.id,
|
||||
required this.vlanId,
|
||||
required this.name,
|
||||
this.description,
|
||||
this.color,
|
||||
});
|
||||
|
||||
factory NetworkVlan.fromMap(Map<String, dynamic> map) {
|
||||
return NetworkVlan(
|
||||
id: map['id'] as String,
|
||||
vlanId: map['vlan_id'] is int
|
||||
? map['vlan_id'] as int
|
||||
: int.tryParse(map['vlan_id']?.toString() ?? '') ?? 0,
|
||||
name: (map['name'] as String?) ?? '',
|
||||
description: map['description'] as String?,
|
||||
color: map['color'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toInsertMap() => {
|
||||
'vlan_id': vlanId,
|
||||
'name': name,
|
||||
if (description != null) 'description': description,
|
||||
if (color != null) 'color': color,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user