You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by pa...@apache.org on 2022/06/22 16:49:51 UTC
[beam] branch master updated: Merge pull request #21981 from [Playground] Upgrade Flutter linter, fix linter issues (#21951)
This is an automated email from the ASF dual-hosted git repository.
pabloem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push:
new 45bebebdafe Merge pull request #21981 from [Playground] Upgrade Flutter linter, fix linter issues (#21951)
45bebebdafe is described below
commit 45bebebdafe7c8df707259ca11c5633aebdb3933
Author: alexeyinkin <44...@users.noreply.github.com>
AuthorDate: Wed Jun 22 20:49:45 2022 +0400
Merge pull request #21981 from [Playground] Upgrade Flutter linter, fix linter issues (#21951)
* Upgrade Flutter linter, fix linter issues (#21951)
* Specify a return type (#21951)
---
playground/frontend/analysis_options.yaml | 66 +++++++++++++++++++++-
.../dropdown_button/dropdown_button.dart | 4 +-
.../lib/components/split_view/split_view.dart | 2 +-
.../modules/editor/components/editor_textarea.dart | 2 +-
.../pipeline_options_dropdown.dart | 2 +-
.../pipeline_options_dropdown_body.dart | 4 +-
.../pipeline_options_form.dart | 2 +-
.../example_list/category_expansion_panel.dart | 2 +-
.../lib/modules/examples/example_selector.dart | 4 +-
.../graph/graph_builder/painters/node_painter.dart | 2 +-
.../components/base_notification.dart | 8 +--
.../modules/sdk/components/sdk_selector_row.dart | 2 +-
.../shortcuts/components/shortcuts_modal.dart | 2 +-
.../lib/modules/shortcuts/models/shortcut.dart | 2 +-
.../components/embedded_split_view.dart | 2 +-
.../feedback/feedback_dropdown_content.dart | 2 +-
.../feedback/feedback_dropdown_icon_button.dart | 2 +-
.../pages/playground/states/examples_state.dart | 10 ++--
.../pages/playground/states/playground_state.dart | 2 +-
playground/frontend/pubspec.lock | 12 ++--
playground/frontend/pubspec.yaml | 35 +++++-------
.../frontend/test/utils/run_with_retry_test.dart | 10 ++--
22 files changed, 117 insertions(+), 62 deletions(-)
diff --git a/playground/frontend/analysis_options.yaml b/playground/frontend/analysis_options.yaml
index 933fe93240d..fd91906eae8 100644
--- a/playground/frontend/analysis_options.yaml
+++ b/playground/frontend/analysis_options.yaml
@@ -28,7 +28,12 @@ include: package:flutter_lints/flutter.yaml
# exclude generated files
analyzer:
- exclude: [lib/api/**, test/**.mocks.dart, lib/**.g.dart, lib/l10n/**.arb, build/**]
+ exclude:
+ - build/**
+ - lib/**.g.dart
+ - lib/api/**
+ - lib/l10n/**.arb
+ - test/**.mocks.dart
linter:
# The lint rules applied to this project can be customized in the
@@ -43,10 +48,65 @@ linter:
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
+ # Turn on those off by default:
+ always_put_control_body_on_new_line: true
+ avoid_bool_literals_in_conditional_expressions: true
+ avoid_catching_errors: true
+ avoid_double_and_int_checks: true
+ avoid_dynamic_calls: true
+ avoid_field_initializers_in_const_classes: true
+ avoid_implementing_value_types: true
+ avoid_js_rounded_ints: true
+ avoid_multiple_declarations_per_line: true
+ avoid_private_typedef_functions: true
+ avoid_returning_null_for_future: true
+ avoid_returning_this: true
+ avoid_setters_without_getters: true
+ avoid_slow_async_io: true
+ avoid_type_to_string: true
+ avoid_unused_constructor_parameters: true
+ cancel_subscriptions: true
+ close_sinks: true
+ comment_references: true
+ conditional_uri_does_not_exist: true
+ deprecated_consistency: true
+ do_not_use_environment: true
eol_at_end_of_file: true
+ invariant_booleans: true
+ leading_newlines_in_multiline_strings: true
+ literal_only_boolean_expressions: true
+ no_runtimeType_toString: true
+ noop_primitive_operations: true
+ one_member_abstracts: true
+ only_throw_errors: true
+ package_api_docs: true
+ parameter_assignments: true
+ prefer_asserts_in_initializer_lists: true
+ prefer_single_quotes: true
+ secure_pubspec_urls: true
+ sized_box_shrink_expand: true
+ sort_pub_dependencies: true
+ sort_unnamed_constructors_first: true
+ test_types_in_equals: true
+ tighten_type_of_initializing_formals: true
+ unnecessary_await_in_return: true
+ unnecessary_null_aware_operator_on_extension_on_nullable: true
+ unnecessary_null_checks: true
+ unnecessary_parenthesis: true
+ unnecessary_statements: true
+ unnecessary_to_list_in_spreads: true
+ unsafe_html: true
+ use_enums: true
+ use_if_null_to_convert_nulls_to_bools: true
+ use_is_even_rather_than_modulo: true
+ use_raw_strings: true
+ use_setters_to_change_properties: true
+ use_to_and_as_if_applicable: true
+
+ #Turn off those on by default:
avoid_web_libraries_in_flutter: false
- avoid_print: false # Uncomment to disable the `avoid_print` rule
- prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
+ avoid_print: false
+ prefer_interpolation_to_compose_strings: false
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
diff --git a/playground/frontend/lib/components/dropdown_button/dropdown_button.dart b/playground/frontend/lib/components/dropdown_button/dropdown_button.dart
index 8f82d7614fc..a554356c635 100644
--- a/playground/frontend/lib/components/dropdown_button/dropdown_button.dart
+++ b/playground/frontend/lib/components/dropdown_button/dropdown_button.dart
@@ -28,7 +28,7 @@ const double kAdditionalDyAlignment = 50.0;
class AppDropdownButton extends StatefulWidget {
final Widget buttonText;
- final Function createDropdown;
+ final Widget Function(void Function()) createDropdown;
final double height;
final double width;
@@ -41,7 +41,7 @@ class AppDropdownButton extends StatefulWidget {
}) : super(key: key);
@override
- _AppDropdownButtonState createState() => _AppDropdownButtonState();
+ State<AppDropdownButton> createState() => _AppDropdownButtonState();
}
class _AppDropdownButtonState extends State<AppDropdownButton>
diff --git a/playground/frontend/lib/components/split_view/split_view.dart b/playground/frontend/lib/components/split_view/split_view.dart
index cbb3ce5d5d0..922aea4e94c 100644
--- a/playground/frontend/lib/components/split_view/split_view.dart
+++ b/playground/frontend/lib/components/split_view/split_view.dart
@@ -47,7 +47,7 @@ class SplitView extends StatefulWidget {
}) : super(key: key);
@override
- _SplitViewState createState() => _SplitViewState();
+ State<SplitView> createState() => _SplitViewState();
}
class _SplitViewState extends State<SplitView> {
diff --git a/playground/frontend/lib/modules/editor/components/editor_textarea.dart b/playground/frontend/lib/modules/editor/components/editor_textarea.dart
index cb75c35de13..dfaf0eb0943 100644
--- a/playground/frontend/lib/modules/editor/components/editor_textarea.dart
+++ b/playground/frontend/lib/modules/editor/components/editor_textarea.dart
@@ -59,7 +59,7 @@ class EditorTextArea extends StatefulWidget {
}) : super(key: key);
@override
- _EditorTextAreaState createState() => _EditorTextAreaState();
+ State<EditorTextArea> createState() => _EditorTextAreaState();
}
class _EditorTextAreaState extends State<EditorTextArea> {
diff --git a/playground/frontend/lib/modules/editor/components/pipeline_options_dropdown/pipeline_options_dropdown.dart b/playground/frontend/lib/modules/editor/components/pipeline_options_dropdown/pipeline_options_dropdown.dart
index acca87088f9..ebf65a6c3ff 100644
--- a/playground/frontend/lib/modules/editor/components/pipeline_options_dropdown/pipeline_options_dropdown.dart
+++ b/playground/frontend/lib/modules/editor/components/pipeline_options_dropdown/pipeline_options_dropdown.dart
@@ -26,7 +26,7 @@ const kDropdownHeight = 375.0;
class PipelineOptionsDropdown extends StatelessWidget {
final String pipelineOptions;
- final Function(String) setPipelineOptions;
+ final void Function(String) setPipelineOptions;
const PipelineOptionsDropdown({
Key? key,
diff --git a/playground/frontend/lib/modules/editor/components/pipeline_options_dropdown/pipeline_options_dropdown_body.dart b/playground/frontend/lib/modules/editor/components/pipeline_options_dropdown/pipeline_options_dropdown_body.dart
index aa6532a08e8..f378ff2f72f 100644
--- a/playground/frontend/lib/modules/editor/components/pipeline_options_dropdown/pipeline_options_dropdown_body.dart
+++ b/playground/frontend/lib/modules/editor/components/pipeline_options_dropdown/pipeline_options_dropdown_body.dart
@@ -33,8 +33,8 @@ final kDefaultOption = [PipelineOptionController()];
class PipelineOptionsDropdownBody extends StatefulWidget {
final String pipelineOptions;
- final Function(String) setPipelineOptions;
- final Function close;
+ final void Function(String) setPipelineOptions;
+ final void Function() close;
const PipelineOptionsDropdownBody({
Key? key,
diff --git a/playground/frontend/lib/modules/editor/components/pipeline_options_dropdown/pipeline_options_form.dart b/playground/frontend/lib/modules/editor/components/pipeline_options_dropdown/pipeline_options_form.dart
index 868ee4b73fc..fa72395dac0 100644
--- a/playground/frontend/lib/modules/editor/components/pipeline_options_dropdown/pipeline_options_form.dart
+++ b/playground/frontend/lib/modules/editor/components/pipeline_options_dropdown/pipeline_options_form.dart
@@ -31,7 +31,7 @@ const kTextFieldHeight = 50.0;
class PipelineOptionsForm extends StatelessWidget {
final List<PipelineOptionController> options;
- final Function(int) onDelete;
+ final void Function(int) onDelete;
const PipelineOptionsForm({
Key? key,
diff --git a/playground/frontend/lib/modules/examples/components/example_list/category_expansion_panel.dart b/playground/frontend/lib/modules/examples/components/example_list/category_expansion_panel.dart
index ab19a2b8d00..c6dcf47271e 100644
--- a/playground/frontend/lib/modules/examples/components/example_list/category_expansion_panel.dart
+++ b/playground/frontend/lib/modules/examples/components/example_list/category_expansion_panel.dart
@@ -54,8 +54,8 @@ class CategoryExpansionPanel extends StatelessWidget {
children: [
Transform.rotate(
angle: -math.pi * animationValue,
- child: const Icon(Icons.keyboard_arrow_down),
alignment: Alignment.center,
+ child: const Icon(Icons.keyboard_arrow_down),
),
SizedBox(
height: kContainerHeight,
diff --git a/playground/frontend/lib/modules/examples/example_selector.dart b/playground/frontend/lib/modules/examples/example_selector.dart
index 272e06f35b0..0e1c359a1d9 100644
--- a/playground/frontend/lib/modules/examples/example_selector.dart
+++ b/playground/frontend/lib/modules/examples/example_selector.dart
@@ -40,7 +40,7 @@ const double kLgContainerHeight = 490.0;
const double kLgContainerWidth = 400.0;
class ExampleSelector extends StatefulWidget {
- final Function changeSelectorVisibility;
+ final void Function() changeSelectorVisibility;
final bool isSelectorOpened;
const ExampleSelector({
@@ -153,7 +153,7 @@ class _ExampleSelectorState extends State<ExampleSelector>
child: SlideTransition(
position: offsetAnimation,
child: Material(
- elevation: kElevation.toDouble(),
+ elevation: kElevation,
child: Container(
height: kLgContainerHeight,
width: kLgContainerWidth,
diff --git a/playground/frontend/lib/modules/graph/graph_builder/painters/node_painter.dart b/playground/frontend/lib/modules/graph/graph_builder/painters/node_painter.dart
index af9257deafc..6e04f880bdd 100644
--- a/playground/frontend/lib/modules/graph/graph_builder/painters/node_painter.dart
+++ b/playground/frontend/lib/modules/graph/graph_builder/painters/node_painter.dart
@@ -80,7 +80,7 @@ class NodeElementPainter {
return size!;
}
- get maxTextWidth {
+ double get maxTextWidth {
var textWidth = getTextSize(element.label, 10.0).width;
if (parentLabel.isNotEmpty) {
final parentLabelSize = getTextSize(parentLabel, 10.0).width;
diff --git a/playground/frontend/lib/modules/notifications/components/base_notification.dart b/playground/frontend/lib/modules/notifications/components/base_notification.dart
index 4f995591124..e115f8dc578 100644
--- a/playground/frontend/lib/modules/notifications/components/base_notification.dart
+++ b/playground/frontend/lib/modules/notifications/components/base_notification.dart
@@ -50,6 +50,10 @@ class BaseNotification extends StatelessWidget {
Widget _renderLeftBorder(BuildContext context) {
return Positioned(
+ width: kNotificationBorderWidth,
+ left: 0,
+ top: 0,
+ bottom: 0,
child: Container(
decoration: BoxDecoration(
color: color,
@@ -59,10 +63,6 @@ class BaseNotification extends StatelessWidget {
),
),
),
- width: kNotificationBorderWidth,
- left: 0,
- top: 0,
- bottom: 0,
);
}
diff --git a/playground/frontend/lib/modules/sdk/components/sdk_selector_row.dart b/playground/frontend/lib/modules/sdk/components/sdk_selector_row.dart
index 4db4a5afa0e..d66dda2dee7 100644
--- a/playground/frontend/lib/modules/sdk/components/sdk_selector_row.dart
+++ b/playground/frontend/lib/modules/sdk/components/sdk_selector_row.dart
@@ -45,11 +45,11 @@ class SdkSelectorRow extends StatelessWidget {
),
),
),
+ onPressed: onSelect,
child: Padding(
padding: const EdgeInsets.all(kLgSpacing),
child: Text(sdk.displayName),
),
- onPressed: onSelect,
);
}
}
diff --git a/playground/frontend/lib/modules/shortcuts/components/shortcuts_modal.dart b/playground/frontend/lib/modules/shortcuts/components/shortcuts_modal.dart
index 649d0bfee9e..c92c2748756 100644
--- a/playground/frontend/lib/modules/shortcuts/components/shortcuts_modal.dart
+++ b/playground/frontend/lib/modules/shortcuts/components/shortcuts_modal.dart
@@ -69,7 +69,6 @@ class ShortcutsModal extends StatelessWidget {
),
actions: [
ElevatedButton(
- child: Text(appLocale.close),
style: ButtonStyle(
elevation: MaterialStateProperty.all<double>(0.0),
fixedSize: MaterialStateProperty.all<Size>(
@@ -80,6 +79,7 @@ class ShortcutsModal extends StatelessWidget {
),
),
onPressed: () => Navigator.of(context).pop(),
+ child: Text(appLocale.close),
),
],
);
diff --git a/playground/frontend/lib/modules/shortcuts/models/shortcut.dart b/playground/frontend/lib/modules/shortcuts/models/shortcut.dart
index 15301a83d0e..0aafe060b05 100644
--- a/playground/frontend/lib/modules/shortcuts/models/shortcut.dart
+++ b/playground/frontend/lib/modules/shortcuts/models/shortcut.dart
@@ -22,7 +22,7 @@ class Shortcut {
final String name;
final LogicalKeySet shortcuts;
final Intent actionIntent;
- final Function createAction;
+ final CallbackAction Function(BuildContext) createAction;
Shortcut({
required this.name,
diff --git a/playground/frontend/lib/pages/embedded_playground/components/embedded_split_view.dart b/playground/frontend/lib/pages/embedded_playground/components/embedded_split_view.dart
index 884fdd36aa5..c5b6ea11ad1 100644
--- a/playground/frontend/lib/pages/embedded_playground/components/embedded_split_view.dart
+++ b/playground/frontend/lib/pages/embedded_playground/components/embedded_split_view.dart
@@ -38,7 +38,7 @@ class EmbeddedSplitView extends StatefulWidget {
}) : super(key: key);
@override
- _EmbeddedSplitViewState createState() => _EmbeddedSplitViewState();
+ State<EmbeddedSplitView> createState() => _EmbeddedSplitViewState();
}
class _EmbeddedSplitViewState extends State<EmbeddedSplitView> {
diff --git a/playground/frontend/lib/pages/playground/components/feedback/feedback_dropdown_content.dart b/playground/frontend/lib/pages/playground/components/feedback/feedback_dropdown_content.dart
index fdba9ceff2a..d94b5246336 100644
--- a/playground/frontend/lib/pages/playground/components/feedback/feedback_dropdown_content.dart
+++ b/playground/frontend/lib/pages/playground/components/feedback/feedback_dropdown_content.dart
@@ -35,7 +35,7 @@ const String kFeedbackContentText = 'Have feedback? We\'d love to hear it,'
'\nHave questions? Try help or support.';
class FeedbackDropdownContent extends StatelessWidget {
- final Function close;
+ final void Function() close;
final TextEditingController textController;
const FeedbackDropdownContent({
diff --git a/playground/frontend/lib/pages/playground/components/feedback/feedback_dropdown_icon_button.dart b/playground/frontend/lib/pages/playground/components/feedback/feedback_dropdown_icon_button.dart
index b99a8df7c37..8b005b1cf5b 100644
--- a/playground/frontend/lib/pages/playground/components/feedback/feedback_dropdown_icon_button.dart
+++ b/playground/frontend/lib/pages/playground/components/feedback/feedback_dropdown_icon_button.dart
@@ -33,7 +33,7 @@ class FeedbackDropdownIconButton extends StatefulWidget {
final String iconAsset;
final String filledIconAsset;
final bool isSelected;
- final Function onClick;
+ final void Function() onClick;
const FeedbackDropdownIconButton({
Key? key,
diff --git a/playground/frontend/lib/pages/playground/states/examples_state.dart b/playground/frontend/lib/pages/playground/states/examples_state.dart
index 3e7bdf95258..256224ad54b 100644
--- a/playground/frontend/lib/pages/playground/states/examples_state.dart
+++ b/playground/frontend/lib/pages/playground/states/examples_state.dart
@@ -50,31 +50,31 @@ class ExampleState with ChangeNotifier {
}
Future<String> getExampleOutput(String id, SDK sdk) async {
- return await _exampleRepository.getExampleOutput(
+ return _exampleRepository.getExampleOutput(
GetExampleRequestWrapper(id, sdk),
);
}
Future<String> getExampleSource(String id, SDK sdk) async {
- return await _exampleRepository.getExampleSource(
+ return _exampleRepository.getExampleSource(
GetExampleRequestWrapper(id, sdk),
);
}
Future<ExampleModel> getExample(String path, SDK sdk) async {
- return await _exampleRepository.getExample(
+ return _exampleRepository.getExample(
GetExampleRequestWrapper(path, sdk),
);
}
Future<String> getExampleLogs(String id, SDK sdk) async {
- return await _exampleRepository.getExampleLogs(
+ return _exampleRepository.getExampleLogs(
GetExampleRequestWrapper(id, sdk),
);
}
Future<String> getExampleGraph(String id, SDK sdk) async {
- return await _exampleRepository.getExampleGraph(
+ return _exampleRepository.getExampleGraph(
GetExampleRequestWrapper(id, sdk),
);
}
diff --git a/playground/frontend/lib/pages/playground/states/playground_state.dart b/playground/frontend/lib/pages/playground/states/playground_state.dart
index b83765755c3..4923c756d4c 100644
--- a/playground/frontend/lib/pages/playground/states/playground_state.dart
+++ b/playground/frontend/lib/pages/playground/states/playground_state.dart
@@ -152,7 +152,7 @@ class PlaygroundState with ChangeNotifier {
notifyListeners();
}
- void runCode({Function? onFinish}) {
+ void runCode({void Function()? onFinish}) {
final parsedPipelineOptions = parsePipelineOptions(pipelineOptions);
if (parsedPipelineOptions == null) {
_result = RunCodeResult(
diff --git a/playground/frontend/pubspec.lock b/playground/frontend/pubspec.lock
index 9a63b0691c4..5c6ec414b16 100644
--- a/playground/frontend/pubspec.lock
+++ b/playground/frontend/pubspec.lock
@@ -149,7 +149,7 @@ packages:
source: hosted
version: "1.0.2"
collection:
- dependency: "direct dev"
+ dependency: "direct main"
description:
name: collection
url: "https://pub.dartlang.org"
@@ -229,7 +229,7 @@ packages:
name: flutter_lints
url: "https://pub.dartlang.org"
source: hosted
- version: "1.0.4"
+ version: "2.0.1"
flutter_localizations:
dependency: "direct main"
description: flutter
@@ -267,7 +267,7 @@ packages:
source: hosted
version: "2.0.2"
google_fonts:
- dependency: "direct dev"
+ dependency: "direct main"
description:
name: google_fonts
url: "https://pub.dartlang.org"
@@ -295,7 +295,7 @@ packages:
source: hosted
version: "3.0.2"
highlight:
- dependency: transitive
+ dependency: "direct main"
description:
name: highlight
url: "https://pub.dartlang.org"
@@ -370,7 +370,7 @@ packages:
name: lints
url: "https://pub.dartlang.org"
source: hosted
- version: "1.0.1"
+ version: "2.0.0"
logging:
dependency: transitive
description:
@@ -762,7 +762,7 @@ packages:
source: hosted
version: "3.0.1"
usage:
- dependency: "direct dev"
+ dependency: "direct main"
description:
name: usage
url: "https://pub.dartlang.org"
diff --git a/playground/frontend/pubspec.yaml b/playground/frontend/pubspec.yaml
index e449c613144..b3f304f28ce 100644
--- a/playground/frontend/pubspec.yaml
+++ b/playground/frontend/pubspec.yaml
@@ -35,7 +35,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
- sdk: ">=2.12.0 <3.0.0"
+ sdk: ">=2.17.0 <3.0.0"
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
@@ -44,37 +44,32 @@ environment:
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
- flutter:
- sdk: flutter
- provider: ^6.0.0
+ aligned_dialog: ^0.0.6
code_text_field: ^1.0.0
- flutter_svg: ^0.22.0
- url_launcher: ^6.0.12
+ collection: ^1.15.0
expansion_widget: ^0.0.2
- grpc: ^3.0.0
- flutter_web_plugins:
+ flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
+ flutter_svg: ^0.22.0
+ flutter_web_plugins:
+ sdk: flutter
+ google_fonts: ^2.3.1
+ grpc: ^3.0.0
+ highlight: ^0.7.0
intl: ^0.17.0
- aligned_dialog: ^0.0.6
+ provider: ^6.0.0
shared_preferences: ^2.0.12
+ url_launcher: ^6.0.12
+ usage: ^4.0.2
dev_dependencies:
+ build_runner: ^2.1.4
+ flutter_lints: ^2.0.1
flutter_test:
sdk: flutter
mockito: ^5.0.16
- build_runner: ^2.1.4
- google_fonts: ^2.3.1
- usage: ^4.0.2
- collection: ^1.15.0
-
- # The "flutter_lints" package below contains a set of recommended lints to
- # encourage good coding practices. The lint set provided by the package is
- # activated in the `analysis_options.yaml` file located at the root of your
- # package. See that file for information about deactivating specific lint
- # rules and activating additional ones.
- flutter_lints: ^1.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
diff --git a/playground/frontend/test/utils/run_with_retry_test.dart b/playground/frontend/test/utils/run_with_retry_test.dart
index 3c92c77da38..39d7a9ddb6b 100644
--- a/playground/frontend/test/utils/run_with_retry_test.dart
+++ b/playground/frontend/test/utils/run_with_retry_test.dart
@@ -22,23 +22,23 @@ import 'package:playground/utils/run_with_retry.dart';
class ExecutionTime<T> {
final int time;
final T? value;
- final T? error;
+ final Object? error;
ExecutionTime(this.time, {this.value, this.error});
}
-Future<ExecutionTime> withExecutionTime(Function fn) async {
+Future<ExecutionTime<T>> withExecutionTime<T>(Future<T> Function() fn) async {
final stopwatch = Stopwatch()..start();
try {
final result = await fn();
- return ExecutionTime(stopwatch.elapsedMilliseconds, value: result);
+ return ExecutionTime<T>(stopwatch.elapsedMilliseconds, value: result);
} catch (e) {
- return ExecutionTime(stopwatch.elapsedMilliseconds, error: e);
+ return ExecutionTime<T>(stopwatch.elapsedMilliseconds, error: e);
}
}
class ResultBuilder {
- static Function getFutureWithResult(List<Future Function()> futures) {
+ static Future<T> Function() getFutureWithResult<T>(List<Future<T> Function()> futures) {
var attempt = 0;
return () async {
final futureCreator = futures[attempt];