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('SHOW TABLES');
  if (res == null || res.isEmpty) return <String>[];

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

  if (parts.isNotEmpty) {
    if (parts[0].contains('Tables_in_mydb')) {
      parts.removeAt(0);
    }

    parts = parts.map((e) => e.trim()).where((e) => e.isNotEmpty).toList();
  }

  return parts;
}