Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Memri
Flutter App for Memri
Commits
591d74e7
Commit
591d74e7
authored
4 years ago
by
Amirjanyan
Browse files
Options
Download
Email Patches
Plain Diff
ItemRecord: json serializable
parent
1be66e65
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/MemriApp/Controllers/Database/ItemRecord.dart
+21
-12
lib/MemriApp/Controllers/Database/ItemRecord.dart
lib/MemriApp/Controllers/Database/ItemRecord.g.dart
+68
-0
lib/MemriApp/Controllers/Database/ItemRecord.g.dart
with
89 additions
and
12 deletions
+89
-12
lib/MemriApp/Controllers/Database/ItemRecord.dart
+
21
-
12
View file @
591d74e7
...
...
@@ -12,6 +12,11 @@ import '../AppController.dart';
import
'DatabaseController.dart'
;
import
'ItemPropertyRecord.dart'
;
import
'package:json_annotation/json_annotation.dart'
;
part
'ItemRecord.g.dart'
;
@JsonSerializable
()
class
ItemRecord
with
EquatableMixin
{
int
?
rowId
;
String
uid
;
...
...
@@ -26,10 +31,10 @@ class ItemRecord with EquatableMixin {
ItemRecord
(
{
this
.
rowId
,
uid
,
String
?
uid
,
required
this
.
type
,
dateCreated
,
dateModified
,
DateTime
?
dateCreated
,
DateTime
?
dateModified
,
this
.
deleted
=
false
,
this
.
syncState
=
SyncState
.
create
,
this
.
syncHasPriority
=
false
})
...
...
@@ -50,15 +55,16 @@ class ItemRecord with EquatableMixin {
ItemsCompanion
toCompanion
()
{
return
ItemsCompanion
(
rowId:
rowId
==
null
?
const
Value
.
absent
()
:
Value
(
rowId
),
id:
Value
(
uid
),
type:
Value
(
type
),
dateCreated:
Value
(
dateCreated
),
dateModified:
Value
(
dateModified
),
dateServerModified:
dateServerModified
==
null
?
const
Value
.
absent
()
:
Value
(
dateServerModified
),
deleted:
Value
(
deleted
),
);
rowId:
rowId
==
null
?
const
Value
.
absent
()
:
Value
(
rowId
!
),
id:
Value
(
uid
),
type:
Value
(
type
),
dateCreated:
Value
(
dateCreated
),
dateModified:
Value
(
dateModified
),
dateServerModified:
dateServerModified
==
null
?
const
Value
.
absent
()
:
Value
(
dateServerModified
),
deleted:
Value
(
deleted
),
syncState:
Value
(
syncState
.
inString
),
syncHasPriority:
Value
(
syncHasPriority
));
}
Future
<
ItemPropertyRecord
?
>
property
(
String
name
,
[
DatabaseController
?
db
])
async
{
...
...
@@ -261,6 +267,9 @@ class ItemRecord with EquatableMixin {
}
}
factory
ItemRecord
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
=
>
_$ItemRecordFromJson
(
json
);
Map
<
String
,
dynamic
>
toJson
()
=
>
_$ItemRecordToJson
(
this
);
@override
List
<
Object
>
get
props
=
>
[
uid
,
type
];
...
...
This diff is collapsed.
Click to expand it.
lib/MemriApp/Controllers/Database/ItemRecord.g.dart
0 → 100644
+
68
-
0
View file @
591d74e7
// GENERATED CODE - DO NOT MODIFY BY HAND
part of
'ItemRecord.dart'
;
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
ItemRecord
_$ItemRecordFromJson
(
Map
<
String
,
dynamic
>
json
)
{
return
ItemRecord
(
rowId:
json
[
'rowId'
]
as
int
?
,
uid:
json
[
'uid'
]
as
String
?
,
type:
json
[
'type'
]
as
String
,
dateCreated:
json
[
'dateCreated'
]
==
null
?
null
:
DateTime
.
parse
(
json
[
'dateCreated'
]
as
String
),
dateModified:
json
[
'dateModified'
]
==
null
?
null
:
DateTime
.
parse
(
json
[
'dateModified'
]
as
String
),
deleted:
json
[
'deleted'
]
as
bool
,
syncState:
_$enumDecode
(
_$SyncStateEnumMap
,
json
[
'syncState'
]),
syncHasPriority:
json
[
'syncHasPriority'
]
as
bool
,
).
.
dateServerModified
=
json
[
'dateServerModified'
]
==
null
?
null
:
DateTime
.
parse
(
json
[
'dateServerModified'
]
as
String
);
}
Map
<
String
,
dynamic
>
_$ItemRecordToJson
(
ItemRecord
instance
)
=
>
<
String
,
dynamic
>{
'rowId'
:
instance
.
rowId
,
'uid'
:
instance
.
uid
,
'type'
:
instance
.
type
,
'dateCreated'
:
instance
.
dateCreated
.
toIso8601String
(),
'dateServerModified'
:
instance
.
dateServerModified
?.
toIso8601String
(),
'dateModified'
:
instance
.
dateModified
.
toIso8601String
(),
'deleted'
:
instance
.
deleted
,
'syncState'
:
_$SyncStateEnumMap
[
instance
.
syncState
],
'syncHasPriority'
:
instance
.
syncHasPriority
,
};
K
_$enumDecode
<
K
,
V
>(
Map
<
K
,
V
>
enumValues
,
Object
?
source
,
{
K
?
unknownValue
,
})
{
if
(
source
==
null
)
{
throw
ArgumentError
(
'A value must be provided. Supported values: '
'
${enumValues.values.join(', ')}
'
,
)
;
}
return
enumValues
.
entries
.
singleWhere
(
(
e
)
=
>
e
.
value
==
source
,
orElse:
()
{
if
(
unknownValue
==
null
)
{
throw
ArgumentError
(
'`
$source
` is not one of the supported values: '
'
${enumValues.values.join(', ')}
'
,
)
;
}
return
MapEntry
(
unknownValue
,
enumValues
.
values
.
first
)
;
},
)
.
key
;
}
const
_$SyncStateEnumMap
=
{
SyncState
.
create
:
'create'
,
SyncState
.
update
:
'update'
,
SyncState
.
noChanges
:
'noChanges'
,
SyncState
.
failed
:
'failed'
,
};
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets