getHighlights method
Future<List<CodeHighlight> >
getHighlights(
- String? code,
- String? language,
- String? theme,
- List<
PhraseLocation> ? emphasisLocations,
override
Implementation
@override
Future<List<CodeHighlight>> getHighlights(
String? code,
String? language,
String? theme,
List<PhraseLocation>? emphasisLocations,
) async {
final arguments = {
"code": code,
"language": (await _getLanguage(language)),
"theme": (await _getTheme(theme)),
"emphasisLocations": jsonEncode(emphasisLocations),
};
final json = await methodChannel.invokeMethod(
methods.getHighlights,
arguments,
);
final data = jsonDecode(json);
if (data is List) {
return data.map((e) => CodeHighlight.fromJson(e)).toList();
} else {
_debugPrint(
'${methods.getHighlights}: Expected List but got ${data.runtimeType}',
);
return [];
}
}