From 91f955fa45173a649390e403357547fbe1eb9b2c Mon Sep 17 00:00:00 2001 From: Kim Gustyr Date: Mon, 14 Oct 2024 12:55:56 +0100 Subject: [PATCH] dart fix --apply --- lib/src/storage_provider.dart | 4 ++-- test/flagsmith_core_test.dart | 24 ++++++++++++------------ test/models/flag_test.dart | 32 ++++++++++++++++---------------- test/storage_reactive_test.dart | 10 +++++----- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/lib/src/storage_provider.dart b/lib/src/storage_provider.dart index d3f15ff..065d6bc 100644 --- a/lib/src/storage_provider.dart +++ b/lib/src/storage_provider.dart @@ -88,8 +88,8 @@ class StorageProvider with SecureStorage { Future saveAll(List items) async { for (var item in items) { - final _current = await read(item.key); - if (_current != null) { + final current = await read(item.key); + if (current != null) { await update(item.key, item); } else { await create(item.key, item); diff --git a/test/flagsmith_core_test.dart b/test/flagsmith_core_test.dart index 5e394f7..c653762 100644 --- a/test/flagsmith_core_test.dart +++ b/test/flagsmith_core_test.dart @@ -43,20 +43,20 @@ void main() { expect(items, isEmpty); }); test('Create a flag', () async { - final _created = await storageProvider.create( + final created = await storageProvider.create( 'test_feature', Flag.seed('test_feature', enabled: false)); - expect(_created, isTrue); + expect(created, isTrue); }); test('Save all flags', () async { - final _created = await storageProvider.saveAll([ + final created = await storageProvider.saveAll([ Flag.seed('test_feature_a', enabled: false), Flag.seed('test_feature_b', enabled: true) ]); - expect(_created, isTrue); - final _all = await storageProvider.getAll(); - expect(_all, isNotEmpty); + expect(created, isTrue); + final all0 = await storageProvider.getAll(); + expect(all0, isNotEmpty); expect( - _all, + all0, const TypeMatcher>().having( (p0) => p0 .firstWhereOrNull((element) => element.key == 'test_feature_a'), @@ -65,15 +65,15 @@ void main() { }); test('Update all flags', () async { - final _created = await storageProvider.saveAll([ + final created = await storageProvider.saveAll([ Flag.seed('test_feature_a', enabled: false), Flag.seed('test_feature_b', enabled: true) ]); - expect(_created, isTrue); - final _all = await storageProvider.getAll(); - expect(_all, isNotEmpty); + expect(created, isTrue); + final all0 = await storageProvider.getAll(); + expect(all0, isNotEmpty); expect( - _all, + all0, const TypeMatcher>().having( (p0) => p0 .firstWhereOrNull((element) => element.key == 'test_feature_a'), diff --git a/test/models/flag_test.dart b/test/models/flag_test.dart index b9024fe..e2a4387 100644 --- a/test/models/flag_test.dart +++ b/test/models/flag_test.dart @@ -44,28 +44,28 @@ void main() { expect(flag.feature.description, isNotNull); }); test('When feature successfuly parsed', () async { - final _feature = + final feature = Feature.fromJson(jsonDecode(featureValue) as Map); - expect(_feature, isNotNull); - expect(_feature.id, 2); + expect(feature, isNotNull); + expect(feature.id, 2); }); test('When flag successfuly parsed', () { var flag = Flag.fromJson(jsonDecode(testValue) as Map); - final _flag = flag.asString(); - expect(_flag, isA()); - expect(_flag, isNotNull); - expect(_flag, isNotEmpty); + final flag0 = flag.asString(); + expect(flag0, isA()); + expect(flag0, isNotNull); + expect(flag0, isNotEmpty); }); test('When flag value successfuly updated', () { var flag = Flag.fromJson(jsonDecode(testValue) as Map); - final _feature = flag.feature.copyWith(initialValue: '12'); - final _flag = flag.copyWith(feature: _feature); + final feature = flag.feature.copyWith(initialValue: '12'); + final flag0 = flag.copyWith(feature: feature); expect(flag.feature.initialValue, '10'); - expect(_flag.feature.initialValue, '12'); - expect(flag.feature.initialValue, isNot(_flag.feature.initialValue)); + expect(flag0.feature.initialValue, '12'); + expect(flag.feature.initialValue, isNot(flag0.feature.initialValue)); }); test('When flag seed state is enabled', () { @@ -100,13 +100,13 @@ void main() { expect(identity.flags, isNotEmpty); expect(identity.traits, isNotEmpty); - final _converted = identity.toJson(); - expect(_converted, isNotNull); - expect(_converted, isNotEmpty); + final converted = identity.toJson(); + expect(converted, isNotNull); + expect(converted, isNotEmpty); - final _copiedIdentity = identity.copyWith(flags: [], traits: []); + final copiedIdentity = identity.copyWith(flags: [], traits: []); expect( - _copiedIdentity, + copiedIdentity, const TypeMatcher() .having((e) => e.flags, 'flags are empty', isEmpty) .having((e) => e.traits, 'traits are empty', isEmpty)); diff --git a/test/storage_reactive_test.dart b/test/storage_reactive_test.dart index 1a1ddcf..0598cb2 100644 --- a/test/storage_reactive_test.dart +++ b/test/storage_reactive_test.dart @@ -21,16 +21,16 @@ void main() { const TypeMatcher() .having((s) => s.enabled, '$myFeature is not enabled', false), ])); - final _toggled = await store.togggleFeature(myFeature); - expect(_toggled, isTrue); + final toggled = await store.togggleFeature(myFeature); + expect(toggled, isTrue); }); test('Subject value changed when flag was changed.', () async { await store.clear(); await store.seed(items: seeds); - final _feature = await store.read(myFeature); - expect(_feature, isNotNull); - expect(_feature!.enabled, isTrue); + final feature = await store.read(myFeature); + expect(feature, isNotNull); + expect(feature!.enabled, isTrue); expect(store.subject(myFeature)?.stream.valueOrNull?.enabled, true); expect(