getDepartamentoIdByName method

Future<int?> getDepartamentoIdByName(
  1. String departamentoName
)

Implementation

Future<int?> getDepartamentoIdByName(String departamentoName) async {
  final db = await database; // Access the database instance
  final result = await db.query(
    'predios', // Table name
    columns: ['departamento_id'], // Column to select
    where: 'departamento_name = ?', // Condition to match
    whereArgs: [departamentoName], // Arguments for the condition
  );

  if (result.isNotEmpty) {
    return result.first['departamento_id'] as int?;
  }
  return null; // Return null if no match is found
}