You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Experimental: Avoid using FutureOr<void> as it's redundant
132
+
# Avoid using FutureOr<void> because the synchronous type void makes no sense since it can't be assigned to a variable
133
+
#
134
+
# Definitly never use it as return type of a function.
135
+
#
136
+
# Exception: It is ok to use it as parameter (also constructor parameter) to accept both a synchronous and asynchronous callback for flexability in API design
137
+
#
138
+
# ```
139
+
# void executeTask(FutureOr<void> Function() task) async { // ok
140
+
# await task();
141
+
# }
142
+
#
143
+
# void main() {
144
+
# executeTask(() => print('Sync task')); // sync is allowed
145
+
# executeTask(() async => await Future.delayed(Duration(seconds: 1), () => print('Async task'))); // will be awaited
146
+
# }
147
+
# ```
134
148
#
149
+
# See discusson at https://github.com/dart-lang/sdk/issues/59232
#Experimental: Avoid using FutureOr<void> as it's redundant
135
+
# Avoid using FutureOr<void> because the synchronous type void makes no sense since it can't be assigned to a variable
136
136
#
137
+
# Definitly never use it as return type of a function.
138
+
#
139
+
# Exception: It is ok to use it as parameter (also constructor parameter) to accept both a synchronous and asynchronous callback for flexability in API design
140
+
#
141
+
# ```
142
+
# void executeTask(FutureOr<void> Function() task) async { // ok
143
+
# await task();
144
+
# }
145
+
#
146
+
# void main() {
147
+
# executeTask(() => print('Sync task')); // sync is allowed
148
+
# executeTask(() async => await Future.delayed(Duration(seconds: 1), () => print('Async task'))); // will be awaited
149
+
# }
150
+
# ```
151
+
#
152
+
# See discusson at https://github.com/dart-lang/sdk/issues/59232
0 commit comments