Skip to content

Commit 3c65587

Browse files
committed
allow BuildContext to be optional on .of()
2.1.1
1 parent c4aa92b commit 3c65587

File tree

4 files changed

+25
-23
lines changed

4 files changed

+25
-23
lines changed

example/pubspec.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages:
77
name: async
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "2.6.1"
10+
version: "2.8.2"
1111
boolean_selector:
1212
dependency: transitive
1313
description:
@@ -21,14 +21,14 @@ packages:
2121
name: characters
2222
url: "https://pub.dartlang.org"
2323
source: hosted
24-
version: "1.1.0"
24+
version: "1.2.0"
2525
charcode:
2626
dependency: transitive
2727
description:
2828
name: charcode
2929
url: "https://pub.dartlang.org"
3030
source: hosted
31-
version: "1.2.0"
31+
version: "1.3.1"
3232
clock:
3333
dependency: transitive
3434
description:
@@ -99,14 +99,14 @@ packages:
9999
name: matcher
100100
url: "https://pub.dartlang.org"
101101
source: hosted
102-
version: "0.12.10"
102+
version: "0.12.11"
103103
meta:
104104
dependency: transitive
105105
description:
106106
name: meta
107107
url: "https://pub.dartlang.org"
108108
source: hosted
109-
version: "1.3.0"
109+
version: "1.7.0"
110110
path:
111111
dependency: transitive
112112
description:
@@ -204,7 +204,7 @@ packages:
204204
path: ".."
205205
relative: true
206206
source: path
207-
version: "2.0.0"
207+
version: "2.1.0"
208208
sky_engine:
209209
dependency: transitive
210210
description: flutter
@@ -251,7 +251,7 @@ packages:
251251
name: test_api
252252
url: "https://pub.dartlang.org"
253253
source: hosted
254-
version: "0.3.0"
254+
version: "0.4.3"
255255
typed_data:
256256
dependency: transitive
257257
description:
@@ -265,7 +265,7 @@ packages:
265265
name: vector_math
266266
url: "https://pub.dartlang.org"
267267
source: hosted
268-
version: "2.1.0"
268+
version: "2.1.1"
269269
win32:
270270
dependency: transitive
271271
description:
@@ -281,5 +281,5 @@ packages:
281281
source: hosted
282282
version: "0.2.0"
283283
sdks:
284-
dart: ">=2.12.0 <3.0.0"
284+
dart: ">=2.14.0 <3.0.0"
285285
flutter: ">=1.20.0"

lib/shared_value.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,13 @@ class SharedValue<T> {
8484

8585
/// Get the value held by this state,
8686
/// and also rebuild the widget in [context] whenever [mutate] is called.
87-
T of(BuildContext context) {
88-
InheritedModel.inheritFrom<SharedValueInheritedModel>(
89-
context,
90-
aspect: this,
91-
);
87+
T of([BuildContext? context]) {
88+
if (context != null) {
89+
InheritedModel.inheritFrom<SharedValueInheritedModel>(
90+
context,
91+
aspect: this,
92+
);
93+
}
9294
return _value;
9395
}
9496

pubspec.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages:
77
name: async
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "2.6.1"
10+
version: "2.8.2"
1111
boolean_selector:
1212
dependency: transitive
1313
description:
@@ -21,14 +21,14 @@ packages:
2121
name: characters
2222
url: "https://pub.dartlang.org"
2323
source: hosted
24-
version: "1.1.0"
24+
version: "1.2.0"
2525
charcode:
2626
dependency: transitive
2727
description:
2828
name: charcode
2929
url: "https://pub.dartlang.org"
3030
source: hosted
31-
version: "1.2.0"
31+
version: "1.3.1"
3232
clock:
3333
dependency: transitive
3434
description:
@@ -92,14 +92,14 @@ packages:
9292
name: matcher
9393
url: "https://pub.dartlang.org"
9494
source: hosted
95-
version: "0.12.10"
95+
version: "0.12.11"
9696
meta:
9797
dependency: transitive
9898
description:
9999
name: meta
100100
url: "https://pub.dartlang.org"
101101
source: hosted
102-
version: "1.3.0"
102+
version: "1.7.0"
103103
path:
104104
dependency: transitive
105105
description:
@@ -237,7 +237,7 @@ packages:
237237
name: test_api
238238
url: "https://pub.dartlang.org"
239239
source: hosted
240-
version: "0.3.0"
240+
version: "0.4.3"
241241
typed_data:
242242
dependency: transitive
243243
description:
@@ -251,7 +251,7 @@ packages:
251251
name: vector_math
252252
url: "https://pub.dartlang.org"
253253
source: hosted
254-
version: "2.1.0"
254+
version: "2.1.1"
255255
win32:
256256
dependency: transitive
257257
description:
@@ -267,5 +267,5 @@ packages:
267267
source: hosted
268268
version: "0.2.0"
269269
sdks:
270-
dart: ">=2.12.0 <3.0.0"
270+
dart: ">=2.14.0 <3.0.0"
271271
flutter: ">=1.20.0"

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: shared_value
22
description: A straightforward way to manage global state in flutter apps.
3-
version: 2.1.0
3+
version: 2.1.1
44
author: Dev Aggarwal <[email protected]>
55
homepage: https://github.com/scientifichackers/flutter-shared-value
66

0 commit comments

Comments
 (0)