Skip to content
Snippets Groups Projects
datamodel.dart 1.96 KiB
Newer Older
import 'package:shared_preferences/shared_preferences.dart';
  int id;
  String urn;
  String label;
  String type;
  String description;
  String status;
  Event(
    this.id,
    this.urn,
    this.label,
    this.type,
    this.description,
    this.status
  );

  factory Event.fromJson(Map<String, dynamic> parsedJson){
    return Event( parsedJson['id'] as int,
        parsedJson['urn'] as String,
        parsedJson['label'] as String,
        parsedJson['type'] as String,
        parsedJson['description'] as String,
        parsedJson['status'] as String );
  }

  @override
  String toString(){
    return '{ ${this.id}, ${this.urn}, ${this.label}, ${this.type}, ${this.description}, ${this.status} }';
  }
}

abstract class EventStoreBase{
  List<Event> store = [];
abstract class EventCurrentBase{
  Event store = Event(0, 'urn0', '', '', '', 'PENDING');
}
  String name;

  EventType(
    this.id,
    this.name
  );

  factory EventType.fromJson(Map<String, dynamic> parsedJson){
    return EventType(parsedJson['id'] as int, parsedJson['name'] as String);
  }
}

abstract class EventTypeStoreBase{
  List<EventType> store = [];
}

class EventStoreInstance extends EventStoreBase {
  static final EventStoreInstance _instance = EventStoreInstance._internal();

  factory EventStoreInstance() {
    return _instance;
  }
  EventStoreInstance._internal() {
    store = [];
  }
class EventCurrentInstance extends EventCurrentBase {
  static final EventCurrentInstance _instance = EventCurrentInstance._internal();

  factory EventCurrentInstance(){
    return _instance;
  }

  EventCurrentInstance._internal(){
    store = Event(0, 'urn0', '', '', '', 'PENDING');
  }
}

class EventTypeStoreInstance extends EventTypeStoreBase{
  static final EventTypeStoreInstance _instance = EventTypeStoreInstance._internal();
  factory EventTypeStoreInstance(){
    return _instance;
  }

  EventTypeStoreInstance._internal(){
    store = [];
  }
}