title: Unhandled Exception: HiveError: Cannot write, unknown type: TimeOfDay. Did you forget to register an adapter?
body: <p>I am trying to add data to my hive box. I have initialised hive, opened the box and then added data into the box. However I get an error asking stating that TimeOfDay is an unknown time although I have already registered/built a time adapter. I have attached part of my code below, can someone figure out the issue?</p>
  <p>task_model.g.dart</p>
  <pre><code>// GENERATED CODE - DO NOT MODIFY BY HAND
  
  part of 'task_model.dart';
  
  // **************************************************************************
  // TypeAdapterGenerator
  // **************************************************************************
  
  class TasksModelAdapter extends TypeAdapter&lt;TasksModel&gt; {
    @override
    final int typeId = 0;
  
    @override
    TasksModel read(BinaryReader reader) {
      final numOfFields = reader.readByte();
      final fields = &lt;int, dynamic&gt;{
        for (int i = 0; i &lt; numOfFields; i++) reader.readByte(): reader.read(),
      };
      return TasksModel(
        taskDetails: fields[0] as String,
        isChecked: fields[1] as bool,
        priority: fields[2] as String,
        time: fields[3] as TimeOfDay,
        date: fields[4] as DateTime,
      );
    }
  
    @override
    void write(BinaryWriter writer, TasksModel obj) {
      writer
        ..writeByte(5)
        ..writeByte(0)
        ..write(obj.taskDetails)
        ..writeByte(1)
        ..write(obj.isChecked)
        ..writeByte(2)
        ..write(obj.priority)
        ..writeByte(3)
        ..write(obj.time)
        ..writeByte(4)
        ..write(obj.date);
    }
  
    @override
    int get hashCode =&gt; typeId.hashCode;
  
    @override
    bool operator ==(Object other) =&gt;
        identical(this, other) ||
        other is TasksModelAdapter &amp;&amp;
            runtimeType == other.runtimeType &amp;&amp;
            typeId == other.typeId;
  }
  </code></pre>
  <p>task_model.dart</p>
  <pre><code>import 'package:flutter/material.dart';
  import 'package:hive/hive.dart';
  
  part 'task_model.g.dart';
  
  @HiveType(typeId: 0)
  class TasksModel{
    @HiveField(0)
    String taskDetails;
  
    @HiveField(1)
    bool isChecked = false;
  
    @HiveField(2)
    String priority;
  
    @HiveField(3)
    TimeOfDay time;
  
    @HiveField(4)
    DateTime date;
  
    TasksModel({@required this.taskDetails, @required this.isChecked, @required this.priority, @required this.time, @required this.date});
  
    void toggle(){
      isChecked = !isChecked;
    }
  }
  </code></pre>
  <p>Creating a new task</p>
  <pre><code>void addNewTask(TasksModel data){
      final taskBox = Hive.box('todoTasks');
      taskBox.add(data);
    }
  
  final newTask = TasksModel(taskDetails: taskName, isChecked: false, priority: priorityVal, time: _time, date: _date);
  addNewTask(newTask);
  </code></pre>