diff --git a/repo_support/analysis_options.yaml b/repo_support/analysis_options.yaml index c1605bf..623f4e6 100644 --- a/repo_support/analysis_options.yaml +++ b/repo_support/analysis_options.yaml @@ -1,2 +1,2 @@ # tekartik analysis_options extension to pedantic -include: package:tekartik_lints/recommended.yaml \ No newline at end of file +include: package:tekartik_lints/strict.yaml \ No newline at end of file diff --git a/repo_support/pubspec.yaml b/repo_support/pubspec.yaml index 6f84d9d..63a6a66 100644 --- a/repo_support/pubspec.yaml +++ b/repo_support/pubspec.yaml @@ -4,7 +4,7 @@ version: 0.2.0 publish_to: none environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.18.0 <3.0.0' dev_dependencies: path: @@ -23,4 +23,3 @@ dev_dependencies: dev_test: pedantic: - diff --git a/sqflite_common_porter/analysis_options.yaml b/sqflite_common_porter/analysis_options.yaml index e4ee515..623f4e6 100644 --- a/sqflite_common_porter/analysis_options.yaml +++ b/sqflite_common_porter/analysis_options.yaml @@ -1,2 +1,2 @@ # tekartik analysis_options extension to pedantic -include: package:tekartik_lints/recommended.yaml +include: package:tekartik_lints/strict.yaml \ No newline at end of file diff --git a/sqflite_common_porter/lib/src/utils.dart b/sqflite_common_porter/lib/src/utils.dart index b8f1567..381108b 100644 --- a/sqflite_common_porter/lib/src/utils.dart +++ b/sqflite_common_porter/lib/src/utils.dart @@ -33,6 +33,9 @@ Future openEmptyDatabase( return db; } +typedef PrintFunction = void Function(Object? message); +PrintFunction _print = core.print; + Iterable rowsToLines(Iterable rows) { return rows.map((Object? row) => row.toString()); } @@ -41,36 +44,32 @@ String formatLines(List rows) { return '[${rowsToLines(rows).join(',\n')}]'; } -Function(Object? message) _print = core.print; - -void dumpSetPrint(Function(Object? message) print) { +void dumpSetPrint(PrintFunction print) { _print = print; } -void dumpLines(List rows, {Function(Object? message)? print}) { +void dumpLines(List rows, {PrintFunction? print}) { print ??= _print; rowsToLines(rows).toList().forEach((line) { print!(line); }); } -void dumpLine(Object? line, {Function(Object? message)? print}) { +void dumpLine(Object? line, {PrintFunction? print}) { print ??= _print; print(line); } -Future dumpTableDefinitions(Database db, - {Function(Object? message)? print}) async { +Future dumpTableDefinitions(Database db, {PrintFunction? print}) async { dumpLines(await db.query('sqlite_master'), print: print); } -Future dumpTable(Database db, String table, - {Function(Object? message)? print}) async { +Future dumpTable(Database db, String table, {PrintFunction? print}) async { dumpLine('TABLE: $table', print: print); dumpLines(await db.query(table), print: print); } -Future dumpTables(Database db, {Function(Object? message)? print}) async { +Future dumpTables(Database db, {PrintFunction? print}) async { for (var row in await db.query('sqlite_master', columns: ['name'])) { var table = row.values.first as String; await dumpTable(db, table, print: print); @@ -89,8 +88,3 @@ Future importSqlDatabase(DatabaseFactory factory, String dbName, })); return db; } - -String bookshelfSql = ''' -CREATE TABLE book (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT); -INSERT INTO book(title) VALUES ('Le petit prince'); -INSERT INTO book(title) VALUES ('Harry Potter');'''; diff --git a/sqflite_common_porter/pubspec.yaml b/sqflite_common_porter/pubspec.yaml index 519dd68..b292641 100644 --- a/sqflite_common_porter/pubspec.yaml +++ b/sqflite_common_porter/pubspec.yaml @@ -4,7 +4,7 @@ version: 0.3.0 publish_to: none environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.18.0 <3.0.0' dependencies: path: any @@ -21,4 +21,3 @@ dev_dependencies: test: process_run: '>=0.10.3' dev_test: - diff --git a/sqflite_common_porter/test/sqflite_porter_ffi_test.dart b/sqflite_common_porter/test/sqflite_porter_ffi_test.dart index 3feaa50..400e682 100644 --- a/sqflite_common_porter/test/sqflite_porter_ffi_test.dart +++ b/sqflite_common_porter/test/sqflite_porter_ffi_test.dart @@ -27,7 +27,7 @@ void main() { test('export empty', () async { var db = await factory.openDatabase(inMemoryDatabasePath); var export = await dbExportSql(db); - expect(export, []); + expect(export, isEmpty); await db.close(); db = await openDatabaseInMemoryFromSqlImport(factory, export); diff --git a/sqflite_common_porter/test/src_utils_test.dart b/sqflite_common_porter/test/src_utils_test.dart index 4194133..f9102ee 100644 --- a/sqflite_common_porter/test/src_utils_test.dart +++ b/sqflite_common_porter/test/src_utils_test.dart @@ -1,6 +1,10 @@ import 'package:dev_test/test.dart'; import 'package:sqflite_common_porter/src/sql_parser.dart'; -import 'package:sqflite_common_porter/src/utils.dart'; + +String bookshelfSql = ''' +CREATE TABLE book (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT); +INSERT INTO book(title) VALUES ('Le petit prince'); +INSERT INTO book(title) VALUES ('Harry Potter');'''; void main() { group('src_utils', () { diff --git a/sqflite_common_server/analysis_options.yaml b/sqflite_common_server/analysis_options.yaml index e4ee515..623f4e6 100644 --- a/sqflite_common_server/analysis_options.yaml +++ b/sqflite_common_server/analysis_options.yaml @@ -1,2 +1,2 @@ # tekartik analysis_options extension to pedantic -include: package:tekartik_lints/recommended.yaml +include: package:tekartik_lints/strict.yaml \ No newline at end of file diff --git a/sqflite_common_server/lib/sqflite.dart b/sqflite_common_server/lib/sqflite.dart index 0d186e9..3e0ce88 100644 --- a/sqflite_common_server/lib/sqflite.dart +++ b/sqflite_common_server/lib/sqflite.dart @@ -69,7 +69,7 @@ class SqfliteServerContext implements SqfliteContext { bool get supportsWithoutRowId => client!.serverInfo.supportsWithoutRowId == true; - Future sendRequest(String method, Object? param) async { + Future sendRequest(String method, Object? param) async { return await _client!.sendRequest(method, param); } diff --git a/sqflite_common_server/pubspec.yaml b/sqflite_common_server/pubspec.yaml index f121caa..38c48d3 100644 --- a/sqflite_common_server/pubspec.yaml +++ b/sqflite_common_server/pubspec.yaml @@ -4,7 +4,7 @@ version: 0.3.3 publish_to: none environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.18.0 <3.0.0' dependencies: path: diff --git a/sqflite_common_server/test/sqflite_server_test.dart b/sqflite_common_server/test/sqflite_server_test.dart index 08fa07f..cb28fb7 100644 --- a/sqflite_common_server/test/sqflite_server_test.dart +++ b/sqflite_common_server/test/sqflite_server_test.dart @@ -43,8 +43,8 @@ void main() { ); var result = await sqfliteClient - .invoke('openDatabase', {'path': inMemoryDatabasePath}); - expect((result as Map)['id'], const TypeMatcher()); + .invoke('openDatabase', {'path': inMemoryDatabasePath}); + expect(result['id'], const TypeMatcher()); expect(sqfliteClient, isNotNull); diff --git a/sqflite_common_test_app/analysis_options.yaml b/sqflite_common_test_app/analysis_options.yaml index 6b7fdd1..0a472e6 100644 --- a/sqflite_common_test_app/analysis_options.yaml +++ b/sqflite_common_test_app/analysis_options.yaml @@ -1,7 +1,7 @@ # Defines a default set of lint rules enforced for # projects at Google. For details and rationale, # see https://github.com/dart-lang/pedantic#enabled-lints. -include: package:tekartik_lints_flutter/recommended.yaml +include: package:tekartik_lints/strict.yaml linter: rules: diff --git a/sqflite_common_test_app/pubspec.yaml b/sqflite_common_test_app/pubspec.yaml index 8b1873a..90fc1c9 100644 --- a/sqflite_common_test_app/pubspec.yaml +++ b/sqflite_common_test_app/pubspec.yaml @@ -5,7 +5,7 @@ homepage: https://github.com/tekartik/sqflite_more/tree/master/sqflite_common_te publish_to: none environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.18.0 <3.0.0' dependencies: sqflite_common: diff --git a/sqflite_porter/analysis_options.yaml b/sqflite_porter/analysis_options.yaml index e4ee515..b751e66 100644 --- a/sqflite_porter/analysis_options.yaml +++ b/sqflite_porter/analysis_options.yaml @@ -1,2 +1,2 @@ # tekartik analysis_options extension to pedantic -include: package:tekartik_lints/recommended.yaml +include: package:tekartik_lints_flutter/strict.yaml \ No newline at end of file diff --git a/sqflite_porter/lib/src/utils.dart b/sqflite_porter/lib/src/utils.dart index 0eb9fc5..160fb76 100644 --- a/sqflite_porter/lib/src/utils.dart +++ b/sqflite_porter/lib/src/utils.dart @@ -3,10 +3,12 @@ import 'dart:core' as core; import 'dart:core'; import 'dart:io'; +import 'package:flutter/foundation.dart'; import 'package:path/path.dart'; import 'package:sqflite/sqflite.dart'; import 'package:sqflite_porter/src/sql_parser.dart'; import 'package:sqflite_porter/src/sqlite_porter.dart'; +export 'package:sqflite_common_porter/src/utils.dart'; Future initEmptyDb(String dbName) async { var databasePath = await getDatabasesPath(); @@ -20,7 +22,9 @@ Future initEmptyDb(String dbName) async { try { await Directory(dirname(path)).create(recursive: true); } catch (e) { - print(e); + if (kDebugMode) { + print(e); + } } } return path; @@ -32,50 +36,6 @@ Future openEmptyDatabase(String dbName) async { return db; } -Iterable rowsToLines(Iterable rows) { - return rows.map((Object? row) => row.toString()); -} - -String formatLines(List rows) { - return '[${rowsToLines(rows).join(',\n')}]'; -} - -Function(Object? message) _print = core.print; - -void dumpSetPrint(Function(Object? message) print) { - _print = print; -} - -void dumpLines(List rows, {Function(Object? message)? print}) { - print ??= _print; - rowsToLines(rows).toList().forEach((line) { - print!(line); - }); -} - -void dumpLine(Object? line, {Function(Object? message)? print}) { - print ??= _print; - print(line); -} - -Future dumpTableDefinitions(Database db, - {Function(Object? message)? print}) async { - dumpLines(await db.query('sqlite_master'), print: print); -} - -Future dumpTable(Database db, String table, - {Function(Object? message)? print}) async { - dumpLine('TABLE: $table', print: print); - dumpLines(await db.query(table), print: print); -} - -Future dumpTables(Database db, {Function(Object? message)? print}) async { - for (var row in await db.query('sqlite_master', columns: ['name'])) { - var table = row.values.first as String; - await dumpTable(db, table, print: print); - } -} - Future importSqlDatabase(String dbName, {String? sql, List? sqlStatements}) async { sqlStatements ??= parseStatements(sql); @@ -86,8 +46,3 @@ Future importSqlDatabase(String dbName, }); return db; } - -String bookshelfSql = ''' -CREATE TABLE book (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT); -INSERT INTO book(title) VALUES ('Le petit prince'); -INSERT INTO book(title) VALUES ('Harry Potter');'''; diff --git a/sqflite_porter/pubspec.yaml b/sqflite_porter/pubspec.yaml index fcc3c79..7131f21 100644 --- a/sqflite_porter/pubspec.yaml +++ b/sqflite_porter/pubspec.yaml @@ -4,7 +4,7 @@ version: 0.2.0+1 publish_to: none environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.18.0 <3.0.0' dependencies: flutter: @@ -23,6 +23,12 @@ dependencies: path: sqflite_test version: '>=0.1.0' csv: + sqflite_common_porter: + git: + url: https://github.com/tekartik/sqflite_more + ref: dart2_3 + path: sqflite_common_porter + version: '>=0.2.0' dev_dependencies: flutter_test: @@ -30,8 +36,15 @@ dev_dependencies: test: process_run: '>=0.10.3' dev_test: - + tekartik_lints_flutter: + git: + url: https://github.com/tekartik/common_flutter.dart + ref: dart2_3 + path: packages/lints_flutter + version: '>=0.1.0' dependency_overrides: + sqflite_common_porter: + path: ../sqflite_common_porter sqflite_test: path: ../sqflite_test sqflite_common_server: diff --git a/sqflite_porter/test/csv_utils_test.dart b/sqflite_porter/test/csv_utils_test.dart index 70075e5..ba904e8 100644 --- a/sqflite_porter/test/csv_utils_test.dart +++ b/sqflite_porter/test/csv_utils_test.dart @@ -1,3 +1,5 @@ +// ignore_for_file: avoid_print + import 'dart:convert'; import 'dart:typed_data'; diff --git a/sqflite_porter/test/db_csv_utils_test.dart b/sqflite_porter/test/db_csv_utils_test.dart index 96f4fc0..0a182e3 100644 --- a/sqflite_porter/test/db_csv_utils_test.dart +++ b/sqflite_porter/test/db_csv_utils_test.dart @@ -7,10 +7,10 @@ import 'package:test/test.dart'; import 'csv_utils_test.dart'; -final String tableTodo = 'todo'; -final String columnId = '_id'; -final String columnTitle = 'title'; -final String columnDone = 'done'; +const String tableTodo = 'todo'; +const String columnId = '_id'; +const String columnTitle = 'title'; +const String columnDone = 'done'; Future main() { return testMain(run); diff --git a/sqflite_porter/test/src_utils_test.dart b/sqflite_porter/test/src_utils_test.dart index 7ab3ea1..300e5e7 100644 --- a/sqflite_porter/test/src_utils_test.dart +++ b/sqflite_porter/test/src_utils_test.dart @@ -1,6 +1,10 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:sqflite_porter/src/sql_parser.dart'; -import 'package:sqflite_porter/src/utils.dart'; + +String bookshelfSql = ''' +CREATE TABLE book (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT); +INSERT INTO book(title) VALUES ('Le petit prince'); +INSERT INTO book(title) VALUES ('Harry Potter');'''; void main() { group('src_utils', () { diff --git a/sqflite_server_app/analysis_options.yaml b/sqflite_server_app/analysis_options.yaml index bf3a72c..d3c8054 100644 --- a/sqflite_server_app/analysis_options.yaml +++ b/sqflite_server_app/analysis_options.yaml @@ -1,5 +1,5 @@ # tekartik analysis_options extension to pedantic -include: package:tekartik_lints_flutter/recommended.yaml +include: package:tekartik_lints_flutter/strict.yaml linter: rules: diff --git a/sqflite_server_app/pubspec.yaml b/sqflite_server_app/pubspec.yaml index b50f172..00a8bb3 100644 --- a/sqflite_server_app/pubspec.yaml +++ b/sqflite_server_app/pubspec.yaml @@ -11,7 +11,7 @@ publish_to: none version: 0.1.0 environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.18.0 <3.0.0' dependencies: flutter: @@ -115,6 +115,8 @@ flutter: dependency_overrides: sqflite_porter: path: ../sqflite_porter + sqflite_common_porter: + path: ../sqflite_common_porter sqflite_common_server: path: ../sqflite_common_server sqflite_test: diff --git a/sqflite_support/analysis_options.yaml b/sqflite_support/analysis_options.yaml index 780c26c..d5d69aa 100644 --- a/sqflite_support/analysis_options.yaml +++ b/sqflite_support/analysis_options.yaml @@ -1,7 +1,7 @@ # Defines a default set of lint rules enforced for # projects at Google. For details and rationale, # see https://github.com/dart-lang/pedantic#enabled-lints. -include: package:tekartik_lints/recommended.yaml +include: package:tekartik_lints/strict.yaml # For lint rules and documentation, see http://dart-lang.github.io/linter/lints. # Uncomment to specify additional rules. @@ -11,4 +11,4 @@ include: package:tekartik_lints/recommended.yaml analyzer: # exclude: -# - path/to/excluded/files/** +# - path/to/excluded/files/** \ No newline at end of file diff --git a/sqflite_support/pubspec.yaml b/sqflite_support/pubspec.yaml index dc46ed3..17e4d21 100644 --- a/sqflite_support/pubspec.yaml +++ b/sqflite_support/pubspec.yaml @@ -4,7 +4,7 @@ version: 0.1.0 publish_to: none environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.18.0 <3.0.0' dependencies: process_run: '>=0.10.10+2' diff --git a/sqflite_test/analysis_options.yaml b/sqflite_test/analysis_options.yaml index 65ae86e..b751e66 100644 --- a/sqflite_test/analysis_options.yaml +++ b/sqflite_test/analysis_options.yaml @@ -1,2 +1,2 @@ # tekartik analysis_options extension to pedantic -include: package:tekartik_lints_flutter/recommended.yaml +include: package:tekartik_lints_flutter/strict.yaml \ No newline at end of file diff --git a/sqflite_test/lib/sqflite_test.dart b/sqflite_test/lib/sqflite_test.dart index c0bec3a..438d338 100644 --- a/sqflite_test/lib/sqflite_test.dart +++ b/sqflite_test/lib/sqflite_test.dart @@ -222,11 +222,11 @@ Android: } @override - Future sendRequest(String method, Object? param) async { + Future sendRequest(String method, Object? param) async { if (_debugModeOn) { print('$param'); } - var t = await super.sendRequest(method, param) as T?; + var t = await super.sendRequest(method, param); if (_debugModeOn) { print(t); } diff --git a/sqflite_test/pubspec.yaml b/sqflite_test/pubspec.yaml index ce34268..20cd614 100644 --- a/sqflite_test/pubspec.yaml +++ b/sqflite_test/pubspec.yaml @@ -4,7 +4,7 @@ version: 0.2.4 publish_to: none environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.18.0 <3.0.0' dependencies: flutter: diff --git a/sqflite_test_app/analysis_options.yaml b/sqflite_test_app/analysis_options.yaml index 40e3d5d..dd3f9ff 100644 --- a/sqflite_test_app/analysis_options.yaml +++ b/sqflite_test_app/analysis_options.yaml @@ -1,5 +1,5 @@ # tekartik analysis_options extension to pedantic -include: package:tekartik_lints_flutter/recommended.yaml +include: package:tekartik_lints_flutter/strict.yaml linter: rules: diff --git a/sqflite_test_app/lib/test_main.dart b/sqflite_test_app/lib/test_main.dart index 8b5c14a..add707e 100644 --- a/sqflite_test_app/lib/test_main.dart +++ b/sqflite_test_app/lib/test_main.dart @@ -61,8 +61,8 @@ class _HomePageState extends State { void initState() { super.initState(); () async { - await Navigator.of(context) - .push(MaterialPageRoute(builder: (context) => const ManualApp())); + await Navigator.of(context).push( + MaterialPageRoute(builder: (context) => const ManualApp())); try { widget.doneCompleter?.complete(); } catch (e) { diff --git a/sqflite_test_app/pubspec.yaml b/sqflite_test_app/pubspec.yaml index 029581d..5576b7c 100644 --- a/sqflite_test_app/pubspec.yaml +++ b/sqflite_test_app/pubspec.yaml @@ -11,7 +11,7 @@ publish_to: none version: 0.1.0 environment: - sdk: '>=2.18.0-0 <3.0.0' + sdk: '>=2.18.0 <3.0.0' dependencies: flutter: diff --git a/various/sqflite_isolate_test_app/analysis_options.yaml b/various/sqflite_isolate_test_app/analysis_options.yaml new file mode 100644 index 0000000..e14b09c --- /dev/null +++ b/various/sqflite_isolate_test_app/analysis_options.yaml @@ -0,0 +1 @@ +include: package:tekartik_lints_flutter/strict.yaml \ No newline at end of file diff --git a/various/sqflite_isolate_test_app/lib/main.dart b/various/sqflite_isolate_test_app/lib/main.dart index fb9bc16..aacd3d0 100644 --- a/various/sqflite_isolate_test_app/lib/main.dart +++ b/various/sqflite_isolate_test_app/lib/main.dart @@ -1,5 +1,8 @@ +// ignore_for_file: depend_on_referenced_packages + import 'dart:isolate'; +import 'package:flutter/foundation.dart'; import 'package:flutter_isolate/flutter_isolate.dart'; import 'package:path/path.dart'; import 'package:sqflite/sqflite.dart'; @@ -51,7 +54,7 @@ void main() { }, showConsole: true); } -final isolateDbName = 'isolate.db'; +const isolateDbName = 'isolate.db'; Future insert(Database db, int id) async { await db.insert('Test', {'id': id, 'name': 'item $id'}, @@ -79,7 +82,9 @@ Future>> simpleTest(String path) async { await insert(db, 2); await insert(db, 3); results = await db.rawQuery('SELECT id, name FROM Test'); - print(results); + if (kDebugMode) { + print(results); + } } finally { await db.close(); } diff --git a/various/sqflite_isolate_test_app/pubspec.yaml b/various/sqflite_isolate_test_app/pubspec.yaml index 708fb5d..34ab4bf 100644 --- a/various/sqflite_isolate_test_app/pubspec.yaml +++ b/various/sqflite_isolate_test_app/pubspec.yaml @@ -15,7 +15,7 @@ version: 1.0.0+1 publish_to: none environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.18.0 <3.0.0' dependencies: flutter: @@ -33,9 +33,15 @@ dependencies: flutter_isolate: sqflite: '>=1.3.1' dev_dependencies: + tekartik_lints_flutter: + git: + url: https://github.com/tekartik/common_flutter.dart + ref: dart2_3 + path: packages/lints_flutter + version: '>=0.1.0' flutter_test: sdk: flutter - + flutter_lints: # For information on the generic Dart part of this file, see the # following page: https://www.dartlang.org/tools/pub/pubspec