map method

  1. @override
SupplierData map(
  1. Map<String, dynamic> data, {
  2. String? tablePrefix,
})

Maps the given row returned by the database into the fitting data class.

Implementation

@override
SupplierData map(Map<String, dynamic> data, {String? tablePrefix}) {
  final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
  return SupplierData(
    id: attachedDatabase.typeMapping.read(
      DriftSqlType.int,
      data['${effectivePrefix}id'],
    )!,
    name: attachedDatabase.typeMapping.read(
      DriftSqlType.string,
      data['${effectivePrefix}name'],
    )!,
    active: attachedDatabase.typeMapping.read(
      DriftSqlType.bool,
      data['${effectivePrefix}active'],
    )!,
    email: attachedDatabase.typeMapping.read(
      DriftSqlType.string,
      data['${effectivePrefix}email'],
    )!,
    address: attachedDatabase.typeMapping.read(
      DriftSqlType.string,
      data['${effectivePrefix}address'],
    ),
    phone: attachedDatabase.typeMapping.read(
      DriftSqlType.string,
      data['${effectivePrefix}phone'],
    ),
    description: attachedDatabase.typeMapping.read(
      DriftSqlType.string,
      data['${effectivePrefix}description'],
    ),
    supplierTypeId: attachedDatabase.typeMapping.read(
      DriftSqlType.int,
      data['${effectivePrefix}supplier_type_id'],
    )!,
    imagePath: attachedDatabase.typeMapping.read(
      DriftSqlType.string,
      data['${effectivePrefix}image_path'],
    ),
  );
}