parse method

Future<List<TextElement>> parse(
  1. String text, {
  2. bool onlyMatches = false,
  3. bool useIsolate = true,
})

Parses the provided text according to the matchers specified in the constructor.

The result contains all the elements in text including the ones not matching any pattern provided by matchers unless onlyMatches is set to true explicitly.

Parsing is executed in an isolate by default except on the web, which dart:isolate does not support. It is for preventing the impact of heavy computation on other processes, but it instead adds some overhead and result in longer execution time. If you prefer to use the main thread, set useIsolate to 'false'.

Implementation

Future<List<TextElement>> parse(
  String text, {
  bool onlyMatches = false,
  bool useIsolate = true,
}) async {
  if (text.isEmpty) {
    return [];
  }

  return useIsolate
      ? exec(parser: _parser, text: text, onlyMatches: onlyMatches)
      : execFuture(parser: _parser, text: text, onlyMatches: onlyMatches);
}