map method

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

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

Implementation

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