equalTo method Null safety

void equalTo(
  1. String field,
  2. dynamic value

You can invoke this method to add a query condition in which the value of a field in an entity class is equal to the specified value.

Supports the following data types:

  • bool for Boolean.
  • int for Byte, Short, Integer, Long, and Date.
  • double for Double, and Float.
  • String for String, and Text.


void equalTo(String field, dynamic value) {
  if (field.isEmpty) {
    throw FormatException('field cannot be an empty string.', field);
  if (value == null) {
    throw FormatException('value cannot be null.', value);
  if (!(value is bool ||
      value is int ||
      value is double ||
      value is String)) {
    throw FormatException(
        'value should be bool, int, double or String.', value);
    <String, dynamic>{
      _QueryConstants.FIELD: field,
      _QueryConstants.OPERATION: _QueryConstants.EQUAL_TO,
      _QueryConstants.VALUE: value,