Skip to content

Commit 1f11aef

Browse files
committed
Resolve analyzer warnings
1 parent 98e1012 commit 1f11aef

File tree

3 files changed

+45
-43
lines changed

3 files changed

+45
-43
lines changed

packages/shared_preferences/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@
2626
## 2.0.2
2727

2828
* Update shared_preferences to 2.0.9.
29-
* Switch to new analysis options and update integration_test.
29+
* Switch to new analysis options.
30+
* Update integration_test.

packages/shared_preferences/lib/src/bindings.dart

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,41 @@ import 'types.dart';
1010

1111
class _PreferenceBindings {
1212
_PreferenceBindings() {
13-
_lib = DynamicLibrary.open('libcapi-appfw-preference.so.0');
13+
final DynamicLibrary lib =
14+
DynamicLibrary.open('libcapi-appfw-preference.so.0');
1415

15-
setInt = _lib.lookupFunction<preference_set_int_native_t, PreferenceSetInt>(
16+
setInt = lib.lookupFunction<PreferenceSetIntNative, PreferenceSetInt>(
1617
'preference_set_int');
17-
getInt = _lib.lookupFunction<preference_get_int_native_t, PreferenceGetInt>(
18+
getInt = lib.lookupFunction<PreferenceGetIntNative, PreferenceGetInt>(
1819
'preference_get_int');
19-
20-
setDouble = _lib.lookupFunction<preference_set_double_native_t,
21-
PreferenceSetDouble>('preference_set_double');
22-
getDouble = _lib.lookupFunction<preference_get_double_native_t,
23-
PreferenceGetDouble>('preference_get_double');
24-
25-
setString = _lib.lookupFunction<preference_set_string_native_t,
26-
PreferenceSetString>('preference_set_string');
27-
getString = _lib.lookupFunction<preference_get_string_native_t,
28-
PreferenceGetString>('preference_get_string');
29-
30-
setBoolean = _lib.lookupFunction<preference_set_boolean_native_t,
31-
PreferenceSetBoolean>('preference_set_boolean');
32-
getBoolean = _lib.lookupFunction<preference_get_boolean_native_t,
33-
PreferenceGetBoolean>('preference_get_boolean');
34-
35-
remove = _lib.lookupFunction<preference_remove_native_t, PreferenceRemove>(
20+
setDouble =
21+
lib.lookupFunction<PreferenceSetDoubleNative, PreferenceSetDouble>(
22+
'preference_set_double');
23+
getDouble =
24+
lib.lookupFunction<PreferenceGetDoubleNative, PreferenceGetDouble>(
25+
'preference_get_double');
26+
setString =
27+
lib.lookupFunction<PreferenceSetStringNative, PreferenceSetString>(
28+
'preference_set_string');
29+
getString =
30+
lib.lookupFunction<PreferenceGetStringNative, PreferenceGetString>(
31+
'preference_get_string');
32+
setBoolean =
33+
lib.lookupFunction<PreferenceSetBooleanNative, PreferenceSetBoolean>(
34+
'preference_set_boolean');
35+
getBoolean =
36+
lib.lookupFunction<PreferenceGetBooleanNative, PreferenceGetBoolean>(
37+
'preference_get_boolean');
38+
remove = lib.lookupFunction<PreferenceRemoveNative, PreferenceRemove>(
3639
'preference_remove');
37-
38-
removeAll = _lib.lookupFunction<preference_remove_all_native_t,
39-
PreferenceRemoveAll>('preference_remove_all');
40-
41-
foreachItem = _lib.lookupFunction<preference_foreach_item_native_t,
42-
PreferenceForeachItem>('preference_foreach_item');
40+
removeAll =
41+
lib.lookupFunction<PreferenceRemoveAllNative, PreferenceRemoveAll>(
42+
'preference_remove_all');
43+
foreachItem =
44+
lib.lookupFunction<PreferenceForeachItemNative, PreferenceForeachItem>(
45+
'preference_foreach_item');
4346
}
4447

45-
late DynamicLibrary _lib;
4648
late PreferenceSetInt setInt;
4749
late PreferenceGetInt getInt;
4850
late PreferenceSetDouble setDouble;

packages/shared_preferences/lib/src/types.dart

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,66 +9,65 @@ import 'dart:ffi';
99
import 'package:ffi/ffi.dart';
1010

1111
// int preference_set_int (const char *key, int value)
12-
typedef preference_set_int_native_t = Int32 Function(
13-
Pointer<Utf8> key, Int32 value);
12+
typedef PreferenceSetIntNative = Int32 Function(Pointer<Utf8> key, Int32 value);
1413
typedef PreferenceSetInt = int Function(Pointer<Utf8> key, int value);
1514

1615
// int preference_get_int (const char *key, int *value)
17-
typedef preference_get_int_native_t = Int32 Function(
16+
typedef PreferenceGetIntNative = Int32 Function(
1817
Pointer<Utf8> key, Pointer<Int32> value);
1918
typedef PreferenceGetInt = int Function(
2019
Pointer<Utf8> key, Pointer<Int32> value);
2120

2221
// int preference_set_double (const char *key, double value)
23-
typedef preference_set_double_native_t = Int32 Function(
22+
typedef PreferenceSetDoubleNative = Int32 Function(
2423
Pointer<Utf8> key, Double value);
2524
typedef PreferenceSetDouble = int Function(Pointer<Utf8> key, double value);
2625

2726
// int preference_get_double (const char *key, double *value)
28-
typedef preference_get_double_native_t = Int32 Function(
27+
typedef PreferenceGetDoubleNative = Int32 Function(
2928
Pointer<Utf8> key, Pointer<Double> value);
3029
typedef PreferenceGetDouble = int Function(
3130
Pointer<Utf8> key, Pointer<Double> value);
3231

3332
// int preference_set_string (const char *key, const char *value)
34-
typedef preference_set_string_native_t = Int32 Function(
33+
typedef PreferenceSetStringNative = Int32 Function(
3534
Pointer<Utf8> key, Pointer<Utf8> value);
3635
typedef PreferenceSetString = int Function(
3736
Pointer<Utf8> key, Pointer<Utf8> value);
3837

3938
// int preference_get_string (const char *key, char **value)
40-
typedef preference_get_string_native_t = Int32 Function(
39+
typedef PreferenceGetStringNative = Int32 Function(
4140
Pointer<Utf8> key, Pointer<Pointer<Utf8>> value);
4241
typedef PreferenceGetString = int Function(
4342
Pointer<Utf8> key, Pointer<Pointer<Utf8>> value);
4443

4544
// int preference_set_boolean (const char *key, bool value)
46-
typedef preference_set_boolean_native_t = Int32 Function(
45+
typedef PreferenceSetBooleanNative = Int32 Function(
4746
Pointer<Utf8> key, Int8 value);
4847
typedef PreferenceSetBoolean = int Function(Pointer<Utf8> key, int value);
4948

5049
// int preference_get_boolean (const char *key, bool *value)
51-
typedef preference_get_boolean_native_t = Int32 Function(
50+
typedef PreferenceGetBooleanNative = Int32 Function(
5251
Pointer<Utf8> key, Pointer<Int8> value);
5352
typedef PreferenceGetBoolean = int Function(
5453
Pointer<Utf8> key, Pointer<Int8> value);
5554

5655
// int preference_remove (const char *key)
57-
typedef preference_remove_native_t = Int32 Function(Pointer<Utf8> key);
56+
typedef PreferenceRemoveNative = Int32 Function(Pointer<Utf8> key);
5857
typedef PreferenceRemove = int Function(Pointer<Utf8> key);
5958

6059
// int preference_remove_all (void)
61-
typedef preference_remove_all_native_t = Int32 Function();
60+
typedef PreferenceRemoveAllNative = Int32 Function();
6261
typedef PreferenceRemoveAll = int Function();
6362

6463
// typedef bool(* preference_item_cb )(const char *key, void *user_data)
65-
typedef preference_item_cb_native_t = Int8 Function(
64+
typedef PreferenceItemCallbackNative = Int8 Function(
6665
Pointer<Utf8> key, Pointer<Void> userData);
6766

6867
// int preference_foreach_item (preference_item_cb callback, void *user_data)
69-
typedef preference_foreach_item_native_t = Int32 Function(
70-
Pointer<NativeFunction<preference_item_cb_native_t>> callback,
68+
typedef PreferenceForeachItemNative = Int32 Function(
69+
Pointer<NativeFunction<PreferenceItemCallbackNative>> callback,
7170
Pointer<Void> userData);
7271
typedef PreferenceForeachItem = int Function(
73-
Pointer<NativeFunction<preference_item_cb_native_t>> callback,
72+
Pointer<NativeFunction<PreferenceItemCallbackNative>> callback,
7473
Pointer<Void> userData);

0 commit comments

Comments
 (0)