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 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 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; }