I am building a Flutter app and have some trouble defining a model. I have model which has some properties. One of those properties can be both null or another model.

```
import 'package:proef/models/worked_time.dart';

class Shift {
  String uuid;
  DateTime start_at;
  DateTime end_at;
  String title;
  String comment;
  WorkedTime worked_time;

  Shift(
      {this.uuid,
      this.start_at,
      this.end_at,
      this.title,
      this.comment,
      this.worked_time});

  factory Shift.fromData(Map<String, dynamic> parsedJson) {
    print(parsedJson);
    return Shift(
        uuid: parsedJson['uuid'],
        start_at: DateTime.parse(parsedJson['start_at']).toLocal(),
        end_at: DateTime.parse(parsedJson['end_at']).toLocal(),
        title: parsedJson['title'],
        comment: parsedJson['comment'],
        worked_time: parsedJson['worked_time'] == null
            ? null
            : parsedJson['worked_time']);
  }
}

```

This does not work. When I use this model it throws me the following error:

```
Unhandled Exception: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'WorkedTime'

```

I am not sure how to fix this, since I am quite new to Dart and Flutter.

The WorkedTime model:

```
class WorkedTime {
  String uuid;
  String comment;
  int status;
  int took_break;
  DateTime start_at;
  DateTime end_at;

  WorkedTime({
    this.uuid,
    this.comment,
    this.status,
    this.took_break,
    this.start_at,
    this.end_at,
  });

  factory WorkedTime.fromData(Map<String, dynamic> parsedJson) {
    print(parsedJson);
    return WorkedTime(
        uuid: parsedJson['uuid'],
        comment: parsedJson['comment'],
        status: parsedJson['status'],
        took_break: parsedJson['took_break'],
        start_at: DateTime.parse(parsedJson['start_at']),
        end_at: DateTime.parse(parsedJson['end_at']));
  }
}

```

The JSON with worked\_time

```
[
    {
        "uuid": "706f40e7-d57c-470c-9023-b0c58e2c7c3a",
        "start_at": "2020-09-01T08:00:00.000000Z",
        "end_at": "2020-09-01T16:00:00.000000Z",
        "title": "Test",
        "comment": "Test",
        "worked_time": {
            "uuid": "6e73b4aa-d6e1-41f7-86cb-09745d2db033",
            "comment": "Test",
            "status": 0,
            "break": 0,
            "start_at": "2020-09-01T08:00:00.000000Z",
            "end_at": "2020-09-01T16:00:00.000000Z",
            "took_break": 0
        }
    }
]

```

The JSON without worked\_time

```
[
    {
        "uuid": "706f40e7-d57c-470c-9023-b0c58e2c7c3a",
        "start_at": "2020-09-01T08:00:00.000000Z",
        "end_at": "2020-09-01T16:00:00.000000Z",
        "title": "Test",
        "comment": "Test",
        "worked_time": null
    }
]

```