snippet method

Expression<String> snippet(
  1. GeneratedColumn<String> column, {
  2. required String before,
  3. required String after,
  4. required String ellipsis,
  5. required int tokenCount,
})

Like highlight, but only reports a tokenCount tokens of text around each match, separated by ellipsis when text was omitted.

When column doesn't contain a match for the query of the surrounding statement, its text is returned as it is. This expression only evaluates to null when the value of column is null itself, which can happen for tables storing their contents in another table.

selectOnly(emails)
  ..addColumns([
    emails.snippet(
      emails.title,
      before: '<b>',
      after: '</b>',
      ellipsis: '…',
      tokenCount: 64,
    ),
  ]);

See the sqlite documentation for details.

Implementation

Expression<String> snippet(
  GeneratedColumn<String> column, {
  required String before,
  required String after,
  required String ellipsis,
  required int tokenCount,
}) {
  return FunctionCallExpression<String>('snippet', [
    _tableReference,
    Variable.withInt(_columnIndex(column)),
    Variable.withString(before),
    Variable.withString(after),
    Variable.withString(ellipsis),
    Variable.withInt(tokenCount),
  ]);
}