23 lines
578 B
Dart
23 lines
578 B
Dart
|
|
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',
|
||
|
|
);
|
||
|
|
}
|