Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dart 2.18 lints #37

Merged
merged 1 commit into from
May 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions idb_shim/lib/src/common/common_value.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ int compareKeys(dynamic first, dynamic second) {
/// when keyPath is an array
/// Return the relevant keyPath at index
KeyRange keyArrayRangeAt(KeyRange keyRange, int index) {
Object? _valueAt(List? value, int index) {
Object? valueAt(List? value, int index) {
return value == null ? null : value[index];
}

return KeyRange.bound(
_valueAt(keyRange.lower as List?, index),
_valueAt(keyRange.upper as List?, index),
valueAt(keyRange.lower as List?, index),
valueAt(keyRange.upper as List?, index),
keyRange.lowerOpen,
keyRange.upperOpen);
}
Expand Down
13 changes: 7 additions & 6 deletions idb_shim/lib/src/native/native_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ class IdbFactoryNativeWrapperImpl extends IdbFactoryBase {
{int? version,
OnUpgradeNeededFunction? onUpgradeNeeded,
OnBlockedFunction? onBlocked}) {
void _onUpgradeNeeded(idb.VersionChangeEvent e) {
void openOnUpgradeNeeded(idb.VersionChangeEvent e) {
final event = VersionChangeEventNative(this, e);
onUpgradeNeeded!(event);
}

void _onBlocked(html.Event e) {
void openOnBlocked(html.Event e) {
if (onBlocked != null) {
Event event = EventNative(e);
onBlocked(event);
Expand All @@ -72,10 +72,11 @@ class IdbFactoryNativeWrapperImpl extends IdbFactoryBase {
return nativeFactory
.open(dbName,
version: version,
onUpgradeNeeded: onUpgradeNeeded == null ? null : _onUpgradeNeeded,
onUpgradeNeeded:
onUpgradeNeeded == null ? null : openOnUpgradeNeeded,
onBlocked: onBlocked == null && onUpgradeNeeded == null
? null
: _onBlocked)
: openOnBlocked)
.then((idb.Database database) {
return DatabaseNative(this, database);
});
Expand All @@ -84,15 +85,15 @@ class IdbFactoryNativeWrapperImpl extends IdbFactoryBase {
@override
Future<IdbFactory> deleteDatabase(String dbName,
{OnBlockedFunction? onBlocked}) {
void _onBlocked(html.Event e) {
void openOnBlocked(html.Event e) {
print('blocked deleting $dbName');
Event event = EventNative(e);
onBlocked!(event);
}

return nativeFactory
.deleteDatabase(dbName,
onBlocked: onBlocked == null ? null : _onBlocked)
onBlocked: onBlocked == null ? null : openOnBlocked)
.then((_) {
return this;
});
Expand Down
12 changes: 6 additions & 6 deletions idb_shim/lib/src/sembast/sembast_transaction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class TransactionSembast extends IdbTransactionBase
// however any delayed action will be out of the transaction
// This fixes sample get/await/get

Future _checkNextAction() {
Future checkNextAction() {
//return new Future.value().then((_) {
if (_index < _actions.length) {
return _next();
Expand All @@ -152,10 +152,10 @@ class TransactionSembast extends IdbTransactionBase
}

if (_transactionLazyMode) {
return Future.delayed(const Duration(), _checkNextAction);
return Future.delayed(const Duration(), checkNextAction);
} else {
//return new Future.sync(new Duration(), _checkNextAction);
return _checkNextAction();
return checkNextAction();
}
}
}
Expand All @@ -179,7 +179,7 @@ class TransactionSembast extends IdbTransactionBase

//lazyExecution = new Future.delayed(new Duration(), () {

Future _sdbAction() {
Future sdbAction() {
//assert(sdbDatabase.transaction == null);

// No return value here
Expand Down Expand Up @@ -214,9 +214,9 @@ class TransactionSembast extends IdbTransactionBase

if (_transactionLazyMode) {
// old lazy mode
_lazyExecution = Future.microtask(_sdbAction);
_lazyExecution = Future.microtask(sdbAction);
} else {
_lazyExecution = Future.sync(_sdbAction);
_lazyExecution = Future.sync(sdbAction);
}

//return lazyExecution;
Expand Down
4 changes: 2 additions & 2 deletions idb_shim/lib/utils/idb_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Future<Database> copySchema(
await txn.completed;
}

void _onUpgradeNeeded(VersionChangeEvent event) {
void openOnUpgradeNeeded(VersionChangeEvent event) {
final db = event.database;
for (final storeMeta in schemaMeta.stores) {
final store = db.createObjectStore(storeMeta.name,
Expand All @@ -55,7 +55,7 @@ Future<Database> copySchema(
// devPrint('Open $dstDbName version $version');
// Open and copy scheme
final dstDatabase = await dstFactory.open(dstDbName,
version: version, onUpgradeNeeded: _onUpgradeNeeded);
version: version, onUpgradeNeeded: openOnUpgradeNeeded);
return dstDatabase;
}

Expand Down
4 changes: 2 additions & 2 deletions idb_shim/test/idb_test_common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Future<Database> setUpSimpleStore(IdbFactory idbFactory, //
meta ??= idbSimpleObjectStoreMeta;

return idbFactory.deleteDatabase(dbName).then((_) {
void _initializeDatabase(VersionChangeEvent e) {
void openOnUpgradeNeeded(VersionChangeEvent e) {
final db = e.database;
final objectStore = db.createObjectStore(meta!.name,
keyPath: meta.keyPath!, autoIncrement: meta.autoIncrement);
Expand All @@ -112,7 +112,7 @@ Future<Database> setUpSimpleStore(IdbFactory idbFactory, //
}

return idbFactory.open(dbName,
version: 1, onUpgradeNeeded: _initializeDatabase);
version: 1, onUpgradeNeeded: openOnUpgradeNeeded);
});
}

Expand Down
12 changes: 6 additions & 6 deletions idb_shim/test/multiplatform/idb_api_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import '../idb_test_common.dart';

void main() {
group('api', () {
void _expectBrowser([Object? e]) {
void expectBrowser([Object? e]) {
if (e != null) {
expect(e, isNot(const TypeMatcher<TestFailure>()));
}
expect(idbIsRunningAsJavascript, isTrue);
}

void _expectIo([Object? e]) {
void expectIo([Object? e]) {
if (e != null) {
expect(e, isNot(const TypeMatcher<TestFailure>()));
}
Expand All @@ -28,16 +28,16 @@ void main() {

try {
idbFactorySembastIo;
_expectIo();
expectIo();
} catch (e) {
_expectBrowser(e);
expectBrowser(e);
}

try {
idbFactoryNative;
_expectBrowser();
expectBrowser();
} catch (e) {
_expectIo(e);
expectIo(e);
}
});
});
Expand Down
4 changes: 2 additions & 2 deletions idb_shim/test/web/bug/ie_count_bug_test_.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ void main() {
if (IdbFactory.supported) {
final dbName = 'com.tekartik.ie_count_bug.test';
await window.indexedDB!.deleteDatabase(dbName);
void _setupDb(VersionChangeEvent e) {
void setupDb(VersionChangeEvent e) {
final db = e.target.result as Database;
db.createObjectStore('store', autoIncrement: true);
}

final db = await window.indexedDB!
.open(dbName, version: 1, onUpgradeNeeded: _setupDb);
.open(dbName, version: 1, onUpgradeNeeded: setupDb);

final transaction = db.transaction('store', 'readwrite');
var objectStore = transaction.objectStore('store');
Expand Down
34 changes: 17 additions & 17 deletions idb_shim/test/web/native_raw_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,25 @@ void main() {

idb.Transaction transaction;
idb.ObjectStore objectStore;
void _createTransactionSync() {
void createTransactionSync() {
transaction = db.transaction('store', 'readonly');
objectStore = transaction.objectStore('store');
}

Future _createTransaction() async {
Future createTransaction() async {
await Future.delayed(const Duration(milliseconds: 1));
_createTransactionSync();
createTransactionSync();
}

// Sync ok
_createTransactionSync();
createTransactionSync();
transaction = db.transaction('store', 'readonly');
objectStore = transaction.objectStore('store');
await objectStore.getObject(0);
await transaction.completed;

// Async ok even on Safari with dart 1.13
await _createTransaction();
await createTransaction();
await objectStore.getObject(0);

await transaction.completed;
Expand All @@ -124,18 +124,18 @@ void main() {

late idb.Transaction transaction;
late idb.ObjectStore objectStore;
void _createTransactionSync() {
void createTransactionSync() {
transaction = db.transaction('store', 'readonly');
objectStore = transaction.objectStore('store');
}

_createTransactionSync();
createTransactionSync();
await objectStore.getObject(0);
Future _get() async {
Future get() async {
await objectStore.getObject(0);
}

await _get();
await get();

await transaction.completed;
}, skip: 'crashing on ie');
Expand All @@ -151,18 +151,18 @@ void main() {

late idb.Transaction transaction;
late idb.ObjectStore objectStore;
void _createTransactionSync() {
void createTransactionSync() {
transaction = db.transaction('store', 'readonly');
objectStore = transaction.objectStore('store');
}

_createTransactionSync();
Future _get() async {
createTransactionSync();
Future doGet() async {
await objectStore.getObject(0);
}

await objectStore.getObject(0).then((_) async {
await _get();
await doGet();
});

await transaction.completed;
Expand All @@ -181,13 +181,13 @@ void main() {

late idb.Transaction transaction;
late idb.ObjectStore objectStore;
void _createTransactionSync() {
void createTransactionSync() {
transaction = db.transaction('store', 'readonly');
objectStore = transaction.objectStore('store');
}

// Sync ok
_createTransactionSync();
createTransactionSync();
await objectStore.getObject(0);
await Future.value();

Expand All @@ -213,12 +213,12 @@ void main() {

late idb.Transaction transaction;
late idb.ObjectStore objectStore;
void _createTransactionSync() {
void createTransactionSync() {
transaction = db.transaction('store', idbModeReadWrite);
objectStore = transaction.objectStore('store');
}

_createTransactionSync();
createTransactionSync();
var key = await objectStore.add(DateTime.fromMillisecondsSinceEpoch(1));
var keyBlob = await objectStore.add(Uint8List.fromList([1, 2, 3]));
expect(
Expand Down
4 changes: 2 additions & 2 deletions idb_shim/test/web/test_runner_bug_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ void main() {
await idbFactory.deleteDatabase(dbName);
} catch (_) {}

void _initializeDatabase(VersionChangeEvent e) {
void onUpgradeNeeded(VersionChangeEvent e) {
final db = e.database;
db.createObjectStore(testStoreName);
}

var db = await idbFactory.open(dbName,
version: 1, onUpgradeNeeded: _initializeDatabase);
version: 1, onUpgradeNeeded: onUpgradeNeeded);

db.close();
} finally {
Expand Down
Loading