├── pkgs ├── args │ ├── .test_config │ ├── example │ │ ├── arg_parser │ │ │ ├── README.md │ │ │ └── pubspec.yaml │ │ └── command_runner │ │ │ ├── README.md │ │ │ └── pubspec.yaml │ ├── .gitignore │ ├── analysis_options.yaml │ ├── lib │ │ ├── args.dart │ │ └── src │ │ │ ├── usage_exception.dart │ │ │ ├── arg_parser_exception.dart │ │ │ └── help_command.dart │ ├── pubspec.yaml │ └── LICENSE ├── crypto │ ├── .gitignore │ ├── .test_config │ ├── AUTHORS │ ├── analysis_options.yaml │ ├── lib │ │ ├── crypto.dart │ │ └── src │ │ │ ├── utils.dart │ │ │ ├── digest_sink.dart │ │ │ ├── hash.dart │ │ │ └── digest.dart │ ├── pubspec.yaml │ ├── tool │ │ └── md5sum.dart │ ├── test │ │ └── utils.dart │ ├── example │ │ └── example.dart │ └── LICENSE ├── convert │ ├── .gitignore │ ├── AUTHORS │ ├── lib │ │ ├── convert.dart │ │ └── src │ │ │ ├── charcodes.dart │ │ │ ├── hex.dart │ │ │ ├── accumulator_sink.dart │ │ │ ├── identity_codec.dart │ │ │ ├── string_accumulator_sink.dart │ │ │ ├── percent.dart │ │ │ ├── utils.dart │ │ │ └── byte_accumulator_sink.dart │ ├── pubspec.yaml │ ├── README.md │ ├── analysis_options.yaml │ ├── example │ │ └── example.dart │ ├── benchmark │ │ └── fixed_datetime_formatter_benchmark.dart │ ├── test │ │ ├── identity_codec_test.dart │ │ ├── accumulator_sink_test.dart │ │ ├── string_accumulator_sink_test.dart │ │ └── byte_accumulator_sink_test.dart │ ├── LICENSE │ └── CHANGELOG.md ├── fixnum │ ├── .gitignore │ ├── AUTHORS │ ├── test │ │ ├── all_tests.dart │ │ └── int_64_vm_test.dart │ ├── pubspec.yaml │ ├── lib │ │ ├── src │ │ │ └── int64.dart │ │ └── fixnum.dart │ ├── README.md │ ├── analysis_options.yaml │ └── LICENSE ├── logging │ ├── .gitignore │ ├── AUTHORS │ ├── lib │ │ ├── logging.dart │ │ └── src │ │ │ └── log_record.dart │ ├── pubspec.yaml │ ├── analysis_options.yaml │ ├── example │ │ └── main.dart │ └── LICENSE ├── os_detect │ ├── .gitignore │ ├── AUTHORS │ ├── lib │ │ ├── override.dart │ │ └── src │ │ │ ├── osid_html.dart │ │ │ ├── osid_unknown.dart │ │ │ └── osid_io.dart │ ├── CHANGELOG.md │ ├── pubspec.yaml │ ├── analysis_options.yaml │ ├── example │ │ ├── tree_shaking.dart │ │ └── example.dart │ ├── bin │ │ └── os_detect.dart │ └── LICENSE ├── lints │ ├── tool │ │ ├── analysis_options.yaml │ │ ├── README.md │ │ └── validate_lib.dart │ ├── example │ │ ├── README.md │ │ ├── pubspec.yaml │ │ └── analysis_options.yaml │ ├── .gitignore │ ├── pubspec.yaml │ ├── lib │ │ └── core.yaml │ └── LICENSE ├── characters │ ├── .gitignore │ ├── analysis_options.yaml │ ├── AUTHORS │ ├── lib │ │ ├── characters.dart │ │ └── src │ │ │ └── extensions.dart │ ├── test │ │ └── src │ │ │ ├── various_tests.dart │ │ │ └── unicode_tests.dart │ ├── pubspec.yaml │ ├── tool │ │ ├── README.txt │ │ └── src │ │ │ ├── graph.dart │ │ │ └── indirect_table.dart │ ├── example │ │ └── main.dart │ ├── LICENSE │ └── third_party │ │ └── Unicode_Consortium │ │ └── UNICODE_LICENSE.txt ├── platform │ ├── example │ │ ├── .gitignore │ │ ├── README.md │ │ ├── pubspec.yaml │ │ ├── bin │ │ │ └── example.dart │ │ └── analysis_options.yaml │ ├── analysis_options.yaml │ ├── AUTHORS │ ├── .gitignore │ ├── lib │ │ ├── platform.dart │ │ └── src │ │ │ └── interface │ │ │ └── local_platform.dart │ ├── pubspec.yaml │ ├── README.md │ ├── test │ │ └── platform.json │ └── LICENSE ├── typed_data │ ├── .gitignore │ ├── AUTHORS │ ├── analysis_options.yaml │ ├── lib │ │ ├── typed_data.dart │ │ └── typed_buffers.dart │ ├── pubspec.yaml │ ├── test │ │ └── typed_buffers_vm_test.dart │ ├── README.md │ ├── LICENSE │ └── CHANGELOG.md ├── collection │ ├── .gitignore │ ├── AUTHORS │ ├── test │ │ ├── analysis_options.yaml │ │ ├── equality_map_test.dart │ │ ├── union_set_controller_test.dart │ │ ├── equality_set_test.dart │ │ └── ignore_ascii_case_test.dart │ ├── lib │ │ ├── equality.dart │ │ ├── iterable_zip.dart │ │ ├── priority_queue.dart │ │ ├── algorithms.dart │ │ ├── wrappers.dart │ │ ├── src │ │ │ ├── utils.dart │ │ │ ├── equality_set.dart │ │ │ ├── equality_map.dart │ │ │ ├── combined_wrappers │ │ │ │ ├── combined_iterator.dart │ │ │ │ └── combined_iterable.dart │ │ │ ├── empty_unmodifiable_set.dart │ │ │ └── iterable_zip.dart │ │ └── collection.dart │ ├── analysis_options.yaml │ ├── pubspec.yaml │ ├── LICENSE │ └── benchmark │ │ └── deep_collection_equality.dart ├── async │ ├── .gitignore │ ├── AUTHORS │ ├── pubspec.yaml │ ├── analysis_options.yaml │ ├── lib │ │ ├── src │ │ │ ├── stream_sink_transformer │ │ │ │ └── typed.dart │ │ │ ├── result │ │ │ │ ├── capture_sink.dart │ │ │ │ ├── capture_transformer.dart │ │ │ │ ├── release_transformer.dart │ │ │ │ ├── release_sink.dart │ │ │ │ ├── future.dart │ │ │ │ └── value.dart │ │ │ ├── stream_sink_extensions.dart │ │ │ ├── delegate │ │ │ │ ├── stream.dart │ │ │ │ ├── sink.dart │ │ │ │ ├── event_sink.dart │ │ │ │ ├── stream_consumer.dart │ │ │ │ ├── future.dart │ │ │ │ └── stream_sink.dart │ │ │ ├── typed_stream_transformer.dart │ │ │ ├── typed │ │ │ │ └── stream_subscription.dart │ │ │ ├── single_subscription_transformer.dart │ │ │ ├── async_memoizer.dart │ │ │ ├── restartable_timer.dart │ │ │ └── lazy_stream.dart │ │ └── async.dart │ ├── test │ │ ├── io_sink_impl.dart │ │ ├── async_memoizer_test.dart │ │ ├── result │ │ │ ├── result_future_test.dart │ │ │ └── result_flattenAll_test.dart │ │ └── single_subscription_transformer_test.dart │ └── LICENSE └── path │ ├── .gitignore │ ├── pubspec.yaml │ ├── lib │ └── src │ │ ├── path_exception.dart │ │ ├── characters.dart │ │ └── path_map.dart │ ├── analysis_options.yaml │ ├── example │ └── example.dart │ ├── test │ ├── browser_test.dart │ ├── utils.dart │ └── path_test.dart │ └── LICENSE ├── .github ├── ISSUE_TEMPLATE │ ├── args.md │ ├── path.md │ ├── async.md │ ├── crypto.md │ ├── fixnum.md │ ├── convert.md │ ├── logging.md │ ├── platform.md │ ├── os_detect.md │ ├── characters.md │ ├── collection.md │ ├── typed_data.md │ └── lints.md ├── dependabot.yaml ├── workflows │ ├── health.yaml │ ├── publish.yaml │ ├── post_summaries.yaml │ ├── pull_request_label.yaml │ ├── lints.yaml │ ├── no-response.yml │ ├── platform.yaml │ └── path.yaml ├── CODEOWNERS └── labeler.yml ├── .gemini ├── config.yaml └── styleguide.md ├── LICENSE └── CONTRIBUTING.md /pkgs/args/.test_config: -------------------------------------------------------------------------------- 1 | { 2 | "test_package": true 3 | } -------------------------------------------------------------------------------- /pkgs/crypto/.gitignore: -------------------------------------------------------------------------------- 1 | .dart_tool 2 | .packages 3 | pubspec.lock 4 | -------------------------------------------------------------------------------- /pkgs/convert/.gitignore: -------------------------------------------------------------------------------- 1 | .dart_tool 2 | .packages 3 | pubspec.lock 4 | -------------------------------------------------------------------------------- /pkgs/fixnum/.gitignore: -------------------------------------------------------------------------------- 1 | .dart_tool/ 2 | .packages 3 | pubspec.lock 4 | -------------------------------------------------------------------------------- /pkgs/logging/.gitignore: -------------------------------------------------------------------------------- 1 | .dart_tool 2 | .packages 3 | pubspec.lock 4 | -------------------------------------------------------------------------------- /pkgs/os_detect/.gitignore: -------------------------------------------------------------------------------- 1 | .dart_tool/ 2 | .packages 3 | pubspec.lock 4 | -------------------------------------------------------------------------------- /pkgs/lints/tool/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: ../lib/recommended.yaml 2 | -------------------------------------------------------------------------------- /pkgs/characters/.gitignore: -------------------------------------------------------------------------------- 1 | .dart_tool/ 2 | .packages 3 | pubspec.lock 4 | doc/api/ 5 | -------------------------------------------------------------------------------- /pkgs/lints/example/README.md: -------------------------------------------------------------------------------- 1 | An example project that uses Dart recommended lints. 2 | -------------------------------------------------------------------------------- /pkgs/crypto/.test_config: -------------------------------------------------------------------------------- 1 | { 2 | "test_package": { 3 | "platforms": ["vm"] 4 | } 5 | } -------------------------------------------------------------------------------- /pkgs/args/example/arg_parser/README.md: -------------------------------------------------------------------------------- 1 | # Example of using `ArgParser` 2 | 3 | `dart run example.dart` 4 | -------------------------------------------------------------------------------- /pkgs/characters/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:dart_flutter_team_lints/analysis_options.yaml 2 | -------------------------------------------------------------------------------- /pkgs/platform/example/.gitignore: -------------------------------------------------------------------------------- 1 | # https://dart.dev/guides/libraries/private-files 2 | # Created by `dart pub` 3 | .dart_tool/ 4 | -------------------------------------------------------------------------------- /pkgs/platform/example/README.md: -------------------------------------------------------------------------------- 1 | A small example application demonstrating how to use the platform information 2 | APIs in `package:platform`. -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/args.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "package:args" 3 | about: "Create a bug or file a feature request against package:args." 4 | labels: "package:args" 5 | --- 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/path.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "package:path" 3 | about: "Create a bug or file a feature request against package:path." 4 | labels: "package:path" 5 | --- 6 | -------------------------------------------------------------------------------- /pkgs/typed_data/.gitignore: -------------------------------------------------------------------------------- 1 | .buildlog 2 | .DS_Store 3 | .idea 4 | .dart_tool/ 5 | .pub/ 6 | .settings/ 7 | build/ 8 | packages 9 | .packages 10 | pubspec.lock 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/async.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "package:async" 3 | about: "Create a bug or file a feature request against package:async." 4 | labels: "package:async" 5 | --- 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/crypto.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "package:crypto" 3 | about: "Create a bug or file a feature request against package:crypto." 4 | labels: "package:crypto" 5 | --- 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/fixnum.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "package:fixnum" 3 | about: "Create a bug or file a feature request against package:fixnum." 4 | labels: "package:fixnum" 5 | --- 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/convert.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "package:convert" 3 | about: "Create a bug or file a feature request against package:convert." 4 | labels: "package:convert" 5 | --- 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/logging.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "package:logging" 3 | about: "Create a bug or file a feature request against package:logging." 4 | labels: "package:logging" 5 | --- 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/platform.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "package:platform" 3 | about: "Create a bug or file a feature request against package:platform." 4 | labels: "package:platform" 5 | --- 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/os_detect.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "package:os_detect" 3 | about: "Create a bug or file a feature request against package:os_detect." 4 | labels: "package:os_detect" 5 | --- 6 | -------------------------------------------------------------------------------- /pkgs/collection/.gitignore: -------------------------------------------------------------------------------- 1 | .buildlog 2 | .DS_Store 3 | .idea 4 | .pub/ 5 | .dart_tool/ 6 | .settings/ 7 | build/ 8 | packages 9 | .packages 10 | pubspec.lock 11 | benchmark/*.exe 12 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/characters.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "package:characters" 3 | about: "Create a bug or file a feature request against package:characters." 4 | labels: "package:characters" 5 | --- 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/collection.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "package:collection" 3 | about: "Create a bug or file a feature request against package:collection." 4 | labels: "package:collection" 5 | --- 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/typed_data.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "package:typed_data" 3 | about: "Create a bug or file a feature request against package:typed_data." 4 | labels: "package:typed_data" 5 | --- 6 | -------------------------------------------------------------------------------- /pkgs/platform/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:dart_flutter_team_lints/analysis_options.yaml 2 | 3 | analyzer: 4 | errors: 5 | # Allow having TODOs in the code 6 | todo: ignore 7 | -------------------------------------------------------------------------------- /pkgs/async/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://dart.dev/guides/libraries/private-files 2 | 3 | .buildlog 4 | .DS_Store 5 | .idea 6 | 7 | .dart_tool/ 8 | .settings/ 9 | build/ 10 | pubspec.lock 11 | .packages 12 | -------------------------------------------------------------------------------- /pkgs/args/example/command_runner/README.md: -------------------------------------------------------------------------------- 1 | # Example of using `CommandRunner` 2 | 3 | This example uses `CommandRunner` to create a tool for drawing ascii art shapes. 4 | 5 | `dart run draw.dart circle --radius=10` 6 | -------------------------------------------------------------------------------- /pkgs/async/AUTHORS: -------------------------------------------------------------------------------- 1 | # Below is a list of people and organizations that have contributed 2 | # to the project. Names should be added to the list like so: 3 | # 4 | # Name/Organization 5 | 6 | Google Inc. 7 | -------------------------------------------------------------------------------- /pkgs/convert/AUTHORS: -------------------------------------------------------------------------------- 1 | # Below is a list of people and organizations that have contributed 2 | # to the project. Names should be added to the list like so: 3 | # 4 | # Name/Organization 5 | 6 | Google Inc. 7 | -------------------------------------------------------------------------------- /pkgs/crypto/AUTHORS: -------------------------------------------------------------------------------- 1 | # Below is a list of people and organizations that have contributed 2 | # to the project. Names should be added to the list like so: 3 | # 4 | # Name/Organization 5 | 6 | Google Inc. 7 | -------------------------------------------------------------------------------- /pkgs/characters/AUTHORS: -------------------------------------------------------------------------------- 1 | # Below is a list of people and organizations that have contributed 2 | # to the Dart project. Names should be added to the list like so: 3 | # 4 | # Name/Organization 5 | 6 | Google LLC 7 | -------------------------------------------------------------------------------- /pkgs/os_detect/AUTHORS: -------------------------------------------------------------------------------- 1 | # Below is a list of people and organizations that have contributed 2 | # to the Dart project. Names should be added to the list like so: 3 | # 4 | # Name/Organization 5 | 6 | Google LLC 7 | -------------------------------------------------------------------------------- /pkgs/typed_data/AUTHORS: -------------------------------------------------------------------------------- 1 | # Below is a list of people and organizations that have contributed 2 | # to the project. Names should be added to the list like so: 3 | # 4 | # Name/Organization 5 | 6 | Google Inc. 7 | -------------------------------------------------------------------------------- /pkgs/platform/AUTHORS: -------------------------------------------------------------------------------- 1 | # Below is a list of people and organizations that have contributed 2 | # to the Process project. Names should be added to the list like so: 3 | # 4 | # Name/Organization 5 | 6 | Google Inc. 7 | -------------------------------------------------------------------------------- /pkgs/fixnum/AUTHORS: -------------------------------------------------------------------------------- 1 | # Names should be added to this file with this pattern: 2 | # 3 | # For individuals: 4 | # Name 5 | # 6 | # For organizations: 7 | # Organization 8 | # 9 | Google Inc. <*@google.com> -------------------------------------------------------------------------------- /pkgs/lints/example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: example 2 | description: An example project that uses Dart recommended lints. 3 | version: 0.1.0 4 | publish_to: none 5 | 6 | environment: 7 | sdk: ^3.0.0 8 | 9 | dev_dependencies: 10 | lints: ^2.1.0 11 | -------------------------------------------------------------------------------- /pkgs/lints/.gitignore: -------------------------------------------------------------------------------- 1 | # Files and directories created by pub 2 | .dart_tool/ 3 | .packages 4 | 5 | # Omit commiting pubspec.lock for library packages: 6 | # https://dart.dev/guides/libraries/private-files#pubspeclock 7 | pubspec.lock 8 | 9 | # Directory created by dartdoc 10 | doc/api/ 11 | -------------------------------------------------------------------------------- /pkgs/logging/AUTHORS: -------------------------------------------------------------------------------- 1 | # Names should be added to this file with this pattern: 2 | # 3 | # For individuals: 4 | # Name 5 | # 6 | # For organizations: 7 | # Organization 8 | # 9 | Google Inc. <*@google.com> 10 | Anton Astashov 11 | -------------------------------------------------------------------------------- /pkgs/collection/AUTHORS: -------------------------------------------------------------------------------- 1 | # Below is a list of people and organizations that have contributed 2 | # to the project. Names should be added to the list like so: 3 | # 4 | # Name/Organization 5 | 6 | Google Inc. 7 | AAABramenko (https://github.com/AAAbramenko) 8 | TimWhiting tim@whitings.org 9 | -------------------------------------------------------------------------------- /pkgs/platform/example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: example 2 | description: Demonstrates how to use the platform api. 3 | version: 1.0.0 4 | publish_to: none 5 | 6 | environment: 7 | sdk: ^3.2.0 8 | 9 | dependencies: 10 | platform: 11 | path: ../ 12 | 13 | dev_dependencies: 14 | lints: ^5.0.0 15 | -------------------------------------------------------------------------------- /pkgs/collection/test/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: ../analysis_options.yaml 2 | 3 | # Turn off the avoid_dynamic_calls lint for the test/ directory. 4 | analyzer: 5 | errors: 6 | avoid_dynamic_calls: ignore 7 | inference_failure_on_collection_literal: ignore 8 | inference_failure_on_instance_creation: ignore 9 | -------------------------------------------------------------------------------- /pkgs/platform/.gitignore: -------------------------------------------------------------------------------- 1 | ### Dart template 2 | # Don’t commit the following directories created by pub. 3 | .buildlog 4 | .dart_tool/ 5 | .pub/ 6 | build/ 7 | packages 8 | .packages 9 | 10 | # Include when developing application packages. 11 | pubspec.lock 12 | 13 | # IDE 14 | .project 15 | .settings 16 | .idea 17 | .c9 18 | -------------------------------------------------------------------------------- /pkgs/path/.gitignore: -------------------------------------------------------------------------------- 1 | # Don’t commit the following directories created by pub. 2 | .buildlog 3 | .pub/ 4 | .dart_tool/ 5 | .idea/ 6 | build/ 7 | .packages 8 | 9 | # Or the files created by dart2js. 10 | *.dart.js 11 | *.js_ 12 | *.js.deps 13 | *.js.map 14 | 15 | # Include when developing application packages. 16 | pubspec.lock 17 | -------------------------------------------------------------------------------- /pkgs/args/.gitignore: -------------------------------------------------------------------------------- 1 | # Don’t commit the following directories created by pub. 2 | .buildlog 3 | .pub/ 4 | .dart_tool/ 5 | build/ 6 | packages 7 | .packages 8 | 9 | # Or the files created by dart2js. 10 | *.dart.js 11 | *.js_ 12 | *.js.deps 13 | *.js.map 14 | 15 | # Include when developing application packages. 16 | pubspec.lock 17 | -------------------------------------------------------------------------------- /pkgs/crypto/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:dart_flutter_team_lints/analysis_options.yaml 2 | 3 | analyzer: 4 | language: 5 | strict-casts: true 6 | strict-inference: true 7 | strict-raw-types: true 8 | 9 | linter: 10 | rules: 11 | - avoid_unused_constructor_parameters 12 | - cancel_subscriptions 13 | -------------------------------------------------------------------------------- /pkgs/logging/lib/logging.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | export 'src/level.dart'; 6 | export 'src/log_record.dart'; 7 | export 'src/logger.dart'; 8 | -------------------------------------------------------------------------------- /pkgs/platform/lib/platform.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | // Core interfaces & classes. 6 | export 'src/interface/local_platform.dart'; 7 | export 'src/interface/platform.dart'; 8 | export 'src/testing/fake_platform.dart'; 9 | -------------------------------------------------------------------------------- /pkgs/typed_data/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # https://dart.dev/guides/language/analysis-options 2 | include: package:dart_flutter_team_lints/analysis_options.yaml 3 | 4 | analyzer: 5 | language: 6 | strict-casts: true 7 | 8 | linter: 9 | rules: 10 | - avoid_unused_constructor_parameters 11 | - cancel_subscriptions 12 | - no_adjacent_strings_in_list 13 | -------------------------------------------------------------------------------- /pkgs/collection/lib/equality.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | /// Import `collection.dart` instead. 6 | @Deprecated('Will be removed in collection 2.0.0.') 7 | library; 8 | 9 | export 'src/equality.dart'; 10 | -------------------------------------------------------------------------------- /.github/dependabot.yaml: -------------------------------------------------------------------------------- 1 | # Dependabot configuration file. 2 | # See https://docs.github.com/en/code-security/dependabot/dependabot-version-updates 3 | version: 2 4 | 5 | updates: 6 | - package-ecosystem: github-actions 7 | directory: / 8 | schedule: 9 | interval: monthly 10 | labels: 11 | - autosubmit 12 | groups: 13 | github-actions: 14 | patterns: 15 | - "*" 16 | -------------------------------------------------------------------------------- /pkgs/collection/lib/iterable_zip.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | /// Import `collection.dart` instead. 6 | @Deprecated('Will be removed in collection 2.0.0.') 7 | library; 8 | 9 | export 'src/iterable_zip.dart'; 10 | -------------------------------------------------------------------------------- /pkgs/collection/lib/priority_queue.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | /// Import `collection.dart` instead. 6 | @Deprecated('Will be removed in collection 2.0.0.') 7 | library; 8 | 9 | export 'src/priority_queue.dart'; 10 | -------------------------------------------------------------------------------- /pkgs/os_detect/lib/override.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | /// Functionality to override information about the current platform. 6 | library; 7 | 8 | export 'src/os_override.dart' show OperatingSystem, overrideOperatingSystem; 9 | -------------------------------------------------------------------------------- /pkgs/characters/lib/characters.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | /// String operations based on characters (Unicode grapheme clusters). 6 | library; 7 | 8 | export 'src/characters.dart'; 9 | export 'src/extensions.dart'; 10 | -------------------------------------------------------------------------------- /pkgs/fixnum/test/all_tests.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'int32_test.dart' as int32_test; 6 | import 'int64_test.dart' as int64_test; 7 | 8 | void main() { 9 | int32_test.main(); 10 | int64_test.main(); 11 | } 12 | -------------------------------------------------------------------------------- /pkgs/typed_data/lib/typed_data.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | /// Utilities and functionality related to the "dart:typed_data" library. 6 | library; 7 | 8 | export 'src/typed_queue.dart'; 9 | export 'typed_buffers.dart'; 10 | -------------------------------------------------------------------------------- /pkgs/args/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # https://dart.dev/guides/language/analysis-options 2 | 3 | include: package:dart_flutter_team_lints/analysis_options.yaml 4 | 5 | linter: 6 | rules: 7 | - avoid_unused_constructor_parameters 8 | - cancel_subscriptions 9 | - literal_only_boolean_expressions 10 | - missing_whitespace_between_adjacent_strings 11 | - no_adjacent_strings_in_list 12 | - no_runtimeType_toString 13 | -------------------------------------------------------------------------------- /pkgs/characters/lib/src/extensions.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'characters.dart'; 6 | 7 | extension StringCharacters on String { 8 | /// The [Characters] of this string. 9 | Characters get characters => Characters(this); 10 | } 11 | -------------------------------------------------------------------------------- /pkgs/crypto/lib/crypto.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | export 'src/digest.dart'; 6 | export 'src/hash.dart'; 7 | export 'src/hmac.dart'; 8 | export 'src/md5.dart'; 9 | export 'src/sha1.dart'; 10 | export 'src/sha256.dart'; 11 | export 'src/sha512.dart'; 12 | -------------------------------------------------------------------------------- /pkgs/args/lib/args.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | export 'src/arg_parser.dart' show ArgParser; 6 | export 'src/arg_parser_exception.dart' show ArgParserException; 7 | export 'src/arg_results.dart' show ArgResults; 8 | export 'src/option.dart' show Option, OptionType; 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/lints.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "package:lints" 3 | about: "Create a bug or file a feature request against package:lints." 4 | labels: "package:lints" 5 | --- 6 | 7 | **Note** this issue tracker is used to: 8 | 9 | - suggest adding an _existing_ lint to the core or recommended lint sets, or 10 | - file a bug or enhancement against `package:lints` 11 | 12 | To propose an entirely new lint, see instead https://github.com/dart-lang/sdk; 13 | thanks! 14 | -------------------------------------------------------------------------------- /pkgs/characters/test/src/various_tests.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | const zalgo = [ 6 | [ 7 | 'Z͑ͫ̓ͪ̂ͫ̽͏̴̙̤̞͉͚̯̞̠͍', 8 | 'A̴̵̜̰͔ͫ͗͢', 9 | 'L̠ͨͧͩ͘', 10 | 'G̴̻͈͍͔̹̑͗̎̅͛́', 11 | 'Ǫ̵̹̻̝̳͂̌̌͘', 12 | '!͖̬̰̙̗̿̋ͥͥ̂ͣ̐́́͜͞', 13 | ], 14 | ]; 15 | -------------------------------------------------------------------------------- /pkgs/platform/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: platform 2 | description: A pluggable, mockable platform information abstraction for Dart. 3 | repository: https://github.com/dart-lang/core/tree/main/pkgs/platform 4 | issue_tracker: https://github.com/dart-lang/core/issues 5 | version: 3.1.7-wip 6 | 7 | topics: 8 | - information 9 | - platform 10 | 11 | environment: 12 | sdk: ^3.2.0 13 | 14 | dev_dependencies: 15 | dart_flutter_team_lints: ^3.1.0 16 | test: ^1.16.8 17 | 18 | -------------------------------------------------------------------------------- /pkgs/collection/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:dart_flutter_team_lints/analysis_options.yaml 2 | 3 | analyzer: 4 | language: 5 | strict-casts: true 6 | 7 | linter: 8 | rules: 9 | - avoid_unused_constructor_parameters 10 | - cancel_subscriptions 11 | - literal_only_boolean_expressions 12 | - missing_whitespace_between_adjacent_strings 13 | - no_adjacent_strings_in_list 14 | - no_runtimeType_toString 15 | - unnecessary_await_in_return 16 | -------------------------------------------------------------------------------- /pkgs/path/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: path 2 | version: 1.9.2-wip 3 | description: A string-based path manipulation library. 4 | repository: https://github.com/dart-lang/core/tree/main/pkgs/path 5 | issue_tracker: https://github.com/dart-lang/core/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Apath 6 | 7 | topics: 8 | - file-system 9 | 10 | environment: 11 | sdk: ^3.4.0 12 | 13 | dev_dependencies: 14 | dart_flutter_team_lints: ^3.0.0 15 | test: ^1.16.6 16 | web: ^1.0.0 17 | -------------------------------------------------------------------------------- /.github/workflows/health.yaml: -------------------------------------------------------------------------------- 1 | name: Health 2 | on: 3 | pull_request: 4 | branches: [ main ] 5 | types: [opened, synchronize, reopened, labeled, unlabeled] 6 | 7 | jobs: 8 | health: 9 | uses: dart-lang/ecosystem/.github/workflows/health.yaml@main 10 | with: 11 | ignore_coverage: "**.mock.dart,**.g.dart" 12 | ignore_license: "**.mock.dart,**.g.dart,**.mocks.dart,pkgs/platform/*" 13 | sdk: beta 14 | permissions: 15 | pull-requests: write 16 | -------------------------------------------------------------------------------- /pkgs/args/example/arg_parser/pubspec.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file 2 | # for details. All rights reserved. Use of this source code is governed by a 3 | # BSD-style license that can be found in the LICENSE file. 4 | 5 | name: arg_parser_example 6 | version: 1.0.0 7 | description: An example of using ArgParser 8 | publish_to: 'none' 9 | 10 | environment: 11 | sdk: ^3.0.0 12 | 13 | dependencies: 14 | args: 15 | path: ../.. 16 | -------------------------------------------------------------------------------- /pkgs/os_detect/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 2.0.4-wip 2 | 3 | - Run `dart format` with the new style. 4 | 5 | ## 2.0.3 6 | 7 | - Move to `package:web`. 8 | - Require Dart 3.5 9 | 10 | ## 2.0.2 11 | 12 | - Require Dart 3.0 13 | - Make work with VM's platform-constants. 14 | - Move to `dart-lang/core` monorepo. 15 | 16 | ## 2.0.1 17 | 18 | - Populate the pubspec `repository` field. 19 | 20 | ## 2.0.0 21 | 22 | - Stable null safety release. 23 | 24 | ## 1.0.0 25 | 26 | - Initial release 27 | -------------------------------------------------------------------------------- /pkgs/args/example/command_runner/pubspec.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file 2 | # for details. All rights reserved. Use of this source code is governed by a 3 | # BSD-style license that can be found in the LICENSE file. 4 | 5 | name: command_runner_example 6 | version: 1.0.0 7 | description: An example of using CommandRunner 8 | publish_to: 'none' 9 | 10 | environment: 11 | sdk: ^3.0.0 12 | 13 | dependencies: 14 | args: 15 | path: ../.. 16 | -------------------------------------------------------------------------------- /pkgs/collection/lib/algorithms.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | /// Import `collection.dart` instead. 6 | @Deprecated('Will be removed in collection 2.0.0.') 7 | library; 8 | 9 | export 'src/algorithms.dart' 10 | show binarySearch, insertionSort, lowerBound, mergeSort, reverse, shuffle; 11 | -------------------------------------------------------------------------------- /pkgs/collection/lib/wrappers.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | /// Import `collection.dart` instead. 6 | @Deprecated('Will be removed in collection 2.0.0.') 7 | library; 8 | 9 | export 'src/canonicalized_map.dart'; 10 | export 'src/unmodifiable_wrappers.dart'; 11 | export 'src/wrappers.dart'; 12 | -------------------------------------------------------------------------------- /pkgs/os_detect/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: os_detect 2 | version: 2.0.4-wip 3 | description: Platform independent OS detection. 4 | repository: https://github.com/dart-lang/core/tree/main/pkgs/os_detect 5 | issue_tracker: https://github.com/dart-lang/core/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aos_detect 6 | 7 | environment: 8 | sdk: ^3.5.0 9 | 10 | dependencies: 11 | meta: ^1.9.0 12 | web: ^1.0.0 13 | 14 | dev_dependencies: 15 | dart_flutter_team_lints: ^3.0.0 16 | test: ^1.24.0 17 | -------------------------------------------------------------------------------- /pkgs/args/lib/src/usage_exception.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | class UsageException implements Exception { 6 | final String message; 7 | final String usage; 8 | 9 | UsageException(this.message, this.usage); 10 | 11 | @override 12 | String toString() => '$message\n\n$usage'; 13 | } 14 | -------------------------------------------------------------------------------- /pkgs/fixnum/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: fixnum 2 | version: 1.2.0-wip 3 | description: >- 4 | Library for 32- and 64-bit signed fixed-width integers with consistent 5 | behavior between native and JS runtimes. 6 | repository: https://github.com/dart-lang/core/tree/main/pkgs/fixnum 7 | issue_tracker: https://github.com/dart-lang/core/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Afixnum 8 | 9 | environment: 10 | sdk: ^3.4.0 11 | 12 | dev_dependencies: 13 | dart_flutter_team_lints: ^3.0.0 14 | test: ^1.16.6 15 | -------------------------------------------------------------------------------- /.github/workflows/publish.yaml: -------------------------------------------------------------------------------- 1 | # A CI configuration to auto-publish pub packages. 2 | 3 | name: Publish 4 | 5 | on: 6 | pull_request: 7 | branches: [ main ] 8 | push: 9 | tags: [ '[A-z]+-v[0-9]+.[0-9]+.[0-9]+' ] 10 | 11 | jobs: 12 | publish: 13 | if: ${{ github.repository_owner == 'dart-lang' }} 14 | uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main 15 | with: 16 | sdk: beta 17 | write-comments: false 18 | permissions: 19 | id-token: write 20 | pull-requests: write 21 | -------------------------------------------------------------------------------- /pkgs/characters/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: characters 2 | version: 1.4.1 3 | description: >- 4 | String replacement with operations that are Unicode/grapheme cluster aware. 5 | repository: https://github.com/dart-lang/core/tree/main/pkgs/characters 6 | issue_tracker: https://github.com/dart-lang/core/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Acharacters 7 | 8 | topics: 9 | - strings 10 | - unicode 11 | 12 | environment: 13 | sdk: ^3.4.0 14 | 15 | dev_dependencies: 16 | dart_flutter_team_lints: ^3.1.0 17 | test: ^1.16.0 18 | -------------------------------------------------------------------------------- /pkgs/platform/README.md: -------------------------------------------------------------------------------- 1 | [![Pub](https://img.shields.io/pub/v/platform.svg)](https://pub.dartlang.org/packages/platform) 2 | 3 | A generic platform abstraction for Dart. 4 | 5 | Like `dart:io`, `package:platform` supplies a rich, Dart-idiomatic API for 6 | accessing platform-specific information. 7 | 8 | `package:platform` provides a lightweight wrapper around the static `Platform` 9 | properties that exist in `dart:io`. However, it uses instance properties rather 10 | than static properties, making it possible to mock out in tests. 11 | -------------------------------------------------------------------------------- /pkgs/fixnum/lib/src/int64.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | // `dart:html` is only available on dart2js (dart2wasm won't support it), so we 6 | // can check availability of it to test whether we're compiling to JS. Other 7 | // targets (AOT, JIT, Wasm) support 64-bit `int`s. 8 | export 'int64_native.dart' if (dart.library.html) 'int64_emulated.dart'; 9 | -------------------------------------------------------------------------------- /pkgs/args/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: args 2 | version: 2.8.0 3 | description: >- 4 | Library for defining parsers for parsing raw command-line arguments into a set 5 | of options and values using GNU and POSIX style options. 6 | repository: https://github.com/dart-lang/core/tree/main/pkgs/args 7 | issue_tracker: https://github.com/dart-lang/core/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aargs 8 | 9 | topics: 10 | - cli 11 | 12 | environment: 13 | sdk: ^3.3.0 14 | 15 | dev_dependencies: 16 | dart_flutter_team_lints: ^3.0.0 17 | test: ^1.16.6 18 | -------------------------------------------------------------------------------- /.github/workflows/post_summaries.yaml: -------------------------------------------------------------------------------- 1 | name: Comment on the pull request 2 | 3 | on: 4 | # Trigger this workflow after the Health workflow completes. This workflow will have permissions to 5 | # do things like create comments on the PR, even if the original workflow couldn't. 6 | workflow_run: 7 | workflows: 8 | - Publish 9 | - Health 10 | types: 11 | - completed 12 | 13 | jobs: 14 | upload: 15 | uses: dart-lang/ecosystem/.github/workflows/post_summaries.yaml@main 16 | permissions: 17 | pull-requests: write 18 | -------------------------------------------------------------------------------- /pkgs/convert/lib/convert.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | export 'src/accumulator_sink.dart'; 6 | export 'src/byte_accumulator_sink.dart'; 7 | export 'src/codepage.dart'; 8 | export 'src/fixed_datetime_formatter.dart'; 9 | export 'src/hex.dart'; 10 | export 'src/identity_codec.dart'; 11 | export 'src/percent.dart'; 12 | export 'src/string_accumulator_sink.dart'; 13 | -------------------------------------------------------------------------------- /pkgs/os_detect/lib/src/osid_html.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:web/web.dart'; 6 | 7 | import 'os_kind.dart' show BrowserOS; 8 | import 'os_override.dart'; 9 | 10 | String get _osVersion => window.navigator.appVersion; 11 | 12 | final OperatingSystem platformOS = OperatingSystemInternal( 13 | const BrowserOS(), 14 | _osVersion, 15 | ); 16 | -------------------------------------------------------------------------------- /pkgs/path/lib/src/path_exception.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | /// An exception class that's thrown when a path operation is unable to be 6 | /// computed accurately. 7 | class PathException implements Exception { 8 | String message; 9 | 10 | PathException(this.message); 11 | 12 | @override 13 | String toString() => 'PathException: $message'; 14 | } 15 | -------------------------------------------------------------------------------- /pkgs/path/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:dart_flutter_team_lints/analysis_options.yaml 2 | 3 | linter: 4 | rules: 5 | - avoid_private_typedef_functions 6 | - avoid_unused_constructor_parameters 7 | - avoid_void_async 8 | - cancel_subscriptions 9 | - join_return_with_assignment 10 | - missing_whitespace_between_adjacent_strings 11 | - no_runtimeType_toString 12 | - prefer_const_declarations 13 | - prefer_expression_function_bodies 14 | - prefer_final_locals 15 | - unnecessary_breaks 16 | - use_string_buffers 17 | -------------------------------------------------------------------------------- /pkgs/crypto/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: crypto 2 | version: 3.0.7 3 | description: Implementations of SHA, MD5, and HMAC cryptographic functions. 4 | repository: https://github.com/dart-lang/core/tree/main/pkgs/crypto 5 | issue_tracker: https://github.com/dart-lang/core/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Acrypto 6 | 7 | topics: 8 | - crypto 9 | - cryptography 10 | 11 | environment: 12 | sdk: ^3.4.0 13 | 14 | dependencies: 15 | typed_data: ^1.3.0 16 | 17 | dev_dependencies: 18 | convert: ^3.0.0 19 | dart_flutter_team_lints: ^3.0.0 20 | test: ^1.16.6 21 | -------------------------------------------------------------------------------- /pkgs/fixnum/lib/fixnum.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | /// Signed 32- and 64-bit integer support. 6 | /// 7 | /// The integer implementations in this library are designed to work identically 8 | /// whether executed on the Dart VM or compiled to JavaScript or Wasm. 9 | library; 10 | 11 | export 'src/int32.dart'; 12 | export 'src/int64.dart'; 13 | export 'src/intx.dart'; 14 | -------------------------------------------------------------------------------- /pkgs/typed_data/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: typed_data 2 | version: 1.4.1-wip 3 | description: >- 4 | Utility functions and classes related to the dart:typed_data library. 5 | repository: https://github.com/dart-lang/core/tree/main/pkgs/typed_data 6 | issue_tracker: https://github.com/dart-lang/core/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Atyped_data 7 | 8 | topics: 9 | - data-structures 10 | 11 | environment: 12 | sdk: ^3.5.0 13 | 14 | dependencies: 15 | collection: ^1.15.0 16 | 17 | dev_dependencies: 18 | dart_flutter_team_lints: ^3.0.0 19 | test: ^1.16.6 20 | -------------------------------------------------------------------------------- /pkgs/platform/test/platform.json: -------------------------------------------------------------------------------- 1 | { 2 | "numberOfProcessors": 8, 3 | "pathSeparator": "/", 4 | "operatingSystem": "macos", 5 | "operatingSystemVersion": "10.14.5", 6 | "localHostname": "platform.test.org", 7 | "environment": { 8 | "PATH": "/bin", 9 | "PWD": "/platform" 10 | }, 11 | "executable": "/bin/dart", 12 | "resolvedExecutable": "/bin/dart", 13 | "script": "file:///platform/test/fake_platform_test.dart", 14 | "executableArguments": [ 15 | "--checked" 16 | ], 17 | "packageConfig": null, 18 | "version": "1.22.0", 19 | "localeName": "de/de" 20 | } -------------------------------------------------------------------------------- /pkgs/async/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: async 2 | version: 2.13.1-wip 3 | description: Utility functions and classes related to the 'dart:async' library. 4 | repository: https://github.com/dart-lang/core/tree/main/pkgs/async 5 | issue_tracker: https://github.com/dart-lang/core/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aasync 6 | 7 | topics: 8 | - async 9 | 10 | environment: 11 | sdk: ^3.4.0 12 | 13 | dependencies: 14 | collection: ^1.15.0 15 | meta: ^1.3.0 16 | 17 | dev_dependencies: 18 | dart_flutter_team_lints: ^3.0.0 19 | fake_async: ^1.2.0 20 | stack_trace: ^1.10.0 21 | test: ^1.16.6 22 | -------------------------------------------------------------------------------- /pkgs/convert/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: convert 2 | version: 3.1.3-wip 3 | description: >- 4 | Utilities for converting between data representations. 5 | Provides a number of Sink, Codec, Decoder, and Encoder types. 6 | repository: https://github.com/dart-lang/core/tree/main/pkgs/convert 7 | issue_tracker: https://github.com/dart-lang/core/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aconvert 8 | 9 | environment: 10 | sdk: ^3.4.0 11 | 12 | dependencies: 13 | typed_data: ^1.3.0 14 | 15 | dev_dependencies: 16 | benchmark_harness: ^2.2.0 17 | dart_flutter_team_lints: ^3.0.0 18 | test: ^1.17.0 19 | -------------------------------------------------------------------------------- /pkgs/logging/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: logging 2 | version: 1.3.1-wip 3 | description: >- 4 | Provides APIs for debugging and error logging, similar to loggers in other 5 | languages, such as the Closure JS Logger and java.util.logging.Logger. 6 | repository: https://github.com/dart-lang/core/tree/main/pkgs/logging 7 | issue_tracker: https://github.com/dart-lang/core/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Alogging 8 | 9 | topics: 10 | - debugging 11 | - logging 12 | 13 | environment: 14 | sdk: ^3.4.0 15 | 16 | dev_dependencies: 17 | dart_flutter_team_lints: ^3.0.0 18 | test: ^1.16.6 19 | -------------------------------------------------------------------------------- /pkgs/path/example/example.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:path/path.dart' as p; 6 | 7 | void main() { 8 | print('Current path style: ${p.style}'); 9 | 10 | print('Current process path: ${p.current}'); 11 | 12 | print('Separators'); 13 | for (var entry in [p.posix, p.windows, p.url]) { 14 | print(' ${entry.style.toString().padRight(7)}: ${entry.separator}'); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /pkgs/collection/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: collection 2 | version: 1.20.0-wip 3 | description: >- 4 | Collections and utilities functions and classes related to collections. 5 | repository: https://github.com/dart-lang/core/tree/main/pkgs/collection 6 | issue_tracker: https://github.com/dart-lang/core/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Acollection 7 | 8 | topics: 9 | - collections 10 | - data-structures 11 | 12 | environment: 13 | sdk: ^3.4.0 14 | 15 | dependencies: 16 | meta: ^1.16.0 17 | 18 | dev_dependencies: 19 | benchmark_harness: ^2.3.1 20 | dart_flutter_team_lints: ^3.0.0 21 | test: ^1.16.6 22 | -------------------------------------------------------------------------------- /pkgs/characters/tool/README.txt: -------------------------------------------------------------------------------- 1 | To re-generate generated files run: 2 | ``` 3 | dart tool/generate.dart 4 | ``` 5 | 6 | To update to new data files, update the paths in `tool/src/data_files` 7 | if necessary, and run `dart tool.generate.dart -u -o`. 8 | The `-u` means read new files from `https://unicode.org/Public`, 9 | and `-o` means try to optimize table chunk sizes, 10 | which is most important when using new data files. 11 | 12 | When using `-u`, the update stops if the license file has changed. 13 | Check the differences, and decide whether to proceed, and if so 14 | run again adding the `--accept-license` command line argument. 15 | 16 | -------------------------------------------------------------------------------- /pkgs/fixnum/README.md: -------------------------------------------------------------------------------- 1 | [![Dart CI](https://github.com/dart-lang/core/actions/workflows/fixnum.yaml/badge.svg)](https://github.com/dart-lang/core/actions/workflows/fixnum.yaml) 2 | [![Pub](https://img.shields.io/pub/v/fixnum.svg)](https://pub.dev/packages/fixnum) 3 | [![package publisher](https://img.shields.io/pub/publisher/fixnum.svg)](https://pub.dev/packages/fixnum/publisher) 4 | 5 | A fixed-width 32- and 64- bit integer library for Dart. 6 | 7 | Provides data types for signed 32- and 64-bit integers. 8 | The integer implementations in this library are designed to work identically 9 | whether executed on the Dart VM or compiled to JavaScript. 10 | -------------------------------------------------------------------------------- /pkgs/fixnum/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:dart_flutter_team_lints/analysis_options.yaml 2 | 3 | analyzer: 4 | language: 5 | strict-casts: true 6 | 7 | linter: 8 | rules: 9 | - avoid_private_typedef_functions 10 | - avoid_unused_constructor_parameters 11 | - cancel_subscriptions 12 | - cascade_invocations 13 | - join_return_with_assignment 14 | - missing_whitespace_between_adjacent_strings 15 | - no_adjacent_strings_in_list 16 | - no_runtimeType_toString 17 | - prefer_const_declarations 18 | - prefer_expression_function_bodies 19 | - unnecessary_raw_strings 20 | - use_string_buffers 21 | -------------------------------------------------------------------------------- /pkgs/lints/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: lints 2 | version: 6.1.0-wip 3 | description: > 4 | Official Dart lint rules. Defines the 'core' and 'recommended' set of lints 5 | suggested by the Dart team. 6 | repository: https://github.com/dart-lang/core/tree/main/pkgs/lints 7 | issue_tracker: https://github.com/dart-lang/core/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Alints 8 | 9 | topics: 10 | - analysis 11 | - lints 12 | 13 | environment: 14 | sdk: ^3.8.0 15 | 16 | # NOTE: Code is not allowed in this package - do not add dependencies. 17 | # dependencies: 18 | 19 | dev_dependencies: 20 | http: ^1.0.0 21 | path: ^1.8.0 22 | yaml: ^3.1.0 23 | -------------------------------------------------------------------------------- /pkgs/crypto/tool/md5sum.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:io'; 6 | 7 | import 'package:crypto/crypto.dart'; 8 | 9 | void main(List args) { 10 | for (var arg in args) { 11 | var data = File(arg).readAsBytesSync(); 12 | var stopwatch = Stopwatch()..start(); 13 | var hash = md5.convert(data); 14 | stopwatch.stop(); 15 | print('Hashed to ${hash.toString()} in ' 16 | '${stopwatch.elapsedMilliseconds} ms'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /pkgs/typed_data/test/typed_buffers_vm_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | @TestOn('vm') 6 | library; 7 | 8 | import 'package:test/test.dart'; 9 | 10 | import 'typed_buffers_test.dart'; 11 | 12 | void main() { 13 | var browserUnsafe = [ 14 | 0x0ffffffffffffffff, 15 | 0xaaaaaaaaaaaaaaaa, 16 | 0x8000000000000001, 17 | 0x7fffffffffffffff, 18 | 0x5555555555555555, 19 | ]; 20 | initTests([...browserSafeIntSamples, ...browserUnsafe]); 21 | } 22 | -------------------------------------------------------------------------------- /.gemini/config.yaml: -------------------------------------------------------------------------------- 1 | # A configuration files for the Gemini Code Assist bot. 2 | # 3 | # https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github. 4 | 5 | # No poems please. 6 | have_fun: false 7 | 8 | code_review: 9 | # Options here are LOW, MEDIUM, HIGH, and CRITICAL. The default is MEDIUM. 10 | comment_severity_threshold: MEDIUM 11 | 12 | # Configure the behavior for PR opened events. 13 | pull_request_opened: 14 | # Keep the default of no help message comments when pull requests are opened. 15 | help: false 16 | # This is noisy; disable. 17 | summary: false 18 | # Keep this on for now. 19 | code_review: true 20 | -------------------------------------------------------------------------------- /pkgs/lints/tool/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## `tool/validate_lib.dart` 3 | 4 | This tool ensures that we don't commit `.dart` source files into the `lib/` 5 | directory; it's automatically run by the CI. To run manually: 6 | 7 | ```shell 8 | dart run tool/validate_lib.dart 9 | ``` 10 | 11 | ## `tool/gen_docs.dart` 12 | 13 | This tool regenerates the lists of core and recommended lints into the package's 14 | `README.md` file. To use it, run: 15 | 16 | ```shell 17 | dart run tool/gen_docs.dart 18 | ``` 19 | 20 | It can also validate that the readme file is up-to-date. It's automatically 21 | run by the CI; to run it manually: 22 | 23 | ```shell 24 | dart run tool/gen_docs.dart --verify 25 | ``` 26 | -------------------------------------------------------------------------------- /.gemini/styleguide.md: -------------------------------------------------------------------------------- 1 | # The dart-lang Dart style guide 2 | 3 | ## Introduction 4 | 5 | This style guide outlines the coding conventions for Dart code contributed to 6 | dart-lang repositories. All Dart code should follow the Effective Dart style 7 | guide (https://dart.dev/effective-dart/style). 8 | 9 | ## Contribution Guidelines 10 | 11 | - larger or significant changes should be discussed in an issue before creating 12 | a PR 13 | - contributions to our repos should follow the Dart style guide and use 'dart 14 | format' 15 | - most changes should add an entry to the changelog and may need to rev the 16 | pubspec package version 17 | - changes to packages require corresponding tests 18 | -------------------------------------------------------------------------------- /.github/workflows/pull_request_label.yaml: -------------------------------------------------------------------------------- 1 | # This workflow applies labels to pull requests based on the paths that are 2 | # modified in the pull request. 3 | # 4 | # Edit `.github/labeler.yml` to configure labels. For more information, see 5 | # https://github.com/actions/labeler. 6 | 7 | name: Pull Request Labeler 8 | permissions: read-all 9 | 10 | on: 11 | pull_request_target 12 | 13 | jobs: 14 | label: 15 | permissions: 16 | pull-requests: write 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/labeler@634933edcd8ababfe52f92936142cc22ac488b1b 20 | with: 21 | repo-token: "${{ secrets.GITHUB_TOKEN }}" 22 | sync-labels: true 23 | -------------------------------------------------------------------------------- /pkgs/convert/README.md: -------------------------------------------------------------------------------- 1 | [![Dart CI](https://github.com/dart-lang/core/actions/workflows/convert.yaml/badge.svg)](https://github.com/dart-lang/core/actions/workflows/convert.yaml) 2 | [![pub package](https://img.shields.io/pub/v/convert.svg)](https://pub.dev/packages/convert) 3 | [![package publisher](https://img.shields.io/pub/publisher/convert.svg)](https://pub.dev/packages/convert/publisher) 4 | 5 | Contains encoders and decoders for converting between different 6 | data representations. It's the external counterpart of the 7 | [`dart:convert`](https://api.dart.dev/dart-convert/dart-convert-library.html) 8 | SDK library, and contains less-central APIs and APIs that need more flexible 9 | versioning. 10 | -------------------------------------------------------------------------------- /pkgs/async/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # https://dart.dev/tools/analysis#the-analysis-options-file 2 | include: package:dart_flutter_team_lints/analysis_options.yaml 3 | 4 | analyzer: 5 | language: 6 | strict-casts: true 7 | errors: 8 | only_throw_errors: ignore 9 | unawaited_futures: ignore 10 | inference_failure_on_instance_creation: ignore 11 | inference_failure_on_function_invocation: ignore 12 | inference_failure_on_collection_literal: ignore 13 | 14 | linter: 15 | rules: 16 | - avoid_unused_constructor_parameters 17 | - literal_only_boolean_expressions 18 | - missing_whitespace_between_adjacent_strings 19 | - no_adjacent_strings_in_list 20 | - no_runtimeType_toString 21 | -------------------------------------------------------------------------------- /pkgs/platform/example/bin/example.dart: -------------------------------------------------------------------------------- 1 | import 'package:platform/platform.dart'; 2 | 3 | void main(List arguments) { 4 | const LocalPlatform platform = LocalPlatform(); 5 | 6 | print('Operating System: ${platform.operatingSystem}.'); 7 | print('Local Hostname: ${platform.localHostname}.'); 8 | print('Number of Processors: ${platform.numberOfProcessors}.'); 9 | print('Path Separator: ${platform.pathSeparator}.'); 10 | print('Locale Name: ${platform.localeName}.'); 11 | print('Stdin Supports ANSI: ${platform.stdinSupportsAnsi}.'); 12 | print('Stdout Supports ANSI: ${platform.stdoutSupportsAnsi}.'); 13 | print('Executable Arguments: ${platform.executableArguments}.'); 14 | print('Dart Version: ${platform.version}.'); 15 | } 16 | -------------------------------------------------------------------------------- /pkgs/path/lib/src/characters.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | // Character-code constants. 6 | 7 | const hash = 0x23; 8 | const percent = 0x25; 9 | const plus = 0x2b; 10 | const minus = 0x2d; 11 | const period = 0x2e; 12 | const slash = 0x2f; 13 | const zero = 0x30; 14 | const nine = 0x39; 15 | const colon = 0x3a; 16 | const question = 0x3f; 17 | const upperA = 0x41; 18 | const upperZ = 0x5a; 19 | const lowerA = 0x61; 20 | const lowerE = 0x65; 21 | const lowerF = 0x66; 22 | const lowerI = 0x69; 23 | const lowerL = 0x6c; 24 | const lowerZ = 0x7a; 25 | const backslash = 0x5c; 26 | -------------------------------------------------------------------------------- /pkgs/convert/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # https://dart.dev/guides/language/analysis-options 2 | include: package:dart_flutter_team_lints/analysis_options.yaml 3 | 4 | analyzer: 5 | language: 6 | strict-casts: true 7 | strict-raw-types: true 8 | 9 | linter: 10 | rules: 11 | - avoid_private_typedef_functions 12 | - avoid_redundant_argument_values 13 | - avoid_unused_constructor_parameters 14 | - avoid_void_async 15 | - cancel_subscriptions 16 | - literal_only_boolean_expressions 17 | - missing_whitespace_between_adjacent_strings 18 | - no_adjacent_strings_in_list 19 | - no_runtimeType_toString 20 | - prefer_const_declarations 21 | - prefer_expression_function_bodies 22 | - unnecessary_await_in_return 23 | - use_string_buffers 24 | -------------------------------------------------------------------------------- /pkgs/typed_data/lib/typed_buffers.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | /// Growable typed-data lists. 6 | /// 7 | /// These lists works just as a typed-data list, except that they are growable. 8 | /// They use an underlying buffer, and when that buffer becomes too small, it 9 | /// is replaced by a new buffer. 10 | /// 11 | /// That means that using the `buffer` getter is not guaranteed 12 | /// to return the same result each time it is used, and that the buffer may 13 | /// be larger than what the list is using. 14 | library; 15 | 16 | export 'src/typed_buffer.dart' hide TypedDataBuffer; 17 | -------------------------------------------------------------------------------- /pkgs/convert/example/example.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:convert'; 6 | 7 | import 'package:convert/convert.dart'; 8 | 9 | void main(List args) { 10 | // Creates a Codec that converts a UTF-8 strings to/from percent encoding 11 | final fusedCodec = utf8.fuse(percent); 12 | 13 | final input = args.isNotEmpty ? args.first : 'ABC 123 @!('; 14 | print(input); 15 | final encodedMessage = fusedCodec.encode(input); 16 | print(encodedMessage); 17 | 18 | final decodedMessage = fusedCodec.decode(encodedMessage); 19 | assert(decodedMessage == input); 20 | } 21 | -------------------------------------------------------------------------------- /pkgs/async/lib/src/stream_sink_transformer/typed.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | import '../stream_sink_transformer.dart'; 8 | 9 | /// A wrapper that coerces the generic type of the sink returned by an inner 10 | /// transformer to `S`. 11 | class TypeSafeStreamSinkTransformer 12 | implements StreamSinkTransformer { 13 | final StreamSinkTransformer _inner; 14 | 15 | TypeSafeStreamSinkTransformer(this._inner); 16 | 17 | @override 18 | StreamSink bind(StreamSink sink) => StreamController(sync: true) 19 | ..stream.cast().pipe(_inner.bind(sink)); 20 | } 21 | -------------------------------------------------------------------------------- /pkgs/os_detect/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # https://dart.dev/tools/analysis#the-analysis-options-file 2 | include: package:dart_flutter_team_lints/analysis_options.yaml 3 | 4 | analyzer: 5 | language: 6 | strict-casts: true 7 | strict-inference: true 8 | strict-raw-types: true 9 | 10 | linter: 11 | rules: 12 | - avoid_bool_literals_in_conditional_expressions 13 | - avoid_classes_with_only_static_members 14 | - avoid_private_typedef_functions 15 | - avoid_redundant_argument_values 16 | - avoid_returning_this 17 | - avoid_unused_constructor_parameters 18 | - avoid_void_async 19 | - literal_only_boolean_expressions 20 | - missing_whitespace_between_adjacent_strings 21 | - no_adjacent_strings_in_list 22 | - no_runtimeType_toString 23 | - prefer_const_declarations 24 | - use_raw_strings 25 | 26 | 27 | -------------------------------------------------------------------------------- /pkgs/async/test/io_sink_impl.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | @Deprecated('Tests deprecated functionality') 6 | library; 7 | 8 | import 'dart:io'; 9 | 10 | import 'package:async/async.dart'; 11 | 12 | /// This class isn't used, it's just used to verify that [IOSinkBase] produces a 13 | /// valid implementation of [IOSink]. 14 | class IOSinkImpl extends IOSinkBase implements IOSink { 15 | @override 16 | void onAdd(List data) {} 17 | 18 | @override 19 | void onError(Object error, [StackTrace? stackTrace]) {} 20 | 21 | @override 22 | void onClose() {} 23 | 24 | @override 25 | Future onFlush() => Future.value(); 26 | } 27 | -------------------------------------------------------------------------------- /pkgs/async/lib/src/result/capture_sink.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | import 'result.dart'; 8 | 9 | /// Used by [Result.captureSink]. 10 | class CaptureSink implements EventSink { 11 | final EventSink> _sink; 12 | 13 | CaptureSink(EventSink> sink) : _sink = sink; 14 | 15 | @override 16 | void add(T value) { 17 | _sink.add(Result.value(value)); 18 | } 19 | 20 | @override 21 | void addError(Object error, [StackTrace? stackTrace]) { 22 | _sink.add(Result.error(error, stackTrace)); 23 | } 24 | 25 | @override 26 | void close() { 27 | _sink.close(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /pkgs/crypto/lib/src/utils.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | /// A bitmask that limits an integer to 32 bits. 6 | const mask32 = 0xFFFFFFFF; 7 | 8 | /// The number of bits in a byte. 9 | const bitsPerByte = 8; 10 | 11 | /// The number of bytes in a 32-bit word. 12 | const bytesPerWord = 4; 13 | 14 | /// Adds [x] and [y] with 32-bit overflow semantics. 15 | int add32(int x, int y) => (x + y) & mask32; 16 | 17 | /// Bitwise rotates [val] to the left by [shift], obeying 32-bit overflow 18 | /// semantics. 19 | int rotl32(int val, int shift) { 20 | var modShift = shift & 31; 21 | return ((val << modShift) & mask32) | ((val & mask32) >> (32 - modShift)); 22 | } 23 | -------------------------------------------------------------------------------- /pkgs/async/lib/src/result/capture_transformer.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | import 'capture_sink.dart'; 8 | import 'result.dart'; 9 | 10 | /// A stream transformer that captures a stream of events into [Result]s. 11 | /// 12 | /// The result of the transformation is a stream of [Result] values and no 13 | /// error events. Exposed by [Result.captureStream]. 14 | class CaptureStreamTransformer extends StreamTransformerBase> { 15 | const CaptureStreamTransformer(); 16 | 17 | @override 18 | Stream> bind(Stream source) => 19 | Stream>.eventTransformed(source, CaptureSink.new); 20 | } 21 | -------------------------------------------------------------------------------- /pkgs/convert/lib/src/charcodes.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | /// Character `%`. 6 | const int $percent = 0x25; 7 | 8 | /// Character `-`. 9 | const int $dash = 0x2d; 10 | 11 | /// Character `.`. 12 | const int $dot = 0x2e; 13 | 14 | /// Character `0`. 15 | const int $0 = 0x30; 16 | 17 | /// Character `9`. 18 | const int $9 = 0x39; 19 | 20 | /// Character `A`. 21 | const int $A = 0x41; 22 | 23 | /// Character `_`. 24 | const int $underscore = 0x5f; 25 | 26 | /// Character `a`. 27 | const int $a = 0x61; 28 | 29 | /// Character `f`. 30 | const int $f = 0x66; 31 | 32 | /// Character `z`. 33 | const int $z = 0x7a; 34 | 35 | /// Character `~`. 36 | const int $tilde = 0x7e; 37 | -------------------------------------------------------------------------------- /pkgs/lints/tool/validate_lib.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:io'; 6 | 7 | import 'package:path/path.dart' as p; 8 | 9 | void main(List args) { 10 | print('Validating that there are no .dart source files in lib/ ...'); 11 | 12 | final dartSourceFiles = Directory('lib') 13 | .listSync(recursive: true) 14 | .whereType() 15 | .where((file) => p.extension(file.path) == '.dart') 16 | .toList(); 17 | 18 | if (dartSourceFiles.isEmpty) { 19 | print('No Dart files found.'); 20 | } else { 21 | for (var file in dartSourceFiles) { 22 | print(' error: found ${file.path}'); 23 | } 24 | exit(1); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /pkgs/async/lib/src/result/release_transformer.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | import 'release_sink.dart'; 8 | import 'result.dart'; 9 | 10 | /// A transformer that releases result events as data and error events. 11 | class ReleaseStreamTransformer extends StreamTransformerBase, T> { 12 | const ReleaseStreamTransformer(); 13 | 14 | @override 15 | Stream bind(Stream> source) { 16 | return Stream.eventTransformed(source, _createSink); 17 | } 18 | 19 | // Since Stream.eventTransformed is not generic, this method can be static. 20 | static EventSink _createSink(EventSink sink) => ReleaseSink(sink); 21 | } 22 | -------------------------------------------------------------------------------- /pkgs/convert/benchmark/fixed_datetime_formatter_benchmark.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:benchmark_harness/benchmark_harness.dart'; 6 | import 'package:convert/convert.dart'; 7 | 8 | /// Test the performance of [FixedDateTimeFormatter.decode]. 9 | class DecodeBenchmark extends BenchmarkBase { 10 | final fixedDateTimeFormatter = FixedDateTimeFormatter('YYYYMMDDhhmmss'); 11 | DecodeBenchmark() : super('Parse 10k strings to DateTime'); 12 | 13 | @override 14 | void run() { 15 | for (var i = 0; i < 10000; i++) { 16 | fixedDateTimeFormatter.decode('19960425050322'); 17 | } 18 | } 19 | } 20 | 21 | void main() { 22 | DecodeBenchmark().report(); 23 | } 24 | -------------------------------------------------------------------------------- /pkgs/async/lib/src/result/release_sink.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | import 'result.dart'; 8 | 9 | /// Used by [Result.releaseSink]. 10 | class ReleaseSink implements EventSink> { 11 | final EventSink _sink; 12 | 13 | ReleaseSink(this._sink); 14 | 15 | @override 16 | void add(Result result) { 17 | result.addTo(_sink); 18 | } 19 | 20 | @override 21 | void addError(Object error, [StackTrace? stackTrace]) { 22 | // Errors may be added by intermediate processing, even if it is never 23 | // added by CaptureSink. 24 | _sink.addError(error, stackTrace); 25 | } 26 | 27 | @override 28 | void close() { 29 | _sink.close(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /pkgs/args/lib/src/arg_parser_exception.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | /// An exception thrown by `ArgParser`. 6 | class ArgParserException extends FormatException { 7 | /// The command(s) that were parsed before discovering the error. 8 | /// 9 | /// This will be empty if the error was on the root parser. 10 | final List commands; 11 | 12 | /// The name of the argument that was being parsed when the error was 13 | /// discovered. 14 | final String? argumentName; 15 | 16 | ArgParserException(super.message, 17 | [Iterable? commands, 18 | this.argumentName, 19 | super.source, 20 | super.offset]) 21 | : commands = commands == null ? const [] : List.unmodifiable(commands); 22 | } 23 | -------------------------------------------------------------------------------- /pkgs/os_detect/example/tree_shaking.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | // Try compiling this example with (if on Linux): 6 | // 7 | // dart compile exe --target-os=linux tree_shaking.dart 8 | // 9 | // then check that "SOMETHING ELSE" does not occur in the 10 | // output `tree_shaking.exe` program, e.g.: 11 | // 12 | // strings tree_shaking.exe | grep SOMETHING 13 | // 14 | // which shows no matches. 15 | 16 | import 'package:os_detect/os_detect.dart' as platform; 17 | 18 | void main() { 19 | if (platform.isLinux) { 20 | print('Is Linux'); 21 | } else { 22 | print('SOMETHING ELSE'); 23 | } 24 | if (platform.operatingSystem == 'linux') { 25 | print('Is Linux'); 26 | } else { 27 | print('SOMETHING ELSE'); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /pkgs/crypto/test/utils.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:typed_data'; 6 | 7 | import 'package:crypto/crypto.dart'; 8 | import 'package:test/test.dart'; 9 | 10 | /// Asserts that an HMAC using [hash] returns [mac] for [input] and [key]. 11 | void expectHmacEquals(Hash hash, List input, List key, String mac) { 12 | var hmac = Hmac(hash, key); 13 | expect(hmac.convert(input).toString(), startsWith(mac)); 14 | } 15 | 16 | final toupleMatch = RegExp('([0-9a-fA-F]{2})'); 17 | 18 | Uint8List bytesFromHexString(String message) { 19 | var bytes = []; 20 | for (var match in toupleMatch.allMatches(message)) { 21 | bytes.add(int.parse(match.group(0)!, radix: 16)); 22 | } 23 | return Uint8List.fromList(bytes); 24 | } 25 | -------------------------------------------------------------------------------- /pkgs/convert/lib/src/hex.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:convert'; 6 | 7 | import 'hex/decoder.dart'; 8 | import 'hex/encoder.dart'; 9 | 10 | export 'hex/decoder.dart' hide hexDecoder; 11 | export 'hex/encoder.dart' hide hexEncoder; 12 | 13 | /// The canonical instance of [HexCodec]. 14 | const hex = HexCodec._(); 15 | 16 | /// A codec that converts byte arrays to and from hexadecimal strings, following 17 | /// [the Base16 spec](https://tools.ietf.org/html/rfc4648#section-8). 18 | /// 19 | /// This should be used via the [hex] field. 20 | class HexCodec extends Codec, String> { 21 | @override 22 | HexEncoder get encoder => hexEncoder; 23 | @override 24 | HexDecoder get decoder => hexDecoder; 25 | 26 | const HexCodec._(); 27 | } 28 | -------------------------------------------------------------------------------- /pkgs/typed_data/README.md: -------------------------------------------------------------------------------- 1 | [![Dart CI](https://github.com/dart-lang/core/actions/workflows/typed_data.yaml/badge.svg)](https://github.com/dart-lang/core/actions/workflows/typed_data.yaml) 2 | [![pub package](https://img.shields.io/pub/v/typed_data.svg)](https://pub.dev/packages/typed_data) 3 | [![package publisher](https://img.shields.io/pub/publisher/typed_data.svg)](https://pub.dev/packages/typed_data/publisher) 4 | 5 | Helper libraries for working with typed data lists. 6 | 7 | The `typed_data` package contains utility functions and classes that makes working with typed data lists easier. 8 | 9 | ## Using 10 | 11 | The `typed_data` package can be imported using: 12 | 13 | ```dart 14 | import 'package:typed_data/typed_data.dart'; 15 | ``` 16 | 17 | ## Typed buffers 18 | 19 | Typed buffers are growable lists backed by typed arrays. These are similar to 20 | the growable lists created by `[]` or `[]`, but store typed data 21 | like a typed data list. 22 | -------------------------------------------------------------------------------- /pkgs/convert/test/identity_codec_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:convert'; 6 | import 'package:convert/convert.dart'; 7 | import 'package:test/test.dart'; 8 | 9 | void main() { 10 | group('IdentityCodec', () { 11 | test('encode', () { 12 | const codec = IdentityCodec(); 13 | expect(codec.encode('hello-world'), equals('hello-world')); 14 | }); 15 | 16 | test('decode', () { 17 | const codec = IdentityCodec(); 18 | expect(codec.decode('hello-world'), equals('hello-world')); 19 | }); 20 | 21 | test('fuse', () { 22 | const stringCodec = IdentityCodec(); 23 | final utf8Strings = stringCodec.fuse(utf8); 24 | expect(utf8Strings, equals(utf8)); 25 | }); 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /pkgs/async/lib/src/result/future.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import '../delegate/future.dart'; 6 | import 'result.dart'; 7 | 8 | /// A [Future] wrapper that provides synchronous access to the result of the 9 | /// wrapped [Future] once it's completed. 10 | class ResultFuture extends DelegatingFuture { 11 | /// Whether the future has fired and [result] is available. 12 | bool get isComplete => result != null; 13 | 14 | /// The result of the wrapped [Future], if it's completed. 15 | /// 16 | /// If it hasn't completed yet, this will be `null`. 17 | Result? get result => _result; 18 | Result? _result; 19 | 20 | ResultFuture(Future future) : super(future) { 21 | Result.capture(future).then((result) { 22 | _result = result; 23 | }); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /pkgs/collection/lib/src/utils.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | /// A [Comparator] that asserts that its first argument is comparable. 6 | /// 7 | /// The function behaves just like [List.sort]'s 8 | /// default comparison function. It is entirely dynamic in its testing. 9 | /// 10 | /// Should be used when optimistically comparing object that are assumed 11 | /// to be comparable. 12 | /// If the elements are known to be comparable, use [compareComparable]. 13 | int defaultCompare(Object? value1, Object? value2) => 14 | (value1 as Comparable).compareTo(value2); 15 | 16 | /// A reusable identity function at any type. 17 | T identity(T value) => value; 18 | 19 | /// A reusable typed comparable comparator. 20 | int compareComparable>(T a, T b) => a.compareTo(b); 21 | -------------------------------------------------------------------------------- /pkgs/os_detect/example/example.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:os_detect/os_detect.dart' as os_detect; 6 | 7 | void main() { 8 | print(''' 9 | OS ID: ${os_detect.operatingSystem} 10 | OS Version: ${os_detect.operatingSystemVersion}'''); 11 | if (os_detect.isAndroid) { 12 | print(' OS Type: Android'); 13 | } else if (os_detect.isBrowser) { 14 | print(' OS Type: Browser'); 15 | } else if (os_detect.isFuchsia) { 16 | print(' OS Type: Fuchsia'); 17 | } else if (os_detect.isIOS) { 18 | print(' OS Type: iOS'); 19 | } else if (os_detect.isLinux) { 20 | print(' OS Type: Linux'); 21 | } else if (os_detect.isMacOS) { 22 | print(' OS Type: MacOS'); 23 | } else if (os_detect.isWindows) { 24 | print(' OS Type: Windows'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Below are suggested reviewers for PRs to packages in this repository. 2 | # 3 | # These are suggestions; it is fine to have your changes reviewed by someone 4 | # else. 5 | 6 | .github/ @dart-lang/dart-ecosystem-team 7 | .gemini/ @dart-lang/dart-ecosystem-team 8 | README.md @dart-lang/dart-ecosystem-team 9 | pkgs/args @dart-lang/dart-ecosystem-team 10 | pkgs/async @dart-lang/dart-core-packages-team 11 | pkgs/characters @lrhn 12 | pkgs/collection @dart-lang/dart-core-packages-team 13 | pkgs/convert @dart-lang/dart-core-packages-team 14 | pkgs/crypto @dart-lang/dart-ecosystem-team 15 | pkgs/fixnum @dart-lang/dart-core-packages-team 16 | pkgs/lints @dart-lang/dart-ecosystem-team 17 | pkgs/logging @dart-lang/dart-ecosystem-team 18 | pkgs/os_detect @lrhn 19 | pkgs/path @dart-lang/dart-ecosystem-team 20 | pkgs/platform @lrhn 21 | pkgs/typed_data @dart-lang/dart-core-packages-team 22 | -------------------------------------------------------------------------------- /pkgs/crypto/lib/src/digest_sink.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'digest.dart'; 6 | 7 | /// A sink used to get a digest value out of `Hash.startChunkedConversion`. 8 | class DigestSink implements Sink { 9 | /// The value added to the sink. 10 | /// 11 | /// A value must have been added using [add] before reading the `value`. 12 | Digest get value => _value!; 13 | 14 | Digest? _value; 15 | 16 | /// Adds [value] to the sink. 17 | /// 18 | /// Unlike most sinks, this may only be called once. 19 | @override 20 | void add(Digest value) { 21 | if (_value != null) throw StateError('add may only be called once.'); 22 | _value = value; 23 | } 24 | 25 | @override 26 | void close() { 27 | if (_value == null) throw StateError('add must be called once.'); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /pkgs/logging/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # https://dart.dev/guides/language/analysis-options 2 | include: package:dart_flutter_team_lints/analysis_options.yaml 3 | 4 | analyzer: 5 | language: 6 | strict-raw-types: true 7 | 8 | linter: 9 | rules: 10 | - avoid_bool_literals_in_conditional_expressions 11 | - avoid_classes_with_only_static_members 12 | - avoid_private_typedef_functions 13 | - avoid_redundant_argument_values 14 | - avoid_returning_this 15 | - avoid_unused_constructor_parameters 16 | - avoid_void_async 17 | - cancel_subscriptions 18 | - join_return_with_assignment 19 | - literal_only_boolean_expressions 20 | - missing_whitespace_between_adjacent_strings 21 | - no_adjacent_strings_in_list 22 | - no_runtimeType_toString 23 | - prefer_const_declarations 24 | - prefer_expression_function_bodies 25 | - prefer_final_locals 26 | - unnecessary_await_in_return 27 | - unnecessary_raw_strings 28 | - use_if_null_to_convert_nulls_to_bools 29 | - use_raw_strings 30 | - use_string_buffers 31 | -------------------------------------------------------------------------------- /pkgs/async/lib/src/stream_sink_extensions.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | import 'stream_sink_transformer.dart'; 8 | import 'stream_sink_transformer/reject_errors.dart'; 9 | 10 | /// Extensions on [StreamSink] to make stream transformations more fluent. 11 | extension StreamSinkExtensions on StreamSink { 12 | /// Transforms a [StreamSink] using [transformer]. 13 | StreamSink transform(StreamSinkTransformer transformer) => 14 | transformer.bind(this); 15 | 16 | /// Returns a [StreamSink] that forwards to `this` but rejects errors. 17 | /// 18 | /// If an error is passed (either by [addError] or [addStream]), the 19 | /// underlying sink will be closed and the error will be forwarded to the 20 | /// returned sink's [StreamSink.done] future. Further events will be ignored. 21 | StreamSink rejectErrors() => RejectErrorsSink(this); 22 | } 23 | -------------------------------------------------------------------------------- /pkgs/collection/lib/collection.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | export 'src/algorithms.dart' 6 | show binarySearch, insertionSort, lowerBound, mergeSort, reverse, shuffle; 7 | export 'src/boollist.dart'; 8 | export 'src/canonicalized_map.dart'; 9 | export 'src/combined_wrappers/combined_iterable.dart'; 10 | export 'src/combined_wrappers/combined_list.dart'; 11 | export 'src/combined_wrappers/combined_map.dart'; 12 | export 'src/comparators.dart'; 13 | export 'src/equality.dart'; 14 | export 'src/equality_map.dart'; 15 | export 'src/equality_set.dart'; 16 | export 'src/functions.dart'; 17 | export 'src/iterable_extensions.dart'; 18 | export 'src/iterable_zip.dart'; 19 | export 'src/list_extensions.dart'; 20 | export 'src/priority_queue.dart'; 21 | export 'src/queue_list.dart'; 22 | export 'src/union_set.dart'; 23 | export 'src/union_set_controller.dart'; 24 | export 'src/unmodifiable_wrappers.dart'; 25 | export 'src/wrappers.dart'; 26 | -------------------------------------------------------------------------------- /pkgs/characters/example/main.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:characters/characters.dart'; 6 | 7 | // Small API examples. For full API docs see: 8 | // https://pub.dev/documentation/characters/latest/characters/characters-library.html 9 | void main() { 10 | var hi = 'Hi 🇩🇰'; 11 | print('String is "$hi"\n'); 12 | 13 | // Length. 14 | print('String.length: ${hi.length}'); 15 | print('Characters.length: ${hi.characters.length}\n'); 16 | 17 | // Last character. 18 | print('The string ends with: ${hi.substring(hi.length - 1)}'); 19 | print('The last character: ${hi.characters.last}\n'); 20 | 21 | // Skip last character. 22 | print('Substring -1: "${hi.substring(0, hi.length - 1)}"'); 23 | print('Skipping last character: "${hi.characters.skipLast(1)}"\n'); 24 | 25 | // Replace characters. 26 | var newHi = hi.characters.replaceAll('🇩🇰'.characters, '🇺🇸'.characters); 27 | print('Change flag: "$newHi"'); 28 | } 29 | -------------------------------------------------------------------------------- /pkgs/lints/example/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the static analysis results for your project (errors, 2 | # warnings, and lints). 3 | # 4 | # This enables the 'recommended' set of lints from `package:lints`. 5 | # This set helps identify many issues that may lead to problems when running 6 | # or consuming Dart code, and enforces writing Dart using a single, idiomatic 7 | # style and format. 8 | # 9 | # If you want a smaller set of lints you can change this to specify 10 | # 'package:lints/core.yaml'. These are just the most critical lints 11 | # (the recommended set includes the core lints). 12 | # The core lints are also what is used by pub.dev for scoring packages. 13 | 14 | include: package:lints/recommended.yaml 15 | 16 | # Uncomment the following section to specify additional rules. 17 | 18 | # linter: 19 | # rules: 20 | # - camel_case_types 21 | 22 | # analyzer: 23 | # exclude: 24 | # - path/to/excluded/files/** 25 | 26 | # For more information about the core and recommended set of lints, see 27 | # https://dart.dev/go/core-lints 28 | 29 | # For additional information about configuring this file, see 30 | # https://dart.dev/guides/language/analysis-options 31 | -------------------------------------------------------------------------------- /pkgs/platform/example/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the static analysis results for your project (errors, 2 | # warnings, and lints). 3 | # 4 | # This enables the 'recommended' set of lints from `package:lints`. 5 | # This set helps identify many issues that may lead to problems when running 6 | # or consuming Dart code, and enforces writing Dart using a single, idiomatic 7 | # style and format. 8 | # 9 | # If you want a smaller set of lints you can change this to specify 10 | # 'package:lints/core.yaml'. These are just the most critical lints 11 | # (the recommended set includes the core lints). 12 | # The core lints are also what is used by pub.dev for scoring packages. 13 | 14 | include: package:lints/recommended.yaml 15 | 16 | # Uncomment the following section to specify additional rules. 17 | 18 | # linter: 19 | # rules: 20 | # - camel_case_types 21 | 22 | # analyzer: 23 | # exclude: 24 | # - path/to/excluded/files/** 25 | 26 | # For more information about the core and recommended set of lints, see 27 | # https://dart.dev/go/core-lints 28 | 29 | # For additional information about configuring this file, see 30 | # https://dart.dev/guides/language/analysis-options 31 | -------------------------------------------------------------------------------- /pkgs/os_detect/bin/os_detect.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | /// Prints the operating system detected by the current compilation environment. 6 | library; 7 | 8 | import 'package:os_detect/os_detect.dart' as os_detect; 9 | 10 | void main() { 11 | final knownName = knownOSName(); 12 | print( 13 | 'OS name : ${os_detect.operatingSystem} ' 14 | '${knownName != null ? '($knownName)' : ''}', 15 | ); 16 | print('OS version : ${os_detect.operatingSystemVersion}'); 17 | } 18 | 19 | String? knownOSName() { 20 | if (os_detect.isAndroid) { 21 | return 'Android'; 22 | } 23 | if (os_detect.isBrowser) { 24 | return 'Browser'; 25 | } 26 | if (os_detect.isFuchsia) { 27 | return 'Fuchsia'; 28 | } 29 | if (os_detect.isIOS) { 30 | return 'iOS'; 31 | } 32 | if (os_detect.isLinux) { 33 | return 'Linux'; 34 | } 35 | if (os_detect.isMacOS) { 36 | return 'MacOS'; 37 | } 38 | if (os_detect.isWindows) { 39 | return 'Windows'; 40 | } 41 | return null; 42 | } 43 | -------------------------------------------------------------------------------- /pkgs/async/lib/src/delegate/stream.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | /// Simple delegating wrapper around a [Stream]. 8 | /// 9 | /// Subclasses can override individual methods, or use this to expose only the 10 | /// [Stream] methods of a subclass. 11 | /// 12 | /// Note that this is identical to [StreamView] in `dart:async`. It's provided 13 | /// under this name for consistency with other `Delegating*` classes. 14 | class DelegatingStream extends StreamView { 15 | DelegatingStream(super.stream); 16 | 17 | /// Creates a wrapper which throws if [stream]'s events aren't instances of 18 | /// `T`. 19 | /// 20 | /// This soundly converts a [Stream] to a `Stream`, regardless of its 21 | /// original generic type, by asserting that its events are instances of `T` 22 | /// whenever they're provided. If they're not, the stream throws a 23 | /// [TypeError]. 24 | @Deprecated('Use stream.cast instead') 25 | static Stream typed(Stream stream) => stream.cast(); 26 | } 27 | -------------------------------------------------------------------------------- /pkgs/collection/test/equality_map_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:collection/collection.dart'; 6 | import 'package:test/test.dart'; 7 | 8 | void main() { 9 | test('uses the given equality', () { 10 | var map = EqualityMap(const IterableEquality()); 11 | expect(map, isEmpty); 12 | 13 | map[[1, 2, 3]] = 1; 14 | expect(map, containsPair([1, 2, 3], 1)); 15 | 16 | map[[1, 2, 3]] = 2; 17 | expect(map, containsPair([1, 2, 3], 2)); 18 | 19 | map[[2, 3, 4]] = 3; 20 | expect(map, containsPair([1, 2, 3], 2)); 21 | expect(map, containsPair([2, 3, 4], 3)); 22 | }); 23 | 24 | test('EqualityMap.from() prefers the lattermost equivalent key', () { 25 | var map = EqualityMap.from(const IterableEquality(), { 26 | [1, 2, 3]: 1, 27 | [2, 3, 4]: 2, 28 | [1, 2, 3]: 3, 29 | [2, 3, 4]: 4, 30 | [1, 2, 3]: 5, 31 | [1, 2, 3]: 6, 32 | }); 33 | 34 | expect(map, containsPair([1, 2, 3], 6)); 35 | expect(map, containsPair([2, 3, 4], 4)); 36 | }); 37 | } 38 | -------------------------------------------------------------------------------- /pkgs/collection/test/union_set_controller_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:collection/collection.dart'; 6 | import 'package:test/test.dart'; 7 | 8 | void main() { 9 | late UnionSetController controller; 10 | late Set innerSet; 11 | setUp(() { 12 | innerSet = {1, 2, 3}; 13 | controller = UnionSetController()..add(innerSet); 14 | }); 15 | 16 | test('exposes a union set', () { 17 | expect(controller.set, unorderedEquals([1, 2, 3])); 18 | 19 | controller.add({3, 4, 5}); 20 | expect(controller.set, unorderedEquals([1, 2, 3, 4, 5])); 21 | 22 | controller.remove(innerSet); 23 | expect(controller.set, unorderedEquals([3, 4, 5])); 24 | }); 25 | 26 | test('exposes a disjoint union set', () { 27 | expect(controller.set, unorderedEquals([1, 2, 3])); 28 | 29 | controller.add({4, 5, 6}); 30 | expect(controller.set, unorderedEquals([1, 2, 3, 4, 5, 6])); 31 | 32 | controller.remove(innerSet); 33 | expect(controller.set, unorderedEquals([4, 5, 6])); 34 | }); 35 | } 36 | -------------------------------------------------------------------------------- /pkgs/convert/lib/src/accumulator_sink.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:collection'; 6 | import 'dart:convert'; 7 | 8 | /// A sink that provides access to all the [events] that have been passed to it. 9 | /// 10 | /// See also [ChunkedConversionSink.withCallback]. 11 | class AccumulatorSink implements Sink { 12 | /// An unmodifiable list of events passed to this sink so far. 13 | List get events => UnmodifiableListView(_events); 14 | final _events = []; 15 | 16 | /// Whether [close] has been called. 17 | bool get isClosed => _isClosed; 18 | var _isClosed = false; 19 | 20 | /// Removes all events from [events]. 21 | /// 22 | /// This can be used to avoid double-processing events. 23 | void clear() { 24 | _events.clear(); 25 | } 26 | 27 | @override 28 | void add(T event) { 29 | if (_isClosed) { 30 | throw StateError("Can't add to a closed sink."); 31 | } 32 | 33 | _events.add(event); 34 | } 35 | 36 | @override 37 | void close() { 38 | _isClosed = true; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /pkgs/async/lib/src/result/value.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | import 'error.dart'; 8 | import 'result.dart'; 9 | 10 | /// A result representing a returned value. 11 | class ValueResult implements Result { 12 | /// The result of a successful computation. 13 | final T value; 14 | 15 | @override 16 | bool get isValue => true; 17 | @override 18 | bool get isError => false; 19 | @override 20 | ValueResult get asValue => this; 21 | @override 22 | ErrorResult? get asError => null; 23 | 24 | ValueResult(this.value); 25 | 26 | @override 27 | void complete(Completer completer) { 28 | completer.complete(value); 29 | } 30 | 31 | @override 32 | void addTo(EventSink sink) { 33 | sink.add(value); 34 | } 35 | 36 | @override 37 | Future get asFuture => Future.value(value); 38 | 39 | @override 40 | int get hashCode => value.hashCode ^ 0x323f1d61; 41 | 42 | @override 43 | bool operator ==(Object other) => 44 | other is ValueResult && value == other.value; 45 | } 46 | -------------------------------------------------------------------------------- /pkgs/crypto/lib/src/hash.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:convert'; 6 | 7 | import 'digest.dart'; 8 | import 'digest_sink.dart'; 9 | 10 | /// An interface for cryptographic hash functions. 11 | /// 12 | /// Every hash is a converter that takes a list of ints and returns a single 13 | /// digest. When used in chunked mode, it will only ever add one digest to the 14 | /// inner [Sink]. 15 | abstract class Hash extends Converter, Digest> { 16 | /// The internal block size of the hash in bytes. 17 | /// 18 | /// This is exposed for use by the `Hmac` class, 19 | /// which needs to know the block size for the [Hash] it uses. 20 | int get blockSize; 21 | 22 | const Hash(); 23 | 24 | @override 25 | Digest convert(List input) { 26 | var innerSink = DigestSink(); 27 | var outerSink = startChunkedConversion(innerSink); 28 | outerSink.add(input); 29 | outerSink.close(); 30 | return innerSink.value; 31 | } 32 | 33 | @override 34 | ByteConversionSink startChunkedConversion(Sink sink); 35 | } 36 | -------------------------------------------------------------------------------- /pkgs/os_detect/lib/src/osid_unknown.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'os_kind.dart'; 6 | import 'os_override.dart'; 7 | 8 | @pragma('vm:platform-const') 9 | const String _os = String.fromEnvironment( 10 | 'dart.os.name', 11 | defaultValue: 'unknown', 12 | ); 13 | const String _osVersion = String.fromEnvironment('dart.os.version'); 14 | 15 | const OperatingSystem platformOS = OperatingSystemInternal( 16 | _os == RecognizedOS.linuxId 17 | ? LinuxOS() 18 | : _os == RecognizedOS.macOSId 19 | ? MacOS() 20 | : _os == RecognizedOS.windowsId 21 | ? WindowsOS() 22 | : _os == RecognizedOS.androidId 23 | ? AndroidOS() 24 | : _os == RecognizedOS.iOSId 25 | ? IOS() 26 | : _os == RecognizedOS.fuchsiaId 27 | ? FuchsiaOS() 28 | : _os == RecognizedOS.browserId 29 | ? BrowserOS() 30 | : UnknownOS(_os), 31 | _osVersion, 32 | ); 33 | -------------------------------------------------------------------------------- /.github/workflows/lints.yaml: -------------------------------------------------------------------------------- 1 | name: package:lints 2 | permissions: read-all 3 | 4 | on: 5 | # Run CI on pushes to the main branch, and on PRs against main. 6 | push: 7 | branches: [ main ] 8 | paths: 9 | - '.github/workflows/lints.yaml' 10 | - 'pkgs/lints/**' 11 | pull_request: 12 | branches: [ main ] 13 | paths: 14 | - '.github/workflows/lints.yaml' 15 | - 'pkgs/lints/**' 16 | schedule: 17 | - cron: "0 0 * * 0" 18 | 19 | defaults: 20 | run: 21 | working-directory: pkgs/lints/ 22 | 23 | jobs: 24 | build: 25 | runs-on: ubuntu-latest 26 | strategy: 27 | fail-fast: false 28 | matrix: 29 | # TODO: Re-add stable to the matrix once 3.8 is out. 30 | sdk: [dev, beta] 31 | 32 | steps: 33 | - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 34 | - uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c 35 | with: 36 | sdk: ${{ matrix.sdk }} 37 | 38 | - run: dart pub get 39 | - run: dart format --output=none --set-exit-if-changed . 40 | if: ${{ matrix.sdk == 'stable' }} 41 | - run: dart analyze --fatal-infos 42 | - run: dart tool/validate_lib.dart 43 | - run: dart tool/gen_docs.dart --verify 44 | -------------------------------------------------------------------------------- /pkgs/async/lib/src/typed_stream_transformer.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | /// Creates a wrapper that coerces the type of [transformer]. 8 | /// 9 | /// This soundly converts a [StreamTransformer] to a `StreamTransformer`, 10 | /// regardless of its original generic type, by asserting that the events 11 | /// emitted by the transformed stream are instances of `T` whenever they're 12 | /// provided. If they're not, the stream throws a [TypeError]. 13 | @Deprecated('Use Stream.cast after binding a transformer instead') 14 | StreamTransformer typedStreamTransformer( 15 | StreamTransformer transformer, 16 | ) => 17 | transformer is StreamTransformer 18 | ? transformer 19 | : _TypeSafeStreamTransformer(transformer); 20 | 21 | /// A wrapper that coerces the type of the stream returned by an inner 22 | /// transformer. 23 | class _TypeSafeStreamTransformer extends StreamTransformerBase { 24 | final StreamTransformer _inner; 25 | 26 | _TypeSafeStreamTransformer(this._inner); 27 | 28 | @override 29 | Stream bind(Stream stream) => _inner.bind(stream).cast(); 30 | } 31 | -------------------------------------------------------------------------------- /pkgs/convert/lib/src/identity_codec.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:convert'; 6 | 7 | class _IdentityConverter extends Converter { 8 | _IdentityConverter(); 9 | @override 10 | T convert(T input) => input; 11 | } 12 | 13 | /// A [Codec] that performs the identity conversion (changing nothing) in both 14 | /// directions. 15 | /// 16 | /// The identity codec passes input directly to output in both directions. 17 | /// This class can be used as a base when combining multiple codecs, 18 | /// because fusing the identity codec with any other codec gives the other 19 | /// codec back. 20 | /// 21 | /// Note, that when fused with another [Codec] the identity codec disppears. 22 | class IdentityCodec extends Codec { 23 | const IdentityCodec(); 24 | 25 | @override 26 | Converter get decoder => _IdentityConverter(); 27 | @override 28 | Converter get encoder => _IdentityConverter(); 29 | 30 | /// Fuse with an other codec. 31 | /// 32 | /// Fusing with the identify converter is a no-op, so this always return 33 | /// [other]. 34 | @override 35 | Codec fuse(Codec other) => other; 36 | } 37 | -------------------------------------------------------------------------------- /pkgs/crypto/example/example.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | import 'dart:io'; 7 | 8 | import 'package:crypto/crypto.dart'; 9 | 10 | final _usage = 'Usage: dart hash.dart '; 11 | 12 | Future main(List args) async { 13 | if (args.length != 2) { 14 | print(_usage); 15 | exitCode = 64; // Command was used incorrectly. 16 | return; 17 | } 18 | 19 | Hash hasher; 20 | 21 | switch (args[0]) { 22 | case 'md5': 23 | hasher = md5; 24 | break; 25 | case 'sha1': 26 | hasher = sha1; 27 | break; 28 | case 'sha256': 29 | hasher = sha256; 30 | break; 31 | default: 32 | print(_usage); 33 | exitCode = 64; // Command was used incorrectly. 34 | return; 35 | } 36 | 37 | var filename = args[1]; 38 | var input = File(filename); 39 | 40 | if (!input.existsSync()) { 41 | print('File "$filename" does not exist.'); 42 | exitCode = 66; // An input file did not exist or was not readable. 43 | return; 44 | } 45 | 46 | var value = await hasher.bind(input.openRead()).first; 47 | 48 | print(value); 49 | } 50 | -------------------------------------------------------------------------------- /pkgs/path/test/browser_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | @TestOn('browser') 6 | library; 7 | 8 | import 'package:path/path.dart' as path; 9 | import 'package:test/test.dart'; 10 | import 'package:web/web.dart'; 11 | 12 | void main() { 13 | group('new Context()', () { 14 | test('uses the window location if root and style are omitted', () { 15 | final context = path.Context(); 16 | expect( 17 | context.current, 18 | Uri.parse(window.location.href).resolve('.').toString(), 19 | ); 20 | }); 21 | 22 | test('uses "." if root is omitted', () { 23 | final context = path.Context(style: path.Style.platform); 24 | expect(context.current, '.'); 25 | }); 26 | 27 | test('uses the host platform if style is omitted', () { 28 | final context = path.Context(); 29 | expect(context.style, path.Style.platform); 30 | }); 31 | }); 32 | 33 | test('Style.platform is url', () { 34 | expect(path.Style.platform, path.Style.url); 35 | }); 36 | 37 | test('current', () { 38 | expect( 39 | path.current, 40 | Uri.parse(window.location.href).resolve('.').toString(), 41 | ); 42 | }); 43 | } 44 | -------------------------------------------------------------------------------- /pkgs/async/lib/src/delegate/sink.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | /// Simple delegating wrapper around a [Sink]. 6 | /// 7 | /// Subclasses can override individual methods, or use this to expose only the 8 | /// [Sink] methods of a subclass. 9 | class DelegatingSink implements Sink { 10 | final Sink _sink; 11 | 12 | /// Create a delegating sink forwarding calls to [sink]. 13 | DelegatingSink(Sink sink) : _sink = sink; 14 | 15 | DelegatingSink._(this._sink); 16 | 17 | /// Creates a wrapper that coerces the type of [sink]. 18 | /// 19 | /// Unlike [DelegatingSink.new], this only requires its argument to be an 20 | /// instance of `Sink`, not `Sink`. This means that calls to [add] may 21 | /// throw a [TypeError] if the argument type doesn't match the reified type of 22 | /// [sink]. 23 | @Deprecated( 24 | 'Use StreamController(sync: true)..stream.cast().pipe(sink)', 25 | ) 26 | static Sink typed(Sink sink) => 27 | sink is Sink ? sink : DelegatingSink._(sink); 28 | 29 | @override 30 | void add(T data) { 31 | _sink.add(data); 32 | } 33 | 34 | @override 35 | void close() { 36 | _sink.close(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /pkgs/collection/lib/src/equality_set.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:collection'; 6 | 7 | import 'equality.dart'; 8 | import 'wrappers.dart'; 9 | 10 | /// A [Set] whose key equality is determined by an [Equality] object. 11 | class EqualitySet extends DelegatingSet { 12 | /// Creates a set with equality based on [equality]. 13 | EqualitySet(Equality equality) 14 | : super( 15 | LinkedHashSet( 16 | equals: equality.equals, 17 | hashCode: equality.hash, 18 | isValidKey: equality.isValidKey, 19 | ), 20 | ); 21 | 22 | /// Creates a set with equality based on [equality] that contains all 23 | /// elements in [other]. 24 | /// 25 | /// If [other] has multiple values that are equivalent according to 26 | /// [equality], the first one reached during iteration takes precedence. 27 | EqualitySet.from(Equality equality, Iterable other) 28 | : super( 29 | LinkedHashSet( 30 | equals: equality.equals, 31 | hashCode: equality.hash, 32 | isValidKey: equality.isValidKey, 33 | ), 34 | ) { 35 | addAll(other); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /pkgs/collection/lib/src/equality_map.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:collection'; 6 | 7 | import 'equality.dart'; 8 | import 'wrappers.dart'; 9 | 10 | /// A [Map] whose key equality is determined by an [Equality] object. 11 | class EqualityMap extends DelegatingMap { 12 | /// Creates a map with equality based on [equality]. 13 | EqualityMap(Equality equality) 14 | : super( 15 | LinkedHashMap( 16 | equals: equality.equals, 17 | hashCode: equality.hash, 18 | isValidKey: equality.isValidKey, 19 | ), 20 | ); 21 | 22 | /// Creates a map with equality based on [equality] that contains all 23 | /// key-value pairs of [other]. 24 | /// 25 | /// If [other] has multiple keys that are equivalent according to [equality], 26 | /// the last one reached during iteration takes precedence. 27 | EqualityMap.from(Equality equality, Map other) 28 | : super( 29 | LinkedHashMap( 30 | equals: equality.equals, 31 | hashCode: equality.hash, 32 | isValidKey: equality.isValidKey, 33 | ), 34 | ) { 35 | addAll(other); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /pkgs/async/lib/src/typed/stream_subscription.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | class TypeSafeStreamSubscription implements StreamSubscription { 8 | final StreamSubscription _subscription; 9 | 10 | @override 11 | bool get isPaused => _subscription.isPaused; 12 | 13 | TypeSafeStreamSubscription(this._subscription); 14 | 15 | @override 16 | void onData(void Function(T)? handleData) { 17 | if (handleData == null) return _subscription.onData(null); 18 | _subscription.onData((data) => handleData(data as T)); 19 | } 20 | 21 | @override 22 | void onError(Function? handleError) { 23 | _subscription.onError(handleError); 24 | } 25 | 26 | @override 27 | void onDone(void Function()? handleDone) { 28 | _subscription.onDone(handleDone); 29 | } 30 | 31 | @override 32 | void pause([Future? resumeFuture]) { 33 | _subscription.pause(resumeFuture); 34 | } 35 | 36 | @override 37 | void resume() { 38 | _subscription.resume(); 39 | } 40 | 41 | @override 42 | Future cancel() => _subscription.cancel(); 43 | 44 | @override 45 | Future asFuture([E? futureValue]) => 46 | _subscription.asFuture(futureValue); 47 | } 48 | -------------------------------------------------------------------------------- /pkgs/collection/lib/src/combined_wrappers/combined_iterator.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | /// The iterator for `CombinedIterableView` and `CombinedListView`. 6 | /// 7 | /// Moves through each iterable's iterator in sequence. 8 | class CombinedIterator implements Iterator { 9 | /// The iterators that this combines, or `null` if done iterating. 10 | /// 11 | /// Because this comes from a call to [Iterable.map], it's lazy and will 12 | /// avoid instantiating unnecessary iterators. 13 | Iterator>? _iterators; 14 | 15 | CombinedIterator(Iterator> iterators) : _iterators = iterators { 16 | if (!iterators.moveNext()) _iterators = null; 17 | } 18 | 19 | @override 20 | T get current { 21 | var iterators = _iterators; 22 | if (iterators != null) return iterators.current.current; 23 | return null as T; 24 | } 25 | 26 | @override 27 | bool moveNext() { 28 | var iterators = _iterators; 29 | if (iterators != null) { 30 | do { 31 | if (iterators.current.moveNext()) { 32 | return true; 33 | } 34 | } while (iterators.moveNext()); 35 | _iterators = null; 36 | } 37 | return false; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /pkgs/logging/example/main.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:logging/logging.dart'; 6 | 7 | final log = Logger('ExampleLogger'); 8 | 9 | /// Example of configuring a logger to print to stdout. 10 | /// 11 | /// This example will print: 12 | /// 13 | /// INFO: 2021-09-13 15:35:10.703401: recursion: n = 4 14 | /// INFO: 2021-09-13 15:35:10.707974: recursion: n = 3 15 | /// Fibonacci(4) is: 3 16 | /// Fibonacci(5) is: 5 17 | /// SHOUT: 2021-09-13 15:35:10.708087: Unexpected negative n: -42 18 | /// Fibonacci(-42) is: 1 19 | void main() { 20 | Logger.root.level = Level.ALL; // defaults to Level.INFO 21 | Logger.root.onRecord.listen((record) { 22 | print('${record.level.name}: ${record.time}: ${record.message}'); 23 | }); 24 | 25 | print('Fibonacci(4) is: ${fibonacci(4)}'); 26 | 27 | Logger.root.level = Level.SEVERE; // skip logs less then severe. 28 | print('Fibonacci(5) is: ${fibonacci(5)}'); 29 | 30 | print('Fibonacci(-42) is: ${fibonacci(-42)}'); 31 | } 32 | 33 | int fibonacci(int n) { 34 | if (n <= 2) { 35 | if (n < 0) log.shout('Unexpected negative n: $n'); 36 | return 1; 37 | } else { 38 | log.info('recursion: n = $n'); 39 | return fibonacci(n - 2) + fibonacci(n - 1); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /pkgs/convert/lib/src/string_accumulator_sink.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:convert'; 6 | 7 | /// A sink that provides access to the concatenated strings passed to it. 8 | /// 9 | /// See also [StringConversionSink.withCallback]. 10 | class StringAccumulatorSink extends StringConversionSinkBase { 11 | /// The string accumulated so far. 12 | String get string => _buffer.toString(); 13 | final _buffer = StringBuffer(); 14 | 15 | /// Whether [close] has been called. 16 | bool get isClosed => _isClosed; 17 | var _isClosed = false; 18 | 19 | /// Empties [string]. 20 | /// 21 | /// This can be used to avoid double-processing data. 22 | void clear() { 23 | _buffer.clear(); 24 | } 25 | 26 | @override 27 | void add(String str) { 28 | if (_isClosed) { 29 | throw StateError("Can't add to a closed sink."); 30 | } 31 | 32 | _buffer.write(str); 33 | } 34 | 35 | @override 36 | void addSlice(String chunk, int start, int end, bool isLast) { 37 | if (_isClosed) { 38 | throw StateError("Can't add to a closed sink."); 39 | } 40 | 41 | _buffer.write(chunk.substring(start, end)); 42 | if (isLast) _isClosed = true; 43 | } 44 | 45 | @override 46 | void close() { 47 | _isClosed = true; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /.github/workflows/no-response.yml: -------------------------------------------------------------------------------- 1 | # A workflow to close issues where the author hasn't responded to a request for 2 | # more information; see https://github.com/actions/stale. 3 | 4 | name: No Response 5 | 6 | # All permissions not specified are set to 'none'. 7 | permissions: 8 | issues: write 9 | pull-requests: write 10 | 11 | # Run as a daily cron. 12 | on: 13 | schedule: 14 | # Every day at 8am 15 | - cron: '0 8 * * *' 16 | 17 | jobs: 18 | no-response: 19 | runs-on: ubuntu-latest 20 | if: ${{ github.repository_owner == 'dart-lang' }} 21 | steps: 22 | - uses: actions/stale@5f858e3efba33a5ca4407a664cc011ad407f2008 23 | with: 24 | # Don't automatically mark inactive issues+PRs as stale. 25 | days-before-stale: -1 26 | # Close needs-info issues and PRs after 14 days of inactivity. 27 | days-before-close: 14 28 | stale-issue-label: "needs-info" 29 | close-issue-message: > 30 | Without additional information we're not able to resolve this issue. 31 | Feel free to add more info or respond to any questions above and we 32 | can reopen the case. Thanks for your contribution! 33 | stale-pr-label: "needs-info" 34 | close-pr-message: > 35 | Without additional information we're not able to resolve this PR. 36 | Feel free to add more info or respond to any questions above. 37 | Thanks for your contribution! 38 | -------------------------------------------------------------------------------- /.github/labeler.yml: -------------------------------------------------------------------------------- 1 | # Configuration for .github/workflows/pull_request_label.yaml. 2 | 3 | 'type-infra': 4 | - changed-files: 5 | - any-glob-to-any-file: '.github/**' 6 | 7 | 'package:args': 8 | - changed-files: 9 | - any-glob-to-any-file: 'pkgs/args/**' 10 | 11 | 'package:async': 12 | - changed-files: 13 | - any-glob-to-any-file: 'pkgs/async/**' 14 | 15 | 'package:characters': 16 | - changed-files: 17 | - any-glob-to-any-file: 'pkgs/characters/**' 18 | 19 | 'package:collection': 20 | - changed-files: 21 | - any-glob-to-any-file: 'pkgs/collection/**' 22 | 23 | 'package:convert': 24 | - changed-files: 25 | - any-glob-to-any-file: 'pkgs/convert/**' 26 | 27 | 'package:crypto': 28 | - changed-files: 29 | - any-glob-to-any-file: 'pkgs/crypto/**' 30 | 31 | 'package:fixnum': 32 | - changed-files: 33 | - any-glob-to-any-file: 'pkgs/fixnum/**' 34 | 35 | 'package:lints': 36 | - changed-files: 37 | - any-glob-to-any-file: 'pkgs/lints/**' 38 | 39 | 'package:logging': 40 | - changed-files: 41 | - any-glob-to-any-file: 'pkgs/logging/**' 42 | 43 | 'package:os_detect': 44 | - changed-files: 45 | - any-glob-to-any-file: 'pkgs/os_detect/**' 46 | 47 | 'package:path': 48 | - changed-files: 49 | - any-glob-to-any-file: 'pkgs/path/**' 50 | 51 | 'package:platform': 52 | - changed-files: 53 | - any-glob-to-any-file: 'pkgs/platform/**' 54 | 55 | 'package:typed_data': 56 | - changed-files: 57 | - any-glob-to-any-file: 'pkgs/typed_data/**' 58 | -------------------------------------------------------------------------------- /pkgs/convert/test/accumulator_sink_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:convert/convert.dart'; 6 | import 'package:test/test.dart'; 7 | 8 | void main() { 9 | late AccumulatorSink sink; 10 | setUp(() { 11 | sink = AccumulatorSink(); 12 | }); 13 | 14 | test("provides access to events as they're added", () { 15 | expect(sink.events, isEmpty); 16 | 17 | sink.add(1); 18 | expect(sink.events, equals([1])); 19 | 20 | sink.add(2); 21 | expect(sink.events, equals([1, 2])); 22 | 23 | sink.add(3); 24 | expect(sink.events, equals([1, 2, 3])); 25 | }); 26 | 27 | test('clear() clears the events', () { 28 | sink 29 | ..add(1) 30 | ..add(2) 31 | ..add(3); 32 | expect(sink.events, equals([1, 2, 3])); 33 | 34 | sink.clear(); 35 | expect(sink.events, isEmpty); 36 | 37 | sink 38 | ..add(4) 39 | ..add(5) 40 | ..add(6); 41 | expect(sink.events, equals([4, 5, 6])); 42 | }); 43 | 44 | test('indicates whether the sink is closed', () { 45 | expect(sink.isClosed, isFalse); 46 | sink.close(); 47 | expect(sink.isClosed, isTrue); 48 | }); 49 | 50 | test("doesn't allow add() to be called after close()", () { 51 | sink.close(); 52 | expect(() => sink.add(1), throwsStateError); 53 | }); 54 | } 55 | -------------------------------------------------------------------------------- /pkgs/lints/lib/core.yaml: -------------------------------------------------------------------------------- 1 | # This is a set of core lints used to identify critical issues. 2 | # Check out https://github.com/dart-lang/lints for more information. 3 | # 4 | # To learn more about customizing static analysis for your package or app, 5 | # visit https://dart.dev/tools/analysis. 6 | 7 | linter: 8 | rules: 9 | - avoid_empty_else 10 | - avoid_relative_lib_imports 11 | - avoid_shadowing_type_parameters 12 | - avoid_types_as_parameter_names 13 | - await_only_futures 14 | - camel_case_extensions 15 | - camel_case_types 16 | - collection_methods_unrelated_type 17 | - curly_braces_in_flow_control_structures 18 | - dangling_library_doc_comments 19 | - depend_on_referenced_packages 20 | - empty_catches 21 | - file_names 22 | - hash_and_equals 23 | - implicit_call_tearoffs 24 | - library_annotations 25 | - no_duplicate_case_values 26 | - no_wildcard_variable_uses 27 | - non_constant_identifier_names 28 | - null_check_on_nullable_type_parameter 29 | - prefer_generic_function_type_aliases 30 | - prefer_is_empty 31 | - prefer_is_not_empty 32 | - prefer_iterable_whereType 33 | - prefer_typing_uninitialized_variables 34 | - provide_deprecation_message 35 | - secure_pubspec_urls 36 | - strict_top_level_inference 37 | - type_literal_in_constant_pattern 38 | - unintended_html_in_doc_comment 39 | - unnecessary_overrides 40 | - unrelated_type_equality_checks 41 | - use_string_in_part_of_directives 42 | - valid_regexps 43 | - void_checks 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2024, the Dart project authors. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following 11 | disclaimer in the documentation and/or other materials provided 12 | with the distribution. 13 | * Neither the name of Google LLC nor the names of its 14 | contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /pkgs/args/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2013, the Dart project authors. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following 11 | disclaimer in the documentation and/or other materials provided 12 | with the distribution. 13 | * Neither the name of Google LLC nor the names of its 14 | contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /pkgs/async/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2015, the Dart project authors. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following 11 | disclaimer in the documentation and/or other materials provided 12 | with the distribution. 13 | * Neither the name of Google LLC nor the names of its 14 | contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /pkgs/async/test/async_memoizer_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:async/async.dart'; 6 | import 'package:test/test.dart'; 7 | 8 | void main() { 9 | late AsyncMemoizer cache; 10 | setUp(() => cache = AsyncMemoizer()); 11 | 12 | test('runs the function only the first time runOnce() is called', () async { 13 | var count = 0; 14 | expect(await cache.runOnce(() => count++), equals(0)); 15 | expect(count, equals(1)); 16 | 17 | expect(await cache.runOnce(() => count++), equals(0)); 18 | expect(count, equals(1)); 19 | }); 20 | 21 | test('forwards the return value from the function', () async { 22 | expect(cache.future, completion(equals('value'))); 23 | expect(cache.runOnce(() => 'value'), completion(equals('value'))); 24 | expect(cache.runOnce(() {}), completion(equals('value'))); 25 | }); 26 | 27 | test('forwards the return value from an async function', () async { 28 | expect(cache.future, completion(equals('value'))); 29 | expect(cache.runOnce(() async => 'value'), completion(equals('value'))); 30 | expect(cache.runOnce(() {}), completion(equals('value'))); 31 | }); 32 | 33 | test('forwards the error from an async function', () async { 34 | expect(cache.future, throwsA('error')); 35 | expect(cache.runOnce(() async => throw 'error'), throwsA('error')); 36 | expect(cache.runOnce(() {}), throwsA('error')); 37 | }); 38 | } 39 | -------------------------------------------------------------------------------- /pkgs/crypto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2015, the Dart project authors. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following 11 | disclaimer in the documentation and/or other materials provided 12 | with the distribution. 13 | * Neither the name of Google LLC nor the names of its 14 | contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /pkgs/fixnum/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014, the Dart project authors. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following 11 | disclaimer in the documentation and/or other materials provided 12 | with the distribution. 13 | * Neither the name of Google LLC nor the names of its 14 | contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /pkgs/lints/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2021, the Dart project authors. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following 11 | disclaimer in the documentation and/or other materials provided 12 | with the distribution. 13 | * Neither the name of Google LLC nor the names of its 14 | contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /pkgs/path/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014, the Dart project authors. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following 11 | disclaimer in the documentation and/or other materials provided 12 | with the distribution. 13 | * Neither the name of Google LLC nor the names of its 14 | contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /pkgs/characters/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019, the Dart project authors. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following 11 | disclaimer in the documentation and/or other materials provided 12 | with the distribution. 13 | * Neither the name of Google LLC nor the names of its 14 | contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /pkgs/collection/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2015, the Dart project authors. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following 11 | disclaimer in the documentation and/or other materials provided 12 | with the distribution. 13 | * Neither the name of Google LLC nor the names of its 14 | contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /pkgs/convert/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2015, the Dart project authors. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following 11 | disclaimer in the documentation and/or other materials provided 12 | with the distribution. 13 | * Neither the name of Google LLC nor the names of its 14 | contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /pkgs/logging/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2013, the Dart project authors. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following 11 | disclaimer in the documentation and/or other materials provided 12 | with the distribution. 13 | * Neither the name of Google LLC nor the names of its 14 | contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /pkgs/logging/lib/src/log_record.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | import 'level.dart'; 8 | import 'logger.dart'; 9 | 10 | /// A log entry representation used to propagate information from [Logger] to 11 | /// individual handlers. 12 | class LogRecord { 13 | final Level level; 14 | final String message; 15 | 16 | /// Non-string message passed to Logger. 17 | final Object? object; 18 | 19 | /// Logger where this record is stored. 20 | final String loggerName; 21 | 22 | /// Time when this record was created. 23 | final DateTime time; 24 | 25 | /// Unique sequence number greater than all log records created before it. 26 | final int sequenceNumber; 27 | 28 | static int _nextNumber = 0; 29 | 30 | /// Associated error (if any) when recording errors messages. 31 | final Object? error; 32 | 33 | /// Associated stackTrace (if any) when recording errors messages. 34 | final StackTrace? stackTrace; 35 | 36 | /// Zone of the calling code which resulted in this LogRecord. 37 | final Zone? zone; 38 | 39 | LogRecord( 40 | this.level, 41 | this.message, 42 | this.loggerName, [ 43 | this.error, 44 | this.stackTrace, 45 | this.zone, 46 | this.object, 47 | ]) : time = DateTime.now(), 48 | sequenceNumber = LogRecord._nextNumber++; 49 | 50 | @override 51 | String toString() => '[${level.name}] $loggerName: $message'; 52 | } 53 | -------------------------------------------------------------------------------- /pkgs/os_detect/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020, the Dart project authors. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following 11 | disclaimer in the documentation and/or other materials provided 12 | with the distribution. 13 | * Neither the name of Google LLC nor the names of its 14 | contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /pkgs/os_detect/lib/src/osid_io.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:io'; 6 | 7 | import 'os_kind.dart'; 8 | import 'os_override.dart'; 9 | 10 | // Uses VM platform-constant functionality to constant fold this expression 11 | // when `Platform.operatingSystem` is known at compile-time. 12 | // Uses a valid "potentially constant" expression for this, instead of, e.g., 13 | // a `switch` expression. 14 | @pragma('vm:platform-const') 15 | final RecognizedOS? _osType = Platform.operatingSystem == RecognizedOS.linuxId 16 | ? const LinuxOS() 17 | : Platform.operatingSystem == RecognizedOS.macOSId 18 | ? const MacOS() 19 | : Platform.operatingSystem == RecognizedOS.windowsId 20 | ? const WindowsOS() 21 | : Platform.operatingSystem == RecognizedOS.androidId 22 | ? const AndroidOS() 23 | : Platform.operatingSystem == RecognizedOS.iOSId 24 | ? const IOS() 25 | : Platform.operatingSystem == RecognizedOS.fuchsiaId 26 | ? const FuchsiaOS() 27 | : Platform.operatingSystem == RecognizedOS.browserId 28 | ? const BrowserOS() 29 | : null; 30 | 31 | final OperatingSystem platformOS = OperatingSystemInternal( 32 | _osType ?? UnknownOS(Platform.operatingSystem), 33 | Platform.operatingSystemVersion, 34 | ); 35 | -------------------------------------------------------------------------------- /pkgs/typed_data/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2015, the Dart project authors. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following 11 | disclaimer in the documentation and/or other materials provided 12 | with the distribution. 13 | * Neither the name of Google LLC nor the names of its 14 | contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /.github/workflows/platform.yaml: -------------------------------------------------------------------------------- 1 | name: package:platform 2 | permissions: read-all 3 | 4 | on: 5 | # Run CI on pushes to the main branch, and on PRs against main. 6 | push: 7 | branches: [ main ] 8 | paths: 9 | - '.github/workflows/platform.yaml' 10 | - 'pkgs/platform/**' 11 | pull_request: 12 | branches: [ main ] 13 | paths: 14 | - '.github/workflows/platform.yaml' 15 | - 'pkgs/platform/**' 16 | schedule: 17 | - cron: "0 0 * * 0" 18 | 19 | defaults: 20 | run: 21 | working-directory: pkgs/platform/ 22 | 23 | jobs: 24 | correctness: 25 | runs-on: ubuntu-latest 26 | steps: 27 | - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 28 | - uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c 29 | with: 30 | sdk: dev 31 | - name: Install dependencies 32 | run: dart pub upgrade 33 | - name: Verify formatting 34 | run: dart format --output=none --set-exit-if-changed . 35 | - name: Analyze project source 36 | run: dart analyze --fatal-infos 37 | test: 38 | runs-on: ${{ matrix.os }} 39 | strategy: 40 | matrix: 41 | os: [ubuntu-latest, macos-latest, windows-latest] 42 | sdk: [stable, beta, dev] 43 | steps: 44 | - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 45 | - uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c 46 | with: 47 | sdk: ${{ matrix.sdk }} 48 | - name: Install dependencies 49 | run: dart pub upgrade 50 | - name: Run Tests 51 | run: dart test 52 | -------------------------------------------------------------------------------- /pkgs/async/lib/src/delegate/event_sink.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | /// Simple delegating wrapper around an [EventSink]. 8 | /// 9 | /// Subclasses can override individual methods, or use this to expose only the 10 | /// [EventSink] methods of a subclass. 11 | class DelegatingEventSink implements EventSink { 12 | final EventSink _sink; 13 | 14 | /// Create a delegating sink forwarding calls to [sink]. 15 | DelegatingEventSink(EventSink sink) : _sink = sink; 16 | 17 | DelegatingEventSink._(this._sink); 18 | 19 | /// Creates a wrapper that coerces the type of [sink]. 20 | /// 21 | /// Unlike [DelegatingEventSink.new], this only requires its argument to be an 22 | /// instance of `EventSink`, not `EventSink`. This means that calls to 23 | /// [add] may throw a [TypeError] if the argument type doesn't match the 24 | /// reified type of [sink]. 25 | @Deprecated( 26 | 'Use StreamController(sync: true)..stream.cast().pipe(sink)', 27 | ) 28 | static EventSink typed(EventSink sink) => 29 | sink is EventSink ? sink : DelegatingEventSink._(sink); 30 | 31 | @override 32 | void add(T data) { 33 | _sink.add(data); 34 | } 35 | 36 | @override 37 | void addError(Object error, [StackTrace? stackTrace]) { 38 | _sink.addError(error, stackTrace); 39 | } 40 | 41 | @override 42 | void close() { 43 | _sink.close(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /pkgs/platform/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2017, the Dart project authors. All rights reserved. 2 | Redistribution and use in source and binary forms, with or without 3 | modification, are permitted provided that the following conditions are 4 | met: 5 | 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above 9 | copyright notice, this list of conditions and the following 10 | disclaimer in the documentation and/or other materials provided 11 | with the distribution. 12 | * Neither the name of Google Inc. nor the names of its 13 | contributors may be used to endorse or promote products derived 14 | from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /pkgs/async/test/result/result_future_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | import 'package:async/async.dart'; 8 | import 'package:stack_trace/stack_trace.dart'; 9 | import 'package:test/test.dart'; 10 | 11 | void main() { 12 | late Completer completer; 13 | late ResultFuture future; 14 | setUp(() { 15 | completer = Completer(); 16 | future = ResultFuture(completer.future); 17 | }); 18 | 19 | test('before completion, result is null', () { 20 | expect(future.result, isNull); 21 | }); 22 | 23 | test('after successful completion, result is the value of the future', () { 24 | completer.complete(12); 25 | 26 | // The completer calls its listeners asynchronously. We have to wait 27 | // before we can access the result. 28 | expect( 29 | future.then((_) => future.result!.asValue!.value), 30 | completion(equals(12)), 31 | ); 32 | }); 33 | 34 | test("after an error completion, result is the future's error", () { 35 | var trace = Trace.current(); 36 | completer.completeError('error', trace); 37 | 38 | // The completer calls its listeners asynchronously. We have to wait 39 | // before we can access the result. 40 | return future.catchError((_) {}).then((_) { 41 | var error = future.result!.asError!; 42 | expect(error.error, equals('error')); 43 | expect(error.stackTrace, equals(trace)); 44 | }); 45 | }); 46 | } 47 | -------------------------------------------------------------------------------- /pkgs/collection/lib/src/combined_wrappers/combined_iterable.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:collection'; 6 | 7 | import 'combined_iterator.dart'; 8 | 9 | /// A view of several iterables combined sequentially into a single iterable. 10 | /// 11 | /// All methods and accessors treat the [CombinedIterableView] as if it were a 12 | /// single concatenated iterable, but the underlying implementation is based on 13 | /// lazily accessing individual iterable instances. This means that if the 14 | /// underlying iterables change, the [CombinedIterableView] will reflect those 15 | /// changes. 16 | class CombinedIterableView extends IterableBase { 17 | /// The iterables that this combines. 18 | final Iterable> _iterables; 19 | 20 | /// Creates a combined view of [_iterables]. 21 | const CombinedIterableView(this._iterables); 22 | 23 | @override 24 | Iterator get iterator => 25 | CombinedIterator(_iterables.map((i) => i.iterator).iterator); 26 | 27 | // Special cased contains/isEmpty/length since many iterables have an 28 | // efficient implementation instead of running through the entire iterator. 29 | 30 | @override 31 | bool contains(Object? element) => _iterables.any((i) => i.contains(element)); 32 | 33 | @override 34 | bool get isEmpty => _iterables.every((i) => i.isEmpty); 35 | 36 | @override 37 | int get length => _iterables.fold(0, (length, i) => length + i.length); 38 | } 39 | -------------------------------------------------------------------------------- /pkgs/async/lib/src/delegate/stream_consumer.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | /// Simple delegating wrapper around a [StreamConsumer]. 8 | /// 9 | /// Subclasses can override individual methods, or use this to expose only the 10 | /// [StreamConsumer] methods of a subclass. 11 | class DelegatingStreamConsumer implements StreamConsumer { 12 | final StreamConsumer _consumer; 13 | 14 | /// Create a delegating consumer forwarding calls to [consumer]. 15 | DelegatingStreamConsumer(StreamConsumer consumer) : _consumer = consumer; 16 | 17 | DelegatingStreamConsumer._(this._consumer); 18 | 19 | /// Creates a wrapper that coerces the type of [consumer]. 20 | /// 21 | /// Unlike [StreamConsumer.new], this only requires its argument to be an 22 | /// instance of `StreamConsumer`, not `StreamConsumer`. This means that 23 | /// calls to [addStream] may throw a [TypeError] if the argument type doesn't 24 | /// match the reified type of [consumer]. 25 | @Deprecated( 26 | 'Use StreamController(sync: true)..stream.cast().pipe(sink)', 27 | ) 28 | static StreamConsumer typed(StreamConsumer consumer) => 29 | consumer is StreamConsumer 30 | ? consumer 31 | : DelegatingStreamConsumer._(consumer); 32 | 33 | @override 34 | Future addStream(Stream stream) => _consumer.addStream(stream); 35 | 36 | @override 37 | Future close() => _consumer.close(); 38 | } 39 | -------------------------------------------------------------------------------- /pkgs/convert/lib/src/percent.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:convert'; 6 | 7 | import 'percent/decoder.dart'; 8 | import 'percent/encoder.dart'; 9 | 10 | export 'percent/decoder.dart' hide percentDecoder; 11 | export 'percent/encoder.dart' hide percentEncoder; 12 | 13 | /// The canonical instance of [PercentCodec]. 14 | const percent = PercentCodec._(); 15 | 16 | // TODO(nweiz): Add flags to support generating and interpreting "+" as a space 17 | // character. Also add an option for custom sets of unreserved characters. 18 | /// A codec that converts byte arrays to and from percent-encoded (also known as 19 | /// URL-encoded) strings according to 20 | /// [RFC 3986](https://tools.ietf.org/html/rfc3986#section-2.1). 21 | /// 22 | /// [encoder] encodes all bytes other than ASCII letters, decimal digits, or one 23 | /// of `-._~`. This matches the behavior of [Uri.encodeQueryComponent] except 24 | /// that it doesn't encode `0x20` bytes to the `+` character. 25 | /// 26 | /// To be maximally flexible, [decoder] will decode any percent-encoded byte and 27 | /// will allow any non-percent-encoded byte other than `%`. By default, it 28 | /// interprets `+` as `0x2B` rather than `0x20` as emitted by 29 | /// [Uri.encodeQueryComponent]. 30 | class PercentCodec extends Codec, String> { 31 | @override 32 | PercentEncoder get encoder => percentEncoder; 33 | @override 34 | PercentDecoder get decoder => percentDecoder; 35 | 36 | const PercentCodec._(); 37 | } 38 | -------------------------------------------------------------------------------- /pkgs/async/lib/src/single_subscription_transformer.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | /// A transformer that converts a broadcast stream into a single-subscription 8 | /// stream. 9 | /// 10 | /// This buffers the broadcast stream's events, which means that it starts 11 | /// listening to a stream as soon as it's bound. 12 | /// 13 | /// This also casts the source stream's events to type `T`. If the cast fails, 14 | /// the result stream will emit a [TypeError]. This behavior is deprecated, and 15 | /// should not be relied upon. 16 | class SingleSubscriptionTransformer extends StreamTransformerBase { 17 | const SingleSubscriptionTransformer(); 18 | 19 | @override 20 | Stream bind(Stream stream) { 21 | late StreamSubscription subscription; 22 | var controller = StreamController( 23 | sync: true, 24 | onCancel: () => subscription.cancel(), 25 | ); 26 | subscription = stream.listen( 27 | (value) { 28 | // TODO(nweiz): When we release a new major version, get rid of the 29 | // second type parameter and avoid this conversion. 30 | try { 31 | controller.add(value as T); 32 | // ignore: avoid_catching_errors 33 | } on TypeError catch (error, stackTrace) { 34 | controller.addError(error, stackTrace); 35 | } 36 | }, 37 | onError: controller.addError, 38 | onDone: controller.close, 39 | ); 40 | return controller.stream; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /pkgs/path/lib/src/path_map.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:collection'; 6 | 7 | import '../path.dart' as p; 8 | 9 | /// A map whose keys are paths, compared using [p.equals] and [p.hash]. 10 | class PathMap extends MapView { 11 | /// Creates an empty [PathMap] whose keys are compared using `context.equals` 12 | /// and `context.hash`. 13 | /// 14 | /// The [context] defaults to the current path context. 15 | PathMap({p.Context? context}) : super(_create(context)); 16 | 17 | /// Creates a [PathMap] with the same keys and values as [other] whose keys 18 | /// are compared using `context.equals` and `context.hash`. 19 | /// 20 | /// The [context] defaults to the current path context. If multiple keys in 21 | /// [other] represent the same logical path, the last key's value will be 22 | /// used. 23 | PathMap.of(Map other, {p.Context? context}) 24 | : super(_create(context)..addAll(other)); 25 | 26 | /// Creates a map that uses [context] for equality and hashing. 27 | static Map _create(p.Context? context) { 28 | context ??= p.context; 29 | return LinkedHashMap( 30 | equals: (path1, path2) { 31 | if (path1 == null) return path2 == null; 32 | if (path2 == null) return false; 33 | return context!.equals(path1, path2); 34 | }, 35 | hashCode: (path) => path == null ? 0 : context!.hash(path), 36 | isValidKey: (path) => path is String || path == null, 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /pkgs/async/lib/src/delegate/future.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | /// A wrapper that forwards calls to a [Future]. 8 | class DelegatingFuture implements Future { 9 | /// The wrapped [Future]. 10 | final Future _future; 11 | 12 | DelegatingFuture(this._future); 13 | 14 | /// Creates a wrapper which throws if [future]'s value isn't an instance of 15 | /// `T`. 16 | /// 17 | /// This soundly converts a [Future] to a `Future`, regardless of its 18 | /// original generic type, by asserting that its value is an instance of `T` 19 | /// whenever it's provided. If it's not, the future throws a [TypeError]. 20 | @Deprecated('Use future.then((v) => v as T) instead.') 21 | static Future typed(Future future) => 22 | future is Future ? future : future.then((v) => v as T); 23 | 24 | @override 25 | Stream asStream() => _future.asStream(); 26 | 27 | @override 28 | Future catchError(Function onError, {bool Function(Object error)? test}) => 29 | _future.catchError(onError, test: test); 30 | 31 | @override 32 | Future then(FutureOr Function(T) onValue, {Function? onError}) => 33 | _future.then(onValue, onError: onError); 34 | 35 | @override 36 | Future whenComplete(FutureOr Function() action) => 37 | _future.whenComplete(action); 38 | 39 | @override 40 | Future timeout(Duration timeLimit, {FutureOr Function()? onTimeout}) => 41 | _future.timeout(timeLimit, onTimeout: onTimeout); 42 | } 43 | -------------------------------------------------------------------------------- /pkgs/crypto/lib/src/digest.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:typed_data'; 6 | 7 | /// A message digest as computed by a `Hash` or `HMAC` function. 8 | class Digest { 9 | /// The message digest as an array of bytes. 10 | final List bytes; 11 | 12 | Digest(this.bytes); 13 | 14 | /// Returns whether this is equal to another digest. 15 | /// 16 | /// This should be used instead of manual comparisons to avoid leaking 17 | /// information via timing. 18 | @override 19 | bool operator ==(Object other) { 20 | if (other is Digest) { 21 | final a = bytes; 22 | final b = other.bytes; 23 | final n = a.length; 24 | if (n != b.length) { 25 | return false; 26 | } 27 | var mismatch = 0; 28 | for (var i = 0; i < n; i++) { 29 | mismatch |= a[i] ^ b[i]; 30 | } 31 | return mismatch == 0; 32 | } 33 | return false; 34 | } 35 | 36 | @override 37 | int get hashCode => Object.hashAll(bytes); 38 | 39 | /// The message digest as a string of hexadecimal digits. 40 | @override 41 | String toString() => _hexEncode(bytes); 42 | } 43 | 44 | String _hexEncode(List bytes) { 45 | const hexDigits = '0123456789abcdef'; 46 | var charCodes = Uint8List(bytes.length * 2); 47 | for (var i = 0, j = 0; i < bytes.length; i++) { 48 | var byte = bytes[i]; 49 | charCodes[j++] = hexDigits.codeUnitAt((byte >> 4) & 0xF); 50 | charCodes[j++] = hexDigits.codeUnitAt(byte & 0xF); 51 | } 52 | return String.fromCharCodes(charCodes); 53 | } 54 | -------------------------------------------------------------------------------- /pkgs/path/test/utils.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:path/path.dart' as p; 6 | import 'package:test/test.dart'; 7 | 8 | /// A matcher for a closure that throws a [p.PathException]. 9 | final throwsPathException = throwsA(const TypeMatcher()); 10 | 11 | void expectEquals(p.Context context, String path1, String path2) { 12 | expect( 13 | context.equals(path1, path2), 14 | isTrue, 15 | reason: 'Expected "$path1" to equal "$path2".', 16 | ); 17 | expect( 18 | context.equals(path2, path1), 19 | isTrue, 20 | reason: 'Expected "$path2" to equal "$path1".', 21 | ); 22 | expect( 23 | context.hash(path1), 24 | equals(context.hash(path2)), 25 | reason: 'Expected "$path1" to hash the same as "$path2".', 26 | ); 27 | } 28 | 29 | void expectNotEquals( 30 | p.Context context, 31 | String path1, 32 | String path2, { 33 | bool allowSameHash = false, 34 | }) { 35 | expect( 36 | context.equals(path1, path2), 37 | isFalse, 38 | reason: 'Expected "$path1" not to equal "$path2".', 39 | ); 40 | expect( 41 | context.equals(path2, path1), 42 | isFalse, 43 | reason: 'Expected "$path2" not to equal "$path1".', 44 | ); 45 | 46 | // Hash collisions are allowed, but the test author should be explicitly aware 47 | // when they occur. 48 | if (allowSameHash) return; 49 | expect( 50 | context.hash(path1), 51 | isNot(equals(context.hash(path2))), 52 | reason: 'Expected "$path1" not to hash the same as "$path2".', 53 | ); 54 | } 55 | -------------------------------------------------------------------------------- /pkgs/collection/lib/src/empty_unmodifiable_set.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:collection'; 6 | 7 | import 'unmodifiable_wrappers.dart'; 8 | import 'wrappers.dart'; 9 | 10 | /// An unmodifiable, empty set which can be constant. 11 | class EmptyUnmodifiableSet extends IterableBase 12 | with UnmodifiableSetMixin 13 | implements UnmodifiableSetView { 14 | const EmptyUnmodifiableSet(); 15 | 16 | @override 17 | Iterator get iterator => Iterable.empty().iterator; 18 | @override 19 | int get length => 0; 20 | @override 21 | EmptyUnmodifiableSet cast() => EmptyUnmodifiableSet(); 22 | @override 23 | bool contains(Object? element) => false; 24 | @override 25 | bool containsAll(Iterable other) => other.isEmpty; 26 | @override 27 | Iterable followedBy(Iterable other) => DelegatingIterable(other); 28 | @override 29 | E? lookup(Object? element) => null; 30 | @Deprecated('Use cast instead') 31 | @override 32 | EmptyUnmodifiableSet retype() => EmptyUnmodifiableSet(); 33 | @override 34 | E singleWhere(bool Function(E) test, {E Function()? orElse}) => 35 | orElse != null ? orElse() : throw StateError('No element'); 36 | @override 37 | Iterable whereType() => Iterable.empty(); 38 | @override 39 | Set toSet() => {}; 40 | @override 41 | Set union(Set other) => Set.of(other); 42 | @override 43 | Set intersection(Set other) => {}; 44 | @override 45 | Set difference(Set other) => {}; 46 | } 47 | -------------------------------------------------------------------------------- /pkgs/convert/lib/src/utils.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'charcodes.dart'; 6 | 7 | /// Returns the digit (0 through 15) corresponding to the hexadecimal code unit 8 | /// at index [index] in [codeUnits]. 9 | /// 10 | /// If the given code unit isn't valid hexadecimal, throws a [FormatException]. 11 | int digitForCodeUnit(List codeUnits, int index) { 12 | // If the code unit is a numeral, get its value. XOR works because 0 in ASCII 13 | // is `0b110000` and the other numerals come after it in ascending order and 14 | // take up at most four bits. 15 | // 16 | // We check for digits first because it ensures there's only a single branch 17 | // for 10 out of 16 of the expected cases. We don't count the `digit >= 0` 18 | // check because branch prediction will always work on it for valid data. 19 | var codeUnit = codeUnits[index]; 20 | var digit = $0 ^ codeUnit; 21 | if (digit <= 9) { 22 | if (digit >= 0) return digit; 23 | } else { 24 | // If the code unit is an uppercase letter, convert it to lowercase. This 25 | // works because uppercase letters in ASCII are exactly `0b100000 = 0x20` 26 | // less than lowercase letters, so if we ensure that that bit is 1 we ensure 27 | // that the letter is lowercase. 28 | var letter = 0x20 | codeUnit; 29 | if ($a <= letter && letter <= $f) return letter - $a + 10; 30 | } 31 | 32 | throw FormatException( 33 | 'Invalid hexadecimal code unit ' 34 | "U+${codeUnit.toRadixString(16).padLeft(4, '0')}.", 35 | codeUnits, 36 | index, 37 | ); 38 | } 39 | -------------------------------------------------------------------------------- /pkgs/async/lib/src/delegate/stream_sink.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | /// Simple delegating wrapper around a [StreamSink]. 8 | /// 9 | /// Subclasses can override individual methods, or use this to expose only the 10 | /// [StreamSink] methods of a subclass. 11 | class DelegatingStreamSink implements StreamSink { 12 | final StreamSink _sink; 13 | 14 | @override 15 | Future get done => _sink.done; 16 | 17 | /// Create delegating sink forwarding calls to [sink]. 18 | DelegatingStreamSink(StreamSink sink) : _sink = sink; 19 | 20 | DelegatingStreamSink._(this._sink); 21 | 22 | /// Creates a wrapper that coerces the type of [sink]. 23 | /// 24 | /// Unlike [StreamSink.new], this only requires its argument to be an instance 25 | /// of `StreamSink`, not `StreamSink`. This means that calls to [add] may 26 | /// throw a [TypeError] if the argument type doesn't match the reified type of 27 | /// [sink]. 28 | @Deprecated( 29 | 'Use StreamController(sync: true)..stream.cast().pipe(sink)', 30 | ) 31 | static StreamSink typed(StreamSink sink) => 32 | sink is StreamSink ? sink : DelegatingStreamSink._(sink); 33 | 34 | @override 35 | void add(T data) { 36 | _sink.add(data); 37 | } 38 | 39 | @override 40 | void addError(Object error, [StackTrace? stackTrace]) { 41 | _sink.addError(error, stackTrace); 42 | } 43 | 44 | @override 45 | Future addStream(Stream stream) => _sink.addStream(stream); 46 | 47 | @override 48 | Future close() => _sink.close(); 49 | } 50 | -------------------------------------------------------------------------------- /pkgs/convert/lib/src/byte_accumulator_sink.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:convert'; 6 | import 'dart:typed_data'; 7 | 8 | import 'package:typed_data/typed_data.dart'; 9 | 10 | /// A sink that provides access to the concatenated bytes passed to it. 11 | /// 12 | /// See also [ByteConversionSink.withCallback]. 13 | class ByteAccumulatorSink extends ByteConversionSinkBase { 14 | /// The bytes accumulated so far. 15 | /// 16 | /// The returned [Uint8List] is viewing a shared buffer, so it should not be 17 | /// changed and any bytes outside the view should not be accessed. 18 | Uint8List get bytes => Uint8List.view(_buffer.buffer, 0, _buffer.length); 19 | 20 | final _buffer = Uint8Buffer(); 21 | 22 | /// Whether [close] has been called. 23 | bool get isClosed => _isClosed; 24 | var _isClosed = false; 25 | 26 | /// Removes all bytes from [bytes]. 27 | /// 28 | /// This can be used to avoid double-processing data. 29 | void clear() { 30 | _buffer.clear(); 31 | } 32 | 33 | @override 34 | void add(List chunk) { 35 | if (_isClosed) { 36 | throw StateError("Can't add to a closed sink."); 37 | } 38 | 39 | _buffer.addAll(chunk); 40 | } 41 | 42 | @override 43 | void addSlice(List chunk, int start, int end, bool isLast) { 44 | if (_isClosed) { 45 | throw StateError("Can't add to a closed sink."); 46 | } 47 | 48 | _buffer.addAll(chunk, start, end); 49 | if (isLast) _isClosed = true; 50 | } 51 | 52 | @override 53 | void close() { 54 | _isClosed = true; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /pkgs/convert/test/string_accumulator_sink_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:convert/convert.dart'; 6 | import 'package:test/test.dart'; 7 | 8 | void main() { 9 | late StringAccumulatorSink sink; 10 | setUp(() { 11 | sink = StringAccumulatorSink(); 12 | }); 13 | 14 | test('provides access to the concatenated string', () { 15 | expect(sink.string, isEmpty); 16 | 17 | sink.add('foo'); 18 | expect(sink.string, equals('foo')); 19 | 20 | sink.addSlice(' bar baz', 1, 4, false); 21 | expect(sink.string, equals('foobar')); 22 | }); 23 | 24 | test('clear() clears the string', () { 25 | sink.add('foo'); 26 | expect(sink.string, equals('foo')); 27 | 28 | sink.clear(); 29 | expect(sink.string, isEmpty); 30 | 31 | sink.add('bar'); 32 | expect(sink.string, equals('bar')); 33 | }); 34 | 35 | test('indicates whether the sink is closed', () { 36 | expect(sink.isClosed, isFalse); 37 | sink.close(); 38 | expect(sink.isClosed, isTrue); 39 | }); 40 | 41 | test('indicates whether the sink is closed via addSlice', () { 42 | expect(sink.isClosed, isFalse); 43 | sink.addSlice('', 0, 0, true); 44 | expect(sink.isClosed, isTrue); 45 | }); 46 | 47 | test("doesn't allow add() to be called after close()", () { 48 | sink.close(); 49 | expect(() => sink.add('x'), throwsStateError); 50 | }); 51 | 52 | test("doesn't allow addSlice() to be called after close()", () { 53 | sink.close(); 54 | expect(() => sink.addSlice('', 0, 0, false), throwsStateError); 55 | }); 56 | } 57 | -------------------------------------------------------------------------------- /pkgs/async/test/single_subscription_transformer_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | import 'package:async/async.dart'; 8 | import 'package:test/test.dart'; 9 | 10 | import 'utils.dart'; 11 | 12 | void main() { 13 | test("buffers events as soon as it's bound", () async { 14 | var controller = StreamController.broadcast(); 15 | var stream = controller.stream.transform( 16 | const SingleSubscriptionTransformer(), 17 | ); 18 | 19 | // Add events before [stream] has a listener to be sure it buffers them. 20 | controller.add(1); 21 | controller.add(2); 22 | await flushMicrotasks(); 23 | 24 | expect(stream.toList(), completion(equals([1, 2, 3, 4]))); 25 | await flushMicrotasks(); 26 | 27 | controller.add(3); 28 | controller.add(4); 29 | controller.close(); 30 | }); 31 | 32 | test( 33 | "cancels the subscription to the broadcast stream when it's canceled", 34 | () async { 35 | var canceled = false; 36 | var controller = StreamController.broadcast( 37 | onCancel: () { 38 | canceled = true; 39 | }, 40 | ); 41 | var stream = controller.stream.transform( 42 | const SingleSubscriptionTransformer(), 43 | ); 44 | await flushMicrotasks(); 45 | expect(canceled, isFalse); 46 | 47 | var subscription = stream.listen(null); 48 | await flushMicrotasks(); 49 | expect(canceled, isFalse); 50 | 51 | subscription.cancel(); 52 | await flushMicrotasks(); 53 | expect(canceled, isTrue); 54 | }, 55 | ); 56 | } 57 | -------------------------------------------------------------------------------- /pkgs/platform/lib/src/interface/local_platform.dart: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | import 'dart:io' as io show Platform, stdin, stdout; 6 | 7 | import 'platform.dart'; 8 | 9 | /// `Platform` implementation that delegates directly to `dart:io`. 10 | class LocalPlatform extends Platform { 11 | /// Creates a new [LocalPlatform]. 12 | const LocalPlatform(); 13 | 14 | @override 15 | int get numberOfProcessors => io.Platform.numberOfProcessors; 16 | 17 | @override 18 | String get pathSeparator => io.Platform.pathSeparator; 19 | 20 | @override 21 | String get operatingSystem => io.Platform.operatingSystem; 22 | 23 | @override 24 | String get operatingSystemVersion => io.Platform.operatingSystemVersion; 25 | 26 | @override 27 | String get localHostname => io.Platform.localHostname; 28 | 29 | @override 30 | Map get environment => io.Platform.environment; 31 | 32 | @override 33 | String get executable => io.Platform.executable; 34 | 35 | @override 36 | String get resolvedExecutable => io.Platform.resolvedExecutable; 37 | 38 | @override 39 | Uri get script => io.Platform.script; 40 | 41 | @override 42 | List get executableArguments => io.Platform.executableArguments; 43 | 44 | @override 45 | String? get packageConfig => io.Platform.packageConfig; 46 | 47 | @override 48 | String get version => io.Platform.version; 49 | 50 | @override 51 | bool get stdinSupportsAnsi => io.stdin.supportsAnsiEscapes; 52 | 53 | @override 54 | bool get stdoutSupportsAnsi => io.stdout.supportsAnsiEscapes; 55 | 56 | @override 57 | String get localeName => io.Platform.localeName; 58 | } 59 | -------------------------------------------------------------------------------- /pkgs/convert/test/byte_accumulator_sink_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:convert/convert.dart'; 6 | import 'package:test/test.dart'; 7 | 8 | void main() { 9 | late ByteAccumulatorSink sink; 10 | setUp(() { 11 | sink = ByteAccumulatorSink(); 12 | }); 13 | 14 | test('provides access to the concatenated bytes', () { 15 | expect(sink.bytes, isEmpty); 16 | 17 | sink.add([1, 2, 3]); 18 | expect(sink.bytes, equals([1, 2, 3])); 19 | 20 | sink.addSlice([4, 5, 6, 7, 8], 1, 4, false); 21 | expect(sink.bytes, equals([1, 2, 3, 5, 6, 7])); 22 | }); 23 | 24 | test('clear() clears the bytes', () { 25 | sink.add([1, 2, 3]); 26 | expect(sink.bytes, equals([1, 2, 3])); 27 | 28 | sink.clear(); 29 | expect(sink.bytes, isEmpty); 30 | 31 | sink.add([4, 5, 6]); 32 | expect(sink.bytes, equals([4, 5, 6])); 33 | }); 34 | 35 | test('indicates whether the sink is closed', () { 36 | expect(sink.isClosed, isFalse); 37 | sink.close(); 38 | expect(sink.isClosed, isTrue); 39 | }); 40 | 41 | test('indicates whether the sink is closed via addSlice', () { 42 | expect(sink.isClosed, isFalse); 43 | sink.addSlice([], 0, 0, true); 44 | expect(sink.isClosed, isTrue); 45 | }); 46 | 47 | test("doesn't allow add() to be called after close()", () { 48 | sink.close(); 49 | expect(() => sink.add([1]), throwsStateError); 50 | }); 51 | 52 | test("doesn't allow addSlice() to be called after close()", () { 53 | sink.close(); 54 | expect(() => sink.addSlice([], 0, 0, false), throwsStateError); 55 | }); 56 | } 57 | -------------------------------------------------------------------------------- /pkgs/collection/test/equality_set_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:collection/collection.dart'; 6 | import 'package:test/test.dart'; 7 | 8 | void main() { 9 | test('uses the given equality', () { 10 | var set = EqualitySet(const IterableEquality()); 11 | expect(set, isEmpty); 12 | 13 | var list1 = [1, 2, 3]; 14 | expect(set.add(list1), isTrue); 15 | expect(set, contains([1, 2, 3])); 16 | expect(set, contains(same(list1))); 17 | 18 | var list2 = [1, 2, 3]; 19 | expect(set.add(list2), isFalse); 20 | expect(set, contains([1, 2, 3])); 21 | expect(set, contains(same(list1))); 22 | expect(set, isNot(contains(same(list2)))); 23 | 24 | var list3 = [2, 3, 4]; 25 | expect(set.add(list3), isTrue); 26 | expect(set, contains(same(list1))); 27 | expect(set, contains(same(list3))); 28 | }); 29 | 30 | test('EqualitySet.from() prefers the lattermost equivalent value', () { 31 | var list1 = [1, 2, 3]; 32 | var list2 = [2, 3, 4]; 33 | var list3 = [1, 2, 3]; 34 | var list4 = [2, 3, 4]; 35 | var list5 = [1, 2, 3]; 36 | var list6 = [1, 2, 3]; 37 | 38 | var set = EqualitySet.from(const IterableEquality(), [ 39 | list1, 40 | list2, 41 | list3, 42 | list4, 43 | list5, 44 | list6, 45 | ]); 46 | 47 | expect(set, contains(same(list1))); 48 | expect(set, contains(same(list2))); 49 | expect(set, isNot(contains(same(list3)))); 50 | expect(set, isNot(contains(same(list4)))); 51 | expect(set, isNot(contains(same(list5)))); 52 | expect(set, isNot(contains(same(list6)))); 53 | }); 54 | } 55 | -------------------------------------------------------------------------------- /pkgs/characters/test/src/unicode_tests.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:characters/src/grapheme_clusters/table.dart'; 6 | 7 | import '../../tool/src/debug_names.dart'; 8 | 9 | export 'unicode_grapheme_tests.dart'; 10 | 11 | /// Readable description of the [expected] grapheme clusters. 12 | /// 13 | /// The list of strings is the expected grapheme cluster separation 14 | /// of the concatenation of those strings. 15 | /// 16 | /// The description converts each code unit to a 4-digit hex number, 17 | /// puts ` × ` between the code units of the same grapheme cluster 18 | /// and ` ÷ ` before, after and between the grapheme clusters. 19 | /// (This is the format of the original Unicode test data, so it 20 | /// can be compared to the original tests.) 21 | String testDescription(List expected) { 22 | var expectedString = expected 23 | .map( 24 | (s) => 25 | s.runes.map((x) => x.toRadixString(16).padLeft(4, '0')).join(' × '), 26 | ) 27 | .join(' ÷ '); 28 | return '÷ $expectedString ÷'; 29 | } 30 | 31 | int categoryOf(int codePoint) { 32 | if (codePoint < 0x10000) return low(codePoint); 33 | var nonBmpOffset = codePoint - 0x10000; 34 | return high(nonBmpOffset >> 10, nonBmpOffset & 0x3ff); 35 | } 36 | 37 | String partCategories(List parts) { 38 | var index = 0; 39 | int posOf(int rune) { 40 | var result = index; 41 | index += rune >= 0xFFFF ? 2 : 1; 42 | return result; 43 | } 44 | 45 | return parts.map((part) { 46 | return part.runes 47 | .map((n) => '#${posOf(n)}:${categoryLongNames[categoryOf(n)]}') 48 | .join(' × '); 49 | }).join(' ÷ '); 50 | } 51 | -------------------------------------------------------------------------------- /pkgs/async/lib/async.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | /// Utilities that expand on the asynchronous features of the `dart:async` 6 | /// library. 7 | /// 8 | /// {@youtube 560 315 https://www.youtube.com/watch?v=r0tHiCjW2w0} 9 | library; 10 | 11 | export 'src/async_cache.dart'; 12 | export 'src/async_memoizer.dart'; 13 | export 'src/byte_collector.dart'; 14 | export 'src/cancelable_operation.dart'; 15 | export 'src/chunked_stream_reader.dart'; 16 | export 'src/delegate/event_sink.dart'; 17 | export 'src/delegate/future.dart'; 18 | export 'src/delegate/sink.dart'; 19 | export 'src/delegate/stream.dart'; 20 | export 'src/delegate/stream_consumer.dart'; 21 | export 'src/delegate/stream_sink.dart'; 22 | export 'src/delegate/stream_subscription.dart'; 23 | export 'src/future_group.dart'; 24 | export 'src/lazy_stream.dart'; 25 | export 'src/null_stream_sink.dart'; 26 | export 'src/restartable_timer.dart'; 27 | export 'src/result/error.dart'; 28 | export 'src/result/future.dart'; 29 | export 'src/result/result.dart'; 30 | export 'src/result/value.dart'; 31 | export 'src/single_subscription_transformer.dart'; 32 | export 'src/sink_base.dart'; 33 | export 'src/stream_closer.dart'; 34 | export 'src/stream_completer.dart'; 35 | export 'src/stream_extensions.dart'; 36 | export 'src/stream_group.dart'; 37 | export 'src/stream_queue.dart'; 38 | export 'src/stream_sink_completer.dart'; 39 | export 'src/stream_sink_extensions.dart'; 40 | export 'src/stream_sink_transformer.dart'; 41 | export 'src/stream_splitter.dart'; 42 | export 'src/stream_subscription_transformer.dart'; 43 | export 'src/stream_zip.dart'; 44 | export 'src/subscription_stream.dart'; 45 | export 'src/typed_stream_transformer.dart'; 46 | -------------------------------------------------------------------------------- /pkgs/async/lib/src/async_memoizer.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | /// A class for running an asynchronous function exactly once and caching its 8 | /// result. 9 | /// 10 | /// An `AsyncMemoizer` is used when some function may be run multiple times in 11 | /// order to get its result, but it only actually needs to be run once for its 12 | /// effect. To memoize the result of an async function, you can create a 13 | /// memoizer outside the function (for example as an instance field if you want 14 | /// to memoize the result of a method), and then wrap the function's body in a 15 | /// call to [runOnce]. 16 | /// 17 | /// This is useful for methods like `close()` and getters that need to do 18 | /// asynchronous work. For example: 19 | /// 20 | /// ```dart 21 | /// class SomeResource { 22 | /// final _closeMemo = AsyncMemoizer(); 23 | /// 24 | /// Future close() => _closeMemo.runOnce(() { 25 | /// // ... 26 | /// }); 27 | /// } 28 | /// ``` 29 | class AsyncMemoizer { 30 | /// The future containing the method's result. 31 | /// 32 | /// This can be accessed at any time, and will fire once [runOnce] is called. 33 | Future get future => _completer.future; 34 | final _completer = Completer(); 35 | 36 | /// Whether [runOnce] has been called yet. 37 | bool get hasRun => _completer.isCompleted; 38 | 39 | /// Runs the function, [computation], if it hasn't been run before. 40 | /// 41 | /// If [runOnce] has already been called, this returns the original result. 42 | Future runOnce(FutureOr Function() computation) { 43 | if (!hasRun) _completer.complete(Future.sync(computation)); 44 | return future; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /pkgs/characters/tool/src/graph.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | /// An asymmetric weighted complete graph. 6 | /// 7 | /// The vertices are identified by numbers 0 through [vertexCount] - 1. 8 | /// Edges are pairs of vertices. 9 | class Graph { 10 | /// Number of vertices. 11 | final int vertexCount; 12 | 13 | /// Table of weights, a list of length `vertexCount`*`vertexCount`. 14 | final List _table; 15 | 16 | /// Creates a new complete graph with [vertexCount] vertices. 17 | /// 18 | /// The initial weights on all edges are [initialWeight]. 19 | Graph(this.vertexCount, [int initialWeight = 0]) 20 | : _table = List.filled(vertexCount * vertexCount, initialWeight); 21 | 22 | /// Update the weight on the edges from [fromVertex] to [toVertex]. 23 | void setWeight(int fromVertex, int toVertex, int newWeight) { 24 | _table[fromVertex * vertexCount + toVertex] = newWeight; 25 | } 26 | 27 | /// The weight of the edge from [fromVertex] to [toVertex]. 28 | int weight(int fromVertex, int toVertex) => 29 | _table[fromVertex * vertexCount + toVertex]; 30 | 31 | /// The cumulative weight of the (sub-)path from `path[from]` to `path[to]`. 32 | /// 33 | /// If [to] is less than [from], the sub-path is traversed in reverse. 34 | /// The values in `path` should be vertices in this graph. 35 | int pathWeight(List path, int from, int to) { 36 | var weight = 0; 37 | var cursor = path[from]; 38 | var step = from <= to ? 1 : -1; 39 | for (var i = from; i != to;) { 40 | i += step; 41 | var next = path[i]; 42 | weight += this.weight(cursor, next); 43 | cursor = next; 44 | } 45 | return weight; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /pkgs/path/test/path_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:path/path.dart' as path; 6 | import 'package:test/test.dart'; 7 | 8 | void main() { 9 | group('path.Style', () { 10 | test('name', () { 11 | expect(path.Style.posix.name, 'posix'); 12 | expect(path.Style.windows.name, 'windows'); 13 | }); 14 | 15 | test('separator', () { 16 | // ignore: deprecated_member_use_from_same_package 17 | expect(path.Style.posix.separator, '/'); 18 | // ignore: deprecated_member_use_from_same_package 19 | expect(path.Style.windows.separator, '\\'); 20 | }); 21 | 22 | test('toString()', () { 23 | expect(path.Style.posix.toString(), 'posix'); 24 | expect(path.Style.windows.toString(), 'windows'); 25 | }); 26 | }); 27 | 28 | group('new Context()', () { 29 | test('uses the given current directory', () { 30 | final context = path.Context(current: '/a/b/c'); 31 | expect(context.current, '/a/b/c'); 32 | }); 33 | 34 | test('uses the given style', () { 35 | final context = path.Context(style: path.Style.windows); 36 | expect(context.style, path.Style.windows); 37 | }); 38 | }); 39 | 40 | test('posix is a default Context for the POSIX style', () { 41 | expect(path.posix.style, path.Style.posix); 42 | expect(path.posix.current, '.'); 43 | }); 44 | 45 | test('windows is a default Context for the Windows style', () { 46 | expect(path.windows.style, path.Style.windows); 47 | expect(path.windows.current, '.'); 48 | }); 49 | 50 | test('url is a default Context for the URL style', () { 51 | expect(path.url.style, path.Style.url); 52 | expect(path.url.current, '.'); 53 | }); 54 | } 55 | -------------------------------------------------------------------------------- /pkgs/characters/tool/src/indirect_table.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:typed_data'; 6 | 7 | /// A table with chunks and indirections. 8 | /// 9 | /// Contains a number, one or more, of chunks, 10 | /// and a list of entries which point to entire chunks or parts of chunks. 11 | /// 12 | /// The entries represent sequences of values. 13 | /// Each such sequence is stored in one of the chunks. 14 | /// 15 | /// The main goal of these tools are to go from an initial complete 16 | /// table with one chunk and non-overlapping entries, 17 | /// to a smaller table with one chunk where the entry sequences may overlap. 18 | /// 19 | /// Having multiple chunks is an intermediate step which allows the code 20 | /// to keep the entries consistent during the transformations. 21 | class IndirectTable { 22 | /// Individual chunks. 23 | List chunks; 24 | 25 | /// Position and length of each entry in one of the [chunks]. 26 | List entries; 27 | IndirectTable(this.chunks, this.entries); 28 | } 29 | 30 | class TableEntry { 31 | int chunkNumber; 32 | int start; 33 | int length; 34 | TableEntry(this.chunkNumber, this.start, this.length); 35 | int get end => start + length; 36 | 37 | void update(int chunkNumber, int start, int length) { 38 | this.chunkNumber = chunkNumber; 39 | this.start = start; 40 | this.length = length; 41 | } 42 | 43 | TableEntry copy() => TableEntry(chunkNumber, start, length); 44 | 45 | void copyFrom(TableEntry other) { 46 | chunkNumber = other.chunkNumber; 47 | start = other.start; 48 | length = other.length; 49 | } 50 | 51 | @override 52 | String toString() => 53 | '$chunkNumber[${start.toRadixString(16)}:${end.toRadixString(16)}]'; 54 | } 55 | -------------------------------------------------------------------------------- /pkgs/args/lib/src/help_command.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import '../command_runner.dart'; 6 | 7 | /// The built-in help command that's added to every [CommandRunner]. 8 | /// 9 | /// This command displays help information for the various subcommands. 10 | class HelpCommand extends Command { 11 | @override 12 | final name = 'help'; 13 | 14 | @override 15 | String get description => 16 | 'Display help information for ${runner!.executableName}.'; 17 | 18 | @override 19 | String get invocation => '${runner!.executableName} help [command]'; 20 | 21 | @override 22 | bool get hidden => true; 23 | 24 | @override 25 | Null run() { 26 | // Show the default help if no command was specified. 27 | if (argResults!.rest.isEmpty) { 28 | runner!.printUsage(); 29 | return; 30 | } 31 | 32 | // Walk the command tree to show help for the selected command or 33 | // subcommand. 34 | var commands = runner!.commands; 35 | Command? command; 36 | var commandString = runner!.executableName; 37 | 38 | for (var name in argResults!.rest) { 39 | if (commands.isEmpty) { 40 | command!.usageException( 41 | 'Command "$commandString" does not expect a subcommand.'); 42 | } 43 | 44 | if (commands[name] == null) { 45 | if (command == null) { 46 | runner!.usageException('Could not find a command named "$name".'); 47 | } 48 | 49 | command.usageException( 50 | 'Could not find a subcommand named "$name" for "$commandString".'); 51 | } 52 | 53 | command = commands[name]; 54 | commands = command!.subcommands; 55 | commandString += ' $name'; 56 | } 57 | 58 | command!.printUsage(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /pkgs/async/lib/src/restartable_timer.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | /// A non-periodic timer that can be restarted any number of times. 8 | /// 9 | /// Once restarted (via [reset]), the timer counts down from its original 10 | /// duration again. 11 | class RestartableTimer implements Timer { 12 | /// The duration of the timer. 13 | final Duration _duration; 14 | 15 | /// The callback to call when the timer fires. 16 | final ZoneCallback _callback; 17 | 18 | /// The timer for the current or most recent countdown. 19 | /// 20 | /// This timer is canceled and overwritten every time this [RestartableTimer] 21 | /// is reset. 22 | Timer _timer; 23 | 24 | /// Creates a new timer. 25 | /// 26 | /// The [_callback] function is invoked after the given [_duration]. Unlike a 27 | /// normal non-periodic [Timer], [_callback] may be called more than once. 28 | RestartableTimer(this._duration, this._callback) 29 | : _timer = Timer(_duration, _callback); 30 | 31 | @override 32 | bool get isActive => _timer.isActive; 33 | 34 | /// Restarts the timer so that it counts down from its original duration 35 | /// again. 36 | /// 37 | /// This restarts the timer even if it has already fired or has been canceled. 38 | void reset() { 39 | _timer.cancel(); 40 | _timer = Timer(_duration, _callback); 41 | } 42 | 43 | @override 44 | void cancel() { 45 | _timer.cancel(); 46 | } 47 | 48 | /// The number of durations preceding the most recent timer event on the most 49 | /// recent countdown. 50 | /// 51 | /// Calls to [reset] will also reset the tick so subsequent tick values may 52 | /// not be strictly larger than previous values. 53 | @override 54 | int get tick => _timer.tick; 55 | } 56 | -------------------------------------------------------------------------------- /pkgs/collection/benchmark/deep_collection_equality.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:benchmark_harness/benchmark_harness.dart'; 6 | import 'package:collection/collection.dart'; 7 | 8 | void main() { 9 | for (var unordered in [true, false]) { 10 | DeepCollectionEqualityEqualsBenchmark(unordered).report(); 11 | DeepCollectionEqualityHashBenchmark(unordered).report(); 12 | } 13 | } 14 | 15 | class DeepCollectionEqualityBase extends BenchmarkBase { 16 | final DeepCollectionEquality equality; 17 | 18 | DeepCollectionEqualityBase(bool unordered, String function) 19 | : equality = unordered 20 | ? const DeepCollectionEquality.unordered() 21 | : const DeepCollectionEquality(), 22 | super('DeepCollectionQuality${unordered ? 'Unordered' : ''}.$function'); 23 | } 24 | 25 | class DeepCollectionEqualityHashBenchmark extends DeepCollectionEqualityBase { 26 | DeepCollectionEqualityHashBenchmark(bool unordered) 27 | : super(unordered, 'hash'); 28 | 29 | @override 30 | void run() { 31 | hash = equality.hash(mapA); 32 | } 33 | 34 | static int hash = 0; 35 | } 36 | 37 | class DeepCollectionEqualityEqualsBenchmark extends DeepCollectionEqualityBase { 38 | DeepCollectionEqualityEqualsBenchmark(bool unordered) 39 | : super(unordered, 'equals'); 40 | 41 | @override 42 | void run() { 43 | equals = equality.equals(mapA, mapB); 44 | } 45 | 46 | static bool equals = false; 47 | } 48 | 49 | final mapA = { 50 | for (var i = 0; i < 100; i++) 51 | { 52 | [for (var j = i; j < i + 10; j++) j]: i.isEven ? i : '$i', 53 | }, 54 | }; 55 | 56 | final mapB = { 57 | for (var i = 0; i < 100; i++) 58 | { 59 | [for (var j = i; j < i + 10; j++) j]: i.isEven ? i : '$i', 60 | }, 61 | }; 62 | -------------------------------------------------------------------------------- /pkgs/typed_data/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.4.1-wip 2 | 3 | - Run `dart format` with the new style. 4 | 5 | ## 1.4.0 6 | 7 | * The type of the `buffer` constructor argument to `TypedDataBuffer` is now 8 | `TypeDataList` (instead of `List`). While this is breaking change 9 | statically there was a runtime cast that makes this change a no-op in 10 | practice. 11 | * Require Dart 3.5 12 | * Move to `dart-lang/core` monorepo. 13 | 14 | ## 1.3.2 15 | 16 | * Added package topics to the pubspec file. 17 | * Require Dart 2.17. 18 | 19 | ## 1.3.1 20 | 21 | * Switch to using `package:lints`. 22 | * Populate the pubspec `repository` field. 23 | 24 | ## 1.3.0 25 | 26 | * Stable release for null safety. 27 | * Update SDK constraints to `>=2.12.0-0 <3.0.0` based on beta release 28 | guidelines. 29 | 30 | ## 1.2.0 31 | 32 | * Add typed queue classes such as `Uint8Queue`. These classes implement both 33 | `Queue` and `List` with a highly-efficient typed-data-backed implementation. 34 | Their `sublist()` methods also return typed data classes. 35 | * Update min Dart SDK to `2.4.0`. 36 | 37 | ## 1.1.6 38 | 39 | * Set max SDK version to `<3.0.0`, and adjust other dependencies. 40 | 41 | ## 1.1.5 42 | 43 | * Undo unnecessary SDK version constraint tweak. 44 | 45 | ## 1.1.4 46 | 47 | * Expand the SDK version constraint to include `<2.0.0-dev.infinity`. 48 | 49 | ## 1.1.3 50 | 51 | * Fix all strong-mode warnings. 52 | 53 | ## 1.1.2 54 | 55 | * Fix a bug where `TypedDataBuffer.insertAll` could fail to insert some elements 56 | of an `Iterable`. 57 | 58 | ## 1.1.1 59 | 60 | * Optimize `insertAll` with an `Iterable` argument and no end-point. 61 | 62 | ## 1.1.0 63 | 64 | * Add `start` and `end` parameters to the `addAll()` and `insertAll()` methods 65 | for the typed data buffer classes. These allow efficient concatenation of 66 | slices of existing typed data. 67 | 68 | * Make `addAll()` for typed data buffer classes more efficient for lists, 69 | especially typed data lists. 70 | 71 | ## 1.0.0 72 | 73 | * ChangeLog starts here 74 | -------------------------------------------------------------------------------- /pkgs/collection/lib/src/iterable_zip.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:collection'; 6 | 7 | /// Iterable that iterates over lists of values from other iterables. 8 | /// 9 | /// When [iterator] is read, an [Iterator] is created for each [Iterable] in 10 | /// the [Iterable] passed to the constructor. 11 | /// 12 | /// As long as all these iterators have a next value, those next values are 13 | /// combined into a single list, which becomes the next value of this 14 | /// [Iterable]'s [Iterator]. As soon as any of the iterators run out, 15 | /// the zipped iterator also stops. 16 | class IterableZip extends IterableBase> { 17 | final Iterable> _iterables; 18 | 19 | IterableZip(Iterable> iterables) : _iterables = iterables; 20 | 21 | /// Returns an iterator that combines values of the iterables' iterators 22 | /// as long as they all have values. 23 | @override 24 | Iterator> get iterator { 25 | var iterators = _iterables.map((x) => x.iterator).toList(growable: false); 26 | return _IteratorZip(iterators); 27 | } 28 | } 29 | 30 | class _IteratorZip implements Iterator> { 31 | final List> _iterators; 32 | List? _current; 33 | 34 | _IteratorZip(List> iterators) : _iterators = iterators; 35 | 36 | @override 37 | bool moveNext() { 38 | if (_iterators.isEmpty) return false; 39 | for (var i = 0; i < _iterators.length; i++) { 40 | if (!_iterators[i].moveNext()) { 41 | _current = null; 42 | return false; 43 | } 44 | } 45 | _current = List.generate( 46 | _iterators.length, 47 | (i) => _iterators[i].current, 48 | growable: false, 49 | ); 50 | return true; 51 | } 52 | 53 | @override 54 | List get current => _current ?? (throw StateError('No element')); 55 | } 56 | -------------------------------------------------------------------------------- /.github/workflows/path.yaml: -------------------------------------------------------------------------------- 1 | name: package:path 2 | permissions: read-all 3 | 4 | on: 5 | # Run CI on pushes to the main branch, and on PRs against main. 6 | push: 7 | branches: [ main ] 8 | paths: 9 | - '.github/workflows/path.yaml' 10 | - 'pkgs/path/**' 11 | pull_request: 12 | branches: [ main ] 13 | paths: 14 | - '.github/workflows/path.yaml' 15 | - 'pkgs/path/**' 16 | schedule: 17 | - cron: "0 0 * * 0" 18 | 19 | defaults: 20 | run: 21 | working-directory: pkgs/path/ 22 | 23 | jobs: 24 | # Check code formatting and static analysis on a single OS (linux) 25 | # against Dart dev and stable. 26 | analyze: 27 | runs-on: ubuntu-latest 28 | strategy: 29 | fail-fast: false 30 | matrix: 31 | sdk: [dev] 32 | steps: 33 | - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 34 | - uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c 35 | with: 36 | sdk: ${{ matrix.sdk }} 37 | - id: install 38 | name: Install dependencies 39 | run: dart pub get 40 | - name: Check formatting 41 | run: dart format --output=none --set-exit-if-changed . 42 | if: always() && steps.install.outcome == 'success' 43 | - name: Analyze code 44 | run: dart analyze --fatal-infos 45 | if: always() && steps.install.outcome == 'success' 46 | 47 | test: 48 | needs: analyze 49 | runs-on: ${{ matrix.os }} 50 | strategy: 51 | matrix: 52 | os: [ubuntu-latest] 53 | sdk: [3.4, dev] 54 | steps: 55 | - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 56 | - uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c 57 | with: 58 | sdk: ${{ matrix.sdk }} 59 | - run: dart pub get 60 | - run: dart test --platform vm,chrome 61 | - name: Run Chrome tests - wasm 62 | run: dart test --platform chrome --compiler dart2wasm 63 | if: always() && steps.install.outcome == 'success' 64 | -------------------------------------------------------------------------------- /pkgs/async/lib/src/lazy_stream.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | import 'stream_completer.dart'; 8 | 9 | /// A [Stream] wrapper that forwards to another [Stream] that's initialized 10 | /// lazily. 11 | /// 12 | /// This class allows a concrete `Stream` to be created only once it has a 13 | /// listener. It's useful to wrapping APIs that do expensive computation to 14 | /// produce a `Stream`. 15 | class LazyStream extends Stream { 16 | /// The callback that's called to create the inner stream. 17 | FutureOr> Function()? _callback; 18 | 19 | /// Creates a single-subscription `Stream` that calls [callback] when it gets 20 | /// a listener and forwards to the returned stream. 21 | LazyStream(FutureOr> Function() callback) : _callback = callback { 22 | // Explicitly check for null because we null out [_callback] internally. 23 | if (_callback == null) throw ArgumentError.notNull('callback'); 24 | } 25 | 26 | @override 27 | StreamSubscription listen( 28 | void Function(T)? onData, { 29 | Function? onError, 30 | void Function()? onDone, 31 | bool? cancelOnError, 32 | }) { 33 | var callback = _callback; 34 | if (callback == null) { 35 | throw StateError('Stream has already been listened to.'); 36 | } 37 | 38 | // Null out the callback before we invoke it to ensure that even while 39 | // running it, this can't be called twice. 40 | _callback = null; 41 | var result = callback(); 42 | 43 | Stream stream; 44 | if (result is Future>) { 45 | stream = StreamCompleter.fromFuture(result); 46 | } else { 47 | stream = result; 48 | } 49 | 50 | return stream.listen( 51 | onData, 52 | onError: onError, 53 | onDone: onDone, 54 | cancelOnError: cancelOnError, 55 | ); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /pkgs/async/test/result/result_flattenAll_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | // ignore_for_file: file_names 6 | 7 | import 'package:async/async.dart'; 8 | import 'package:test/test.dart'; 9 | 10 | final someStack = StackTrace.current; 11 | Result res(T n) => Result.value(n); 12 | Result err(int n) => ErrorResult('$n', someStack); 13 | 14 | /// Helper function creating an iterable of results. 15 | Iterable> results( 16 | int count, { 17 | bool Function(int index)? throwWhen, 18 | }) sync* { 19 | for (var i = 0; i < count; i++) { 20 | if (throwWhen != null && throwWhen(i)) { 21 | yield err(i); 22 | } else { 23 | yield res(i); 24 | } 25 | } 26 | } 27 | 28 | void main() { 29 | void expectAll(Result result, Result expectation) { 30 | if (expectation.isError) { 31 | expect(result, expectation); 32 | } else { 33 | expect(result.isValue, true); 34 | expect(result.asValue!.value, expectation.asValue!.value); 35 | } 36 | } 37 | 38 | test('empty', () { 39 | expectAll(Result.flattenAll(results(0)), res([])); 40 | }); 41 | test('single value', () { 42 | expectAll(Result.flattenAll(results(1)), res([0])); 43 | }); 44 | test('single error', () { 45 | expectAll( 46 | Result.flattenAll(results(1, throwWhen: (_) => true)), 47 | err(0), 48 | ); 49 | }); 50 | test('multiple values', () { 51 | expectAll(Result.flattenAll(results(5)), res([0, 1, 2, 3, 4])); 52 | }); 53 | test('multiple errors', () { 54 | expectAll( 55 | Result.flattenAll(results(5, throwWhen: (x) => x.isOdd)), 56 | err(1), 57 | ); // First error is result. 58 | }); 59 | test('error last', () { 60 | expectAll( 61 | Result.flattenAll(results(5, throwWhen: (x) => x == 4)), 62 | err(4), 63 | ); 64 | }); 65 | } 66 | -------------------------------------------------------------------------------- /pkgs/convert/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 3.1.3-wip 2 | 3 | - Run `dart format` with the new style. 4 | 5 | ## 3.1.2 6 | 7 | - Require Dart 3.4 8 | - Add chunked decoding support (`startChunkedConversion`) for `CodePage` 9 | encodings. 10 | - Upper-cast the return type of the decoder from `List` to `Uint8List`. 11 | - Move to `dart-lang/core` monorepo. 12 | 13 | ## 3.1.1 14 | 15 | - Require Dart 2.18 16 | - Fix a number of comment references. 17 | 18 | ## 3.1.0 19 | 20 | - Add a fixed-pattern DateTime formatter. See 21 | [#210](https://github.com/dart-lang/intl/issues/210) in package:intl. 22 | 23 | ## 3.0.2 24 | 25 | - Fix bug in `CodePage` class. See issue 26 | [#47](https://github.com/dart-lang/convert/issues/47). 27 | 28 | ## 3.0.1 29 | 30 | - Dependency clean-up. 31 | 32 | ## 3.0.0 33 | 34 | - Stable null safety release. 35 | - Added `CodePage` class for single-byte `Encoding` implementations. 36 | 37 | ## 2.1.1 38 | 39 | - Fixed a DDC compilation regression for consumers using the Dart 1.x SDK that 40 | was introduced in `2.1.0`. 41 | 42 | ## 2.1.0 43 | 44 | - Added an `IdentityCodec` which implements `Codec` for use as default 45 | value for in functions accepting an optional `Codec` as parameter. 46 | 47 | ## 2.0.2 48 | 49 | - Set max SDK version to `<3.0.0`, and adjust other dependencies. 50 | 51 | ## 2.0.1 52 | 53 | - `PercentEncoder` no longer encodes digits. This follows the specified 54 | behavior. 55 | 56 | ## 2.0.0 57 | 58 | **Note**: No new APIs have been added in 2.0.0. Packages that would use 2.0.0 as 59 | a lower bound should use 1.0.0 instead—for example, `convert: ">=1.0.0 <3.0.0"`. 60 | 61 | - `HexDecoder`, `HexEncoder`, `PercentDecoder`, and `PercentEncoder` no longer 62 | extend `ChunkedConverter`. 63 | 64 | ## 1.1.1 65 | 66 | - Fix all strong-mode warnings. 67 | 68 | ## 1.1.0 69 | 70 | - Add `AccumulatorSink`, `ByteAccumulatorSink`, and `StringAccumulatorSink` 71 | classes for providing synchronous access to the output of chunked converters. 72 | 73 | ## 1.0.1 74 | 75 | - Small improvement in percent decoder efficiency. 76 | 77 | ## 1.0.0 78 | 79 | - Initial version 80 | -------------------------------------------------------------------------------- /pkgs/fixnum/test/int_64_vm_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | @TestOn('vm') 6 | library; 7 | 8 | import 'package:fixnum/fixnum.dart'; 9 | import 'package:test/test.dart'; 10 | 11 | void main() { 12 | group('conversions', () { 13 | test('toInt', () { 14 | expect( 15 | Int64.parseInt('-10000000000000000').toInt(), 16 | same(-10000000000000000), 17 | ); 18 | expect( 19 | Int64.parseInt('-10000000000000001').toInt(), 20 | same(-10000000000000001), 21 | ); 22 | expect( 23 | Int64.parseInt('-10000000000000002').toInt(), 24 | same(-10000000000000002), 25 | ); 26 | expect( 27 | Int64.parseInt('-10000000000000003').toInt(), 28 | same(-10000000000000003), 29 | ); 30 | expect( 31 | Int64.parseInt('-10000000000000004').toInt(), 32 | same(-10000000000000004), 33 | ); 34 | expect( 35 | Int64.parseInt('-10000000000000005').toInt(), 36 | same(-10000000000000005), 37 | ); 38 | expect( 39 | Int64.parseInt('-10000000000000006').toInt(), 40 | same(-10000000000000006), 41 | ); 42 | expect( 43 | Int64.parseInt('-10000000000000007').toInt(), 44 | same(-10000000000000007), 45 | ); 46 | expect( 47 | Int64.parseInt('-10000000000000008').toInt(), 48 | same(-10000000000000008), 49 | ); 50 | }); 51 | }); 52 | 53 | test('', () { 54 | void check(int n) { 55 | // Sign change should commute with conversion. 56 | expect(-Int64(-n), Int64(n)); 57 | expect(Int64(-n), -Int64(n)); 58 | } 59 | 60 | check(10); 61 | check(1000000000000000000); 62 | check(9223372000000000000); // near Int64.MAX_VALUE, has exact double value 63 | check(9223372036854775807); // Int64.MAX_VALUE, rounds up to -MIN_VALUE 64 | check(-9223372036854775808); // Int64.MIN_VALUE 65 | }); 66 | } 67 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to Contribute 2 | 3 | We'd love to accept your patches and contributions to this project. There are 4 | just a few small guidelines you need to follow. 5 | 6 | ## Contributor License Agreement 7 | 8 | Contributions to this project must be accompanied by a Contributor License 9 | Agreement (CLA). You (or your employer) retain the copyright to your 10 | contribution; this simply gives us permission to use and redistribute your 11 | contributions as part of the project. Head over to 12 | to see your current agreements on file or 13 | to sign a new one. 14 | 15 | You generally only need to submit a CLA once, so if you've already submitted one 16 | (even if it was for a different project), you probably don't need to do it 17 | again. 18 | 19 | ## Code Reviews 20 | 21 | All submissions, including submissions by project members, require review. We 22 | use GitHub pull requests for this purpose. Consult 23 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more 24 | information on using pull requests. 25 | 26 | ## Coding style 27 | 28 | The Dart source code in this repo follows the: 29 | 30 | * [Dart style guide](https://dart.dev/guides/language/effective-dart/style) 31 | 32 | You should familiarize yourself with those guidelines. 33 | 34 | ## File headers 35 | 36 | All files in the Dart project must start with the following header; if you add a 37 | new file please also add this. The year should be a single number stating the 38 | year the file was created (don't use a range like "2011-2012"). Additionally, if 39 | you edit an existing file, you shouldn't update the year. 40 | 41 | // Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file 42 | // for details. All rights reserved. Use of this source code is governed by a 43 | // BSD-style license that can be found in the LICENSE file. 44 | 45 | ## Community Guidelines 46 | 47 | This project follows 48 | [Google's Open Source Community Guidelines](https://opensource.google/conduct/). 49 | 50 | We pledge to maintain an open and welcoming environment. For details, see our 51 | [code of conduct](https://dart.dev/code-of-conduct). 52 | -------------------------------------------------------------------------------- /pkgs/characters/third_party/Unicode_Consortium/UNICODE_LICENSE.txt: -------------------------------------------------------------------------------- 1 | UNICODE LICENSE V3 2 | 3 | COPYRIGHT AND PERMISSION NOTICE 4 | 5 | Copyright © 1991-2024 Unicode, Inc. 6 | 7 | NOTICE TO USER: Carefully read the following legal agreement. BY 8 | DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR 9 | SOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE 10 | TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT 11 | DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE. 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a 14 | copy of data files and any associated documentation (the "Data Files") or 15 | software and any associated documentation (the "Software") to deal in the 16 | Data Files or Software without restriction, including without limitation 17 | the rights to use, copy, modify, merge, publish, distribute, and/or sell 18 | copies of the Data Files or Software, and to permit persons to whom the 19 | Data Files or Software are furnished to do so, provided that either (a) 20 | this copyright and permission notice appear with all copies of the Data 21 | Files or Software, or (b) this copyright and permission notice appear in 22 | associated Documentation. 23 | 24 | THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 25 | KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 27 | THIRD PARTY RIGHTS. 28 | 29 | IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE 30 | BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, 31 | OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 32 | WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 33 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA 34 | FILES OR SOFTWARE. 35 | 36 | Except as contained in this notice, the name of a copyright holder shall 37 | not be used in advertising or otherwise to promote the sale, use or other 38 | dealings in these Data Files or Software without prior written 39 | authorization of the copyright holder. 40 | -------------------------------------------------------------------------------- /pkgs/collection/test/ignore_ascii_case_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | /// Tests case-ignoring compare and equality. 6 | library; 7 | 8 | import 'package:collection/collection.dart'; 9 | import 'package:test/test.dart'; 10 | 11 | void main() { 12 | test('equality ignore ASCII case', () { 13 | var strings = [ 14 | '0@`aopz[{', 15 | '0@`aopz[{', 16 | '0@`Aopz[{', 17 | '0@`aOpz[{', 18 | '0@`AOpz[{', 19 | '0@`aoPz[{', 20 | '0@`AoPz[{', 21 | '0@`aOPz[{', 22 | '0@`AOPz[{', 23 | '0@`aopZ[{', 24 | '0@`AopZ[{', 25 | '0@`aOpZ[{', 26 | '0@`AOpZ[{', 27 | '0@`aoPZ[{', 28 | '0@`AoPZ[{', 29 | '0@`aOPZ[{', 30 | '0@`AOPZ[{', 31 | ]; 32 | 33 | for (var s1 in strings) { 34 | for (var s2 in strings) { 35 | var reason = '$s1 =?= $s2'; 36 | expect(equalsIgnoreAsciiCase(s1, s2), true, reason: reason); 37 | expect( 38 | hashIgnoreAsciiCase(s1), 39 | hashIgnoreAsciiCase(s2), 40 | reason: reason, 41 | ); 42 | } 43 | } 44 | 45 | var upperCaseLetters = '@`abcdefghijklmnopqrstuvwxyz[{åÅ'; 46 | var lowerCaseLetters = '@`ABCDEFGHIJKLMNOPQRSTUVWXYZ[{åÅ'; 47 | expect(equalsIgnoreAsciiCase(upperCaseLetters, lowerCaseLetters), true); 48 | 49 | void testChars(String char1, String char2, bool areEqual) { 50 | expect( 51 | equalsIgnoreAsciiCase(char1, char2), 52 | areEqual, 53 | reason: "$char1 ${areEqual ? "=" : "!"}= $char2", 54 | ); 55 | } 56 | 57 | for (var i = 0; i < upperCaseLetters.length; i++) { 58 | for (var j = 0; i < upperCaseLetters.length; i++) { 59 | testChars(upperCaseLetters[i], upperCaseLetters[j], i == j); 60 | testChars(lowerCaseLetters[i], upperCaseLetters[j], i == j); 61 | testChars(upperCaseLetters[i], lowerCaseLetters[j], i == j); 62 | testChars(lowerCaseLetters[i], lowerCaseLetters[j], i == j); 63 | } 64 | } 65 | }); 66 | } 67 | --------------------------------------------------------------------------------