Task: Add toJson interfaces and export
This commit is contained in:
parent
19ddc8114c
commit
942095bbdd
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:cubetiq/src/json.dart';
|
||||||
import 'package:cubetiq/xlog.dart';
|
import 'package:cubetiq/xlog.dart';
|
||||||
|
|
||||||
void main(List<String> args) {
|
void main(List<String> args) {
|
||||||
@ -15,17 +16,18 @@ void main(List<String> args) {
|
|||||||
|
|
||||||
XLog.warning(null);
|
XLog.warning(null);
|
||||||
|
|
||||||
var json = Person(1, 'Sambo');
|
var person = Person(1, 'Sambo');
|
||||||
|
|
||||||
XLog.warning(json, [null, null]);
|
XLog.warning(person, [null, null]);
|
||||||
}
|
}
|
||||||
|
|
||||||
class Person {
|
class Person implements ToJson {
|
||||||
final id;
|
final id;
|
||||||
final name;
|
final name;
|
||||||
|
|
||||||
Person(this.id, this.name);
|
Person(this.id, this.name);
|
||||||
|
|
||||||
|
@override
|
||||||
Map toJson() => {
|
Map toJson() => {
|
||||||
'id': id,
|
'id': id,
|
||||||
'name': name,
|
'name': name,
|
||||||
|
3
lib/interfaces.dart
Normal file
3
lib/interfaces.dart
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
library interfaces;
|
||||||
|
|
||||||
|
export 'src/json.dart';
|
3
lib/src/json.dart
Normal file
3
lib/src/json.dart
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
abstract class ToJson {
|
||||||
|
Map toJson();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user