You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.1 KiB
Dart
46 lines
1.1 KiB
Dart
import 'dart:developer';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
class PangeaTokenText {
|
|
int offset;
|
|
String content;
|
|
int length;
|
|
|
|
PangeaTokenText({
|
|
required this.offset,
|
|
required this.content,
|
|
required this.length,
|
|
});
|
|
|
|
factory PangeaTokenText.fromJson(Map<String, dynamic> json) {
|
|
debugger(when: kDebugMode && json[_offsetKey] == null);
|
|
return PangeaTokenText(
|
|
offset: json[_offsetKey],
|
|
content: json[_contentKey],
|
|
length: json[_lengthKey] ?? (json[_contentKey] as String).length,
|
|
);
|
|
}
|
|
|
|
static const String _offsetKey = "offset";
|
|
static const String _contentKey = "content";
|
|
static const String _lengthKey = "length";
|
|
|
|
Map<String, dynamic> toJson() =>
|
|
{_offsetKey: offset, _contentKey: content, _lengthKey: length};
|
|
|
|
//override equals and hashcode
|
|
@override
|
|
bool operator ==(Object other) {
|
|
if (other is PangeaTokenText) {
|
|
return other.offset == offset &&
|
|
other.content == content &&
|
|
other.length == length;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@override
|
|
int get hashCode => offset.hashCode ^ content.hashCode ^ length.hashCode;
|
|
}
|