getTableColumns method

  1. @override
List<List> getTableColumns(
  1. TableName tableName
)
override

Get the tableName columns as array of:

  • name (string),
  • type (string),
  • isPrimaryKey (int, 1 for true)
  • notnull (int).

Implementation

@override
List<List<dynamic>> getTableColumns(TableName tableName) {
  checkOpen();
  String sql = "PRAGMA table_info(${tableName.fixedName})";
  List<List<dynamic>> columnsList = [];

  var res = select(sql);
  res.forEach((QueryResultRow row) {
    String colName = row.get('name');
    String colType = row.get('type');
    int isPk = row.get('pk');
    int notNull = row.get('notnull');
    columnsList.add([colName, colType, isPk, notNull]);
  });
  return columnsList;
}