listTables method

  1. @override
Future<List<String>> listTables()
override

List the database tables names.

Implementation

@override
Future<List<String>> listTables() async {
  var res = await container!.runSQL(r'\d');
  if (res == null || res.isEmpty) return <String>[];

  var body = res.split(RegExp(r'--+\+--+\+--+\+'))[1];
  var parts = body.split(RegExp(r'[\r\n]'));

  var names = parts
      .where((p) => p.contains(RegExp(r'\s+\|\s+\w+\s+\|')))
      .map((p) => p.split(RegExp(r'\s+\|\s+'))[1].trim())
      .toList();

  return names;
}