mnemo_cards/lib/features/worker/worker_ext.dart

23 lines
578 B
Dart
Raw Normal View History

2024-08-24 21:09:58 +00:00
import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
extension JsonStringExt<T> on String {
Future<T> isolatedDecode<T>([T Function(Map<String, dynamic>)? fromJson]) =>
compute(
(_) => this.decode(fromJson),
null,
debugLabel: 'decode: $T',
);
Future<List<T>> isolatedDecodeList<T>(
[T Function(Map<String, dynamic>)? fromJson]) =>
compute(
(_) => this.decodeList(fromJson),
null,
debugLabel: 'decodeList: $T',
);
}