parent
7211d15be2
commit
c11c631229
@ -0,0 +1,27 @@
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'content_list_model.dart';
|
||||
part 'ContentHive.g.dart';
|
||||
|
||||
|
||||
@JsonSerializable()
|
||||
@HiveType(typeId:2)
|
||||
class ContentHive extends Equatable{
|
||||
@HiveField(0)
|
||||
final int id;
|
||||
@HiveField(1)
|
||||
final String content;
|
||||
@HiveField(2)
|
||||
final List<ContentListModel> list;
|
||||
factory ContentHive.fromJson(Map<String, dynamic> json) =>_$ContentHiveFromJson(json);
|
||||
|
||||
const ContentHive({
|
||||
required this.id,
|
||||
required this.content,
|
||||
required this.list,
|
||||
});
|
||||
@override
|
||||
List<Object?> get props => [id,content,list];
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'ContentHive.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// TypeAdapterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class ContentHiveAdapter extends TypeAdapter<ContentHive> {
|
||||
@override
|
||||
final int typeId = 0;
|
||||
|
||||
@override
|
||||
ContentHive read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return ContentHive(
|
||||
id: fields[0] as int,
|
||||
content: fields[1] as String,
|
||||
list: (fields[3] as List).cast<ContentListModel>(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, ContentHive obj) {
|
||||
writer
|
||||
..writeByte(3)
|
||||
..writeByte(0)
|
||||
..write(obj.id)
|
||||
..writeByte(1)
|
||||
..write(obj.content)
|
||||
..writeByte(3)
|
||||
..write(obj.list);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is ContentHiveAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
ContentHive _$ContentHiveFromJson(Map<String, dynamic> json) => ContentHive(
|
||||
id: json['id'] as int,
|
||||
content: json['content'] as String,
|
||||
list: (json['list'] as List<dynamic>)
|
||||
.map((e) => ContentListModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
@ -0,0 +1,19 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
part 'content_list_model.g.dart';
|
||||
|
||||
|
||||
@JsonSerializable()
|
||||
class ContentListModel extends Equatable{
|
||||
final int index;
|
||||
final String content;
|
||||
factory ContentListModel.fromJson(Map<String, dynamic> json) =>_$ContentListModelFromJson(json);
|
||||
|
||||
|
||||
const ContentListModel({
|
||||
required this.index,
|
||||
required this.content,
|
||||
});
|
||||
@override
|
||||
List<Object?> get props => [index,content];
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'content_list_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
ContentListModel _$ContentListModelFromJson(Map<String, dynamic> json) =>
|
||||
ContentListModel(
|
||||
index: json['index'] as int,
|
||||
content: json['content'] as String,
|
||||
);
|
@ -0,0 +1,14 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
import '../model/hive/ContentHive.dart';
|
||||
|
||||
class ContentListModel extends ChangeNotifier{
|
||||
late Box _regionBox;
|
||||
List<ContentHive> _regions=[];
|
||||
List<ContentHive> get regions=>_regions;
|
||||
Future init() async{}
|
||||
// _regionBox = await Hive.openBox("ContentListBox");
|
||||
// var
|
||||
|
||||
}
|
Loading…
Reference in new issue