diff --git a/.cirrus.yml b/.cirrus.yml index 3d83be3b41..f159c264fd 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -33,17 +33,14 @@ task: FIREBASE_PUBLIC_TOKEN: ENCRYPTED[37e8b82f167864cae9a3f4d2cf3f37dea331d9375c295327c45de524f6c588fa6f6d63e5784f10f6d43ce29689f36c92] docs_script: ./dev/bots/docs.sh - name: deploy_gallery - only_if: $CIRRUS_BRANCH == 'dev' depends_on: - docs - analyze - - tests-linux - - tool_tests-linux - build_tests-linux env: SHARD: deploy_gallery GOOGLE_DEVELOPER_SERVICE_ACCOUNT_ACTOR_FASTLANE: ENCRYPTED[d9ac1462c3c556fc2f8165c9d5566a16497d8ebc38a50357f7f3abf136b7f83e1d1d76dde36fee356cb0f9ebf7a89346] - ANDROID_GALLERY_UPLOAD_KEY: ENCRYPTED[0b3e681b4507aec433ef29c79b715f15f8c75ecd25315ea286b0b2bcb8b28d578634eead5aa2c54086a25e8da1bb219a] + ANDROID_GALLERY_UPLOAD_KEY: ENCRYPTED[0f2aca35f05b26add5d9edea2a7449341269a2b7e22d5c667f876996e2e8bc44ff1369431ebf73b7c5581fd95d0e5902] test_script: ./dev/bots/deploy_gallery.sh - name: analyze test_script: @@ -118,7 +115,7 @@ task: - bin\flutter.bat update-packages - git fetch origin master test_all_script: - - bin\cache\dart-sdk\bin\dart.exe -c dev\bots\test.dart + - bin\cache\dart-sdk\bin\dart.exe --enable-asserts dev\bots\test.dart matrix: - name: tests-windows env: @@ -144,28 +141,23 @@ task: task: use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true' name: deploy_gallery-macos - only_if: $CIRRUS_BRANCH == 'dev' pub_cache: folder: ~/.pub-cache depends_on: - analyze - - tests-macos - - tool_tests-macos - build_tests-macos - - add2app-macos env: # Name the SDK directory to include a space so that we constantly # test path names with spaces in them. CIRRUS_WORKING_DIR: "/tmp/flutter sdk" SHARD: deploy_gallery + # Apple Fastlane password. + FASTLANE_PASSWORD: ENCRYPTED[4b1f0b8d52874e9de965acd46c79743f3b81f3a513614179b9be7cf53dc8258753e257bdadb11a298ee455259df21865] + # Private repo for publishing certificates. + PUBLISHING_MATCH_CERTIFICATE_REPO: ENCRYPTED[3c0e78877d933fc80107aa6f3790fd1cf927250b852d6cb53202be696b4903ed8ca839b809626aaf18050bf7e436fab7] + PUBLISHING_MATCH_REPO_TOKEN: ENCRYPTED[3d1230b744c6ed6c788a91bec741b769401dbcd426b18f9af8080bfeefdfc21913ca4047980c5b5b7ce823f12e7b6b19] # Apple Certificates Match Passphrase MATCH_PASSWORD: ENCRYPTED[db07f252234397090e3ec59152d9ec1831f5ecd0ef97d247b1dca757bbb9ef9b7c832a39bce2caf1949ccdf097e59a73] - # Apple Fastlane password, ASP, and Session information. - FASTLANE_PASSWORD: ENCRYPTED[0bf9bb0cc2cb32a0ed18470cf2c9df0f587cce5f8b04adbd6cff15ca5bde7a74f721ee580227b132ab6b032f08e52ae0] - FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: ENCRYPTED[b219cc13c757f36cb62bfca5102d6115f1cc283aeb974f20c657bc4991c0cc144e30cf5d8183e41cc1df1668b4d14210] - FASTLANE_SESSION: ENCRYPTED[88246e355e55cd5e361a575f5d5b762f5826cb9d5285cb93a263b1cad04ec09bdedb1cbd74df5ec02d6043360fa04acd] - # Private repo for publishing certificates. - PUBLISHING_MATCH_CERTIFICATE_REPO: git@github.com:flutter/private_publishing_certificates.git osx_instance: image: mojave-xcode-10.1 # occasionally the clock on these machines is out of sync diff --git a/.github/ISSUE_TEMPLATE/ACTIVATION.md b/.github/ISSUE_TEMPLATE/ACTIVATION.md index 3fbe21c746..c438b36052 100644 --- a/.github/ISSUE_TEMPLATE/ACTIVATION.md +++ b/.github/ISSUE_TEMPLATE/ACTIVATION.md @@ -10,13 +10,13 @@ about: You have run into problems while downloading or installing Flutter, or th If you are looking for support, please check out our documentation or consider asking a question on Stack Overflow: - * https://flutter.io/ + * https://flutter.dev/ * https://docs.flutter.io/ * https://stackoverflow.com/questions/tagged/flutter?sort=frequent If you have found a bug or if our documentation doesn't have an answer to what you're looking for, then fill our the template below. Please read - our guide to filing a bug first: https://flutter.io/bug-reports/ + our guide to filing a bug first: https://flutter.dev/bug-reports/ --> ## Steps to Reproduce diff --git a/.github/ISSUE_TEMPLATE/BUG.md b/.github/ISSUE_TEMPLATE/BUG.md index c5dc70f408..aa8a8e7ca5 100644 --- a/.github/ISSUE_TEMPLATE/BUG.md +++ b/.github/ISSUE_TEMPLATE/BUG.md @@ -9,13 +9,13 @@ about: You are writing an application with Flutter but the application is crashi If you are looking for support, please check out our documentation or consider asking a question on Stack Overflow: - * https://flutter.io/ + * https://flutter.dev/ * https://docs.flutter.io/ * https://stackoverflow.com/questions/tagged/flutter?sort=frequent If you have found a bug or if our documentation doesn't have an answer to what you're looking for, then fill our the template below. Please read - our guide to filing a bug first: https://flutter.io/bug-reports/ + our guide to filing a bug first: https://flutter.dev/bug-reports/ --> ## Steps to Reproduce diff --git a/.github/ISSUE_TEMPLATE/SUPPORT.md b/.github/ISSUE_TEMPLATE/SUPPORT.md index 82d2b542f1..6ac0badb37 100644 --- a/.github/ISSUE_TEMPLATE/SUPPORT.md +++ b/.github/ISSUE_TEMPLATE/SUPPORT.md @@ -8,7 +8,7 @@ about: You have a question for how to achieve a particular effect, or you need h diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3f125ce8bb..5515c8c2a6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -21,7 +21,7 @@ our trust and demonstrated a commitment to Flutter. This document focuses on what is needed to contribute by writing code and submitting pull requests for the Flutter framework. For information on contributing in other ways, see [the community page -on flutter.io](https://flutter.io/community). +on flutter.dev](https://flutter.dev/community). Developing for Flutter ---------------------- @@ -50,17 +50,17 @@ presented. which describes the steps you need to configure your computer to work on Flutter's framework. Flutter's framework uses mainly Dart. -4. [Tree hygiene](https://github.com/flutter/flutter/wiki/Tree-hygiene), +5. [Tree hygiene](https://github.com/flutter/flutter/wiki/Tree-hygiene), which covers how to land a PR, how to do code review, how to handle breaking changes, how to handle regressions, and how to handle post-commit test failures. -3. [Issue hygiene](https://github.com/flutter/flutter/wiki/Issue-hygiene), +6. [Issue hygiene](https://github.com/flutter/flutter/wiki/Issue-hygiene), which covers our processes around triaging bugs, escalating high priority bugs, assigning bugs, and our GitHub labels and milestones. -5. [Our style guide](https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo), +7. [Our style guide](https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo), which includes advice for designing APIs for Flutter, and how to format code in the framework. diff --git a/README.md b/README.md index cf919a3dbc..868a291341 100644 --- a/README.md +++ b/README.md @@ -1,107 +1,62 @@ -# Flutter ![Flutter logo][] +# [![Flutter logo][]][flutter.dev] -[![Gitter Channel][]][Gitter badge] [![Build Status - Cirrus][]][Build status] +[![Gitter Channel][]][Gitter badge] -# Build beautiful native apps in record time +Flutter is Google's mobile app SDK for crafting high-quality native interfaces +on iOS and Android in record time. Flutter works with existing code, is used by +developers and organizations around the world, and is free and open source. -Flutter is Google’s mobile app SDK for crafting high-quality native interfaces on iOS and Android in record time. Flutter works with existing code, is used by developers and organizations around the world, and is free and open source. +## Documentation -### Documentation - -**Main site: [flutter.dev][]** -* [Install](https://flutter.dev/get-started/install/) -* [Get started](https://flutter.dev/get-started/) -* [API documentation](https://docs.flutter.dev/) -* [Changelog](https://github.com/flutter/flutter/wiki/Changelog) -* [How to contribute](https://github.com/flutter/flutter/blob/master/CONTRIBUTING.md) +* [Install Flutter](https://flutter.dev/get-started/) +* [Flutter documentation](https://flutter.dev/docs) +* [Development wiki](https://github.com/flutter/flutter/wiki) +* [Contributing to Flutter](https://github.com/flutter/flutter/blob/master/CONTRIBUTING.md) For announcements about new releases and breaking changes, follow the [flutter-announce@googlegroups.com](https://groups.google.com/forum/#!forum/flutter-announce) mailing list. -## Fast development +## About Flutter -Flutter's hot reload helps you quickly -and easily experiment, build UIs, add features, and fix -bugs. Experience sub-second reload times, -without losing state, on -emulators, simulators, and hardware for iOS -and Android. +We think Flutter will help you create beautiful, fast apps, with a productive, +extensible and open development model. -Make a change in your code, and your app changes instantly. +### Beautiful apps -## Expressive and flexible UI -Quickly ship features with a focus on native end-user experiences. -Layered architecture allows full customization, which results in incredibly -fast rendering and expressive and flexible designs. +We want to enable designers to deliver their full creative vision without being +forced to water it down due to limitations of the underlying framework. +Flutter's [layered architecture] gives you control over every pixel on the +screen, and its powerful compositing capabilities let you overlay and animate +graphics, video, text and controls without limitation. Flutter includes a full +[set of widgets][widget catalog] that deliver pixel-perfect experiences on both +iOS and Android. -Delight your users with Flutter's built-in -beautiful Material Design and -Cupertino (iOS-flavor) widgets, rich motion APIs, -smooth natural scrolling, and platform awareness. +![Reflectly hero image][Reflectly hero image] -[Brand-first shopping design](https://github.com/flutter/flutter/tree/master/examples/flutter_gallery/lib/demo/animation) -Fitness app design +### Fast apps -[Contact app design](https://github.com/flutter/flutter/blob/master/examples/flutter_gallery/lib/demo/contacts_demo.dart) -[iOS chat app design](https://codelabs.developers.google.com/codelabs/flutter/) +Flutter is fast. It's powered by the same hardware-accelerated [Skia] 2D +graphics library that underpins Chrome and Android. We architected Flutter to +support glitch-free, jank-free graphics at the native speed of your device. +Flutter code is powered by the world-class [Dart platform], which enables +compilation to native 32-bit and 64-bit ARM code for iOS and Android. -Browse the widget catalog. +### Productive development -## Modern, reactive framework +Flutter offers stateful hot reload, allowing you to make changes to your code +and see the results instantly without restarting your app or losing its state. -Easily compose your UI with Flutter's -modern functional-reactive framework and -rich set of platform, layout, and foundation widgets. -Solve your tough UI challenges with -powerful and flexible APIs for 2D, animation, gestures, -effects, and more. +[![Hot reload animation][]][Hot reload] -```dart -class CounterState extends State { - int counter = 0; +### Extensible and open model - void increment() { - // Tells the Flutter framework that state has changed, - // so the framework can run build() and update the display. - setState(() { - counter++; - }); - } - - Widget build(BuildContext context) { - // This method is rerun every time setState is called. - // The Flutter framework has been optimized to make rerunning - // build methods fast, so that you can just rebuild anything that - // needs updating rather than having to individually change - // instances of widgets. - return Row( - children: [ - RaisedButton( - onPressed: increment, - child: Text('Increment'), - ), - Text('Count: $counter'), - ], - ); - } -} -``` - -Browse the widget catalog -and learn more about the -functional-reactive framework. - -## Access native features and SDKs - -Make your app come to life -with platform APIs, 3rd party SDKs, -and native code. -Flutter lets you reuse your existing Java/Kotlin and ObjC/Swift code, -and access native features and SDKs on Android and iOS. - -Accessing platform features is easy. Here is a snippet from our interop example: +Flutter works with any development tool, but includes editor plug-ins for both +[Visual Studio Code] and [IntelliJ / Android Studio]. Flutter provides +[thousands of packages][Flutter packages] to speed your development, regardless +of your target platform. And accessing platform features is easy. Here is a +snippet from our [interop example]: ```dart Future getBatteryLevel() async { @@ -118,35 +73,24 @@ Future getBatteryLevel() async { } ``` -Learn how to use packages or -write platform channels -to access native code, APIs, and SDKs. - -## Unified app development - -Flutter has the tools and libraries to help you easily -bring your ideas to life on iOS and Android. -If you don't have any mobile development experience, Flutter -is an easy and fast way to build beautiful mobile apps. -If you are an experienced iOS or Android developer, -you can use Flutter for your views and leverage much of your -existing Java/Kotlin/ObjC/Swift investment. - -Learn more about what makes Flutter special in the -technical overview. - -# More resources - -Join us in our [Gitter chat room](https://gitter.im/flutter/flutter) or join our public mailing list, -[flutter-dev@googlegroups.com](https://groups.google.com/forum/#!forum/flutter-dev). - -# How to contribute - -To join the team working on Flutter, see our [contributor guide](CONTRIBUTING.md). +Flutter is a fully open source project, and we welcome contributions. +Information on how to get started can be found at our +[contributor guide](CONTRIBUTING.md). +[Flutter logo]: https://flutter.dev/assets/flutter-lockup-4cb0ee072ab312e59784d9fbf4fb7ad42688a7fdaea1270ccf6bbf4f34b7e03f.svg +[flutter.dev]: https://flutter.dev [Build Status - Cirrus]: https://api.cirrus-ci.com/github/flutter/flutter.svg [Build status]: https://cirrus-ci.com/github/flutter/flutter/master -[flutter.dev]: https://flutter.dev -[Flutter logo]: https://github.com/dart-lang/site-shared/blob/master/src/_assets/image/flutter/icon/64.png?raw=1 [Gitter Channel]: https://badges.gitter.im/flutter/flutter.svg -[Gitter badge]: https://gitter.im/flutter/flutter?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge \ No newline at end of file +[Gitter badge]: https://gitter.im/flutter/flutter?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge +[layered architecture]: https://flutter.dev/docs/resources/inside-flutter +[widget catalog]: https://flutter.dev/widgets/ +[Reflectly hero image]: https://github.com/flutter/website/blob/master/src/images/homepage/reflectly-hero-600px.png +[Skia]: https://skia.org/ +[Dart platform]: https://www.dartlang.org/ +[Hot reload animation]: https://raw.githubusercontent.com/flutter/website/master/src/_assets/image/tools/android-studio/hot-reload.gif +[Hot reload]: https://flutter.dev/docs/development/tools/hot-reload +[Visual Studio Code]: https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter +[IntelliJ / Android Studio]: https://plugins.jetbrains.com/plugin/9212-flutter +[Flutter packages]: https://pub.dartlang.org/flutter +[interop example]: https://github.com/flutter/flutter/tree/master/examples/platform_channel \ No newline at end of file diff --git a/bin/flutter b/bin/flutter index 178994f56d..18bad48710 100755 --- a/bin/flutter +++ b/bin/flutter @@ -41,11 +41,11 @@ function _rmlock () { function retry_upgrade { local total_tries="10" - local remaining_tries=$(($total_tries - 1)) - while [[ "$remaining_tries" > 0 ]]; do + local remaining_tries=$((total_tries - 1)) + while [[ "$remaining_tries" -gt 0 ]]; do (cd "$FLUTTER_TOOLS_DIR" && "$PUB" upgrade "$VERBOSITY") && break echo "Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... ($remaining_tries tries left)" - remaining_tries=$(($remaining_tries - 1)) + remaining_tries=$((remaining_tries - 1)) sleep 5 done @@ -102,6 +102,12 @@ function upgrade_flutter () { fi local revision="$(cd "$FLUTTER_ROOT"; git rev-parse HEAD)" + + # Invalidate cache if: + # * SNAPSHOT_PATH is not a file, or + # * STAMP_PATH is not a file with nonzero size, or + # * Contents of STAMP_PATH is not our local git HEAD revision, or + # * pubspec.yaml last modified after pubspec.lock if [[ ! -f "$SNAPSHOT_PATH" || ! -s "$STAMP_PATH" || "$(cat "$STAMP_PATH")" != "$revision" || "$FLUTTER_TOOLS_DIR/pubspec.yaml" -nt "$FLUTTER_TOOLS_DIR/pubspec.lock" ]]; then rm -f "$FLUTTER_ROOT/version" touch "$FLUTTER_ROOT/bin/cache/.dartignore" @@ -121,7 +127,7 @@ function upgrade_flutter () { retry_upgrade - "$DART" --snapshot="$SNAPSHOT_PATH" --snapshot-kind=app-jit --packages="$FLUTTER_TOOLS_DIR/.packages" "$SCRIPT_PATH" training + "$DART" $FLUTTER_TOOL_ARGS --snapshot="$SNAPSHOT_PATH" --packages="$FLUTTER_TOOLS_DIR/.packages" "$SCRIPT_PATH" echo "$revision" > "$STAMP_PATH" fi # The exit here is duplicitous since the function is run in a subshell, diff --git a/bin/flutter.bat b/bin/flutter.bat index 7aa7020c2b..4547692f87 100644 --- a/bin/flutter.bat +++ b/bin/flutter.bat @@ -152,7 +152,11 @@ GOTO :after_subroutine POPD - "%dart%" --snapshot="%snapshot_path%" --snapshot-kind=app-jit --packages="%flutter_tools_dir%\.packages" "%script_path%" + IF "%FLUTTER_TOOL_ARGS%" == "" ( + "%dart%" --snapshot="%snapshot_path%" --packages="%flutter_tools_dir%\.packages" "%script_path%" + ) else ( + "%dart%" "%FLUTTER_TOOL_ARGS%" --snapshot="%snapshot_path%" --packages="%flutter_tools_dir%\.packages" "%script_path%" + ) IF "%ERRORLEVEL%" NEQ "0" ( ECHO Error: Unable to create dart snapshot for flutter tool. SET exit_code=%ERRORLEVEL% diff --git a/bin/internal/engine.version b/bin/internal/engine.version index 3f047b14fd..1267d857a6 100644 --- a/bin/internal/engine.version +++ b/bin/internal/engine.version @@ -1 +1 @@ -0d83a2ecd1bb78f8e1f0ed9719ff3751cdfdd064 +7d1da567434a820853ed6fae1f6ed65b9de5ba4f diff --git a/bin/internal/goldens.version b/bin/internal/goldens.version index 3100f32ba6..acb3aae6dc 100644 --- a/bin/internal/goldens.version +++ b/bin/internal/goldens.version @@ -1 +1 @@ -894e9634cda6eb940d1ad4efb20b63a174bb7797 +3048ed023e5cc1d8e201f7abbba346e73cf5fa2c diff --git a/bin/internal/update_dart_sdk.ps1 b/bin/internal/update_dart_sdk.ps1 index 99eb647271..c64be58f44 100644 --- a/bin/internal/update_dart_sdk.ps1 +++ b/bin/internal/update_dart_sdk.ps1 @@ -28,7 +28,7 @@ $psMajorVersionRequired = 5 $psMajorVersionLocal = $PSVersionTable.PSVersion.Major if ($psMajorVersionLocal -lt $psMajorVersionRequired) { Write-Host "Flutter requires PowerShell $psMajorVersionRequired.0 or newer." - Write-Host "See https://flutter.io/docs/get-started/install/windows for more." + Write-Host "See https://flutter.dev/docs/get-started/install/windows for more." return } diff --git a/bin/internal/update_dart_sdk.sh b/bin/internal/update_dart_sdk.sh index 999576c178..761886fd98 100755 --- a/bin/internal/update_dart_sdk.sh +++ b/bin/internal/update_dart_sdk.sh @@ -74,7 +74,7 @@ if [ ! -f "$ENGINE_STAMP" ] || [ "$ENGINE_VERSION" != `cat "$ENGINE_STAMP"` ]; t echo echo "Failed to retrieve the Dart SDK from: $DART_SDK_URL" echo "If you're located in China, please see this page:" - echo " https://flutter.io/community/china" + echo " https://flutter.dev/community/china" echo rm -f -- "$DART_SDK_ZIP" exit 1 diff --git a/dev/automated_tests/flutter_test/exception_handling_expectation.txt b/dev/automated_tests/flutter_test/exception_handling_expectation.txt index a7ec74b22a..18da868e75 100644 --- a/dev/automated_tests/flutter_test/exception_handling_expectation.txt +++ b/dev/automated_tests/flutter_test/exception_handling_expectation.txt @@ -8,8 +8,8 @@ When the exception was thrown, this was the stack: #1 .+ \(package:flutter_test[/\\]src[/\\]widget_tester\.dart:[0-9]+:[0-9]+\) <> -^\(elided [0-9]+ .+\)$ - +^\(elided [0-9]+ frames.+$ +<> The test description was: Exception handling in test harness - string ════════════════════════════════════════════════════════════════════════════════════════════════════ @@ -27,8 +27,8 @@ When the exception was thrown, this was the stack: #1 .+ \(package:flutter_test[/\\]src[/\\]widget_tester\.dart:[0-9]+:[0-9]+\) <> -^\(elided [0-9]+ .+\)$ - +^\(elided [0-9]+ .+$ +<> The test description was: Exception handling in test harness - FlutterError ════════════════════════════════════════════════════════════════════════════════════════════════════ @@ -49,8 +49,8 @@ When the exception was thrown, this was the stack: #[0-9]+ +.+ \(package:flutter_test[/\\]src[/\\]binding.dart:[0-9]+:[0-9]+\) #[0-9]+ +.+ \(package:flutter_test[/\\]src[/\\]widget_tester\.dart:[0-9]+:[0-9]+\) <> -^\(elided [0-9]+ .+\)$ - +^\(elided [0-9]+ .+$ +<> The test description was: Exception handling in test harness - uncaught Future error ════════════════════════════════════════════════════════════════════════════════════════════════════ diff --git a/dev/automated_tests/pubspec.yaml b/dev/automated_tests/pubspec.yaml index 116f819896..1ff3dee217 100644 --- a/dev/automated_tests/pubspec.yaml +++ b/dev/automated_tests/pubspec.yaml @@ -9,29 +9,26 @@ dependencies: sdk: flutter flutter_test: sdk: flutter - test: 1.5.3 + test: 1.6.1 - analyzer: 0.35.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + analyzer: 0.35.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" args: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - front_end: 0.1.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + front_end: 0.1.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - html: 0.13.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http: 0.12.0+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 2.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 0.3.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - json_rpc_2: 2.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - kernel: 0.3.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + json_rpc_2: 2.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + kernel: 0.3.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 0.9.6+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" multi_server_socket: 1.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -40,32 +37,30 @@ dependencies: package_resolver: 1.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - plugin: 0.2.0+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - quiver: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + quiver: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf: 0.7.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf_web_socket: 0.2.2+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf_web_socket: 0.2.2+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_map_stack_trace: 1.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_maps: 0.10.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_core: 0.2.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_core: 0.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - utf: 0.9.0+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vector_math: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - vm_service_client: 0.2.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + vm_service_client: 0.2.6+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 0.9.7+10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - web_socket_channel: 1.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + web_socket_channel: 1.0.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" flutter: uses-material-design: true -# PUBSPEC CHECKSUM: 9655 +# PUBSPEC CHECKSUM: df08 diff --git a/dev/benchmarks/complex_layout/pubspec.yaml b/dev/benchmarks/complex_layout/pubspec.yaml index 299ce115e7..f04b1fcff0 100644 --- a/dev/benchmarks/complex_layout/pubspec.yaml +++ b/dev/benchmarks/complex_layout/pubspec.yaml @@ -17,65 +17,60 @@ dependencies: # flutter update-packages --force-upgrade flutter_gallery_assets: 0.1.8 - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" file: 5.0.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - intl: 0.15.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - json_rpc_2: 2.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl: 0.15.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + json_rpc_2: 2.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vector_math: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - vm_service_client: 0.2.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - web_socket_channel: 1.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + vm_service_client: 0.2.6+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + web_socket_channel: 1.0.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" dev_dependencies: flutter_test: sdk: flutter - test: 1.5.3 + test: 1.6.1 - analyzer: 0.35.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + analyzer: 0.35.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" args: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - front_end: 0.1.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + front_end: 0.1.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - html: 0.13.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http: 0.12.0+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 2.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 0.3.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - kernel: 0.3.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + kernel: 0.3.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 0.9.6+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" multi_server_socket: 1.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" node_preamble: 1.4.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" package_config: 1.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" package_resolver: 1.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - plugin: 0.2.0+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - quiver: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + quiver: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf: 0.7.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf_web_socket: 0.2.2+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf_web_socket: 0.2.2+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_map_stack_trace: 1.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_maps: 0.10.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_core: 0.2.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - utf: 0.9.0+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_core: 0.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 0.9.7+10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -85,4 +80,4 @@ flutter: - packages/flutter_gallery_assets/people/square/ali.png - packages/flutter_gallery_assets/places/india_chettinad_silk_maker.png -# PUBSPEC CHECKSUM: ca28 +# PUBSPEC CHECKSUM: 68db diff --git a/dev/benchmarks/macrobenchmarks/pubspec.yaml b/dev/benchmarks/macrobenchmarks/pubspec.yaml index efa702c596..5bb5eb20f9 100644 --- a/dev/benchmarks/macrobenchmarks/pubspec.yaml +++ b/dev/benchmarks/macrobenchmarks/pubspec.yaml @@ -17,69 +17,64 @@ dependencies: # flutter update-packages --force-upgrade flutter_gallery_assets: 0.1.8 - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" file: 5.0.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - intl: 0.15.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - json_rpc_2: 2.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl: 0.15.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + json_rpc_2: 2.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vector_math: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - vm_service_client: 0.2.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - web_socket_channel: 1.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + vm_service_client: 0.2.6+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + web_socket_channel: 1.0.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" dev_dependencies: flutter_test: sdk: flutter - test: 1.5.3 + test: 1.6.1 - analyzer: 0.35.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + analyzer: 0.35.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" args: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - front_end: 0.1.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + front_end: 0.1.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - html: 0.13.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http: 0.12.0+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 2.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 0.3.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - kernel: 0.3.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + kernel: 0.3.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 0.9.6+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" multi_server_socket: 1.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" node_preamble: 1.4.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" package_config: 1.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" package_resolver: 1.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - plugin: 0.2.0+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - quiver: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + quiver: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf: 0.7.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf_web_socket: 0.2.2+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf_web_socket: 0.2.2+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_map_stack_trace: 1.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_maps: 0.10.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_core: 0.2.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - utf: 0.9.0+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_core: 0.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 0.9.7+10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" flutter: uses-material-design: true -# PUBSPEC CHECKSUM: ca28 +# PUBSPEC CHECKSUM: 68db diff --git a/dev/benchmarks/microbenchmarks/lib/geometry/rrect_contains_bench.dart b/dev/benchmarks/microbenchmarks/lib/geometry/rrect_contains_bench.dart new file mode 100644 index 0000000000..810a9a4e4d --- /dev/null +++ b/dev/benchmarks/microbenchmarks/lib/geometry/rrect_contains_bench.dart @@ -0,0 +1,29 @@ +// Copyright 2019 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:ui'; + +import '../common.dart'; + +const int _kNumIters = 10000; + +void main() { + final Stopwatch watch = Stopwatch(); + print('RRect contains benchmark...'); + watch.start(); + for (int i = 0; i < _kNumIters; i += 1) { + final RRect outter = RRect.fromLTRBR(10, 10, 20, 20, const Radius.circular(2.0)); + outter.contains(const Offset(15, 15)); + } + watch.stop(); + + final BenchmarkResultPrinter printer = BenchmarkResultPrinter(); + printer.addResult( + description: 'RRect contains', + value: watch.elapsedMicroseconds / _kNumIters, + unit: 'µs per iteration', + name: 'rrect_contains_iteration', + ); + printer.printToStdout(); +} diff --git a/dev/benchmarks/microbenchmarks/pubspec.yaml b/dev/benchmarks/microbenchmarks/pubspec.yaml index a0a646e60f..82f4663c1e 100644 --- a/dev/benchmarks/microbenchmarks/pubspec.yaml +++ b/dev/benchmarks/microbenchmarks/pubspec.yaml @@ -13,33 +13,30 @@ dependencies: sdk: flutter stocks: path: ../../../examples/stocks - test: 1.5.3 + test: 1.6.1 - analyzer: 0.35.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + analyzer: 0.35.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" args: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - dart_style: 1.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - front_end: 0.1.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + dart_style: 1.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + front_end: 0.1.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - html: 0.13.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http: 0.12.0+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 2.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - intl: 0.15.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl: 0.15.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" intl_translation: 0.17.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 0.3.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" isolate: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - json_rpc_2: 2.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - kernel: 0.3.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + json_rpc_2: 2.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + kernel: 0.3.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 0.9.6+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" multi_server_socket: 1.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" node_preamble: 1.4.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -48,32 +45,30 @@ dependencies: path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" petitparser: 2.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - plugin: 0.2.0+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - quiver: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + quiver: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf: 0.7.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf_web_socket: 0.2.2+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf_web_socket: 0.2.2+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_map_stack_trace: 1.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_maps: 0.10.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_core: 0.2.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_core: 0.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - utf: 0.9.0+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vector_math: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - vm_service_client: 0.2.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + vm_service_client: 0.2.6+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 0.9.7+10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - web_socket_channel: 1.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + web_socket_channel: 1.0.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" flutter: uses-material-design: true -# PUBSPEC CHECKSUM: a9b0 +# PUBSPEC CHECKSUM: ae65 diff --git a/dev/bots/analyze-sample-code.dart b/dev/bots/analyze-sample-code.dart index 6af14703f9..23a97584e5 100644 --- a/dev/bots/analyze-sample-code.dart +++ b/dev/bots/analyze-sample-code.dart @@ -165,7 +165,7 @@ class SampleChecker { static final RegExp _codeBlockEndRegex = RegExp(r'///\s+```\s*$'); /// A RegExp that matches a Dart constructor. - static final RegExp _constructorRegExp = RegExp(r'[A-Z][a-zA-Z0-9<>.]*\('); + static final RegExp _constructorRegExp = RegExp(r'(const\s+)?_*[A-Z][a-zA-Z0-9<>._]*\('); /// Whether or not to keep the temp directory around after running. /// @@ -742,7 +742,7 @@ linter: if (block.isEmpty) { throw SampleCheckerException('$line: Empty ```dart block in sample code.'); } - if (block.first.startsWith('new ') || block.first.startsWith('const ') || block.first.startsWith(_constructorRegExp)) { + if (block.first.startsWith('new ') || block.first.startsWith(_constructorRegExp)) { _expressionId += 1; return Section.surround(line, 'dynamic expression$_expressionId = ', block.toList(), ';'); } else if (block.first.startsWith('await ')) { diff --git a/dev/bots/analyze.dart b/dev/bots/analyze.dart index b6c4ab1784..4456bdcfb7 100644 --- a/dev/bots/analyze.dart +++ b/dev/bots/analyze.dart @@ -94,12 +94,12 @@ Future _verifyInternationalizations() async { final EvalResult genResult = await _evalCommand( dart, [ - path.join('dev', 'tools', 'gen_localizations.dart'), + path.join('dev', 'tools', 'localization', 'gen_localizations.dart'), ], workingDirectory: flutterRoot, ); - final String localizationsFile = path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n', 'localizations.dart'); + final String localizationsFile = path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n', 'generated_material_localizations.dart'); final String expectedResult = await File(localizationsFile).readAsString(); if (genResult.stdout.trim() != expectedResult.trim()) { diff --git a/dev/bots/deploy_gallery.sh b/dev/bots/deploy_gallery.sh index b47126c492..24e7dfa951 100755 --- a/dev/bots/deploy_gallery.sh +++ b/dev/bots/deploy_gallery.sh @@ -35,7 +35,7 @@ if [[ "$SHARD" = "deploy_gallery" ]]; then flutter build apk --release -t lib/main_publish.dart ) echo "Android Flutter Gallery built" - if [[ -z "$CIRRUS_PULL_REQUEST" && "$CIRRUS_BRANCH" == "dev" && "$version" != *"pre"* ]]; then + if [[ -z "$CIRRUS_PR" && "$CIRRUS_BRANCH" == "dev" && "$version" != *"pre"* ]]; then echo "Deploying Flutter Gallery $version to Play Store..." set +x # Don't echo back the below. if [ -n "$ANDROID_GALLERY_UPLOAD_KEY" ]; then @@ -56,11 +56,12 @@ if [[ "$SHARD" = "deploy_gallery" ]]; then flutter build ios --release --no-codesign -t lib/main_publish.dart ) echo "iOS Flutter Gallery built" - if [[ -z "$CIRRUS_PULL_REQUEST" ]]; then + if [[ -z "$CIRRUS_PR" ]]; then if [[ "$CIRRUS_BRANCH" == "dev" && "$version" != *"pre"* ]]; then echo "Archiving with distribution profile and deploying to TestFlight..." ( cd examples/flutter_gallery/ios + export DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS="-t DAV" fastlane build_and_deploy_testflight upload:true ) else diff --git a/dev/bots/docs.sh b/dev/bots/docs.sh index 05ee7ae8ae..5dab299139 100755 --- a/dev/bots/docs.sh +++ b/dev/bots/docs.sh @@ -104,7 +104,7 @@ if [[ -d "$FLUTTER_PUB_CACHE" ]]; then fi # Install and activate dartdoc. -"$PUB" global activate dartdoc 0.28.2 +"$PUB" global activate dartdoc 0.28.3+1 # This script generates a unified doc set, and creates # a custom index.html, placing everything into dev/docs/doc. diff --git a/dev/bots/pubspec.yaml b/dev/bots/pubspec.yaml index f4710b6fb0..c4b3d6a8e4 100644 --- a/dev/bots/pubspec.yaml +++ b/dev/bots/pubspec.yaml @@ -13,62 +13,56 @@ dependencies: platform: 2.2.0 http: 0.12.0+1 http_parser: 3.1.3 - test: 1.5.3 + test: 1.6.1 googleapis: 0.53.0 googleapis_auth: 0.2.7 _discoveryapis_commons: 0.1.8+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - analyzer: 0.35.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + analyzer: 0.35.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" file: 5.0.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - front_end: 0.1.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + front_end: 0.1.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - html: 0.13.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 2.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - intl: 0.15.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl: 0.15.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 0.3.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - json_rpc_2: 2.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - kernel: 0.3.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + json_rpc_2: 2.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + kernel: 0.3.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 0.9.6+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" multi_server_socket: 1.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" node_preamble: 1.4.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" package_config: 1.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" package_resolver: 1.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - plugin: 0.2.0+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf: 0.7.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf_web_socket: 0.2.2+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf_web_socket: 0.2.2+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_map_stack_trace: 1.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_maps: 0.10.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_core: 0.2.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_core: 0.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - utf: 0.9.0+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - vm_service_client: 0.2.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + vm_service_client: 0.2.6+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 0.9.7+10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - web_socket_channel: 1.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + web_socket_channel: 1.0.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" dev_dependencies: mockito: 4.0.0 - test_api: 0.2.2 + test_api: 0.2.4 - -# PUBSPEC CHECKSUM: 422e +# PUBSPEC CHECKSUM: 81e0 diff --git a/dev/bots/test.dart b/dev/bots/test.dart index 60a54b8b86..5b92184caa 100644 --- a/dev/bots/test.dart +++ b/dev/bots/test.dart @@ -180,16 +180,24 @@ Future _runToolTests() async { final bq.BigqueryApi bigqueryApi = await _getBigqueryApi(); await _runSmokeTests(); + // The flutter_tool will currently be snapshotted without asserts. We need + // to force it to be regenerated with them enabled. + if (!Platform.isWindows) { + File(path.join(flutterRoot, 'bin', 'cache', 'flutter_tools.snapshot')).deleteSync(); + File(path.join(flutterRoot, 'bin', 'cache', 'flutter_tools.stamp')).deleteSync(); + } if (noUseBuildRunner) { await _pubRunTest( path.join(flutterRoot, 'packages', 'flutter_tools'), tableData: bigqueryApi?.tabledata, + enableFlutterToolAsserts: !Platform.isWindows, ); } else { await _buildRunnerTest( path.join(flutterRoot, 'packages', 'flutter_tools'), flutterRoot, tableData: bigqueryApi?.tabledata, + enableFlutterToolAsserts: !Platform.isWindows, ); } diff --git a/dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart b/dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart index 6a00c15f9a..fd3c78ed3f 100644 --- a/dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart +++ b/dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart @@ -7,6 +7,10 @@ // Examples can assume: // bool _visible = true; +// class _Text extends Text { +// const _Text(String text) : super(text); +// const _Text.__(String text) : super(text); +// } /// A blabla that blabla its blabla blabla blabla. /// @@ -41,3 +45,41 @@ /// ) /// ``` /// {@end-tool} +/// +/// {@tool sample} +/// regular const constructor +/// +/// ```dart +/// const Text('Poor wandering ones!') +/// ``` +/// {@end-tool} +/// +/// {@tool sample} +/// const private constructor +/// ```dart +/// const _Text('Poor wandering ones!') +/// ``` +/// {@end-tool} +/// +/// {@tool sample} +/// yet another const private constructor +/// ```dart +/// const _Text.__('Poor wandering ones!') +/// ``` +/// {@end-tool} +/// +/// {@tool sample} +/// const variable +/// +/// ```dart +/// const text0 = Text('Poor wandering ones!'); +/// ``` +/// {@end-tool} +/// +/// {@tool sample} +/// more const variables +/// +/// ```dart +/// const text1 = _Text('Poor wandering ones!'); +/// ``` +/// {@end-tool} diff --git a/dev/bots/test/analyze-sample-code_test.dart b/dev/bots/test/analyze-sample-code_test.dart index 0d46585a6d..8e0f347a15 100644 --- a/dev/bots/test/analyze-sample-code_test.dart +++ b/dev/bots/test/analyze-sample-code_test.dart @@ -17,14 +17,14 @@ void main() { ..removeWhere((String line) => line.startsWith('Analyzer output:')); expect(process.exitCode, isNot(equals(0))); expect(stderrLines, [ - 'known_broken_documentation.dart:26:9: new Opacity(', + 'known_broken_documentation.dart:30:9: new Opacity(', '>>> Unnecessary new keyword (unnecessary_new)', - 'known_broken_documentation.dart:38:9: new Opacity(', + 'known_broken_documentation.dart:42:9: new Opacity(', '>>> Unnecessary new keyword (unnecessary_new)', '', 'Found 1 sample code errors.', '', ]); - expect(stdoutLines, ['Found 2 sample code sections.', 'Starting analysis of samples.', '']); + expect(stdoutLines, ['Found 7 sample code sections.', 'Starting analysis of samples.', '']); }, skip: Platform.isWindows); } diff --git a/dev/ci/docker_linux/Dockerfile b/dev/ci/docker_linux/Dockerfile index 8f0e546059..44fd67a829 100644 --- a/dev/ci/docker_linux/Dockerfile +++ b/dev/ci/docker_linux/Dockerfile @@ -1,4 +1,4 @@ -# Flutter (https://flutter.io) Developement Environment for Linux +# Flutter (https://flutter.dev) Developement Environment for Linux # =============================================================== # # This environment passes all Linux Flutter Doctor checks and is sufficient @@ -58,7 +58,7 @@ RUN unzip -q -d "${ANDROID_TOOLS_ROOT}" "${ANDROID_SDK_ARCHIVE}" # Suppressing output of sdkmanager to keep log size down # (it prints install progress WAY too often). RUN yes "y" | "${ANDROID_TOOLS_ROOT}/tools/bin/sdkmanager" "tools" > /dev/null -RUN yes "y" | "${ANDROID_TOOLS_ROOT}/tools/bin/sdkmanager" "build-tools;28.0.0" > /dev/null +RUN yes "y" | "${ANDROID_TOOLS_ROOT}/tools/bin/sdkmanager" "build-tools;28.0.3" > /dev/null RUN yes "y" | "${ANDROID_TOOLS_ROOT}/tools/bin/sdkmanager" "platforms;android-28" > /dev/null RUN yes "y" | "${ANDROID_TOOLS_ROOT}/tools/bin/sdkmanager" "platform-tools" > /dev/null RUN yes "y" | "${ANDROID_TOOLS_ROOT}/tools/bin/sdkmanager" "extras;android;m2repository" > /dev/null @@ -100,6 +100,10 @@ ENV LANG en_US.UTF-8 # Install coveralls and Firebase # This is why we need ruby installed. -RUN gem install coveralls -RUN gem install bundler +# Skip all the documentation (-N) since it's just on CI. +RUN gem install coveralls -N +RUN gem install bundler -N +# Install fastlane which is used on Linux to build and deploy Android +# builds to the Play Store. +RUN gem install fastlane -N diff --git a/dev/devicelab/bin/tasks/drive_perf_debug_warning.dart b/dev/devicelab/bin/tasks/drive_perf_debug_warning.dart new file mode 100644 index 0000000000..78bf7be7b3 --- /dev/null +++ b/dev/devicelab/bin/tasks/drive_perf_debug_warning.dart @@ -0,0 +1,52 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +import 'package:flutter_devicelab/framework/adb.dart'; +import 'package:flutter_devicelab/framework/framework.dart'; +import 'package:flutter_devicelab/framework/utils.dart'; + +Future _runWithMode(String mode, String deviceId) async { + final StringBuffer stderr = StringBuffer(); + await evalFlutter('drive', stderr: stderr, options: [ + mode, + '-t', + 'test_driver/scroll_perf.dart', + '-d', + deviceId, + ]); + return stderr.toString(); +} + +Future run() async { + cd('${flutterDirectory.path}/examples/flutter_gallery'); + final Device device = await devices.workingDevice; + await device.unlock(); + final String deviceId = device.deviceId; + await flutter('packages', options: ['get']); + + const String warningPiece = 'THIS BENCHMARK IS BEING RUN IN DEBUG MODE'; + + final String debugOutput = await _runWithMode('--debug', deviceId); + if (!debugOutput.contains(warningPiece)) { + return TaskResult.failure( + 'Could not find the following warning message piece: $warningPiece' + ); + } + + final String profileOutput = await _runWithMode('--profile', deviceId); + if (profileOutput.contains(warningPiece)) { + return TaskResult.failure( + 'Unexpected warning message piece in profile mode: $warningPiece' + ); + } + + return TaskResult.success(null); +} + +Future main() async { + deviceOperatingSystem = DeviceOperatingSystem.android; + await task(run); +} diff --git a/dev/devicelab/bin/tasks/flutter_test_performance.dart b/dev/devicelab/bin/tasks/flutter_test_performance.dart index 0e5ef8d979..3843f1c53f 100644 --- a/dev/devicelab/bin/tasks/flutter_test_performance.dart +++ b/dev/devicelab/bin/tasks/flutter_test_performance.dart @@ -36,11 +36,18 @@ enum TestStep { testPassed, } -Future runTest() async { +Future runTest({bool coverage = false}) async { final Stopwatch clock = Stopwatch()..start(); + final List arguments = [ + 'test', + ]; + if (coverage) { + arguments.add('--coverage'); + } + arguments.add(path.join('flutter_test', 'trivial_widget_test.dart')); final Process analysis = await startProcess( path.join(flutterDirectory.path, 'bin', 'flutter'), - ['test', path.join('flutter_test', 'trivial_widget_test.dart')], + arguments, workingDirectory: path.join(flutterDirectory.path, 'dev', 'automated_tests'), ); int badLines = 0; @@ -50,6 +57,8 @@ Future runTest() async { if (step == TestStep.starting && entry == 'Building flutter tool...') { // ignore this line step = TestStep.buildingFlutterTool; + } else if (step == TestStep.testPassed && entry.contains('Collecting coverage information...')) { + // ignore this line } else if (step.index < TestStep.runningPubGet.index && entry == 'Running "flutter packages get" in automated_tests...') { // ignore this line step = TestStep.runningPubGet; @@ -113,10 +122,13 @@ void main() { .replaceAll('_xyzzy', 'owner') ); final int interfaceChange = await runTest(); // run test again with interface changed + // run test with coverage enabled. + final int withCoverage = await runTest(coverage: true); final Map data = { 'without_change_elapsed_time_ms': withoutChange, 'implementation_change_elapsed_time_ms': implementationChange, 'interface_change_elapsed_time_ms': interfaceChange, + 'with_coverage_time_ms': withCoverage, }; return TaskResult.success(data, benchmarkScoreKeys: data.keys.toList()); } finally { diff --git a/dev/devicelab/bin/tasks/uncaught_image_error_linux.dart b/dev/devicelab/bin/tasks/uncaught_image_error_linux.dart new file mode 100644 index 0000000000..6b9567f7ec --- /dev/null +++ b/dev/devicelab/bin/tasks/uncaught_image_error_linux.dart @@ -0,0 +1,57 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; + +import 'package:flutter_devicelab/framework/adb.dart'; +import 'package:flutter_devicelab/framework/framework.dart'; +import 'package:flutter_devicelab/framework/utils.dart'; +import 'package:path/path.dart' as path; + +Future main() async { + deviceOperatingSystem = DeviceOperatingSystem.android; + await task(() async { + return inDirectory('${flutterDirectory.path}/dev/integration_tests/image_loading', () async { + final Device device = await devices.workingDevice; + await device.unlock(); + final String deviceId = device.deviceId; + await flutter('packages', options: ['get']); + bool passed = false; + + final List options = [ + '-v', + '-t', + 'lib/main.dart', + '-d', + deviceId, + ]; + final Process process = await startProcess( + path.join(flutterDirectory.path, 'bin', 'flutter'), + ['run']..addAll(options)); + + final Stream lines = process.stdout + .transform(utf8.decoder) + .transform(const LineSplitter()); + + await for (String line in lines) { + print(line); + if (line.contains('ERROR caught by framework')) { + passed = true; + break; + } + if (line.contains('EXCEPTION CAUGHT BY FLUTTER FRAMEWORK ')) { + passed = false; + break; + } + } + if (passed) { + return TaskResult.success(null); + } else { + return TaskResult.failure('Failed to catch sync error in image loading.'); + } + }); + }); +} diff --git a/dev/devicelab/lib/framework/utils.dart b/dev/devicelab/lib/framework/utils.dart index fc99b47cee..c562a3fd9a 100644 --- a/dev/devicelab/lib/framework/utils.dart +++ b/dev/devicelab/lib/framework/utils.dart @@ -303,6 +303,7 @@ Future eval( Map environment, bool canFail = false, // as in, whether failures are ok. False means that they are fatal. String workingDirectory, + StringBuffer stderr, // if not null, the stderr will be written here }) async { final Process process = await startProcess(executable, arguments, environment: environment, workingDirectory: workingDirectory); @@ -321,6 +322,7 @@ Future eval( .transform(const LineSplitter()) .listen((String line) { print('stderr: $line'); + stderr?.writeln(line); }, onDone: () { stderrDone.complete(); }); await Future.wait(>[stdoutDone.future, stderrDone.future]); @@ -347,10 +349,11 @@ Future evalFlutter(String command, { List options = const [], bool canFail = false, // as in, whether failures are ok. False means that they are fatal. Map environment, + StringBuffer stderr, // if not null, the stderr will be written here. }) { final List args = [command]..addAll(options); return eval(path.join(flutterDirectory.path, 'bin', 'flutter'), args, - canFail: canFail, environment: environment); + canFail: canFail, environment: environment, stderr: stderr); } String get dartBin => diff --git a/dev/devicelab/lib/tasks/integration_tests.dart b/dev/devicelab/lib/tasks/integration_tests.dart index e59337bc1e..f6c7eb739a 100644 --- a/dev/devicelab/lib/tasks/integration_tests.dart +++ b/dev/devicelab/lib/tasks/integration_tests.dart @@ -71,6 +71,13 @@ TaskFunction createCodegenerationIntegrationTest() { ); } +TaskFunction createImageLoadingIntegrationTest() { + return DriverTest( + '${flutterDirectory.path}/dev/integration_tests/image_loading', + 'lib/main.dart', + ); +} + TaskFunction createFlutterCreateOfflineTest() { return () async { final Directory tempDir = Directory.systemTemp.createTempSync('flutter_create_test.'); diff --git a/dev/devicelab/lib/tasks/microbenchmarks.dart b/dev/devicelab/lib/tasks/microbenchmarks.dart index c4dd4ef24e..e1128ef649 100644 --- a/dev/devicelab/lib/tasks/microbenchmarks.dart +++ b/dev/devicelab/lib/tasks/microbenchmarks.dart @@ -51,6 +51,7 @@ TaskFunction createMicrobenchmarkTask() { final Map allResults = {}; allResults.addAll(await _runMicrobench('lib/stocks/layout_bench.dart')); allResults.addAll(await _runMicrobench('lib/stocks/build_bench.dart')); + allResults.addAll(await _runMicrobench('lib/geometry/rrect_contains_bench.dart')); allResults.addAll(await _runMicrobench('lib/gestures/velocity_tracker_bench.dart')); allResults.addAll(await _runMicrobench('lib/stocks/animation_bench.dart')); diff --git a/dev/devicelab/lib/tasks/perf_tests.dart b/dev/devicelab/lib/tasks/perf_tests.dart index 515d122636..98217cddbb 100644 --- a/dev/devicelab/lib/tasks/perf_tests.dart +++ b/dev/devicelab/lib/tasks/perf_tests.dart @@ -274,7 +274,7 @@ class CompileTest { await flutter('build', options: options); watch.stop(); final String appPath = '$cwd/build/ios/Release-iphoneos/Runner.app/'; - // IPAs are created manually, https://flutter.io/ios-release/ + // IPAs are created manually, https://flutter.dev/ios-release/ await exec('tar', ['-zcf', 'build/app.ipa', appPath]); releaseSizeInBytes = await file('$cwd/build/app.ipa').length(); if (reportPackageContentSizes) diff --git a/dev/devicelab/manifest.yaml b/dev/devicelab/manifest.yaml index a5db41a1a1..015125febe 100644 --- a/dev/devicelab/manifest.yaml +++ b/dev/devicelab/manifest.yaml @@ -97,6 +97,14 @@ tasks: stage: devicelab required_agent_capabilities: ["linux/android"] + uncaught_image_error_linux: + description: > + Ensures that an error thrown into the zone can be caught by the ImageStream + completer + stage: devicelab + flaky: true + required_agent_capabilities: ["linux/android"] + flutter_gallery_android__compile: description: > Collects various performance metrics of compiling the Flutter @@ -140,6 +148,13 @@ tasks: stage: devicelab required_agent_capabilities: ["mac/android"] + drive_perf_debug_warning: + description: > + Check that driver will print warnings when traceAction is called in debug mode. + stage: devicelab + required_agent_capabilities: ["mac/android"] + flaky: true + cull_opacity_perf__timeline_summary: description: > Measures the runtime performance of culling opacity widgets on Android. @@ -151,7 +166,6 @@ tasks: Measures the runtime performance of cubic bezier animations on Android. stage: devicelab required_agent_capabilities: ["mac/android"] - flaky: true flavors_test: description: > diff --git a/dev/devicelab/pubspec.yaml b/dev/devicelab/pubspec.yaml index bc79d221b5..fa6d5ee5ca 100644 --- a/dev/devicelab/pubspec.yaml +++ b/dev/devicelab/pubspec.yaml @@ -16,62 +16,59 @@ dependencies: platform: 2.2.0 process: 3.0.9 stack_trace: 1.9.3 - vm_service_client: 0.2.6 + vm_service_client: 0.2.6+1 + + logging: 0.11.3+2 archive: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - intl: 0.15.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - json_rpc_2: 2.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl: 0.15.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + json_rpc_2: 2.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" petitparser: 2.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - web_socket_channel: 1.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + web_socket_channel: 1.0.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" xml: 3.4.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" dev_dependencies: # See packages/flutter_test/pubspec.yaml for why we're pinning this version. - test: 1.5.3 + test: 1.6.1 - analyzer: 0.35.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + analyzer: 0.35.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - front_end: 0.1.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + front_end: 0.1.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - html: 0.13.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http: 0.12.0+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 2.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 0.3.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - kernel: 0.3.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + kernel: 0.3.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 0.9.6+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" multi_server_socket: 1.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" node_preamble: 1.4.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" package_config: 1.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" package_resolver: 1.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - plugin: 0.2.0+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf: 0.7.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf_web_socket: 0.2.2+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf_web_socket: 0.2.2+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_map_stack_trace: 1.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_maps: 0.10.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_core: 0.2.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - utf: 0.9.0+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_core: 0.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 0.9.7+10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" -# PUBSPEC CHECKSUM: d7e6 +# PUBSPEC CHECKSUM: 7c5d diff --git a/dev/docs/dashing.json b/dev/docs/dashing.json index 4076446758..3e96f0bb24 100644 --- a/dev/docs/dashing.json +++ b/dev/docs/dashing.json @@ -3,7 +3,7 @@ "package": "flutter", "author": { "name": "The Flutter Team", - "link": "https://flutter.io" + "link": "https://flutter.dev" }, "index": "index.html", "icon32x32": "flutter/static-assets/favicon.png", diff --git a/dev/integration_tests/android_semantics_testing/pubspec.yaml b/dev/integration_tests/android_semantics_testing/pubspec.yaml index fc34fbbfa4..285b467552 100644 --- a/dev/integration_tests/android_semantics_testing/pubspec.yaml +++ b/dev/integration_tests/android_semantics_testing/pubspec.yaml @@ -6,31 +6,28 @@ dependencies: sdk: flutter flutter_driver: sdk: flutter - test: 1.5.3 + test: 1.6.1 - analyzer: 0.35.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + analyzer: 0.35.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" args: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" file: 5.0.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - front_end: 0.1.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + front_end: 0.1.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - html: 0.13.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http: 0.12.0+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 2.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - intl: 0.15.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl: 0.15.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 0.3.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - json_rpc_2: 2.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - kernel: 0.3.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + json_rpc_2: 2.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + kernel: 0.3.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 0.9.6+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" multi_server_socket: 1.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -39,31 +36,29 @@ dependencies: package_resolver: 1.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - plugin: 0.2.0+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf: 0.7.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf_web_socket: 0.2.2+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf_web_socket: 0.2.2+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_map_stack_trace: 1.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_maps: 0.10.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_core: 0.2.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_core: 0.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - utf: 0.9.0+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vector_math: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - vm_service_client: 0.2.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + vm_service_client: 0.2.6+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 0.9.7+10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - web_socket_channel: 1.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + web_socket_channel: 1.0.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" flutter: uses-material-design: true -# PUBSPEC CHECKSUM: 2b9e +# PUBSPEC CHECKSUM: 6251 diff --git a/dev/integration_tests/android_views/pubspec.yaml b/dev/integration_tests/android_views/pubspec.yaml index 9325cf43aa..e272fb83cb 100644 --- a/dev/integration_tests/android_views/pubspec.yaml +++ b/dev/integration_tests/android_views/pubspec.yaml @@ -15,68 +15,63 @@ dependencies: ref: c47f1308188dca65b3899228cac37f252ea8b411 path: dev/integration_tests/assets_for_android_views - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" file: 5.0.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - intl: 0.15.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - json_rpc_2: 2.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl: 0.15.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + json_rpc_2: 2.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vector_math: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - vm_service_client: 0.2.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - web_socket_channel: 1.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + vm_service_client: 0.2.6+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + web_socket_channel: 1.0.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" dev_dependencies: flutter_test: sdk: flutter - test: 1.5.3 + test: 1.6.1 - analyzer: 0.35.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + analyzer: 0.35.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" args: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - front_end: 0.1.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + front_end: 0.1.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - html: 0.13.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http: 0.12.0+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 2.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 0.3.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - kernel: 0.3.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + kernel: 0.3.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 0.9.6+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" multi_server_socket: 1.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" node_preamble: 1.4.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" package_config: 1.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" package_resolver: 1.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - plugin: 0.2.0+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - quiver: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + quiver: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf: 0.7.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf_web_socket: 0.2.2+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf_web_socket: 0.2.2+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_map_stack_trace: 1.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_maps: 0.10.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_core: 0.2.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - utf: 0.9.0+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_core: 0.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 0.9.7+10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" flutter: uses-material-design: true -# PUBSPEC CHECKSUM: 49ac +# PUBSPEC CHECKSUM: dd60 diff --git a/dev/integration_tests/channels/pubspec.yaml b/dev/integration_tests/channels/pubspec.yaml index 39872ef4f6..c968783dd2 100644 --- a/dev/integration_tests/channels/pubspec.yaml +++ b/dev/integration_tests/channels/pubspec.yaml @@ -10,31 +10,28 @@ dependencies: sdk: flutter flutter_driver: sdk: flutter - test: 1.5.3 + test: 1.6.1 - analyzer: 0.35.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + analyzer: 0.35.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" args: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" file: 5.0.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - front_end: 0.1.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + front_end: 0.1.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - html: 0.13.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http: 0.12.0+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 2.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - intl: 0.15.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl: 0.15.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 0.3.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - json_rpc_2: 2.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - kernel: 0.3.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + json_rpc_2: 2.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + kernel: 0.3.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 0.9.6+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" multi_server_socket: 1.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -43,31 +40,29 @@ dependencies: package_resolver: 1.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - plugin: 0.2.0+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf: 0.7.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf_web_socket: 0.2.2+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf_web_socket: 0.2.2+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_map_stack_trace: 1.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_maps: 0.10.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_core: 0.2.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_core: 0.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - utf: 0.9.0+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vector_math: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - vm_service_client: 0.2.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + vm_service_client: 0.2.6+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 0.9.7+10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - web_socket_channel: 1.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + web_socket_channel: 1.0.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" flutter: uses-material-design: true -# PUBSPEC CHECKSUM: 2b9e +# PUBSPEC CHECKSUM: 6251 diff --git a/dev/integration_tests/codegen/pubspec.yaml b/dev/integration_tests/codegen/pubspec.yaml index c3cbf60e54..1a656f1c97 100644 --- a/dev/integration_tests/codegen/pubspec.yaml +++ b/dev/integration_tests/codegen/pubspec.yaml @@ -11,62 +11,57 @@ dependencies: flutter_driver: sdk: flutter - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" file: 5.0.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - intl: 0.15.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - json_rpc_2: 2.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl: 0.15.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + json_rpc_2: 2.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vector_math: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - vm_service_client: 0.2.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - web_socket_channel: 1.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + vm_service_client: 0.2.6+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + web_socket_channel: 1.0.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" dev_dependencies: - test: 1.5.3 + test: 1.6.1 - analyzer: 0.35.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + analyzer: 0.35.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" args: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - front_end: 0.1.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + front_end: 0.1.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - html: 0.13.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http: 0.12.0+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 2.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 0.3.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - kernel: 0.3.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + kernel: 0.3.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 0.9.6+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" multi_server_socket: 1.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" node_preamble: 1.4.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" package_config: 1.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" package_resolver: 1.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - plugin: 0.2.0+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf: 0.7.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf_web_socket: 0.2.2+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf_web_socket: 0.2.2+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_map_stack_trace: 1.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_maps: 0.10.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_core: 0.2.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - utf: 0.9.0+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_core: 0.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 0.9.7+10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -78,4 +73,4 @@ builders: flutter: uses-material-design: true -# PUBSPEC CHECKSUM: 2b9e +# PUBSPEC CHECKSUM: 6251 diff --git a/dev/integration_tests/external_ui/pubspec.yaml b/dev/integration_tests/external_ui/pubspec.yaml index 6e580305ad..1b39d3b000 100644 --- a/dev/integration_tests/external_ui/pubspec.yaml +++ b/dev/integration_tests/external_ui/pubspec.yaml @@ -10,31 +10,28 @@ dependencies: sdk: flutter flutter_driver: sdk: flutter - test: 1.5.3 + test: 1.6.1 - analyzer: 0.35.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + analyzer: 0.35.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" args: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" file: 5.0.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - front_end: 0.1.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + front_end: 0.1.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - html: 0.13.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http: 0.12.0+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 2.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - intl: 0.15.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl: 0.15.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 0.3.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - json_rpc_2: 2.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - kernel: 0.3.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + json_rpc_2: 2.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + kernel: 0.3.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 0.9.6+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" multi_server_socket: 1.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -43,31 +40,29 @@ dependencies: package_resolver: 1.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - plugin: 0.2.0+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf: 0.7.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf_web_socket: 0.2.2+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf_web_socket: 0.2.2+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_map_stack_trace: 1.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_maps: 0.10.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_core: 0.2.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_core: 0.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - utf: 0.9.0+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vector_math: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - vm_service_client: 0.2.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + vm_service_client: 0.2.6+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 0.9.7+10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - web_socket_channel: 1.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + web_socket_channel: 1.0.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" flutter: uses-material-design: true -# PUBSPEC CHECKSUM: 2b9e +# PUBSPEC CHECKSUM: 6251 diff --git a/dev/integration_tests/flavors/pubspec.yaml b/dev/integration_tests/flavors/pubspec.yaml index cade712a20..492c23ea21 100644 --- a/dev/integration_tests/flavors/pubspec.yaml +++ b/dev/integration_tests/flavors/pubspec.yaml @@ -10,31 +10,28 @@ dependencies: sdk: flutter flutter_driver: sdk: flutter - test: 1.5.3 + test: 1.6.1 - analyzer: 0.35.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + analyzer: 0.35.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" args: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" file: 5.0.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - front_end: 0.1.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + front_end: 0.1.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - html: 0.13.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http: 0.12.0+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 2.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - intl: 0.15.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl: 0.15.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 0.3.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - json_rpc_2: 2.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - kernel: 0.3.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + json_rpc_2: 2.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + kernel: 0.3.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 0.9.6+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" multi_server_socket: 1.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -43,31 +40,29 @@ dependencies: package_resolver: 1.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - plugin: 0.2.0+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf: 0.7.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf_web_socket: 0.2.2+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf_web_socket: 0.2.2+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_map_stack_trace: 1.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_maps: 0.10.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_core: 0.2.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_core: 0.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - utf: 0.9.0+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vector_math: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - vm_service_client: 0.2.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + vm_service_client: 0.2.6+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 0.9.7+10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - web_socket_channel: 1.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + web_socket_channel: 1.0.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" flutter: uses-material-design: true -# PUBSPEC CHECKSUM: 2b9e +# PUBSPEC CHECKSUM: 6251 diff --git a/dev/integration_tests/image_loading/android/.project b/dev/integration_tests/image_loading/android/.project new file mode 100644 index 0000000000..3964dd3f5b --- /dev/null +++ b/dev/integration_tests/image_loading/android/.project @@ -0,0 +1,17 @@ + + + android + Project android created by Buildship. + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.buildship.core.gradleprojectnature + + diff --git a/dev/integration_tests/image_loading/android/app/.project b/dev/integration_tests/image_loading/android/app/.project new file mode 100644 index 0000000000..ac485d7c3e --- /dev/null +++ b/dev/integration_tests/image_loading/android/app/.project @@ -0,0 +1,23 @@ + + + app + Project app created by Buildship. + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.buildship.core.gradleprojectnature + + diff --git a/dev/integration_tests/image_loading/android/app/bin/build.gradle b/dev/integration_tests/image_loading/android/app/bin/build.gradle new file mode 100644 index 0000000000..9ebebef363 --- /dev/null +++ b/dev/integration_tests/image_loading/android/app/bin/build.gradle @@ -0,0 +1,57 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withInputStream { stream -> + localProperties.load(stream) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +apply plugin: 'com.android.application' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion 28 + + lintOptions { + disable 'InvalidPackage' + } + + defaultConfig { + minSdkVersion 16 + targetSdkVersion 28 + versionCode 1 + versionName "0.0.1" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } + + aaptOptions { + // TODO(goderbauer): remove when https://github.com/flutter/flutter/issues/8986 is resolved. + if(System.getenv("FLUTTER_CI_WIN")) { + println "AAPT cruncher disabled when running on Win CI." + cruncherEnabled false + } + } +} + +flutter { + source '../..' +} + +dependencies { + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.2' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' +} diff --git a/dev/integration_tests/image_loading/android/app/bin/src/main/AndroidManifest.xml b/dev/integration_tests/image_loading/android/app/bin/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..6703641433 --- /dev/null +++ b/dev/integration_tests/image_loading/android/app/bin/src/main/AndroidManifest.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + diff --git a/dev/integration_tests/image_loading/android/app/bin/src/main/res/mipmap-hdpi/ic_launcher.png b/dev/integration_tests/image_loading/android/app/bin/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000..db77bb4b7b Binary files /dev/null and b/dev/integration_tests/image_loading/android/app/bin/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/dev/integration_tests/image_loading/android/app/bin/src/main/res/mipmap-mdpi/ic_launcher.png b/dev/integration_tests/image_loading/android/app/bin/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000..17987b79bb Binary files /dev/null and b/dev/integration_tests/image_loading/android/app/bin/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/dev/integration_tests/image_loading/android/app/bin/src/main/res/mipmap-xhdpi/ic_launcher.png b/dev/integration_tests/image_loading/android/app/bin/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000000..09d4391482 Binary files /dev/null and b/dev/integration_tests/image_loading/android/app/bin/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/dev/integration_tests/image_loading/android/app/bin/src/main/res/mipmap-xxhdpi/ic_launcher.png b/dev/integration_tests/image_loading/android/app/bin/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000..d5f1c8d34e Binary files /dev/null and b/dev/integration_tests/image_loading/android/app/bin/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/dev/integration_tests/image_loading/android/app/bin/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/dev/integration_tests/image_loading/android/app/bin/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000..4d6372eebd Binary files /dev/null and b/dev/integration_tests/image_loading/android/app/bin/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/dev/integration_tests/image_loading/android/app/build.gradle b/dev/integration_tests/image_loading/android/app/build.gradle new file mode 100644 index 0000000000..9ebebef363 --- /dev/null +++ b/dev/integration_tests/image_loading/android/app/build.gradle @@ -0,0 +1,57 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withInputStream { stream -> + localProperties.load(stream) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +apply plugin: 'com.android.application' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion 28 + + lintOptions { + disable 'InvalidPackage' + } + + defaultConfig { + minSdkVersion 16 + targetSdkVersion 28 + versionCode 1 + versionName "0.0.1" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } + + aaptOptions { + // TODO(goderbauer): remove when https://github.com/flutter/flutter/issues/8986 is resolved. + if(System.getenv("FLUTTER_CI_WIN")) { + println "AAPT cruncher disabled when running on Win CI." + cruncherEnabled false + } + } +} + +flutter { + source '../..' +} + +dependencies { + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.2' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' +} diff --git a/dev/integration_tests/image_loading/android/app/src/main/AndroidManifest.xml b/dev/integration_tests/image_loading/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..6703641433 --- /dev/null +++ b/dev/integration_tests/image_loading/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + diff --git a/dev/integration_tests/image_loading/android/app/src/main/java/com/yourcompany/platforminteraction/MainActivity.java b/dev/integration_tests/image_loading/android/app/src/main/java/com/yourcompany/platforminteraction/MainActivity.java new file mode 100644 index 0000000000..0b076eff28 --- /dev/null +++ b/dev/integration_tests/image_loading/android/app/src/main/java/com/yourcompany/platforminteraction/MainActivity.java @@ -0,0 +1,18 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package com.yourcompany.platforminteraction; + +import android.os.Bundle; +import io.flutter.app.FlutterActivity; +import io.flutter.plugins.GeneratedPluginRegistrant; +import io.flutter.view.FlutterView; + +public class MainActivity extends FlutterActivity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + GeneratedPluginRegistrant.registerWith(this); + } +} diff --git a/dev/integration_tests/image_loading/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/dev/integration_tests/image_loading/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000..db77bb4b7b Binary files /dev/null and b/dev/integration_tests/image_loading/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/dev/integration_tests/image_loading/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/dev/integration_tests/image_loading/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000..17987b79bb Binary files /dev/null and b/dev/integration_tests/image_loading/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/dev/integration_tests/image_loading/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/dev/integration_tests/image_loading/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000000..09d4391482 Binary files /dev/null and b/dev/integration_tests/image_loading/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/dev/integration_tests/image_loading/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/dev/integration_tests/image_loading/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000..d5f1c8d34e Binary files /dev/null and b/dev/integration_tests/image_loading/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/dev/integration_tests/image_loading/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/dev/integration_tests/image_loading/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000..4d6372eebd Binary files /dev/null and b/dev/integration_tests/image_loading/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/dev/integration_tests/image_loading/android/build.gradle b/dev/integration_tests/image_loading/android/build.gradle new file mode 100644 index 0000000000..bb8a303898 --- /dev/null +++ b/dev/integration_tests/image_loading/android/build.gradle @@ -0,0 +1,29 @@ +buildscript { + repositories { + google() + jcenter() + } + + dependencies { + classpath 'com.android.tools.build:gradle:3.2.1' + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/dev/integration_tests/image_loading/android/gradle.properties b/dev/integration_tests/image_loading/android/gradle.properties new file mode 100644 index 0000000000..8bd86f6805 --- /dev/null +++ b/dev/integration_tests/image_loading/android/gradle.properties @@ -0,0 +1 @@ +org.gradle.jvmargs=-Xmx1536M diff --git a/dev/integration_tests/image_loading/android/gradle/wrapper/gradle-wrapper.properties b/dev/integration_tests/image_loading/android/gradle/wrapper/gradle-wrapper.properties new file mode 100755 index 0000000000..2819f022f1 --- /dev/null +++ b/dev/integration_tests/image_loading/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jun 23 08:50:38 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip diff --git a/dev/integration_tests/image_loading/android/settings.gradle b/dev/integration_tests/image_loading/android/settings.gradle new file mode 100644 index 0000000000..115da6cb4f --- /dev/null +++ b/dev/integration_tests/image_loading/android/settings.gradle @@ -0,0 +1,15 @@ +include ':app' + +def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() + +def plugins = new Properties() +def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') +if (pluginsFile.exists()) { + pluginsFile.withInputStream { stream -> plugins.load(stream) } +} + +plugins.each { name, path -> + def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() + include ":$name" + project(":$name").projectDir = pluginDirectory +} diff --git a/dev/integration_tests/image_loading/lib/main.dart b/dev/integration_tests/image_loading/lib/main.dart new file mode 100644 index 0000000000..a1a3e8e9c2 --- /dev/null +++ b/dev/integration_tests/image_loading/lib/main.dart @@ -0,0 +1,69 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:mockito/mockito.dart'; + +void main() { + final ThrowingHttpClient httpClient = ThrowingHttpClient(); + final HttpOverrides overrides = ProvidedHttpOverrides(httpClient); + HttpOverrides.global = overrides; + final ZoneSpecification specification = ZoneSpecification( + handleUncaughtError:(Zone zone, ZoneDelegate delegate, Zone parent, Object error, StackTrace stackTrace) { + FlutterError.reportError(FlutterErrorDetails( + exception: error, + context: 'In the Zone handleUncaughtError handler', + silent: false, + )); + }); + when(httpClient.getUrl(any)).thenAnswer((Invocation invocation) { + final Completer completer = Completer.sync(); + completer.completeError(Error()); + return completer.future; + }); + Zone.current.fork(specification: specification).run(() { + runApp(ImageLoader()); + }); +} + +class ImageLoader extends StatefulWidget { + @override + _ImageLoaderState createState() => _ImageLoaderState(); +} + +class _ImageLoaderState extends State { + bool caughtError = false; + + @override + void initState() { + // This is not an image, but we don't care since we're using a faked + // http client. + final NetworkImage image = NetworkImage('https://github.com/flutter/flutter'); + final ImageStream stream = image.resolve(ImageConfiguration.empty); + stream.addListener((ImageInfo info, bool syncCall) {}, onError: (dynamic error, StackTrace stackTrace) { + print('ERROR caught by framework'); + }); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return const Text('hello', textDirection: TextDirection.ltr); + } +} + +class ThrowingHttpClient extends Mock implements HttpClient {} + +class ProvidedHttpOverrides extends HttpOverrides { + ProvidedHttpOverrides(this.httpClient); + + final ThrowingHttpClient httpClient; + @override + HttpClient createHttpClient(SecurityContext context) { + return httpClient; + } +} diff --git a/dev/integration_tests/image_loading/pubspec.yaml b/dev/integration_tests/image_loading/pubspec.yaml new file mode 100644 index 0000000000..a09b757c4f --- /dev/null +++ b/dev/integration_tests/image_loading/pubspec.yaml @@ -0,0 +1,63 @@ +name: image_loading +description: Integration testing library for Android semantics + +dependencies: + flutter: + sdk: flutter + test: 1.6.1 + mockito: 4.0.0 + + analyzer: 0.35.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + args: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + file: 5.0.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + front_end: 0.1.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + http: 0.12.0+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + http_multi_server: 2.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + http_parser: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl: 0.15.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + io: 0.3.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + js: 0.6.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + json_rpc_2: 2.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + kernel: 0.3.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + meta: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + mime: 0.9.6+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + multi_server_socket: 1.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + node_preamble: 1.4.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + package_config: 1.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + package_resolver: 1.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + pool: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf: 0.7.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf_packages_handler: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf_web_socket: 0.2.2+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + source_map_stack_trace: 1.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + source_maps: 0.10.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_core: 0.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + vector_math: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + vm_service_client: 0.2.6+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + watcher: 0.9.7+10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + web_socket_channel: 1.0.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + +flutter: + uses-material-design: true + +# PUBSPEC CHECKSUM: c495 diff --git a/dev/integration_tests/ios_add2app/Pods/Local Podspecs/Flutter.podspec.json b/dev/integration_tests/ios_add2app/Pods/Local Podspecs/Flutter.podspec.json index 0a8331b392..beaea03e6f 100644 --- a/dev/integration_tests/ios_add2app/Pods/Local Podspecs/Flutter.podspec.json +++ b/dev/integration_tests/ios_add2app/Pods/Local Podspecs/Flutter.podspec.json @@ -3,7 +3,7 @@ "version": "1.0.0", "summary": "High-performance, high-fidelity mobile apps.", "description": "Flutter provides an easy and productive way to build and deploy high-performance mobile apps for Android and iOS.", - "homepage": "https://flutter.io", + "homepage": "https://flutter.dev", "license": { "type": "MIT" }, diff --git a/dev/integration_tests/ios_add2app/Pods/Local Podspecs/FlutterPluginRegistrant.podspec.json b/dev/integration_tests/ios_add2app/Pods/Local Podspecs/FlutterPluginRegistrant.podspec.json index 45d68a8ff0..529af09189 100644 --- a/dev/integration_tests/ios_add2app/Pods/Local Podspecs/FlutterPluginRegistrant.podspec.json +++ b/dev/integration_tests/ios_add2app/Pods/Local Podspecs/FlutterPluginRegistrant.podspec.json @@ -3,7 +3,7 @@ "version": "0.0.1", "summary": "Registers plugins with your flutter app", "description": "Depends on all your plugins, and provides a function to register them.", - "homepage": "https://flutter.io", + "homepage": "https://flutter.dev", "license": { "type": "BSD" }, diff --git a/dev/integration_tests/ios_add2app/flutterapp/README.md b/dev/integration_tests/ios_add2app/flutterapp/README.md index a627bb57a9..ae7d53fdc6 100644 --- a/dev/integration_tests/ios_add2app/flutterapp/README.md +++ b/dev/integration_tests/ios_add2app/flutterapp/README.md @@ -5,4 +5,4 @@ A new flutter module project. ## Getting Started For help getting started with Flutter, view our online -[documentation](https://flutter.io/). +[documentation](https://flutter.dev/). diff --git a/dev/integration_tests/ios_add2app/flutterapp/pubspec.yaml b/dev/integration_tests/ios_add2app/flutterapp/pubspec.yaml index 02629b37fe..a748965c96 100644 --- a/dev/integration_tests/ios_add2app/flutterapp/pubspec.yaml +++ b/dev/integration_tests/ios_add2app/flutterapp/pubspec.yaml @@ -36,19 +36,19 @@ dev_dependencies: # For information on the generic Dart part of this file, see the # following page: https://www.dartlang.org/tools/pub/pubspec - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - quiver: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + quiver: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" flutter: # The following line ensures that the Material Icons font is @@ -63,10 +63,10 @@ flutter: # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.io/assets-and-images/#resolution-aware. + # https://flutter.dev/assets-and-images/#resolution-aware. # For details regarding adding assets from package dependencies, see - # https://flutter.io/assets-and-images/#from-packages + # https://flutter.dev/assets-and-images/#from-packages # To add Flutter specific custom fonts to your application, add a fonts # section here, in this "flutter" section. Each entry in this list should @@ -86,7 +86,7 @@ flutter: # weight: 700 # # For details regarding fonts from package dependencies, - # see https://flutter.io/custom-fonts/#from-packages + # see https://flutter.dev/custom-fonts/#from-packages # This section identifies your Flutter project as a module meant for # embedding in a native host app. These identifiers should _not_ ordinarily @@ -98,4 +98,4 @@ flutter: androidPackage: com.example.iosadd2appflutter iosBundleIdentifier: com.example.iosAdd2appFlutter -# PUBSPEC CHECKSUM: 3a66 +# PUBSPEC CHECKSUM: 4cfa diff --git a/dev/integration_tests/platform_interaction/pubspec.yaml b/dev/integration_tests/platform_interaction/pubspec.yaml index bc7c1aaf57..be47f91ee3 100644 --- a/dev/integration_tests/platform_interaction/pubspec.yaml +++ b/dev/integration_tests/platform_interaction/pubspec.yaml @@ -10,31 +10,28 @@ dependencies: sdk: flutter flutter_driver: sdk: flutter - test: 1.5.3 + test: 1.6.1 - analyzer: 0.35.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + analyzer: 0.35.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" args: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" file: 5.0.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - front_end: 0.1.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + front_end: 0.1.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - html: 0.13.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http: 0.12.0+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 2.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - intl: 0.15.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl: 0.15.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 0.3.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - json_rpc_2: 2.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - kernel: 0.3.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + json_rpc_2: 2.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + kernel: 0.3.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 0.9.6+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" multi_server_socket: 1.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -43,31 +40,29 @@ dependencies: package_resolver: 1.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - plugin: 0.2.0+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf: 0.7.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf_web_socket: 0.2.2+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf_web_socket: 0.2.2+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_map_stack_trace: 1.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_maps: 0.10.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_core: 0.2.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_core: 0.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - utf: 0.9.0+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vector_math: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - vm_service_client: 0.2.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + vm_service_client: 0.2.6+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 0.9.7+10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - web_socket_channel: 1.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + web_socket_channel: 1.0.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" flutter: uses-material-design: true -# PUBSPEC CHECKSUM: 2b9e +# PUBSPEC CHECKSUM: 6251 diff --git a/dev/integration_tests/simple_codegen/pubspec.yaml b/dev/integration_tests/simple_codegen/pubspec.yaml index eccfd9ce8d..53829d4dcb 100644 --- a/dev/integration_tests/simple_codegen/pubspec.yaml +++ b/dev/integration_tests/simple_codegen/pubspec.yaml @@ -2,31 +2,27 @@ name: simple_codegen description: A package for testing codegen dependencies: - build: 1.1.1 + build: 1.1.2 - analyzer: 0.35.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + analyzer: 0.35.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" args: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - front_end: 0.1.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + front_end: 0.1.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - html: 0.13.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - kernel: 0.3.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + kernel: 0.3.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" package_config: 1.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - plugin: 0.2.0+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - utf: 0.9.0+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 0.9.7+10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -34,4 +30,4 @@ environment: # The pub client defaults to an <2.0.0 sdk constraint which we need to explicitly overwrite. sdk: ">=2.0.0-dev.68.0 <3.0.0" -# PUBSPEC CHECKSUM: eed2 +# PUBSPEC CHECKSUM: e8fd diff --git a/dev/integration_tests/ui/pubspec.yaml b/dev/integration_tests/ui/pubspec.yaml index 916c28802a..855258af7c 100644 --- a/dev/integration_tests/ui/pubspec.yaml +++ b/dev/integration_tests/ui/pubspec.yaml @@ -11,32 +11,29 @@ dependencies: sdk: flutter flutter_driver: sdk: flutter - test: 1.5.3 + test: 1.6.1 - analyzer: 0.35.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + analyzer: 0.35.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" archive: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" args: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" file: 5.0.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - front_end: 0.1.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + front_end: 0.1.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - html: 0.13.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http: 0.12.0+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 2.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - intl: 0.15.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl: 0.15.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 0.3.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - json_rpc_2: 2.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - kernel: 0.3.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + json_rpc_2: 2.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + kernel: 0.3.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 0.9.6+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" multi_server_socket: 1.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -46,38 +43,36 @@ dependencies: path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" petitparser: 2.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - plugin: 0.2.0+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf: 0.7.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf_web_socket: 0.2.2+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf_web_socket: 0.2.2+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_map_stack_trace: 1.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_maps: 0.10.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_core: 0.2.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_core: 0.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - utf: 0.9.0+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vector_math: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - vm_service_client: 0.2.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + vm_service_client: 0.2.6+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 0.9.7+10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - web_socket_channel: 1.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + web_socket_channel: 1.0.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" xml: 3.4.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" dev_dependencies: flutter_test: sdk: flutter - test_api: 0.2.2 + test_api: 0.2.4 - quiver: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + quiver: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" flutter: uses-material-design: true -# PUBSPEC CHECKSUM: aeb8 +# PUBSPEC CHECKSUM: cf6c diff --git a/dev/manual_tests/lib/raw_keyboard.dart b/dev/manual_tests/lib/raw_keyboard.dart index a2474eed56..631da005ec 100644 --- a/dev/manual_tests/lib/raw_keyboard.dart +++ b/dev/manual_tests/lib/raw_keyboard.dart @@ -97,6 +97,11 @@ class _HardwareKeyDemoState extends State { dataText.add(Text('characters: ${data.characters}')); dataText.add(Text('charactersIgnoringModifiers: ${data.charactersIgnoringModifiers}')); dataText.add(Text('modifiers: ${data.modifiers} (${_asHex(data.modifiers)})')); + } else if (data is RawKeyEventDataLinux) { + dataText.add(Text('keyCode: ${data.keyCode} (${_asHex(data.keyCode)})')); + dataText.add(Text('scanCode: ${data.scanCode}')); + dataText.add(Text('codePoint: ${data.codePoint}')); + dataText.add(Text('modifiers: ${data.modifiers} (${_asHex(data.modifiers)})')); } dataText.add(Text('logical: ${_event.logicalKey}')); dataText.add(Text('physical: ${_event.physicalKey}')); diff --git a/dev/manual_tests/pubspec.yaml b/dev/manual_tests/pubspec.yaml index 54802c1f57..e47144de54 100644 --- a/dev/manual_tests/pubspec.yaml +++ b/dev/manual_tests/pubspec.yaml @@ -19,21 +19,21 @@ dev_dependencies: mockito: 4.0.0 - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - quiver: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + quiver: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" flutter: uses-material-design: true -# PUBSPEC CHECKSUM: 3806 +# PUBSPEC CHECKSUM: 6b9a diff --git a/dev/snippets/pubspec.yaml b/dev/snippets/pubspec.yaml index afbe7d7b84..e60b2ad746 100644 --- a/dev/snippets/pubspec.yaml +++ b/dev/snippets/pubspec.yaml @@ -14,36 +14,31 @@ dartdoc: dependencies: args: 1.5.1 - dart_style: 1.2.3 + dart_style: 1.2.4 meta: 1.1.6 platform: 2.2.0 - analyzer: 0.35.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + analyzer: 0.35.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - front_end: 0.1.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + front_end: 0.1.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - html: 0.13.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - kernel: 0.3.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + kernel: 0.3.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" package_config: 1.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - plugin: 0.2.0+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - utf: 0.9.0+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 0.9.7+10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" dev_dependencies: - test: 1.5.3 + test: 1.6.1 boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http: 0.12.0+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -51,26 +46,26 @@ dev_dependencies: http_parser: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 0.3.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - json_rpc_2: 2.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + json_rpc_2: 2.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 0.9.6+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" multi_server_socket: 1.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" node_preamble: 1.4.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" package_resolver: 1.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf: 0.7.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf_web_socket: 0.2.2+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf_web_socket: 0.2.2+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_map_stack_trace: 1.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_maps: 0.10.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_core: 0.2.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - vm_service_client: 0.2.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - web_socket_channel: 1.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_core: 0.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + vm_service_client: 0.2.6+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + web_socket_channel: 1.0.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" executables: snippets: null @@ -101,4 +96,4 @@ executables: vm_service_client: 0.2.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" web_socket_channel: 1.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" -# PUBSPEC CHECKSUM: 4eba +# PUBSPEC CHECKSUM: 996d diff --git a/dev/tools/dartdoc.dart b/dev/tools/dartdoc.dart index b7424ac045..76fc486af8 100644 --- a/dev/tools/dartdoc.dart +++ b/dev/tools/dartdoc.dart @@ -49,7 +49,7 @@ Future main(List arguments) async { // Create the pubspec.yaml file. final StringBuffer buf = StringBuffer(); buf.writeln('name: Flutter'); - buf.writeln('homepage: https://flutter.io'); + buf.writeln('homepage: https://flutter.dev'); buf.writeln('version: $version'); buf.writeln('dependencies:'); for (String package in findPackageNames()) { @@ -389,8 +389,8 @@ void changePackageToSdkInTitlebar() { final File indexFile = File('$kPublishRoot/index.html'); String indexContents = indexFile.readAsStringSync(); indexContents = indexContents.replaceFirst( - '
  • Flutter package
  • ', - '
  • Flutter SDK
  • ', + '
  • Flutter package
  • ', + '
  • Flutter SDK
  • ', ); indexFile.writeAsStringSync(indexContents); diff --git a/dev/tools/gen_keycodes/bin/gen_keycodes.dart b/dev/tools/gen_keycodes/bin/gen_keycodes.dart index 1b1ccb43d0..dd1d6c304a 100644 --- a/dev/tools/gen_keycodes/bin/gen_keycodes.dart +++ b/dev/tools/gen_keycodes/bin/gen_keycodes.dart @@ -38,6 +38,11 @@ Future getAndroidScanCodes() async { return utf8.decode(base64.decode(await http.read(scanCodesUri))); } +Future getGlfwKeyCodes() async { + final Uri keyCodesUri = Uri.parse('https://raw.githubusercontent.com/glfw/glfw/master/include/GLFW/glfw3.h'); + return await http.read(keyCodesUri); +} + Future main(List rawArguments) async { final ArgParser argParser = ArgParser(); argParser.addOption( @@ -66,6 +71,19 @@ Future main(List rawArguments) async { defaultsTo: path.join(flutterRoot.path, 'dev', 'tools', 'gen_keycodes', 'data', 'key_name_to_android_name.json'), help: 'The path to where the Android keycode to DomKey mapping is.', ); + argParser.addOption( + 'glfw-keycodes', + defaultsTo: null, + help: 'The path to where the GLFW keycodes header file should be read. ' + 'If --glfw-keycodes is not specified, the input will be read from the ' + 'correct file in the GLFW github repository.', + ); + argParser.addOption( + 'glfw-domkey', + defaultsTo: path.join(flutterRoot.path, 'dev', 'tools', 'gen_keycodes', 'data', 'key_name_to_glfw_name.json'), + help: 'The path to where the GLFW keycode to DomKey mapping is.', + ); + argParser.addOption( 'data', defaultsTo: path.join(flutterRoot.path, 'dev', 'tools', 'gen_keycodes', 'data', 'key_data.json'), @@ -136,8 +154,17 @@ Future main(List rawArguments) async { androidScanCodes = File(parsedArguments['android-scancodes']).readAsStringSync(); } + String glfwKeyCodes; + if (parsedArguments['glfw-keycodes'] == null) { + glfwKeyCodes = await getGlfwKeyCodes(); + } else { + glfwKeyCodes = File(parsedArguments['glfw-keycodes']).readAsStringSync(); + } + + final String glfwToDomKey = File(parsedArguments['glfw-domkey']).readAsStringSync(); final String androidToDomKey = File(parsedArguments['android-domkey']).readAsStringSync(); - data = KeyData(hidCodes, androidScanCodes, androidKeyCodes, androidToDomKey); + + data = KeyData(hidCodes, androidScanCodes, androidKeyCodes, androidToDomKey, glfwKeyCodes, glfwToDomKey); const JsonEncoder encoder = JsonEncoder.withIndent(' '); File(parsedArguments['data']).writeAsStringSync(encoder.convert(data.toJson())); diff --git a/dev/tools/gen_keycodes/data/key_data.json b/dev/tools/gen_keycodes/data/key_data.json index 585295f0eb..ea6d4d9cae 100644 --- a/dev/tools/gen_keycodes/data/key_data.json +++ b/dev/tools/gen_keycodes/data/key_data.json @@ -6,7 +6,8 @@ "UNKNOWN" ], "english": "None", - "chromium": "none" + "chromium": "none", + "glfw": null }, "scanCodes": { "android": null, @@ -19,7 +20,8 @@ "keyCodes": { "android": [ 0 - ] + ], + "glfw": null } }, "hyper": { @@ -27,7 +29,8 @@ "domkey": "Hyper", "android": null, "english": "Hyper", - "chromium": "hyper" + "chromium": "hyper", + "glfw": null }, "scanCodes": { "android": null, @@ -38,7 +41,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "superKey": { @@ -46,7 +50,8 @@ "domkey": "Super", "android": null, "english": "Super Key", - "chromium": "super" + "chromium": "super", + "glfw": null }, "scanCodes": { "android": null, @@ -57,7 +62,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "fn": { @@ -67,7 +73,8 @@ "FUNCTION" ], "english": "Fn", - "chromium": "fn" + "chromium": "fn", + "glfw": null }, "scanCodes": { "android": [ @@ -82,7 +89,8 @@ "keyCodes": { "android": [ 119 - ] + ], + "glfw": null } }, "fnLock": { @@ -90,7 +98,8 @@ "domkey": "FnLock", "android": null, "english": "Fn Lock", - "chromium": "fnLock" + "chromium": "fnLock", + "glfw": null }, "scanCodes": { "android": null, @@ -101,7 +110,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "suspend": { @@ -111,7 +121,8 @@ "SUSPEND" ], "english": "Suspend", - "chromium": "suspend" + "chromium": "suspend", + "glfw": null }, "scanCodes": { "android": [ @@ -124,7 +135,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "resume": { @@ -132,7 +144,8 @@ "domkey": "Resume", "android": null, "english": "Resume", - "chromium": "resume" + "chromium": "resume", + "glfw": null }, "scanCodes": { "android": null, @@ -143,7 +156,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "turbo": { @@ -151,7 +165,8 @@ "domkey": "Turbo", "android": null, "english": "Turbo", - "chromium": "turbo" + "chromium": "turbo", + "glfw": null }, "scanCodes": { "android": null, @@ -162,30 +177,8 @@ "macos": null }, "keyCodes": { - "android": null - } - }, - "launchAssistant": { - "names": { - "domkey": "LaunchAssistant", - "android": [ - "ASSIST" - ], - "english": "Launch Assistant", - "chromium": "launchAssistant" - }, - "scanCodes": { "android": null, - "usb": 23, - "linux": 583, - "xkb": 591, - "windows": null, - "macos": null - }, - "keyCodes": { - "android": [ - 219 - ] + "glfw": null } }, "sleep": { @@ -195,7 +188,8 @@ "SLEEP" ], "english": "Sleep", - "chromium": "sleep" + "chromium": "sleep", + "glfw": null }, "scanCodes": { "android": [ @@ -210,7 +204,8 @@ "keyCodes": { "android": [ 223 - ] + ], + "glfw": null } }, "wakeUp": { @@ -220,7 +215,8 @@ "WAKEUP" ], "english": "Wake Up", - "chromium": "wakeUp" + "chromium": "wakeUp", + "glfw": null }, "scanCodes": { "android": [ @@ -235,7 +231,29 @@ "keyCodes": { "android": [ 224 - ] + ], + "glfw": null + } + }, + "displayToggleIntExt": { + "names": { + "domkey": "DisplayToggleIntExt", + "android": null, + "english": "Display Toggle Int Ext", + "chromium": "displayToggleIntExt", + "glfw": null + }, + "scanCodes": { + "android": null, + "usb": 65717, + "linux": 227, + "xkb": 235, + "windows": null, + "macos": null + }, + "keyCodes": { + "android": null, + "glfw": null } }, "usbReserved": { @@ -243,7 +261,8 @@ "domkey": null, "android": null, "english": "Usb Reserved", - "chromium": "usbReserved" + "chromium": "usbReserved", + "glfw": null }, "scanCodes": { "android": null, @@ -254,7 +273,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "usbErrorRollOver": { @@ -262,7 +282,8 @@ "domkey": null, "android": null, "english": "Usb Error Roll Over", - "chromium": "usbErrorRollOver" + "chromium": "usbErrorRollOver", + "glfw": null }, "scanCodes": { "android": null, @@ -273,7 +294,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "usbPostFail": { @@ -281,7 +303,8 @@ "domkey": null, "android": null, "english": "Usb Post Fail", - "chromium": "usbPostFail" + "chromium": "usbPostFail", + "glfw": null }, "scanCodes": { "android": null, @@ -292,7 +315,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "usbErrorUndefined": { @@ -300,7 +324,8 @@ "domkey": null, "android": null, "english": "Usb Error Undefined", - "chromium": "usbErrorUndefined" + "chromium": "usbErrorUndefined", + "glfw": null }, "scanCodes": { "android": null, @@ -311,7 +336,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "keyA": { @@ -321,7 +347,10 @@ "A" ], "english": "Key A", - "chromium": "usA" + "chromium": "usA", + "glfw": [ + "A" + ] }, "scanCodes": { "android": [ @@ -336,6 +365,9 @@ "keyCodes": { "android": [ 29 + ], + "glfw": [ + 65 ] } }, @@ -346,7 +378,10 @@ "B" ], "english": "Key B", - "chromium": "usB" + "chromium": "usB", + "glfw": [ + "B" + ] }, "scanCodes": { "android": [ @@ -361,6 +396,9 @@ "keyCodes": { "android": [ 30 + ], + "glfw": [ + 66 ] } }, @@ -371,7 +409,10 @@ "C" ], "english": "Key C", - "chromium": "usC" + "chromium": "usC", + "glfw": [ + "C" + ] }, "scanCodes": { "android": [ @@ -386,6 +427,9 @@ "keyCodes": { "android": [ 31 + ], + "glfw": [ + 67 ] } }, @@ -396,7 +440,10 @@ "D" ], "english": "Key D", - "chromium": "usD" + "chromium": "usD", + "glfw": [ + "D" + ] }, "scanCodes": { "android": [ @@ -411,6 +458,9 @@ "keyCodes": { "android": [ 32 + ], + "glfw": [ + 68 ] } }, @@ -421,7 +471,10 @@ "E" ], "english": "Key E", - "chromium": "usE" + "chromium": "usE", + "glfw": [ + "E" + ] }, "scanCodes": { "android": [ @@ -436,6 +489,9 @@ "keyCodes": { "android": [ 33 + ], + "glfw": [ + 69 ] } }, @@ -446,7 +502,10 @@ "F" ], "english": "Key F", - "chromium": "usF" + "chromium": "usF", + "glfw": [ + "F" + ] }, "scanCodes": { "android": [ @@ -461,6 +520,9 @@ "keyCodes": { "android": [ 34 + ], + "glfw": [ + 70 ] } }, @@ -471,7 +533,10 @@ "G" ], "english": "Key G", - "chromium": "usG" + "chromium": "usG", + "glfw": [ + "G" + ] }, "scanCodes": { "android": [ @@ -486,6 +551,9 @@ "keyCodes": { "android": [ 35 + ], + "glfw": [ + 71 ] } }, @@ -496,7 +564,10 @@ "H" ], "english": "Key H", - "chromium": "usH" + "chromium": "usH", + "glfw": [ + "H" + ] }, "scanCodes": { "android": [ @@ -511,6 +582,9 @@ "keyCodes": { "android": [ 36 + ], + "glfw": [ + 72 ] } }, @@ -521,7 +595,10 @@ "I" ], "english": "Key I", - "chromium": "usI" + "chromium": "usI", + "glfw": [ + "I" + ] }, "scanCodes": { "android": [ @@ -536,6 +613,9 @@ "keyCodes": { "android": [ 37 + ], + "glfw": [ + 73 ] } }, @@ -546,7 +626,10 @@ "J" ], "english": "Key J", - "chromium": "usJ" + "chromium": "usJ", + "glfw": [ + "J" + ] }, "scanCodes": { "android": [ @@ -561,6 +644,9 @@ "keyCodes": { "android": [ 38 + ], + "glfw": [ + 74 ] } }, @@ -571,7 +657,10 @@ "K" ], "english": "Key K", - "chromium": "usK" + "chromium": "usK", + "glfw": [ + "K" + ] }, "scanCodes": { "android": [ @@ -586,6 +675,9 @@ "keyCodes": { "android": [ 39 + ], + "glfw": [ + 75 ] } }, @@ -596,7 +688,10 @@ "L" ], "english": "Key L", - "chromium": "usL" + "chromium": "usL", + "glfw": [ + "L" + ] }, "scanCodes": { "android": [ @@ -611,6 +706,9 @@ "keyCodes": { "android": [ 40 + ], + "glfw": [ + 76 ] } }, @@ -621,7 +719,10 @@ "M" ], "english": "Key M", - "chromium": "usM" + "chromium": "usM", + "glfw": [ + "M" + ] }, "scanCodes": { "android": [ @@ -636,6 +737,9 @@ "keyCodes": { "android": [ 41 + ], + "glfw": [ + 77 ] } }, @@ -646,7 +750,10 @@ "N" ], "english": "Key N", - "chromium": "usN" + "chromium": "usN", + "glfw": [ + "N" + ] }, "scanCodes": { "android": [ @@ -661,6 +768,9 @@ "keyCodes": { "android": [ 42 + ], + "glfw": [ + 78 ] } }, @@ -671,7 +781,10 @@ "O" ], "english": "Key O", - "chromium": "usO" + "chromium": "usO", + "glfw": [ + "O" + ] }, "scanCodes": { "android": [ @@ -686,6 +799,9 @@ "keyCodes": { "android": [ 43 + ], + "glfw": [ + 79 ] } }, @@ -696,7 +812,10 @@ "P" ], "english": "Key P", - "chromium": "usP" + "chromium": "usP", + "glfw": [ + "P" + ] }, "scanCodes": { "android": [ @@ -711,6 +830,9 @@ "keyCodes": { "android": [ 44 + ], + "glfw": [ + 80 ] } }, @@ -721,7 +843,10 @@ "Q" ], "english": "Key Q", - "chromium": "usQ" + "chromium": "usQ", + "glfw": [ + "Q" + ] }, "scanCodes": { "android": [ @@ -736,6 +861,9 @@ "keyCodes": { "android": [ 45 + ], + "glfw": [ + 81 ] } }, @@ -746,7 +874,10 @@ "R" ], "english": "Key R", - "chromium": "usR" + "chromium": "usR", + "glfw": [ + "R" + ] }, "scanCodes": { "android": [ @@ -761,6 +892,9 @@ "keyCodes": { "android": [ 46 + ], + "glfw": [ + 82 ] } }, @@ -771,7 +905,10 @@ "S" ], "english": "Key S", - "chromium": "usS" + "chromium": "usS", + "glfw": [ + "S" + ] }, "scanCodes": { "android": [ @@ -786,6 +923,9 @@ "keyCodes": { "android": [ 47 + ], + "glfw": [ + 83 ] } }, @@ -796,7 +936,10 @@ "T" ], "english": "Key T", - "chromium": "usT" + "chromium": "usT", + "glfw": [ + "T" + ] }, "scanCodes": { "android": [ @@ -811,6 +954,9 @@ "keyCodes": { "android": [ 48 + ], + "glfw": [ + 84 ] } }, @@ -821,7 +967,10 @@ "U" ], "english": "Key U", - "chromium": "usU" + "chromium": "usU", + "glfw": [ + "U" + ] }, "scanCodes": { "android": [ @@ -836,6 +985,9 @@ "keyCodes": { "android": [ 49 + ], + "glfw": [ + 85 ] } }, @@ -846,7 +998,10 @@ "V" ], "english": "Key V", - "chromium": "usV" + "chromium": "usV", + "glfw": [ + "V" + ] }, "scanCodes": { "android": [ @@ -861,6 +1016,9 @@ "keyCodes": { "android": [ 50 + ], + "glfw": [ + 86 ] } }, @@ -871,7 +1029,10 @@ "W" ], "english": "Key W", - "chromium": "usW" + "chromium": "usW", + "glfw": [ + "W" + ] }, "scanCodes": { "android": [ @@ -886,6 +1047,9 @@ "keyCodes": { "android": [ 51 + ], + "glfw": [ + 87 ] } }, @@ -896,7 +1060,10 @@ "X" ], "english": "Key X", - "chromium": "usX" + "chromium": "usX", + "glfw": [ + "X" + ] }, "scanCodes": { "android": [ @@ -911,6 +1078,9 @@ "keyCodes": { "android": [ 52 + ], + "glfw": [ + 88 ] } }, @@ -921,7 +1091,10 @@ "Y" ], "english": "Key Y", - "chromium": "usY" + "chromium": "usY", + "glfw": [ + "Y" + ] }, "scanCodes": { "android": [ @@ -936,6 +1109,9 @@ "keyCodes": { "android": [ 53 + ], + "glfw": [ + 89 ] } }, @@ -946,7 +1122,10 @@ "Z" ], "english": "Key Z", - "chromium": "usZ" + "chromium": "usZ", + "glfw": [ + "Z" + ] }, "scanCodes": { "android": [ @@ -961,6 +1140,9 @@ "keyCodes": { "android": [ 54 + ], + "glfw": [ + 90 ] } }, @@ -971,7 +1153,10 @@ "1" ], "english": "Digit 1", - "chromium": "digit1" + "chromium": "digit1", + "glfw": [ + "1" + ] }, "scanCodes": { "android": [ @@ -986,6 +1171,9 @@ "keyCodes": { "android": [ 8 + ], + "glfw": [ + 49 ] } }, @@ -996,7 +1184,10 @@ "2" ], "english": "Digit 2", - "chromium": "digit2" + "chromium": "digit2", + "glfw": [ + "2" + ] }, "scanCodes": { "android": [ @@ -1011,6 +1202,9 @@ "keyCodes": { "android": [ 9 + ], + "glfw": [ + 50 ] } }, @@ -1021,7 +1215,10 @@ "3" ], "english": "Digit 3", - "chromium": "digit3" + "chromium": "digit3", + "glfw": [ + "3" + ] }, "scanCodes": { "android": [ @@ -1036,6 +1233,9 @@ "keyCodes": { "android": [ 10 + ], + "glfw": [ + 51 ] } }, @@ -1046,7 +1246,10 @@ "4" ], "english": "Digit 4", - "chromium": "digit4" + "chromium": "digit4", + "glfw": [ + "4" + ] }, "scanCodes": { "android": [ @@ -1061,6 +1264,9 @@ "keyCodes": { "android": [ 11 + ], + "glfw": [ + 52 ] } }, @@ -1071,7 +1277,10 @@ "5" ], "english": "Digit 5", - "chromium": "digit5" + "chromium": "digit5", + "glfw": [ + "5" + ] }, "scanCodes": { "android": [ @@ -1086,6 +1295,9 @@ "keyCodes": { "android": [ 12 + ], + "glfw": [ + 53 ] } }, @@ -1096,7 +1308,10 @@ "6" ], "english": "Digit 6", - "chromium": "digit6" + "chromium": "digit6", + "glfw": [ + "6" + ] }, "scanCodes": { "android": [ @@ -1111,6 +1326,9 @@ "keyCodes": { "android": [ 13 + ], + "glfw": [ + 54 ] } }, @@ -1121,7 +1339,10 @@ "7" ], "english": "Digit 7", - "chromium": "digit7" + "chromium": "digit7", + "glfw": [ + "7" + ] }, "scanCodes": { "android": [ @@ -1136,6 +1357,9 @@ "keyCodes": { "android": [ 14 + ], + "glfw": [ + 55 ] } }, @@ -1146,7 +1370,10 @@ "8" ], "english": "Digit 8", - "chromium": "digit8" + "chromium": "digit8", + "glfw": [ + "8" + ] }, "scanCodes": { "android": [ @@ -1161,6 +1388,9 @@ "keyCodes": { "android": [ 15 + ], + "glfw": [ + 56 ] } }, @@ -1171,7 +1401,10 @@ "9" ], "english": "Digit 9", - "chromium": "digit9" + "chromium": "digit9", + "glfw": [ + "9" + ] }, "scanCodes": { "android": [ @@ -1186,6 +1419,9 @@ "keyCodes": { "android": [ 16 + ], + "glfw": [ + 57 ] } }, @@ -1196,7 +1432,10 @@ "0" ], "english": "Digit 0", - "chromium": "digit0" + "chromium": "digit0", + "glfw": [ + "0" + ] }, "scanCodes": { "android": [ @@ -1211,6 +1450,9 @@ "keyCodes": { "android": [ 7 + ], + "glfw": [ + 48 ] } }, @@ -1221,7 +1463,10 @@ "ENTER" ], "english": "Enter", - "chromium": "enter" + "chromium": "enter", + "glfw": [ + "ENTER" + ] }, "scanCodes": { "android": [ @@ -1236,6 +1481,9 @@ "keyCodes": { "android": [ 66 + ], + "glfw": [ + 257 ] } }, @@ -1246,7 +1494,10 @@ "ESCAPE" ], "english": "Escape", - "chromium": "escape" + "chromium": "escape", + "glfw": [ + "ESCAPE" + ] }, "scanCodes": { "android": [ @@ -1261,6 +1512,9 @@ "keyCodes": { "android": [ 111 + ], + "glfw": [ + 256 ] } }, @@ -1271,7 +1525,10 @@ "DEL" ], "english": "Backspace", - "chromium": "backspace" + "chromium": "backspace", + "glfw": [ + "BACKSPACE" + ] }, "scanCodes": { "android": [ @@ -1286,6 +1543,9 @@ "keyCodes": { "android": [ 67 + ], + "glfw": [ + 259 ] } }, @@ -1296,7 +1556,10 @@ "TAB" ], "english": "Tab", - "chromium": "tab" + "chromium": "tab", + "glfw": [ + "TAB" + ] }, "scanCodes": { "android": [ @@ -1311,6 +1574,9 @@ "keyCodes": { "android": [ 61 + ], + "glfw": [ + 258 ] } }, @@ -1321,7 +1587,10 @@ "SPACE" ], "english": "Space", - "chromium": "space" + "chromium": "space", + "glfw": [ + "SPACE" + ] }, "scanCodes": { "android": [ @@ -1336,6 +1605,9 @@ "keyCodes": { "android": [ 62 + ], + "glfw": [ + 32 ] } }, @@ -1346,7 +1618,10 @@ "MINUS" ], "english": "Minus", - "chromium": "minus" + "chromium": "minus", + "glfw": [ + "MINUS" + ] }, "scanCodes": { "android": [ @@ -1361,6 +1636,9 @@ "keyCodes": { "android": [ 69 + ], + "glfw": [ + 45 ] } }, @@ -1371,7 +1649,10 @@ "EQUALS" ], "english": "Equal", - "chromium": "equal" + "chromium": "equal", + "glfw": [ + "EQUAL" + ] }, "scanCodes": { "android": [ @@ -1386,6 +1667,9 @@ "keyCodes": { "android": [ 70 + ], + "glfw": [ + 61 ] } }, @@ -1396,7 +1680,10 @@ "LEFT_BRACKET" ], "english": "Bracket Left", - "chromium": "bracketLeft" + "chromium": "bracketLeft", + "glfw": [ + "LEFT_BRACKET" + ] }, "scanCodes": { "android": [ @@ -1411,6 +1698,9 @@ "keyCodes": { "android": [ 71 + ], + "glfw": [ + 91 ] } }, @@ -1421,7 +1711,10 @@ "RIGHT_BRACKET" ], "english": "Bracket Right", - "chromium": "bracketRight" + "chromium": "bracketRight", + "glfw": [ + "RIGHT_BRACKET" + ] }, "scanCodes": { "android": [ @@ -1436,6 +1729,9 @@ "keyCodes": { "android": [ 72 + ], + "glfw": [ + 93 ] } }, @@ -1446,7 +1742,10 @@ "BACKSLASH" ], "english": "Backslash", - "chromium": "backslash" + "chromium": "backslash", + "glfw": [ + "BACKSLASH" + ] }, "scanCodes": { "android": [ @@ -1462,6 +1761,9 @@ "keyCodes": { "android": [ 73 + ], + "glfw": [ + 92 ] } }, @@ -1472,7 +1774,10 @@ "SEMICOLON" ], "english": "Semicolon", - "chromium": "semicolon" + "chromium": "semicolon", + "glfw": [ + "SEMICOLON" + ] }, "scanCodes": { "android": [ @@ -1487,6 +1792,9 @@ "keyCodes": { "android": [ 74 + ], + "glfw": [ + 59 ] } }, @@ -1497,7 +1805,10 @@ "APOSTROPHE" ], "english": "Quote", - "chromium": "quote" + "chromium": "quote", + "glfw": [ + "APOSTROPHE" + ] }, "scanCodes": { "android": [ @@ -1512,6 +1823,9 @@ "keyCodes": { "android": [ 75 + ], + "glfw": [ + 39 ] } }, @@ -1522,7 +1836,10 @@ "GRAVE" ], "english": "Backquote", - "chromium": "backquote" + "chromium": "backquote", + "glfw": [ + "GRAVE_ACCENT" + ] }, "scanCodes": { "android": [ @@ -1537,6 +1854,9 @@ "keyCodes": { "android": [ 68 + ], + "glfw": [ + 96 ] } }, @@ -1547,7 +1867,10 @@ "COMMA" ], "english": "Comma", - "chromium": "comma" + "chromium": "comma", + "glfw": [ + "COMMA" + ] }, "scanCodes": { "android": [ @@ -1562,6 +1885,9 @@ "keyCodes": { "android": [ 55 + ], + "glfw": [ + 44 ] } }, @@ -1572,7 +1898,10 @@ "PERIOD" ], "english": "Period", - "chromium": "period" + "chromium": "period", + "glfw": [ + "PERIOD" + ] }, "scanCodes": { "android": [ @@ -1587,6 +1916,9 @@ "keyCodes": { "android": [ 56 + ], + "glfw": [ + 46 ] } }, @@ -1597,7 +1929,10 @@ "SLASH" ], "english": "Slash", - "chromium": "slash" + "chromium": "slash", + "glfw": [ + "SLASH" + ] }, "scanCodes": { "android": [ @@ -1612,6 +1947,9 @@ "keyCodes": { "android": [ 76 + ], + "glfw": [ + 47 ] } }, @@ -1622,7 +1960,10 @@ "CAPS_LOCK" ], "english": "Caps Lock", - "chromium": "capsLock" + "chromium": "capsLock", + "glfw": [ + "CAPS_LOCK" + ] }, "scanCodes": { "android": [ @@ -1637,6 +1978,9 @@ "keyCodes": { "android": [ 115 + ], + "glfw": [ + 280 ] } }, @@ -1647,7 +1991,10 @@ "F1" ], "english": "F1", - "chromium": "f1" + "chromium": "f1", + "glfw": [ + "F1" + ] }, "scanCodes": { "android": [ @@ -1662,6 +2009,9 @@ "keyCodes": { "android": [ 131 + ], + "glfw": [ + 290 ] } }, @@ -1672,7 +2022,10 @@ "F2" ], "english": "F2", - "chromium": "f2" + "chromium": "f2", + "glfw": [ + "F2" + ] }, "scanCodes": { "android": [ @@ -1687,6 +2040,9 @@ "keyCodes": { "android": [ 132 + ], + "glfw": [ + 291 ] } }, @@ -1697,7 +2053,10 @@ "F3" ], "english": "F3", - "chromium": "f3" + "chromium": "f3", + "glfw": [ + "F3" + ] }, "scanCodes": { "android": [ @@ -1712,6 +2071,9 @@ "keyCodes": { "android": [ 133 + ], + "glfw": [ + 292 ] } }, @@ -1722,7 +2084,10 @@ "F4" ], "english": "F4", - "chromium": "f4" + "chromium": "f4", + "glfw": [ + "F4" + ] }, "scanCodes": { "android": [ @@ -1737,6 +2102,9 @@ "keyCodes": { "android": [ 134 + ], + "glfw": [ + 293 ] } }, @@ -1747,7 +2115,10 @@ "F5" ], "english": "F5", - "chromium": "f5" + "chromium": "f5", + "glfw": [ + "F5" + ] }, "scanCodes": { "android": [ @@ -1762,6 +2133,9 @@ "keyCodes": { "android": [ 135 + ], + "glfw": [ + 294 ] } }, @@ -1772,7 +2146,10 @@ "F6" ], "english": "F6", - "chromium": "f6" + "chromium": "f6", + "glfw": [ + "F6" + ] }, "scanCodes": { "android": [ @@ -1787,6 +2164,9 @@ "keyCodes": { "android": [ 136 + ], + "glfw": [ + 295 ] } }, @@ -1797,7 +2177,10 @@ "F7" ], "english": "F7", - "chromium": "f7" + "chromium": "f7", + "glfw": [ + "F7" + ] }, "scanCodes": { "android": [ @@ -1812,6 +2195,9 @@ "keyCodes": { "android": [ 137 + ], + "glfw": [ + 296 ] } }, @@ -1822,7 +2208,10 @@ "F8" ], "english": "F8", - "chromium": "f8" + "chromium": "f8", + "glfw": [ + "F8" + ] }, "scanCodes": { "android": [ @@ -1837,6 +2226,9 @@ "keyCodes": { "android": [ 138 + ], + "glfw": [ + 297 ] } }, @@ -1847,7 +2239,10 @@ "F9" ], "english": "F9", - "chromium": "f9" + "chromium": "f9", + "glfw": [ + "F9" + ] }, "scanCodes": { "android": [ @@ -1862,6 +2257,9 @@ "keyCodes": { "android": [ 139 + ], + "glfw": [ + 298 ] } }, @@ -1872,7 +2270,10 @@ "F10" ], "english": "F10", - "chromium": "f10" + "chromium": "f10", + "glfw": [ + "F10" + ] }, "scanCodes": { "android": [ @@ -1887,6 +2288,9 @@ "keyCodes": { "android": [ 140 + ], + "glfw": [ + 299 ] } }, @@ -1897,7 +2301,10 @@ "F11" ], "english": "F11", - "chromium": "f11" + "chromium": "f11", + "glfw": [ + "F11" + ] }, "scanCodes": { "android": [ @@ -1912,6 +2319,9 @@ "keyCodes": { "android": [ 141 + ], + "glfw": [ + 300 ] } }, @@ -1922,7 +2332,10 @@ "F12" ], "english": "F12", - "chromium": "f12" + "chromium": "f12", + "glfw": [ + "F12" + ] }, "scanCodes": { "android": [ @@ -1937,6 +2350,9 @@ "keyCodes": { "android": [ 142 + ], + "glfw": [ + 301 ] } }, @@ -1947,7 +2363,10 @@ "SYSRQ" ], "english": "Print Screen", - "chromium": "printScreen" + "chromium": "printScreen", + "glfw": [ + "PRINT_SCREEN" + ] }, "scanCodes": { "android": [ @@ -1962,6 +2381,9 @@ "keyCodes": { "android": [ 120 + ], + "glfw": [ + 283 ] } }, @@ -1972,7 +2394,8 @@ "SCROLL_LOCK" ], "english": "Scroll Lock", - "chromium": "scrollLock" + "chromium": "scrollLock", + "glfw": null }, "scanCodes": { "android": [ @@ -1987,7 +2410,8 @@ "keyCodes": { "android": [ 116 - ] + ], + "glfw": null } }, "pause": { @@ -1997,7 +2421,10 @@ "BREAK" ], "english": "Pause", - "chromium": "pause" + "chromium": "pause", + "glfw": [ + "PAUSE" + ] }, "scanCodes": { "android": [ @@ -2013,6 +2440,9 @@ "keyCodes": { "android": [ 121 + ], + "glfw": [ + 284 ] } }, @@ -2023,7 +2453,10 @@ "INSERT" ], "english": "Insert", - "chromium": "insert" + "chromium": "insert", + "glfw": [ + "INSERT" + ] }, "scanCodes": { "android": [ @@ -2038,6 +2471,9 @@ "keyCodes": { "android": [ 124 + ], + "glfw": [ + 260 ] } }, @@ -2048,7 +2484,10 @@ "MOVE_HOME" ], "english": "Home", - "chromium": "home" + "chromium": "home", + "glfw": [ + "HOME" + ] }, "scanCodes": { "android": [ @@ -2063,6 +2502,9 @@ "keyCodes": { "android": [ 122 + ], + "glfw": [ + 268 ] } }, @@ -2073,7 +2515,10 @@ "PAGE_UP" ], "english": "Page Up", - "chromium": "pageUp" + "chromium": "pageUp", + "glfw": [ + "PAGE_UP" + ] }, "scanCodes": { "android": [ @@ -2089,6 +2534,9 @@ "keyCodes": { "android": [ 92 + ], + "glfw": [ + 266 ] } }, @@ -2099,7 +2547,10 @@ "FORWARD_DEL" ], "english": "Delete", - "chromium": "del" + "chromium": "del", + "glfw": [ + "DELETE" + ] }, "scanCodes": { "android": [ @@ -2114,6 +2565,9 @@ "keyCodes": { "android": [ 112 + ], + "glfw": [ + 261 ] } }, @@ -2124,7 +2578,10 @@ "MOVE_END" ], "english": "End", - "chromium": "end" + "chromium": "end", + "glfw": [ + "END" + ] }, "scanCodes": { "android": [ @@ -2139,6 +2596,9 @@ "keyCodes": { "android": [ 123 + ], + "glfw": [ + 269 ] } }, @@ -2149,7 +2609,10 @@ "PAGE_DOWN" ], "english": "Page Down", - "chromium": "pageDown" + "chromium": "pageDown", + "glfw": [ + "PAGE_DOWN" + ] }, "scanCodes": { "android": [ @@ -2165,6 +2628,9 @@ "keyCodes": { "android": [ 93 + ], + "glfw": [ + 267 ] } }, @@ -2175,7 +2641,10 @@ "DPAD_RIGHT" ], "english": "Arrow Right", - "chromium": "arrowRight" + "chromium": "arrowRight", + "glfw": [ + "RIGHT" + ] }, "scanCodes": { "android": [ @@ -2190,6 +2659,9 @@ "keyCodes": { "android": [ 22 + ], + "glfw": [ + 262 ] } }, @@ -2200,7 +2672,10 @@ "DPAD_LEFT" ], "english": "Arrow Left", - "chromium": "arrowLeft" + "chromium": "arrowLeft", + "glfw": [ + "LEFT" + ] }, "scanCodes": { "android": [ @@ -2215,6 +2690,9 @@ "keyCodes": { "android": [ 21 + ], + "glfw": [ + 263 ] } }, @@ -2225,7 +2703,10 @@ "DPAD_DOWN" ], "english": "Arrow Down", - "chromium": "arrowDown" + "chromium": "arrowDown", + "glfw": [ + "DOWN" + ] }, "scanCodes": { "android": [ @@ -2240,6 +2721,9 @@ "keyCodes": { "android": [ 20 + ], + "glfw": [ + 264 ] } }, @@ -2250,7 +2734,10 @@ "DPAD_UP" ], "english": "Arrow Up", - "chromium": "arrowUp" + "chromium": "arrowUp", + "glfw": [ + "UP" + ] }, "scanCodes": { "android": [ @@ -2265,6 +2752,9 @@ "keyCodes": { "android": [ 19 + ], + "glfw": [ + 265 ] } }, @@ -2275,7 +2765,10 @@ "NUM_LOCK" ], "english": "Num Lock", - "chromium": "numLock" + "chromium": "numLock", + "glfw": [ + "NUM_LOCK" + ] }, "scanCodes": { "android": [ @@ -2290,6 +2783,9 @@ "keyCodes": { "android": [ 143 + ], + "glfw": [ + 282 ] } }, @@ -2300,7 +2796,10 @@ "NUMPAD_DIVIDE" ], "english": "Numpad Divide", - "chromium": "numpadDivide" + "chromium": "numpadDivide", + "glfw": [ + "KP_DIVIDE" + ] }, "scanCodes": { "android": [ @@ -2315,6 +2814,9 @@ "keyCodes": { "android": [ 154 + ], + "glfw": [ + 331 ] } }, @@ -2325,7 +2827,10 @@ "NUMPAD_MULTIPLY" ], "english": "Numpad Multiply", - "chromium": "numpadMultiply" + "chromium": "numpadMultiply", + "glfw": [ + "KP_MULTIPLY" + ] }, "scanCodes": { "android": [ @@ -2340,6 +2845,9 @@ "keyCodes": { "android": [ 155 + ], + "glfw": [ + 332 ] } }, @@ -2350,7 +2858,10 @@ "NUMPAD_SUBTRACT" ], "english": "Numpad Subtract", - "chromium": "numpadSubtract" + "chromium": "numpadSubtract", + "glfw": [ + "NUMPAD_SUBTRACT" + ] }, "scanCodes": { "android": [ @@ -2365,7 +2876,8 @@ "keyCodes": { "android": [ 156 - ] + ], + "glfw": null } }, "numpadAdd": { @@ -2375,7 +2887,10 @@ "NUMPAD_ADD" ], "english": "Numpad Add", - "chromium": "numpadAdd" + "chromium": "numpadAdd", + "glfw": [ + "KP_ADD" + ] }, "scanCodes": { "android": [ @@ -2390,6 +2905,9 @@ "keyCodes": { "android": [ 157 + ], + "glfw": [ + 334 ] } }, @@ -2400,7 +2918,10 @@ "NUMPAD_ENTER" ], "english": "Numpad Enter", - "chromium": "numpadEnter" + "chromium": "numpadEnter", + "glfw": [ + "KP_ENTER" + ] }, "scanCodes": { "android": [ @@ -2415,6 +2936,9 @@ "keyCodes": { "android": [ 160 + ], + "glfw": [ + 335 ] } }, @@ -2425,7 +2949,10 @@ "NUMPAD_1" ], "english": "Numpad 1", - "chromium": "numpad1" + "chromium": "numpad1", + "glfw": [ + "KP_1" + ] }, "scanCodes": { "android": [ @@ -2440,6 +2967,9 @@ "keyCodes": { "android": [ 145 + ], + "glfw": [ + 321 ] } }, @@ -2450,7 +2980,10 @@ "NUMPAD_2" ], "english": "Numpad 2", - "chromium": "numpad2" + "chromium": "numpad2", + "glfw": [ + "KP_2" + ] }, "scanCodes": { "android": [ @@ -2465,6 +2998,9 @@ "keyCodes": { "android": [ 146 + ], + "glfw": [ + 322 ] } }, @@ -2475,7 +3011,10 @@ "NUMPAD_3" ], "english": "Numpad 3", - "chromium": "numpad3" + "chromium": "numpad3", + "glfw": [ + "KP_3" + ] }, "scanCodes": { "android": [ @@ -2490,6 +3029,9 @@ "keyCodes": { "android": [ 147 + ], + "glfw": [ + 323 ] } }, @@ -2500,7 +3042,10 @@ "NUMPAD_4" ], "english": "Numpad 4", - "chromium": "numpad4" + "chromium": "numpad4", + "glfw": [ + "KP_4" + ] }, "scanCodes": { "android": [ @@ -2515,6 +3060,9 @@ "keyCodes": { "android": [ 148 + ], + "glfw": [ + 324 ] } }, @@ -2525,7 +3073,10 @@ "NUMPAD_5" ], "english": "Numpad 5", - "chromium": "numpad5" + "chromium": "numpad5", + "glfw": [ + "KP_5" + ] }, "scanCodes": { "android": [ @@ -2540,6 +3091,9 @@ "keyCodes": { "android": [ 149 + ], + "glfw": [ + 325 ] } }, @@ -2550,7 +3104,10 @@ "NUMPAD_6" ], "english": "Numpad 6", - "chromium": "numpad6" + "chromium": "numpad6", + "glfw": [ + "KP_6" + ] }, "scanCodes": { "android": [ @@ -2565,6 +3122,9 @@ "keyCodes": { "android": [ 150 + ], + "glfw": [ + 326 ] } }, @@ -2575,7 +3135,10 @@ "NUMPAD_7" ], "english": "Numpad 7", - "chromium": "numpad7" + "chromium": "numpad7", + "glfw": [ + "KP_7" + ] }, "scanCodes": { "android": [ @@ -2590,6 +3153,9 @@ "keyCodes": { "android": [ 151 + ], + "glfw": [ + 327 ] } }, @@ -2600,7 +3166,10 @@ "NUMPAD_8" ], "english": "Numpad 8", - "chromium": "numpad8" + "chromium": "numpad8", + "glfw": [ + "KP_8" + ] }, "scanCodes": { "android": [ @@ -2615,6 +3184,9 @@ "keyCodes": { "android": [ 152 + ], + "glfw": [ + 328 ] } }, @@ -2625,7 +3197,10 @@ "NUMPAD_9" ], "english": "Numpad 9", - "chromium": "numpad9" + "chromium": "numpad9", + "glfw": [ + "KP_9" + ] }, "scanCodes": { "android": [ @@ -2640,6 +3215,9 @@ "keyCodes": { "android": [ 153 + ], + "glfw": [ + 329 ] } }, @@ -2650,7 +3228,10 @@ "NUMPAD_0" ], "english": "Numpad 0", - "chromium": "numpad0" + "chromium": "numpad0", + "glfw": [ + "KP_0" + ] }, "scanCodes": { "android": [ @@ -2665,6 +3246,9 @@ "keyCodes": { "android": [ 144 + ], + "glfw": [ + 320 ] } }, @@ -2675,7 +3259,10 @@ "NUMPAD_DOT" ], "english": "Numpad Decimal", - "chromium": "numpadDecimal" + "chromium": "numpadDecimal", + "glfw": [ + "KP_DECIMAL" + ] }, "scanCodes": { "android": [ @@ -2690,6 +3277,9 @@ "keyCodes": { "android": [ 158 + ], + "glfw": [ + 330 ] } }, @@ -2698,7 +3288,8 @@ "domkey": "IntlBackslash", "android": null, "english": "Intl Backslash", - "chromium": "intlBackslash" + "chromium": "intlBackslash", + "glfw": null }, "scanCodes": { "android": null, @@ -2709,7 +3300,8 @@ "macos": 10 }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "contextMenu": { @@ -2719,7 +3311,10 @@ "MENU" ], "english": "Context Menu", - "chromium": "contextMenu" + "chromium": "contextMenu", + "glfw": [ + "MENU" + ] }, "scanCodes": { "android": [ @@ -2735,6 +3330,9 @@ "keyCodes": { "android": [ 82 + ], + "glfw": [ + 348 ] } }, @@ -2745,7 +3343,8 @@ "POWER" ], "english": "Power", - "chromium": "power" + "chromium": "power", + "glfw": null }, "scanCodes": { "android": [ @@ -2761,7 +3360,8 @@ "keyCodes": { "android": [ 26 - ] + ], + "glfw": null } }, "numpadEqual": { @@ -2771,7 +3371,10 @@ "NUMPAD_EQUALS" ], "english": "Numpad Equal", - "chromium": "numpadEqual" + "chromium": "numpadEqual", + "glfw": [ + "KP_EQUAL" + ] }, "scanCodes": { "android": [ @@ -2786,6 +3389,9 @@ "keyCodes": { "android": [ 161 + ], + "glfw": [ + 336 ] } }, @@ -2796,7 +3402,10 @@ "F13" ], "english": "F13", - "chromium": "f13" + "chromium": "f13", + "glfw": [ + "F13" + ] }, "scanCodes": { "android": [ @@ -2809,7 +3418,10 @@ "macos": 105 }, "keyCodes": { - "android": null + "android": null, + "glfw": [ + 302 + ] } }, "f14": { @@ -2819,7 +3431,10 @@ "F14" ], "english": "F14", - "chromium": "f14" + "chromium": "f14", + "glfw": [ + "F14" + ] }, "scanCodes": { "android": [ @@ -2832,7 +3447,10 @@ "macos": 107 }, "keyCodes": { - "android": null + "android": null, + "glfw": [ + 303 + ] } }, "f15": { @@ -2842,7 +3460,10 @@ "F15" ], "english": "F15", - "chromium": "f15" + "chromium": "f15", + "glfw": [ + "F15" + ] }, "scanCodes": { "android": [ @@ -2855,7 +3476,10 @@ "macos": 113 }, "keyCodes": { - "android": null + "android": null, + "glfw": [ + 304 + ] } }, "f16": { @@ -2865,7 +3489,10 @@ "F16" ], "english": "F16", - "chromium": "f16" + "chromium": "f16", + "glfw": [ + "F16" + ] }, "scanCodes": { "android": [ @@ -2878,7 +3505,10 @@ "macos": 106 }, "keyCodes": { - "android": null + "android": null, + "glfw": [ + 305 + ] } }, "f17": { @@ -2888,7 +3518,10 @@ "F17" ], "english": "F17", - "chromium": "f17" + "chromium": "f17", + "glfw": [ + "F17" + ] }, "scanCodes": { "android": [ @@ -2901,7 +3534,10 @@ "macos": 64 }, "keyCodes": { - "android": null + "android": null, + "glfw": [ + 306 + ] } }, "f18": { @@ -2911,7 +3547,10 @@ "F18" ], "english": "F18", - "chromium": "f18" + "chromium": "f18", + "glfw": [ + "F18" + ] }, "scanCodes": { "android": [ @@ -2924,7 +3563,10 @@ "macos": 79 }, "keyCodes": { - "android": null + "android": null, + "glfw": [ + 307 + ] } }, "f19": { @@ -2934,7 +3576,10 @@ "F19" ], "english": "F19", - "chromium": "f19" + "chromium": "f19", + "glfw": [ + "F19" + ] }, "scanCodes": { "android": [ @@ -2947,7 +3592,10 @@ "macos": 80 }, "keyCodes": { - "android": null + "android": null, + "glfw": [ + 308 + ] } }, "f20": { @@ -2957,7 +3605,10 @@ "F20" ], "english": "F20", - "chromium": "f20" + "chromium": "f20", + "glfw": [ + "F20" + ] }, "scanCodes": { "android": [ @@ -2970,7 +3621,10 @@ "macos": 90 }, "keyCodes": { - "android": null + "android": null, + "glfw": [ + 309 + ] } }, "f21": { @@ -2980,7 +3634,10 @@ "F21" ], "english": "F21", - "chromium": "f21" + "chromium": "f21", + "glfw": [ + "F21" + ] }, "scanCodes": { "android": [ @@ -2993,7 +3650,10 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": [ + 310 + ] } }, "f22": { @@ -3003,7 +3663,10 @@ "F22" ], "english": "F22", - "chromium": "f22" + "chromium": "f22", + "glfw": [ + "F22" + ] }, "scanCodes": { "android": [ @@ -3016,7 +3679,10 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": [ + 311 + ] } }, "f23": { @@ -3026,7 +3692,10 @@ "F23" ], "english": "F23", - "chromium": "f23" + "chromium": "f23", + "glfw": [ + "F23" + ] }, "scanCodes": { "android": [ @@ -3039,7 +3708,10 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": [ + 312 + ] } }, "f24": { @@ -3049,7 +3721,8 @@ "F24" ], "english": "F24", - "chromium": "f24" + "chromium": "f24", + "glfw": null }, "scanCodes": { "android": [ @@ -3062,7 +3735,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "open": { @@ -3072,7 +3746,8 @@ "OPEN" ], "english": "Open", - "chromium": "open" + "chromium": "open", + "glfw": null }, "scanCodes": { "android": [ @@ -3085,7 +3760,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "help": { @@ -3095,7 +3771,8 @@ "HELP" ], "english": "Help", - "chromium": "help" + "chromium": "help", + "glfw": null }, "scanCodes": { "android": [ @@ -3110,7 +3787,8 @@ "keyCodes": { "android": [ 259 - ] + ], + "glfw": null } }, "select": { @@ -3118,7 +3796,8 @@ "domkey": "Select", "android": null, "english": "Select", - "chromium": "select" + "chromium": "select", + "glfw": null }, "scanCodes": { "android": null, @@ -3129,7 +3808,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "again": { @@ -3139,7 +3819,8 @@ "AGAIN" ], "english": "Again", - "chromium": "again" + "chromium": "again", + "glfw": null }, "scanCodes": { "android": [ @@ -3152,7 +3833,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "undo": { @@ -3162,7 +3844,8 @@ "UNDO" ], "english": "Undo", - "chromium": "undo" + "chromium": "undo", + "glfw": null }, "scanCodes": { "android": [ @@ -3175,7 +3858,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "cut": { @@ -3185,7 +3869,8 @@ "CUT" ], "english": "Cut", - "chromium": "cut" + "chromium": "cut", + "glfw": null }, "scanCodes": { "android": [ @@ -3200,7 +3885,8 @@ "keyCodes": { "android": [ 277 - ] + ], + "glfw": null } }, "copy": { @@ -3210,7 +3896,8 @@ "COPY" ], "english": "Copy", - "chromium": "copy" + "chromium": "copy", + "glfw": null }, "scanCodes": { "android": [ @@ -3225,7 +3912,8 @@ "keyCodes": { "android": [ 278 - ] + ], + "glfw": null } }, "paste": { @@ -3235,7 +3923,8 @@ "PASTE" ], "english": "Paste", - "chromium": "paste" + "chromium": "paste", + "glfw": null }, "scanCodes": { "android": [ @@ -3250,7 +3939,8 @@ "keyCodes": { "android": [ 279 - ] + ], + "glfw": null } }, "find": { @@ -3260,7 +3950,8 @@ "FIND" ], "english": "Find", - "chromium": "find" + "chromium": "find", + "glfw": null }, "scanCodes": { "android": [ @@ -3273,7 +3964,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "audioVolumeMute": { @@ -3283,7 +3975,8 @@ "VOLUME_MUTE" ], "english": "Audio Volume Mute", - "chromium": "volumeMute" + "chromium": "volumeMute", + "glfw": null }, "scanCodes": { "android": [ @@ -3298,7 +3991,8 @@ "keyCodes": { "android": [ 164 - ] + ], + "glfw": null } }, "audioVolumeUp": { @@ -3308,7 +4002,8 @@ "VOLUME_UP" ], "english": "Audio Volume Up", - "chromium": "volumeUp" + "chromium": "volumeUp", + "glfw": null }, "scanCodes": { "android": [ @@ -3323,7 +4018,8 @@ "keyCodes": { "android": [ 24 - ] + ], + "glfw": null } }, "audioVolumeDown": { @@ -3333,7 +4029,8 @@ "VOLUME_DOWN" ], "english": "Audio Volume Down", - "chromium": "volumeDown" + "chromium": "volumeDown", + "glfw": null }, "scanCodes": { "android": [ @@ -3348,7 +4045,8 @@ "keyCodes": { "android": [ 25 - ] + ], + "glfw": null } }, "numpadComma": { @@ -3358,7 +4056,8 @@ "NUMPAD_COMMA" ], "english": "Numpad Comma", - "chromium": "numpadComma" + "chromium": "numpadComma", + "glfw": null }, "scanCodes": { "android": [ @@ -3374,7 +4073,8 @@ "keyCodes": { "android": [ 159 - ] + ], + "glfw": null } }, "intlRo": { @@ -3382,7 +4082,8 @@ "domkey": "IntlRo", "android": null, "english": "Intl Ro", - "chromium": "intlRo" + "chromium": "intlRo", + "glfw": null }, "scanCodes": { "android": null, @@ -3393,7 +4094,8 @@ "macos": 94 }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "kanaMode": { @@ -3401,7 +4103,8 @@ "domkey": "KanaMode", "android": null, "english": "Kana Mode", - "chromium": "kanaMode" + "chromium": "kanaMode", + "glfw": null }, "scanCodes": { "android": null, @@ -3412,7 +4115,8 @@ "macos": 104 }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "intlYen": { @@ -3420,7 +4124,8 @@ "domkey": "IntlYen", "android": null, "english": "Intl Yen", - "chromium": "intlYen" + "chromium": "intlYen", + "glfw": null }, "scanCodes": { "android": null, @@ -3431,7 +4136,8 @@ "macos": 93 }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "convert": { @@ -3441,7 +4147,8 @@ "HENKAN" ], "english": "Convert", - "chromium": "convert" + "chromium": "convert", + "glfw": null }, "scanCodes": { "android": [ @@ -3456,7 +4163,8 @@ "keyCodes": { "android": [ 214 - ] + ], + "glfw": null } }, "nonConvert": { @@ -3466,7 +4174,8 @@ "MUHENKAN" ], "english": "Non Convert", - "chromium": "nonConvert" + "chromium": "nonConvert", + "glfw": null }, "scanCodes": { "android": [ @@ -3481,7 +4190,8 @@ "keyCodes": { "android": [ 213 - ] + ], + "glfw": null } }, "lang1": { @@ -3489,7 +4199,8 @@ "domkey": "Lang1", "android": null, "english": "Lang 1", - "chromium": "lang1" + "chromium": "lang1", + "glfw": null }, "scanCodes": { "android": null, @@ -3500,7 +4211,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "lang2": { @@ -3508,7 +4220,8 @@ "domkey": "Lang2", "android": null, "english": "Lang 2", - "chromium": "lang2" + "chromium": "lang2", + "glfw": null }, "scanCodes": { "android": null, @@ -3519,7 +4232,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "lang3": { @@ -3529,7 +4243,8 @@ "KATAKANA" ], "english": "Lang 3", - "chromium": "lang3" + "chromium": "lang3", + "glfw": null }, "scanCodes": { "android": [ @@ -3542,7 +4257,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "lang4": { @@ -3552,7 +4268,8 @@ "HIRAGANA" ], "english": "Lang 4", - "chromium": "lang4" + "chromium": "lang4", + "glfw": null }, "scanCodes": { "android": [ @@ -3565,7 +4282,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "lang5": { @@ -3573,7 +4291,8 @@ "domkey": "Lang5", "android": null, "english": "Lang 5", - "chromium": "lang5" + "chromium": "lang5", + "glfw": null }, "scanCodes": { "android": null, @@ -3584,7 +4303,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "abort": { @@ -3592,7 +4312,8 @@ "domkey": "Abort", "android": null, "english": "Abort", - "chromium": "abort" + "chromium": "abort", + "glfw": null }, "scanCodes": { "android": null, @@ -3603,7 +4324,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "props": { @@ -3613,7 +4335,8 @@ "PROPS" ], "english": "Props", - "chromium": "props" + "chromium": "props", + "glfw": null }, "scanCodes": { "android": [ @@ -3626,7 +4349,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "numpadParenLeft": { @@ -3636,7 +4360,8 @@ "NUMPAD_LEFT_PAREN" ], "english": "Numpad Paren Left", - "chromium": "numpadParenLeft" + "chromium": "numpadParenLeft", + "glfw": null }, "scanCodes": { "android": [ @@ -3651,7 +4376,8 @@ "keyCodes": { "android": [ 162 - ] + ], + "glfw": null } }, "numpadParenRight": { @@ -3661,7 +4387,8 @@ "NUMPAD_RIGHT_PAREN" ], "english": "Numpad Paren Right", - "chromium": "numpadParenRight" + "chromium": "numpadParenRight", + "glfw": null }, "scanCodes": { "android": [ @@ -3676,7 +4403,8 @@ "keyCodes": { "android": [ 163 - ] + ], + "glfw": null } }, "numpadBackspace": { @@ -3684,7 +4412,8 @@ "domkey": "NumpadBackspace", "android": null, "english": "Numpad Backspace", - "chromium": "numpadBackspace" + "chromium": "numpadBackspace", + "glfw": null }, "scanCodes": { "android": null, @@ -3695,7 +4424,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "numpadMemoryStore": { @@ -3703,7 +4433,8 @@ "domkey": "NumpadMemoryStore", "android": null, "english": "Numpad Memory Store", - "chromium": "numpadMemoryStore" + "chromium": "numpadMemoryStore", + "glfw": null }, "scanCodes": { "android": null, @@ -3714,7 +4445,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "numpadMemoryRecall": { @@ -3722,7 +4454,8 @@ "domkey": "NumpadMemoryRecall", "android": null, "english": "Numpad Memory Recall", - "chromium": "numpadMemoryRecall" + "chromium": "numpadMemoryRecall", + "glfw": null }, "scanCodes": { "android": null, @@ -3733,7 +4466,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "numpadMemoryClear": { @@ -3741,7 +4475,8 @@ "domkey": "NumpadMemoryClear", "android": null, "english": "Numpad Memory Clear", - "chromium": "numpadMemoryClear" + "chromium": "numpadMemoryClear", + "glfw": null }, "scanCodes": { "android": null, @@ -3752,7 +4487,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "numpadMemoryAdd": { @@ -3760,7 +4496,8 @@ "domkey": "NumpadMemoryAdd", "android": null, "english": "Numpad Memory Add", - "chromium": "numpadMemoryAdd" + "chromium": "numpadMemoryAdd", + "glfw": null }, "scanCodes": { "android": null, @@ -3771,7 +4508,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "numpadMemorySubtract": { @@ -3779,7 +4517,8 @@ "domkey": "NumpadMemorySubtract", "android": null, "english": "Numpad Memory Subtract", - "chromium": "numpadMemorySubtract" + "chromium": "numpadMemorySubtract", + "glfw": null }, "scanCodes": { "android": null, @@ -3790,7 +4529,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "numpadSignChange": { @@ -3798,7 +4538,8 @@ "domkey": null, "android": null, "english": "Numpad Sign Change", - "chromium": "numpadSignChange" + "chromium": "numpadSignChange", + "glfw": null }, "scanCodes": { "android": null, @@ -3809,7 +4550,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "numpadClear": { @@ -3817,7 +4559,8 @@ "domkey": "NumpadClear", "android": null, "english": "Numpad Clear", - "chromium": "numpadClear" + "chromium": "numpadClear", + "glfw": null }, "scanCodes": { "android": null, @@ -3828,7 +4571,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "numpadClearEntry": { @@ -3836,7 +4580,8 @@ "domkey": "NumpadClearEntry", "android": null, "english": "Numpad Clear Entry", - "chromium": "numpadClearEntry" + "chromium": "numpadClearEntry", + "glfw": null }, "scanCodes": { "android": null, @@ -3847,7 +4592,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "controlLeft": { @@ -3857,7 +4603,10 @@ "CTRL_LEFT" ], "english": "Control Left", - "chromium": "controlLeft" + "chromium": "controlLeft", + "glfw": [ + "LEFT_CONTROL" + ] }, "scanCodes": { "android": [ @@ -3872,6 +4621,9 @@ "keyCodes": { "android": [ 113 + ], + "glfw": [ + 341 ] } }, @@ -3882,7 +4634,10 @@ "SHIFT_LEFT" ], "english": "Shift Left", - "chromium": "shiftLeft" + "chromium": "shiftLeft", + "glfw": [ + "LEFT_SHIFT" + ] }, "scanCodes": { "android": [ @@ -3897,6 +4652,9 @@ "keyCodes": { "android": [ 59 + ], + "glfw": [ + 340 ] } }, @@ -3907,7 +4665,10 @@ "ALT_LEFT" ], "english": "Alt Left", - "chromium": "altLeft" + "chromium": "altLeft", + "glfw": [ + "LEFT_ALT" + ] }, "scanCodes": { "android": [ @@ -3922,6 +4683,9 @@ "keyCodes": { "android": [ 57 + ], + "glfw": [ + 342 ] } }, @@ -3932,7 +4696,8 @@ "META_LEFT" ], "english": "Meta Left", - "chromium": "metaLeft" + "chromium": "metaLeft", + "glfw": null }, "scanCodes": { "android": [ @@ -3947,7 +4712,8 @@ "keyCodes": { "android": [ 117 - ] + ], + "glfw": null } }, "controlRight": { @@ -3957,7 +4723,10 @@ "CTRL_RIGHT" ], "english": "Control Right", - "chromium": "controlRight" + "chromium": "controlRight", + "glfw": [ + "RIGHT_CONTROL" + ] }, "scanCodes": { "android": [ @@ -3972,6 +4741,9 @@ "keyCodes": { "android": [ 114 + ], + "glfw": [ + 345 ] } }, @@ -3982,7 +4754,10 @@ "SHIFT_RIGHT" ], "english": "Shift Right", - "chromium": "shiftRight" + "chromium": "shiftRight", + "glfw": [ + "RIGHT_SHIFT" + ] }, "scanCodes": { "android": [ @@ -3997,6 +4772,9 @@ "keyCodes": { "android": [ 60 + ], + "glfw": [ + 344 ] } }, @@ -4007,7 +4785,10 @@ "ALT_RIGHT" ], "english": "Alt Right", - "chromium": "altRight" + "chromium": "altRight", + "glfw": [ + "RIGHT_ALT" + ] }, "scanCodes": { "android": [ @@ -4022,6 +4803,9 @@ "keyCodes": { "android": [ 58 + ], + "glfw": [ + 346 ] } }, @@ -4032,7 +4816,8 @@ "META_RIGHT" ], "english": "Meta Right", - "chromium": "metaRight" + "chromium": "metaRight", + "glfw": null }, "scanCodes": { "android": [ @@ -4047,7 +4832,8 @@ "keyCodes": { "android": [ 118 - ] + ], + "glfw": null } }, "info": { @@ -4057,7 +4843,8 @@ "INFO" ], "english": "Info", - "chromium": "info" + "chromium": "info", + "glfw": null }, "scanCodes": { "android": [ @@ -4072,7 +4859,8 @@ "keyCodes": { "android": [ 165 - ] + ], + "glfw": null } }, "closedCaptionToggle": { @@ -4082,7 +4870,8 @@ "CAPTIONS" ], "english": "Closed Caption Toggle", - "chromium": "closedCaptionToggle" + "chromium": "closedCaptionToggle", + "glfw": null }, "scanCodes": { "android": null, @@ -4095,7 +4884,8 @@ "keyCodes": { "android": [ 175 - ] + ], + "glfw": null } }, "brightnessUp": { @@ -4105,7 +4895,8 @@ "BRIGHTNESS_UP" ], "english": "Brightness Up", - "chromium": "brightnessUp" + "chromium": "brightnessUp", + "glfw": null }, "scanCodes": { "android": [ @@ -4120,7 +4911,8 @@ "keyCodes": { "android": [ 221 - ] + ], + "glfw": null } }, "brightnessDown": { @@ -4130,7 +4922,8 @@ "BRIGHTNESS_DOWN" ], "english": "Brightness Down", - "chromium": "brightnessDown" + "chromium": "brightnessDown", + "glfw": null }, "scanCodes": { "android": [ @@ -4145,7 +4938,8 @@ "keyCodes": { "android": [ 220 - ] + ], + "glfw": null } }, "brightnessToggle": { @@ -4153,7 +4947,8 @@ "domkey": null, "android": null, "english": "Brightness Toggle", - "chromium": "brightnessToggle" + "chromium": "brightnessToggle", + "glfw": null }, "scanCodes": { "android": null, @@ -4164,7 +4959,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "brightnessMinimum": { @@ -4172,7 +4968,8 @@ "domkey": null, "android": null, "english": "Brightness Minimum", - "chromium": "brightnessMinimum" + "chromium": "brightnessMinimum", + "glfw": null }, "scanCodes": { "android": null, @@ -4183,7 +4980,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "brightnessMaximum": { @@ -4191,7 +4989,8 @@ "domkey": null, "android": null, "english": "Brightness Maximum", - "chromium": "brightnessMaximum" + "chromium": "brightnessMaximum", + "glfw": null }, "scanCodes": { "android": null, @@ -4202,7 +5001,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "brightnessAuto": { @@ -4210,7 +5010,8 @@ "domkey": null, "android": null, "english": "Brightness Auto", - "chromium": "brightnessAuto" + "chromium": "brightnessAuto", + "glfw": null }, "scanCodes": { "android": null, @@ -4221,7 +5022,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "mediaLast": { @@ -4231,7 +5033,8 @@ "LAST_CHANNEL" ], "english": "Media Last", - "chromium": "mediaLast" + "chromium": "mediaLast", + "glfw": null }, "scanCodes": { "android": null, @@ -4244,7 +5047,8 @@ "keyCodes": { "android": [ 229 - ] + ], + "glfw": null } }, "launchPhone": { @@ -4252,7 +5056,8 @@ "domkey": null, "android": null, "english": "Launch Phone", - "chromium": "launchPhone" + "chromium": "launchPhone", + "glfw": null }, "scanCodes": { "android": null, @@ -4263,7 +5068,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "programGuide": { @@ -4271,7 +5077,8 @@ "domkey": null, "android": null, "english": "Program Guide", - "chromium": "programGuide" + "chromium": "programGuide", + "glfw": null }, "scanCodes": { "android": null, @@ -4282,7 +5089,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "exit": { @@ -4292,7 +5100,8 @@ "EXIT" ], "english": "Exit", - "chromium": "exit" + "chromium": "exit", + "glfw": null }, "scanCodes": { "android": [ @@ -4305,7 +5114,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "channelUp": { @@ -4315,7 +5125,8 @@ "CHANNEL_UP" ], "english": "Channel Up", - "chromium": "channelUp" + "chromium": "channelUp", + "glfw": null }, "scanCodes": { "android": [ @@ -4330,7 +5141,8 @@ "keyCodes": { "android": [ 166 - ] + ], + "glfw": null } }, "channelDown": { @@ -4340,7 +5152,8 @@ "CHANNEL_DOWN" ], "english": "Channel Down", - "chromium": "channelDown" + "chromium": "channelDown", + "glfw": null }, "scanCodes": { "android": [ @@ -4355,7 +5168,8 @@ "keyCodes": { "android": [ 167 - ] + ], + "glfw": null } }, "mediaPlay": { @@ -4365,7 +5179,8 @@ "MEDIA_PLAY" ], "english": "Media Play", - "chromium": "mediaPlay" + "chromium": "mediaPlay", + "glfw": null }, "scanCodes": { "android": [ @@ -4381,7 +5196,8 @@ "keyCodes": { "android": [ 126 - ] + ], + "glfw": null } }, "mediaRecord": { @@ -4391,7 +5207,8 @@ "MEDIA_RECORD" ], "english": "Media Record", - "chromium": "mediaRecord" + "chromium": "mediaRecord", + "glfw": null }, "scanCodes": { "android": [ @@ -4406,7 +5223,8 @@ "keyCodes": { "android": [ 130 - ] + ], + "glfw": null } }, "mediaFastForward": { @@ -4416,7 +5234,8 @@ "MEDIA_FAST_FORWARD" ], "english": "Media Fast Forward", - "chromium": "mediaFastForward" + "chromium": "mediaFastForward", + "glfw": null }, "scanCodes": { "android": [ @@ -4431,7 +5250,8 @@ "keyCodes": { "android": [ 90 - ] + ], + "glfw": null } }, "mediaRewind": { @@ -4441,7 +5261,8 @@ "MEDIA_REWIND" ], "english": "Media Rewind", - "chromium": "mediaRewind" + "chromium": "mediaRewind", + "glfw": null }, "scanCodes": { "android": [ @@ -4456,7 +5277,8 @@ "keyCodes": { "android": [ 89 - ] + ], + "glfw": null } }, "mediaTrackNext": { @@ -4466,7 +5288,8 @@ "MEDIA_NEXT" ], "english": "Media Track Next", - "chromium": "mediaTrackNext" + "chromium": "mediaTrackNext", + "glfw": null }, "scanCodes": { "android": [ @@ -4481,7 +5304,8 @@ "keyCodes": { "android": [ 87 - ] + ], + "glfw": null } }, "mediaTrackPrevious": { @@ -4491,7 +5315,8 @@ "MEDIA_PREVIOUS" ], "english": "Media Track Previous", - "chromium": "mediaTrackPrevious" + "chromium": "mediaTrackPrevious", + "glfw": null }, "scanCodes": { "android": [ @@ -4506,7 +5331,8 @@ "keyCodes": { "android": [ 88 - ] + ], + "glfw": null } }, "mediaStop": { @@ -4516,7 +5342,8 @@ "MEDIA_STOP" ], "english": "Media Stop", - "chromium": "mediaStop" + "chromium": "mediaStop", + "glfw": null }, "scanCodes": { "android": [ @@ -4532,7 +5359,8 @@ "keyCodes": { "android": [ 86 - ] + ], + "glfw": null } }, "eject": { @@ -4542,7 +5370,8 @@ "MEDIA_EJECT" ], "english": "Eject", - "chromium": "eject" + "chromium": "eject", + "glfw": null }, "scanCodes": { "android": [ @@ -4558,7 +5387,8 @@ "keyCodes": { "android": [ 129 - ] + ], + "glfw": null } }, "mediaPlayPause": { @@ -4568,7 +5398,8 @@ "MEDIA_PLAY_PAUSE" ], "english": "Media Play Pause", - "chromium": "mediaPlayPause" + "chromium": "mediaPlayPause", + "glfw": null }, "scanCodes": { "android": [ @@ -4583,7 +5414,8 @@ "keyCodes": { "android": [ 85 - ] + ], + "glfw": null } }, "speechInputToggle": { @@ -4591,7 +5423,8 @@ "domkey": null, "android": null, "english": "Speech Input Toggle", - "chromium": "speechInputToggle" + "chromium": "speechInputToggle", + "glfw": null }, "scanCodes": { "android": null, @@ -4602,7 +5435,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "bassBoost": { @@ -4612,7 +5446,8 @@ "BASSBOOST" ], "english": "Bass Boost", - "chromium": "bassBoost" + "chromium": "bassBoost", + "glfw": null }, "scanCodes": { "android": [ @@ -4625,7 +5460,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "mediaSelect": { @@ -4633,7 +5469,8 @@ "domkey": "MediaSelect", "android": null, "english": "Media Select", - "chromium": "mediaSelect" + "chromium": "mediaSelect", + "glfw": null }, "scanCodes": { "android": null, @@ -4644,7 +5481,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "launchWordProcessor": { @@ -4652,7 +5490,8 @@ "domkey": null, "android": null, "english": "Launch Word Processor", - "chromium": "launchWordProcessor" + "chromium": "launchWordProcessor", + "glfw": null }, "scanCodes": { "android": null, @@ -4663,7 +5502,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "launchSpreadsheet": { @@ -4671,7 +5511,8 @@ "domkey": null, "android": null, "english": "Launch Spreadsheet", - "chromium": "launchSpreadsheet" + "chromium": "launchSpreadsheet", + "glfw": null }, "scanCodes": { "android": null, @@ -4682,7 +5523,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "launchMail": { @@ -4692,7 +5534,8 @@ "ENVELOPE" ], "english": "Launch Mail", - "chromium": "launchMail" + "chromium": "launchMail", + "glfw": null }, "scanCodes": { "android": [ @@ -4708,7 +5551,8 @@ "keyCodes": { "android": [ 65 - ] + ], + "glfw": null } }, "launchContacts": { @@ -4718,7 +5562,8 @@ "CONTACTS" ], "english": "Launch Contacts", - "chromium": "launchContacts" + "chromium": "launchContacts", + "glfw": null }, "scanCodes": { "android": [ @@ -4733,7 +5578,8 @@ "keyCodes": { "android": [ 207 - ] + ], + "glfw": null } }, "launchCalendar": { @@ -4743,7 +5589,8 @@ "CALENDAR" ], "english": "Launch Calendar", - "chromium": "launchCalendar" + "chromium": "launchCalendar", + "glfw": null }, "scanCodes": { "android": [ @@ -4758,7 +5605,8 @@ "keyCodes": { "android": [ 208 - ] + ], + "glfw": null } }, "launchApp2": { @@ -4766,7 +5614,8 @@ "domkey": "LaunchApp2", "android": null, "english": "Launch App2", - "chromium": "launchApp2" + "chromium": "launchApp2", + "glfw": null }, "scanCodes": { "android": null, @@ -4777,7 +5626,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "launchApp1": { @@ -4785,7 +5635,8 @@ "domkey": "LaunchApp1", "android": null, "english": "Launch App1", - "chromium": "launchApp1" + "chromium": "launchApp1", + "glfw": null }, "scanCodes": { "android": null, @@ -4796,7 +5647,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "launchInternetBrowser": { @@ -4804,7 +5656,8 @@ "domkey": null, "android": null, "english": "Launch Internet Browser", - "chromium": "launchInternetBrowser" + "chromium": "launchInternetBrowser", + "glfw": null }, "scanCodes": { "android": null, @@ -4815,7 +5668,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "logOff": { @@ -4823,7 +5677,8 @@ "domkey": null, "android": null, "english": "Log Off", - "chromium": "logOff" + "chromium": "logOff", + "glfw": null }, "scanCodes": { "android": null, @@ -4834,7 +5689,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "lockScreen": { @@ -4842,7 +5698,8 @@ "domkey": null, "android": null, "english": "Lock Screen", - "chromium": "lockScreen" + "chromium": "lockScreen", + "glfw": null }, "scanCodes": { "android": null, @@ -4853,7 +5710,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "launchControlPanel": { @@ -4861,7 +5719,8 @@ "domkey": "LaunchControlPanel", "android": null, "english": "Launch Control Panel", - "chromium": "launchControlPanel" + "chromium": "launchControlPanel", + "glfw": null }, "scanCodes": { "android": null, @@ -4872,7 +5731,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "selectTask": { @@ -4880,7 +5740,8 @@ "domkey": "SelectTask", "android": null, "english": "Select Task", - "chromium": "selectTask" + "chromium": "selectTask", + "glfw": null }, "scanCodes": { "android": null, @@ -4891,7 +5752,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "launchDocuments": { @@ -4899,7 +5761,8 @@ "domkey": null, "android": null, "english": "Launch Documents", - "chromium": "launchDocuments" + "chromium": "launchDocuments", + "glfw": null }, "scanCodes": { "android": null, @@ -4910,7 +5773,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "spellCheck": { @@ -4918,7 +5782,8 @@ "domkey": null, "android": null, "english": "Spell Check", - "chromium": "spellCheck" + "chromium": "spellCheck", + "glfw": null }, "scanCodes": { "android": null, @@ -4929,7 +5794,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "launchKeyboardLayout": { @@ -4937,7 +5803,8 @@ "domkey": null, "android": null, "english": "Launch Keyboard Layout", - "chromium": "launchKeyboardLayout" + "chromium": "launchKeyboardLayout", + "glfw": null }, "scanCodes": { "android": null, @@ -4948,7 +5815,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "launchScreenSaver": { @@ -4956,7 +5824,8 @@ "domkey": "LaunchScreenSaver", "android": null, "english": "Launch Screen Saver", - "chromium": "launchScreenSaver" + "chromium": "launchScreenSaver", + "glfw": null }, "scanCodes": { "android": null, @@ -4967,7 +5836,33 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null + } + }, + "launchAssistant": { + "names": { + "domkey": "LaunchAssistant", + "android": [ + "ASSIST" + ], + "english": "Launch Assistant", + "chromium": "launchAssistant", + "glfw": null + }, + "scanCodes": { + "android": null, + "usb": 786891, + "linux": 583, + "xkb": 591, + "windows": null, + "macos": null + }, + "keyCodes": { + "android": [ + 219 + ], + "glfw": null } }, "launchAudioBrowser": { @@ -4975,7 +5870,8 @@ "domkey": null, "android": null, "english": "Launch Audio Browser", - "chromium": "launchAudioBrowser" + "chromium": "launchAudioBrowser", + "glfw": null }, "scanCodes": { "android": null, @@ -4986,7 +5882,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "newKey": { @@ -4996,7 +5893,8 @@ "NEW" ], "english": "New Key", - "chromium": "new" + "chromium": "new", + "glfw": null }, "scanCodes": { "android": [ @@ -5009,7 +5907,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "close": { @@ -5020,7 +5919,8 @@ "CLOSE" ], "english": "Close", - "chromium": "close" + "chromium": "close", + "glfw": null }, "scanCodes": { "android": [ @@ -5036,7 +5936,8 @@ "keyCodes": { "android": [ 128 - ] + ], + "glfw": null } }, "save": { @@ -5044,7 +5945,8 @@ "domkey": null, "android": null, "english": "Save", - "chromium": "save" + "chromium": "save", + "glfw": null }, "scanCodes": { "android": null, @@ -5055,7 +5957,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "print": { @@ -5065,7 +5968,8 @@ "PRINT" ], "english": "Print", - "chromium": "print" + "chromium": "print", + "glfw": null }, "scanCodes": { "android": [ @@ -5078,7 +5982,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "browserSearch": { @@ -5088,7 +5993,8 @@ "SEARCH" ], "english": "Browser Search", - "chromium": "browserSearch" + "chromium": "browserSearch", + "glfw": null }, "scanCodes": { "android": [ @@ -5103,7 +6009,8 @@ "keyCodes": { "android": [ 84 - ] + ], + "glfw": null } }, "browserHome": { @@ -5111,7 +6018,8 @@ "domkey": "BrowserHome", "android": null, "english": "Browser Home", - "chromium": "browserHome" + "chromium": "browserHome", + "glfw": null }, "scanCodes": { "android": null, @@ -5122,7 +6030,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "browserBack": { @@ -5130,7 +6039,8 @@ "domkey": "BrowserBack", "android": null, "english": "Browser Back", - "chromium": "browserBack" + "chromium": "browserBack", + "glfw": null }, "scanCodes": { "android": null, @@ -5141,7 +6051,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "browserForward": { @@ -5151,7 +6062,8 @@ "FORWARD" ], "english": "Browser Forward", - "chromium": "browserForward" + "chromium": "browserForward", + "glfw": null }, "scanCodes": { "android": [ @@ -5166,7 +6078,8 @@ "keyCodes": { "android": [ 125 - ] + ], + "glfw": null } }, "browserStop": { @@ -5174,7 +6087,8 @@ "domkey": "BrowserStop", "android": null, "english": "Browser Stop", - "chromium": "browserStop" + "chromium": "browserStop", + "glfw": null }, "scanCodes": { "android": null, @@ -5185,7 +6099,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "browserRefresh": { @@ -5193,7 +6108,8 @@ "domkey": "BrowserRefresh", "android": null, "english": "Browser Refresh", - "chromium": "browserRefresh" + "chromium": "browserRefresh", + "glfw": null }, "scanCodes": { "android": null, @@ -5204,7 +6120,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "browserFavorites": { @@ -5214,7 +6131,8 @@ "BOOKMARK" ], "english": "Browser Favorites", - "chromium": "browserFavorites" + "chromium": "browserFavorites", + "glfw": null }, "scanCodes": { "android": [ @@ -5229,7 +6147,8 @@ "keyCodes": { "android": [ 174 - ] + ], + "glfw": null } }, "zoomIn": { @@ -5239,7 +6158,8 @@ "ZOOM_IN" ], "english": "Zoom In", - "chromium": "zoomIn" + "chromium": "zoomIn", + "glfw": null }, "scanCodes": { "android": null, @@ -5252,7 +6172,8 @@ "keyCodes": { "android": [ 168 - ] + ], + "glfw": null } }, "zoomOut": { @@ -5262,7 +6183,8 @@ "ZOOM_OUT" ], "english": "Zoom Out", - "chromium": "zoomOut" + "chromium": "zoomOut", + "glfw": null }, "scanCodes": { "android": null, @@ -5275,7 +6197,8 @@ "keyCodes": { "android": [ 169 - ] + ], + "glfw": null } }, "zoomToggle": { @@ -5285,20 +6208,22 @@ "TV_ZOOM_MODE" ], "english": "Zoom Toggle", - "chromium": "zoomToggle" + "chromium": "zoomToggle", + "glfw": null }, "scanCodes": { "android": null, "usb": 786994, - "linux": null, - "xkb": null, + "linux": 372, + "xkb": 380, "windows": null, "macos": null }, "keyCodes": { "android": [ 255 - ] + ], + "glfw": null } }, "redo": { @@ -5308,7 +6233,8 @@ "REDO" ], "english": "Redo", - "chromium": "redo" + "chromium": "redo", + "glfw": null }, "scanCodes": { "android": [ @@ -5321,7 +6247,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "mailReply": { @@ -5329,7 +6256,8 @@ "domkey": "MailReply", "android": null, "english": "Mail Reply", - "chromium": "mailReply" + "chromium": "mailReply", + "glfw": null }, "scanCodes": { "android": null, @@ -5340,7 +6268,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "mailForward": { @@ -5348,7 +6277,8 @@ "domkey": "MailForward", "android": null, "english": "Mail Forward", - "chromium": "mailForward" + "chromium": "mailForward", + "glfw": null }, "scanCodes": { "android": null, @@ -5359,7 +6289,8 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null } }, "mailSend": { @@ -5367,7 +6298,8 @@ "domkey": "MailSend", "android": null, "english": "Mail Send", - "chromium": "mailSend" + "chromium": "mailSend", + "glfw": null }, "scanCodes": { "android": null, @@ -5378,7 +6310,29 @@ "macos": null }, "keyCodes": { - "android": null + "android": null, + "glfw": null + } + }, + "showAllWindows": { + "names": { + "domkey": "ShowAllWindows", + "android": null, + "english": "Show All Windows", + "chromium": "showAllWindows", + "glfw": null + }, + "scanCodes": { + "android": null, + "usb": 787103, + "linux": 120, + "xkb": 128, + "windows": null, + "macos": null + }, + "keyCodes": { + "android": null, + "glfw": null } } } \ No newline at end of file diff --git a/dev/tools/gen_keycodes/data/key_name_to_glfw_name.json b/dev/tools/gen_keycodes/data/key_name_to_glfw_name.json new file mode 100644 index 0000000000..a1e435d256 --- /dev/null +++ b/dev/tools/gen_keycodes/data/key_name_to_glfw_name.json @@ -0,0 +1,116 @@ +{ + "altLeft": ["LEFT_ALT"], + "altRight": ["RIGHT_ALT"], + "arrowDown": ["DOWN"], + "arrowLeft": ["LEFT"], + "arrowRight": ["RIGHT"], + "arrowUp": ["UP"], + "backquote": ["GRAVE_ACCENT"], + "backslash": ["BACKSLASH"], + "backspace": ["BACKSPACE"], + "bracketLeft": ["LEFT_BRACKET"], + "bracketRight": ["RIGHT_BRACKET"], + "capsLock": ["CAPS_LOCK"], + "controlLeft": ["LEFT_CONTROL"], + "controlRight": ["RIGHT_CONTROL"], + "contextMenu": ["MENU"], + "comma": ["COMMA"], + "delete": ["DELETE"], + "digit0": ["0"], + "digit1": ["1"], + "digit2": ["2"], + "digit3": ["3"], + "digit4": ["4"], + "digit5": ["5"], + "digit6": ["6"], + "digit7": ["7"], + "digit8": ["8"], + "digit9": ["9"], + "end": ["END"], + "enter": ["ENTER"], + "equal": ["EQUAL"], + "escape": ["ESCAPE"], + "f1": ["F1"], + "f2": ["F2"], + "f3": ["F3"], + "f4": ["F4"], + "f5": ["F5"], + "f6": ["F6"], + "f7": ["F7"], + "f8": ["F8"], + "f9": ["F9"], + "f10": ["F10"], + "f11": ["F11"], + "f12": ["F12"], + "f13": ["F13"], + "f14": ["F14"], + "f15": ["F15"], + "f16": ["F16"], + "f17": ["F17"], + "f18": ["F18"], + "f19": ["F19"], + "f20": ["F20"], + "f21": ["F21"], + "f22": ["F22"], + "f23": ["F23"], + "f25": ["F25"], + "home": ["HOME"], + "insert": ["INSERT"], + "keyA": ["A"], + "keyB": ["B"], + "keyC": ["C"], + "keyD": ["D"], + "keyE": ["E"], + "keyF": ["F"], + "keyG": ["G"], + "keyH": ["H"], + "keyI": ["I"], + "keyJ": ["J"], + "keyK": ["K"], + "keyL": ["L"], + "keyM": ["M"], + "keyN": ["N"], + "keyO": ["O"], + "keyP": ["P"], + "keyQ": ["Q"], + "keyR": ["R"], + "keyS": ["S"], + "keyT": ["T"], + "keyU": ["U"], + "keyV": ["V"], + "keyW": ["W"], + "keyX": ["X"], + "keyY": ["Y"], + "keyZ": ["Z"], + "minus": ["MINUS"], + "numLock": ["NUM_LOCK"], + "numpad0": ["KP_0"], + "numpad1": ["KP_1"], + "numpad2": ["KP_2"], + "numpad3": ["KP_3"], + "numpad4": ["KP_4"], + "numpad5": ["KP_5"], + "numpad6": ["KP_6"], + "numpad7": ["KP_7"], + "numpad8": ["KP_8"], + "numpad9": ["KP_9"], + "numpadDecimal": ["KP_DECIMAL"], + "numpadDivide": ["KP_DIVIDE"], + "numpadMultiply": ["KP_MULTIPLY"], + "numpadSubtract": ["NUMPAD_SUBTRACT"], + "numpadAdd": ["KP_ADD"], + "numpadEnter": ["KP_ENTER"], + "numpadEqual": ["KP_EQUAL"], + "pageDown": ["PAGE_DOWN"], + "pageUp": ["PAGE_UP"], + "pause": ["PAUSE"], + "printScreen": ["PRINT_SCREEN"], + "quote": ["APOSTROPHE"], + "period": ["PERIOD"], + "semicolon": ["SEMICOLON"], + "slash": ["SLASH"], + "space": ["SPACE"], + "shiftLeft": ["LEFT_SHIFT"], + "shiftRight": ["RIGHT_SHIFT"], + "tab": ["TAB"] +} diff --git a/dev/tools/gen_keycodes/data/keyboard_maps.tmpl b/dev/tools/gen_keycodes/data/keyboard_maps.tmpl index 06e6352481..3dd9ac2afb 100644 --- a/dev/tools/gen_keycodes/data/keyboard_maps.tmpl +++ b/dev/tools/gen_keycodes/data/keyboard_maps.tmpl @@ -40,6 +40,8 @@ const Map kFuchsiaToPhysicalKey = kMacOsToPhysicalKey = { @@@MACOS_SCAN_CODE_MAP@@@ }; @@ -50,3 +52,21 @@ const Map kMacOsToPhysicalKey = kMacOsNumPadMap = { @@@MACOS_NUMPAD_MAP@@@ }; + +/// Maps GLFW-specific key codes to the matching [LogicalKeyboardKey]. +const Map kGlfwToLogicalKey = { +@@@GLFW_KEY_CODE_MAP@@@ +}; + +/// A map of GLFW key codes which have printable representations, but appear +/// on the number pad. Used to provide different key objects for keys like +/// KEY_EQUALS and NUMPAD_EQUALS. +const Map kGlfwNumpadMap = { +@@@GLFW_NUMPAD_MAP@@@ +}; + +/// Maps XKB specific key code values representing [PhysicalKeyboardKey]. +const Map kLinuxToPhysicalKey = { +@@@XKB_SCAN_CODE_MAP@@@ +}; + diff --git a/dev/tools/gen_keycodes/lib/code_gen.dart b/dev/tools/gen_keycodes/lib/code_gen.dart index 0ba5308a51..0df57d2202 100644 --- a/dev/tools/gen_keycodes/lib/code_gen.dart +++ b/dev/tools/gen_keycodes/lib/code_gen.dart @@ -93,6 +93,46 @@ $otherComments static const LogicalKeyboardKey ${entry.constantName} = LogicalK return keyCodeMap.toString().trimRight(); } + /// This generates the map of GLFW number pad key codes to logical keys. + String get glfwNumpadMap { + final StringBuffer glfwNumpadMap = StringBuffer(); + final List onlyNumpads = keyData.data.where((Key entry) { + return entry.constantName.startsWith('numpad') && entry.keyLabel != null; + }).toList(); + for (Key entry in onlyNumpads) { + if (entry.glfwKeyCodes != null) { + for (int code in entry.glfwKeyCodes.cast()) { + glfwNumpadMap.writeln(' $code: LogicalKeyboardKey.${entry.constantName},'); + } + } + } + return glfwNumpadMap.toString().trimRight(); + } + + /// This generates the map of GLFW key codes to logical keys. + String get glfwKeyCodeMap { + final StringBuffer glfwKeyCodeMap = StringBuffer(); + for (Key entry in keyData.data) { + if (entry.glfwKeyCodes != null) { + for (int code in entry.glfwKeyCodes.cast()) { + glfwKeyCodeMap.writeln(' $code: LogicalKeyboardKey.${entry.constantName},'); + } + } + } + return glfwKeyCodeMap.toString().trimRight(); + } + + /// This generates the map of XKB USB HID codes to physical keys. + String get xkbScanCodeMap { + final StringBuffer xkbScanCodeMap = StringBuffer(); + for (Key entry in keyData.data) { + if (entry.xKbScanCode != null) { + xkbScanCodeMap.writeln(' ${toHex(entry.xKbScanCode)}: PhysicalKeyboardKey.${entry.constantName},'); + } + } + return xkbScanCodeMap.toString().trimRight(); + } + /// This generates the map of Android key codes to logical keys. String get androidKeyCodeMap { final StringBuffer androidKeyCodeMap = StringBuffer(); @@ -210,6 +250,9 @@ $otherComments static const LogicalKeyboardKey ${entry.constantName} = LogicalK 'FUCHSIA_KEY_CODE_MAP': fuchsiaKeyCodeMap, 'MACOS_SCAN_CODE_MAP': macOsScanCodeMap, 'MACOS_NUMPAD_MAP': macOsNumpadMap, + 'GLFW_KEY_CODE_MAP': glfwKeyCodeMap, + 'GLFW_NUMPAD_MAP': glfwNumpadMap, + 'XKB_SCAN_CODE_MAP': xkbScanCodeMap, }; final String template = File(path.join(flutterRoot.path, 'dev', 'tools', 'gen_keycodes', 'data', 'keyboard_maps.tmpl')).readAsStringSync(); diff --git a/dev/tools/gen_keycodes/lib/key_data.dart b/dev/tools/gen_keycodes/lib/key_data.dart index 21fa94ffca..a8d9994ac0 100644 --- a/dev/tools/gen_keycodes/lib/key_data.dart +++ b/dev/tools/gen_keycodes/lib/key_data.dart @@ -26,14 +26,25 @@ class KeyData { String androidKeyboardLayout, String androidKeyCodeHeader, String androidNameMap, + String glfwKeyCodeHeader, + String glfwNameMap ) : assert(chromiumHidCodes != null), assert(androidKeyboardLayout != null), assert(androidKeyCodeHeader != null), - assert(androidNameMap != null) { + assert(androidNameMap != null), + assert(glfwKeyCodeHeader != null), + assert(glfwNameMap != null) { _nameToAndroidScanCodes = _readAndroidScanCodes(androidKeyboardLayout); _nameToAndroidKeyCode = _readAndroidKeyCodes(androidKeyCodeHeader); - final Map> dynamicNames = json.decode(androidNameMap).cast>(); - _nameToAndroidName = dynamicNames.map>((String key, List value) { + _nameToGlfwKeyCode = _readGlfwKeyCodes(glfwKeyCodeHeader); + // Cast Android dom map + final Map> dynamicAndroidNames = json.decode(androidNameMap).cast>(); + _nameToAndroidName = dynamicAndroidNames.map>((String key, List value) { + return MapEntry>(key, value.cast()); + }); + // Cast GLFW dom map + final Map> dynamicGlfwNames = json.decode(glfwNameMap).cast>(); + _nameToGlfwName = dynamicGlfwNames.map>((String key, List value) { return MapEntry>(key, value.cast()); }); data = _readHidEntries(chromiumHidCodes); @@ -51,6 +62,7 @@ class KeyData { /// [KeyData.fromJson]. Map toJson() { for (Key entry in data) { + // Android Key names entry.androidKeyNames = _nameToAndroidName[entry.constantName]?.cast(); if (entry.androidKeyNames != null && entry.androidKeyNames.isNotEmpty) { for (String androidKeyName in entry.androidKeyNames) { @@ -64,6 +76,17 @@ class KeyData { } } } + + // GLFW key names + entry.glfwKeyNames = _nameToGlfwName[entry.constantName]?.cast(); + if (entry.glfwKeyNames != null && entry.glfwKeyNames.isNotEmpty) { + for (String glfwKeyName in entry.glfwKeyNames) { + if (_nameToGlfwKeyCode[glfwKeyName] != null) { + entry.glfwKeyCodes ??= []; + entry.glfwKeyCodes.add(_nameToGlfwKeyCode[glfwKeyName]); + } + } + } } final Map outputMap = {}; @@ -83,6 +106,13 @@ class KeyData { /// JSON. Map> _nameToAndroidName; + /// The mapping from the Flutter name (e.g. "eject") to the GLFW name (e.g. + /// "GLFW_MEDIA_EJECT"). + /// + /// Only populated if data is parsed from the source files, not if parsed from + /// JSON. + Map> _nameToGlfwName; + /// The mapping from the Android name (e.g. "MEDIA_EJECT") to the integer scan /// code (physical location) of the key. /// @@ -97,6 +127,13 @@ class KeyData { /// JSON. Map _nameToAndroidKeyCode; + /// The mapping from GLFW name (e.g. "GLFW_KEY_COMMA") to the integer key code + /// (logical meaning) of the key. + /// + /// Only populated if data is parsed from the source files, not if parsed from + /// JSON. + Map _nameToGlfwKeyCode; + /// Parses entries from Androids Generic.kl scan code data file. /// /// Lines in this file look like this (without the ///): @@ -147,6 +184,30 @@ class KeyData { return result; } + /// Parses entries from GLFW's keycodes.h key code data file. + /// + /// Lines in this file look like this (without the ///): + /// /** Space key. */ + /// #define GLFW_KEY_SPACE 32, + Map _readGlfwKeyCodes(String headerFile) { + // Only get the KEY definitions, ignore the rest (mouse, joystick, etc). + final RegExp enumEntry = RegExp(r'''define GLFW_KEY_([A-Z0-9_]+)\s*([A-Z0-9_]+),?'''); + final Map replaced = {}; + headerFile.replaceAllMapped(enumEntry, (Match match) { + replaced[match.group(1)] = int.tryParse(match.group(2)) ?? match.group(2).replaceAll('GLFW_KEY_', ''); + }); + final Map result = {}; + replaced.forEach((String key, dynamic value) { + // Some definition values point to other definitions (e.g #define GLFW_KEY_LAST GLFW_KEY_MENU). + if (value is String) { + result[key] = replaced[value]; + } else { + result[key] = value; + } + }); + return result; + } + /// Parses entries from Chromium's HID code mapping header file. /// /// Lines in this file look like this (without the ///): @@ -211,6 +272,8 @@ class Key { this.androidKeyNames, this.androidScanCodes, this.androidKeyCodes, + this.glfwKeyNames, + this.glfwKeyCodes, }) : assert(usbHidCode != null), assert(chromiumName != null), _constantName = enumName; @@ -261,6 +324,15 @@ class Key { /// code value. List androidScanCodes; + /// The list of names that GFLW gives to this key (symbol names minus the + /// prefix). + List glfwKeyNames; + + /// The list of GLFW key codes matching this key, created by looking up the + /// Linux name in the Chromium data, and substituting the GLFW key code + /// value. + List glfwKeyCodes; + /// Creates a JSON map from the key data. Map toJson() { return { @@ -269,6 +341,7 @@ class Key { 'android': androidKeyNames, 'english': commentName, 'chromium': chromiumName, + 'glfw': glfwKeyNames, }, 'scanCodes': { 'android': androidScanCodes, @@ -280,6 +353,7 @@ class Key { }, 'keyCodes': >{ 'android': androidKeyCodes, + 'glfw': glfwKeyCodes, }, }; } @@ -337,8 +411,8 @@ class Key { @override String toString() { return """'$constantName': (name: "$name", usbHidCode: ${toHex(usbHidCode)}, """ - '''linuxKeyCode: ${toHex(linuxScanCode)}, xKbKeyCode: ${toHex(xKbScanCode)}, ''' - '''windowsKeyCode: ${toHex(windowsScanCode)}, macOsKeyCode: ${toHex(macOsScanCode)}, ''' + '''linuxScanCode: ${toHex(linuxScanCode)}, xKbScanCode: ${toHex(xKbScanCode)}, ''' + '''windowsKeyCode: ${toHex(windowsScanCode)}, macOsScanCode: ${toHex(macOsScanCode)}, ''' '''chromiumSymbolName: $chromiumName'''; } diff --git a/dev/tools/gen_keycodes/pubspec.yaml b/dev/tools/gen_keycodes/pubspec.yaml index ea6a339165..ddb98fe1f4 100644 --- a/dev/tools/gen_keycodes/pubspec.yaml +++ b/dev/tools/gen_keycodes/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: path: 1.6.2 platform: 2.2.0 - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -21,4 +21,4 @@ dependencies: term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" -# PUBSPEC CHECKSUM: b23e +# PUBSPEC CHECKSUM: 0637 diff --git a/dev/tools/gen_date_localizations.dart b/dev/tools/localization/gen_date_localizations.dart similarity index 85% rename from dev/tools/gen_date_localizations.dart rename to dev/tools/localization/gen_date_localizations.dart index b60ffecda6..7681619a8f 100644 --- a/dev/tools/gen_date_localizations.dart +++ b/dev/tools/localization/gen_date_localizations.dart @@ -7,7 +7,7 @@ /// package. /// /// The extracted data is written into: -/// packages/flutter_localizations/lib/src/l10n/date_localizations.dart +/// packages/flutter_localizations/lib/src/l10n/generated_date_localizations.dart /// /// ## Usage /// @@ -16,14 +16,14 @@ /// The following outputs the generated Dart code to the console as a dry run: /// /// ``` -/// dart dev/tools/gen_date_localizations.dart +/// dart dev/tools/localization/gen_date_localizations.dart /// ``` /// /// If the data looks good, use the `--overwrite` option to overwrite the /// lib/src/l10n/date_localizations.dart file: /// /// ``` -/// dart dev/tools/gen_date_localizations.dart --overwrite +/// dart dev/tools/localization/gen_date_localizations.dart --overwrite /// ``` import 'dart:async'; @@ -68,7 +68,6 @@ Future main(List rawArgs) async { final Map symbolFiles = _listIntlData(dateSymbolsDirectory); final Directory datePatternsDirectory = Directory(path.join(pathToIntl, 'src', 'data', 'dates', 'patterns')); final Map patternFiles = _listIntlData(datePatternsDirectory); - final List materialLocales = _materialLocales().toList(); final StringBuffer buffer = StringBuffer(); buffer.writeln( @@ -79,7 +78,7 @@ Future main(List rawArgs) async { // This file has been automatically generated. Please do not edit it manually. // To regenerate run (omit --overwrite to print to console instead of the file): -// dart --enable-asserts dev/tools/gen_date_localizations.dart --overwrite +// dart --enable-asserts dev/tools/localization/gen_date_localizations.dart --overwrite ''' ); @@ -88,7 +87,7 @@ Future main(List rawArgs) async { /// supported by flutter_localizations.'''); buffer.writeln('const Map dateSymbols = {'); symbolFiles.forEach((String locale, File data) { - if (materialLocales.contains(locale)) + if (_supportedLocales().contains(locale)) buffer.writeln(_jsonToMapEntry(locale, json.decode(data.readAsStringSync()))); }); buffer.writeln('};'); @@ -100,7 +99,7 @@ Future main(List rawArgs) async { /// supported by flutter_localizations.'''); buffer.writeln('const Map> datePatterns = > {'); patternFiles.forEach((String locale, File data) { - if (materialLocales.contains(locale)) { + if (_supportedLocales().contains(locale)) { final Map patterns = json.decode(data.readAsStringSync()); buffer.writeln("'$locale': {"); patterns.forEach((String key, dynamic value) { @@ -113,7 +112,7 @@ Future main(List rawArgs) async { buffer.writeln('};'); if (writeToFile) { - final File dateLocalizationsFile = File(path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n', 'date_localizations.dart')); + final File dateLocalizationsFile = File(path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n', 'generated_date_localizations.dart')); dateLocalizationsFile.writeAsStringSync(buffer.toString()); Process.runSync(path.join('bin', 'cache', 'dart-sdk', 'bin', 'dartfmt'), [ '-w', @@ -154,14 +153,16 @@ String _jsonToMap(dynamic json) { throw 'Unsupported JSON type ${json.runtimeType} of value $json.'; } -Iterable _materialLocales() sync* { - final RegExp filenameRE = RegExp(r'material_(\w+)\.arb$'); - final Directory materialLocalizationsDirectory = Directory(path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n')); - for (FileSystemEntity entity in materialLocalizationsDirectory.listSync()) { +Set _supportedLocales() { + final Set supportedLocales = {}; + final RegExp filenameRE = RegExp(r'(?:material|cupertino)_(\w+)\.arb$'); + final Directory supportedLocalesDirectory = Directory(path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n')); + for (FileSystemEntity entity in supportedLocalesDirectory.listSync()) { final String filePath = entity.path; if (FileSystemEntity.isFileSync(filePath) && filenameRE.hasMatch(filePath)) - yield filenameRE.firstMatch(filePath)[1]; + supportedLocales.add(filenameRE.firstMatch(filePath)[1]); } + return supportedLocales; } Map _listIntlData(Directory directory) { diff --git a/dev/tools/gen_localizations.dart b/dev/tools/localization/gen_localizations.dart similarity index 63% rename from dev/tools/gen_localizations.dart rename to dev/tools/localization/gen_localizations.dart index 8b3007b6bc..205b5f777b 100644 --- a/dev/tools/gen_localizations.dart +++ b/dev/tools/localization/gen_localizations.dart @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// This program generates a getTranslation() function that looks up the -// translations contained by the arb files. The returned value is an +// This program generates a getMaterialTranslation() function that looks up the +// translations provided by the arb files. The returned value is a generated // instance of GlobalMaterialLocalizations that corresponds to a single // locale. // @@ -28,96 +28,49 @@ // The following outputs the generated Dart code to the console as a dry run: // // ``` -// dart dev/tools/gen_localizations.dart +// dart dev/tools/localization/gen_localizations.dart // ``` // // If the data looks good, use the `-w` or `--overwrite` option to overwrite the -// packages/flutter_localizations/lib/src/l10n/localizations.dart file: +// packages/flutter_localizations/lib/src/l10n/generated_material_localizations.dart file: // // ``` -// dart dev/tools/gen_localizations.dart --overwrite +// dart dev/tools/localization/gen_localizations.dart --overwrite // ``` import 'dart:async'; -import 'dart:convert'; import 'dart:io'; import 'package:path/path.dart' as path; import 'package:meta/meta.dart'; +import 'gen_material_localizations.dart'; import 'localizations_utils.dart'; import 'localizations_validator.dart'; -const String outputHeader = ''' -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// This file has been automatically generated. Please do not edit it manually. -// To regenerate the file, use: -// @(regenerate) - -import 'dart:collection'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart' as intl; - -import '../material_localizations.dart'; -'''; - -/// Maps locales to resource key/value pairs. -final Map> localeToResources = >{}; - -/// Maps locales to resource key/attributes pairs. -/// -/// See also: -final Map> localeToResourceAttributes = >{}; - -/// Set that holds the locales that were assumed from the existing locales. -/// -/// For example, when the data lacks data for zh_Hant, we will use the data of -/// the first Hant Chinese locale as a default by repeating the data. If an -/// explicit match is later found, we can reference this set to see if we should -/// overwrite the existing assumed data. -final Set assumedLocales = {}; - -/// Return `s` as a Dart-parseable raw string in single or double quotes. -/// -/// Double quotes are expanded: -/// -/// ``` -/// foo => r'foo' -/// foo "bar" => r'foo "bar"' -/// foo 'bar' => r'foo ' "'" r'bar' "'" -/// ``` -String generateString(String s) { - if (!s.contains("'")) - return "r'$s'"; - - final StringBuffer output = StringBuffer(); - bool started = false; // Have we started writing a raw string. - for (int i = 0; i < s.length; i++) { - if (s[i] == "'") { - if (started) - output.write("'"); - output.write(' "\'" '); - started = false; - } else if (!started) { - output.write("r'${s[i]}"); - started = true; - } else { - output.write(s[i]); - } - } - if (started) - output.write("'"); - return output.toString(); -} - /// This is the core of this script; it generates the code used for translations. -String generateTranslationBundles() { +String generateArbBasedLocalizationSubclasses({ + @required Map> localeToResources, + @required Map> localeToResourceAttributes, + @required String generatedClassPrefix, + @required String baseClass, + @required HeaderGenerator generateHeader, + @required ConstructorGenerator generateConstructor, + @required String factoryDeclaration, + @required String factoryArguments, +}) { + assert(localeToResources != null); + assert(localeToResourceAttributes != null); + assert(generatedClassPrefix.isNotEmpty); + assert(baseClass.isNotEmpty); + assert(generateHeader != null); + assert(generateConstructor != null); + assert(factoryDeclaration.isNotEmpty); + assert(factoryArguments.isNotEmpty); + final StringBuffer output = StringBuffer(); + output.writeln(generateHeader('dart dev/tools/localization/gen_localizations.dart --overwrite')); + final StringBuffer supportedLocales = StringBuffer(); final Map> languageToLocales = >{}; @@ -140,17 +93,9 @@ String generateTranslationBundles() { allResourceIdentifiers.addAll(localeToResources[locale].keys); } - output.writeln(''' -// The classes defined here encode all of the translations found in the -// `flutter_localizations/lib/src/l10n/*.arb` files. -// -// These classes are constructed by the [getTranslation] method at the bottom of -// this file, and used by the [_MaterialLocalizationsDelegate.load] method defined -// in `flutter_localizations/lib/src/material_localizations.dart`.'''); - // We generate one class per supported language (e.g. - // `MaterialLocalizationEn`). These implement everything that is needed by - // GlobalMaterialLocalizations. + // `MaterialLocalizationEn`). These implement everything that is needed by the + // superclass (e.g. GlobalMaterialLocalizations). // We also generate one subclass for each locale with a script code (e.g. // `MaterialLocalizationZhHant`). Their superclasses are the aforementioned @@ -177,7 +122,9 @@ String generateTranslationBundles() { final LocaleInfo canonicalLocale = LocaleInfo.fromString('en'); for (String languageName in languageCodes) { final LocaleInfo languageLocale = LocaleInfo.fromString(languageName); - writeClassHeader(output, languageLocale, 'GlobalMaterialLocalizations'); + output.writeln(generateClassDeclaration(languageLocale, generatedClassPrefix, baseClass)); + output.writeln(generateConstructor(languageLocale)); + final Map languageResources = localeToResources[languageLocale]; for (String key in allKeys) { final Map attributes = localeToResourceAttributes[canonicalLocale][key]; @@ -192,7 +139,12 @@ String generateTranslationBundles() { // script default values before language default values. for (String scriptCode in languageToScriptCodes[languageName]) { final LocaleInfo scriptBaseLocale = LocaleInfo.fromString(languageName + '_' + scriptCode); - writeClassHeader(output, scriptBaseLocale, 'MaterialLocalization${camelCase(languageLocale)}'); + output.writeln(generateClassDeclaration( + scriptBaseLocale, + generatedClassPrefix, + '$generatedClassPrefix${camelCase(languageLocale)}', + )); + output.writeln(generateConstructor(scriptBaseLocale)); final Map scriptResources = localeToResources[scriptBaseLocale]; for (String key in scriptResources.keys) { if (languageResources[key] == scriptResources[key]) @@ -211,7 +163,12 @@ String generateTranslationBundles() { if (locale.scriptCode != scriptCode) continue; countryCodeCount += 1; - writeClassHeader(output, locale, 'MaterialLocalization${camelCase(scriptBaseLocale)}'); + output.writeln(generateClassDeclaration( + locale, + generatedClassPrefix, + '$generatedClassPrefix${camelCase(scriptBaseLocale)}', + )); + output.writeln(generateConstructor(locale)); final Map localeResources = localeToResources[locale]; for (String key in localeResources.keys) { // When script fallback contains the key, we compare to it instead of language fallback. @@ -232,7 +189,12 @@ String generateTranslationBundles() { continue; countryCodeCount += 1; final Map localeResources = localeToResources[locale]; - writeClassHeader(output, locale, 'MaterialLocalization${camelCase(languageLocale)}'); + output.writeln(generateClassDeclaration( + locale, + generatedClassPrefix, + '$generatedClassPrefix${camelCase(languageLocale)}', + )); + output.writeln(generateConstructor(locale)); for (String key in localeResources.keys) { if (languageResources[key] == localeResources[key]) continue; @@ -256,13 +218,13 @@ String generateTranslationBundles() { } } - // Generate the getTranslation function. Given a Locale it returns the - // corresponding const GlobalMaterialLocalizations. + // Generate the factory function. Given a Locale it returns the corresponding + // base class implementation. output.writeln(''' /// The set of supported languages, as language code strings. /// -/// The [GlobalMaterialLocalizations.delegate] can generate localizations for +/// The [$baseClass.delegate] can generate localizations for /// any [Locale] with a language code from this set, regardless of the region. /// Some regions have specific support (e.g. `de` covers all forms of German, /// but there is support for `de-CH` specifically to override some of the @@ -270,15 +232,15 @@ String generateTranslationBundles() { /// /// See also: /// -/// * [getTranslation], whose documentation describes these values. +/// * [getMaterialTranslation], whose documentation describes these values. final Set kSupportedLanguages = HashSet.from(const [ -${languageCodes.map((String value) => " '$value', // ${describeLocale(value)}").toList().join('\n')} +${languageCodes.map((String value) => " '$value', // ${describeLocale(value)}").join('\n')} ]); -/// Creates a [GlobalMaterialLocalizations] instance for the given `locale`. +/// Creates a [$baseClass] instance for the given `locale`. /// -/// All of the function's arguments except `locale` will be passed to the [new -/// GlobalMaterialLocalizations] constructor. (The `localeName` argument of that +/// All of the function's arguments except `locale` will be passed to the [ +/// $baseClass] constructor. (The `localeName` argument of that /// constructor is specified by the actual subclass constructor by this /// function.) /// @@ -288,24 +250,15 @@ ${languageCodes.map((String value) => " '$value', // ${describeLocale(v $supportedLocales/// {@endtemplate} /// /// Generally speaking, this method is only intended to be used by -/// [GlobalMaterialLocalizations.delegate]. -GlobalMaterialLocalizations getTranslation( - Locale locale, - intl.DateFormat fullYearFormat, - intl.DateFormat mediumDateFormat, - intl.DateFormat longDateFormat, - intl.DateFormat yearMonthFormat, - intl.NumberFormat decimalFormat, - intl.NumberFormat twoDigitZeroPaddedFormat, -) { +/// [$baseClass.delegate]. +$factoryDeclaration switch (locale.languageCode) {'''); - const String arguments = 'fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat'; for (String language in languageToLocales.keys) { // Only one instance of the language. if (languageToLocales[language].length == 1) { output.writeln(''' case '$language': - return MaterialLocalization${camelCase(languageToLocales[language][0])}($arguments);'''); + return $generatedClassPrefix${camelCase(languageToLocales[language][0])}($factoryArguments);'''); } else if (!languageToScriptCodes.containsKey(language)) { // Does not distinguish between scripts. Switch on countryCode directly. output.writeln(''' case '$language': { @@ -317,11 +270,11 @@ GlobalMaterialLocalizations getTranslation( final String countryCode = locale.countryCode; output.writeln(''' case '$countryCode': - return MaterialLocalization${camelCase(locale)}($arguments);'''); + return $generatedClassPrefix${camelCase(locale)}($factoryArguments);'''); } output.writeln(''' } - return MaterialLocalization${camelCase(LocaleInfo.fromString(language))}($arguments); + return $generatedClassPrefix${camelCase(LocaleInfo.fromString(language))}($factoryArguments); }'''); } else { // Language has scriptCode, add additional switch logic. bool hasCountryCode = false; @@ -347,7 +300,7 @@ GlobalMaterialLocalizations getTranslation( final String countryCode = locale.countryCode; output.writeln(''' case '$countryCode': - return MaterialLocalization${camelCase(locale)}($arguments);'''); + return $generatedClassPrefix${camelCase(locale)}($factoryArguments);'''); } } // Return a fallback locale that matches scriptCode, but not countryCode. @@ -359,7 +312,7 @@ GlobalMaterialLocalizations getTranslation( }'''); } output.writeln(''' - return MaterialLocalization${camelCase(scriptLocale)}($arguments); + return $generatedClassPrefix${camelCase(scriptLocale)}($factoryArguments); }'''); } else { // Not Explicitly defined, fallback to first locale with the same language and @@ -372,7 +325,7 @@ GlobalMaterialLocalizations getTranslation( }'''); } output.writeln(''' - return MaterialLocalization${camelCase(scriptLocale)}($arguments); + return $generatedClassPrefix${camelCase(scriptLocale)}($factoryArguments); }'''); break; } @@ -392,36 +345,25 @@ GlobalMaterialLocalizations getTranslation( final String countryCode = locale.countryCode; output.writeln(''' case '$countryCode': - return MaterialLocalization${camelCase(locale)}($arguments);'''); + return $generatedClassPrefix${camelCase(locale)}($factoryArguments);'''); } output.writeln(''' }'''); } output.writeln(''' - return MaterialLocalization${camelCase(LocaleInfo.fromString(language))}($arguments); + return $generatedClassPrefix${camelCase(LocaleInfo.fromString(language))}($factoryArguments); }'''); } } output.writeln(''' } - assert(false, 'getTranslation() called for unsupported locale "\$locale"'); + assert(false, 'getMaterialTranslation() called for unsupported locale "\$locale"'); return null; }'''); return output.toString(); } -/// Writes the header of each class which corresponds to a locale. -void writeClassHeader(StringBuffer output, LocaleInfo locale, String superClass) { - final String camelCaseName = camelCase(locale); - final String className = 'MaterialLocalization$camelCaseName'; - final String constructor = generateConstructor(className, locale); - output.writeln(''); - output.writeln('/// The translations for ${describeLocale(locale.originalString)} (`${locale.originalString}`).'); - output.writeln('class $className extends $superClass {'); - output.writeln(constructor); -} - /// Returns the appropriate type for getters with the given attributes. /// /// Typically "String", but some (e.g. "timeOfDayFormat") return enums. @@ -486,6 +428,7 @@ const Map _scriptCategoryToEnum = { String generateValue(String value, Map attributes) { if (value == null) return null; + // cupertino_en.arb doesn't use x-flutter-type. if (attributes != null) { switch (attributes['x-flutter-type']) { case 'icuShortTimePattern': @@ -523,77 +466,6 @@ String generateGetter(String key, String value, Map attributes) $type get $key => $value;'''; } -/// Returns the source of the constructor for a GlobalMaterialLocalizations -/// subclass. -String generateConstructor(String className, LocaleInfo locale) { - final String localeName = locale.originalString; - return ''' - /// Create an instance of the translation bundle for ${describeLocale(localeName)}. - /// - /// For details on the meaning of the arguments, see [GlobalMaterialLocalizations]. - const $className({ - String localeName = '$localeName', - @required intl.DateFormat fullYearFormat, - @required intl.DateFormat mediumDateFormat, - @required intl.DateFormat longDateFormat, - @required intl.DateFormat yearMonthFormat, - @required intl.NumberFormat decimalFormat, - @required intl.NumberFormat twoDigitZeroPaddedFormat, - }) : super( - localeName: localeName, - fullYearFormat: fullYearFormat, - mediumDateFormat: mediumDateFormat, - longDateFormat: longDateFormat, - yearMonthFormat: yearMonthFormat, - decimalFormat: decimalFormat, - twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat, - );'''; -} - -/// Parse the data for a locale from a file, and store it in the [attributes] -/// and [resources] keys. -void processBundle(File file, { @required String localeString }) { - assert(localeString != null); - // Helper method to fill the maps with the correct data from file. - void populateResources(LocaleInfo locale) { - final Map resources = localeToResources[locale]; - final Map attributes = localeToResourceAttributes[locale]; - final Map bundle = json.decode(file.readAsStringSync()); - for (String key in bundle.keys) { - // The ARB file resource "attributes" for foo are called @foo. - if (key.startsWith('@')) - attributes[key.substring(1)] = bundle[key]; - else - resources[key] = bundle[key]; - } - } - // Only pre-assume scriptCode if there is a country or script code to assume off of. - // When we assume scriptCode based on languageCode-only, we want this initial pass - // to use the un-assumed version as a base class. - LocaleInfo locale = LocaleInfo.fromString(localeString, deriveScriptCode: localeString.split('_').length > 1); - // Allow overwrite if the existing data is assumed. - if (assumedLocales.contains(locale)) { - localeToResources[locale] = {}; - localeToResourceAttributes[locale] = {}; - assumedLocales.remove(locale); - } else { - localeToResources[locale] ??= {}; - localeToResourceAttributes[locale] ??= {}; - } - populateResources(locale); - // Add an assumed locale to default to when there is no info on scriptOnly locales. - locale = LocaleInfo.fromString(localeString, deriveScriptCode: true); - if (locale.scriptCode != null) { - final LocaleInfo scriptLocale = LocaleInfo.fromString(locale.languageCode + '_' + locale.scriptCode); - if (!localeToResources.containsKey(scriptLocale)) { - assumedLocales.add(scriptLocale); - localeToResources[scriptLocale] ??= {}; - localeToResourceAttributes[scriptLocale] ??= {}; - populateResources(scriptLocale); - } - } -} - Future main(List rawArgs) async { checkCwdIsRepoRoot('gen_localizations'); final GeneratorOptions options = parseArgs(rawArgs); @@ -603,37 +475,64 @@ Future main(List rawArgs) async { // code. In most cases both codes are just two characters. final Directory directory = Directory(path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n')); - final RegExp filenameRE = RegExp(r'material_(\w+)\.arb$'); + final RegExp materialFilenameRE = RegExp(r'material_(\w+)\.arb$'); + final RegExp cupertinoFilenameRE = RegExp(r'cupertino_(\w+)\.arb$'); try { validateEnglishLocalizations(File(path.join(directory.path, 'material_en.arb'))); + validateEnglishLocalizations(File(path.join(directory.path, 'cupertino_en.arb'))); } on ValidationError catch (exception) { exitWithError('$exception'); } await precacheLanguageAndRegionTags(); - for (FileSystemEntity entity in directory.listSync()) { - final String entityPath = entity.path; - if (FileSystemEntity.isFileSync(entityPath) && filenameRE.hasMatch(entityPath)) { - processBundle(File(entityPath), localeString: filenameRE.firstMatch(entityPath)[1]); - } - } + // Maps of locales to resource key/value pairs for Material ARBs. + final Map> materialLocaleToResources = >{}; + // Maps of locales to resource key/attributes pairs for Material ARBs.. + // https://github.com/googlei18n/app-resource-bundle/wiki/ApplicationResourceBundleSpecification#resource-attributes + final Map> materialLocaleToResourceAttributes = >{}; + // Maps of locales to resource key/value pairs for Cupertino ARBs. + final Map> cupertinoLocaleToResources = >{}; + // Maps of locales to resource key/attributes pairs for Cupertino ARBs.. + // https://github.com/googlei18n/app-resource-bundle/wiki/ApplicationResourceBundleSpecification#resource-attributes + final Map> cupertinoLocaleToResourceAttributes = >{}; + + loadMatchingArbsIntoBundleMaps( + directory: directory, + filenamePattern: materialFilenameRE, + localeToResources: materialLocaleToResources, + localeToResourceAttributes: materialLocaleToResourceAttributes, + ); + loadMatchingArbsIntoBundleMaps( + directory: directory, + filenamePattern: cupertinoFilenameRE, + localeToResources: cupertinoLocaleToResources, + localeToResourceAttributes: cupertinoLocaleToResourceAttributes, + ); try { - validateLocalizations(localeToResources, localeToResourceAttributes); + validateLocalizations(materialLocaleToResources, materialLocaleToResourceAttributes); + validateLocalizations(cupertinoLocaleToResources, cupertinoLocaleToResourceAttributes); } on ValidationError catch (exception) { exitWithError('$exception'); } - final StringBuffer buffer = StringBuffer(); - buffer.writeln(outputHeader.replaceFirst('@(regenerate)', 'dart dev/tools/gen_localizations.dart --overwrite')); - buffer.write(generateTranslationBundles()); + final String materialLocalizations = generateArbBasedLocalizationSubclasses( + localeToResources: materialLocaleToResources, + localeToResourceAttributes: materialLocaleToResourceAttributes, + generatedClassPrefix: 'MaterialLocalization', + baseClass: 'GlobalMaterialLocalizations', + generateHeader: generateMaterialHeader, + generateConstructor: generateMaterialConstructor, + factoryDeclaration: materialFactoryDeclaration, + factoryArguments: materialFactoryArguments, + ); if (options.writeToFile) { - final File localizationsFile = File(path.join(directory.path, 'localizations.dart')); - localizationsFile.writeAsStringSync(buffer.toString()); + final File localizationsFile = File(path.join(directory.path, 'generated_material_localizations.dart')); + localizationsFile.writeAsStringSync(materialLocalizations, flush: true); } else { - stdout.write(buffer.toString()); + stdout.write(materialLocalizations); } } diff --git a/dev/tools/localization/gen_material_localizations.dart b/dev/tools/localization/gen_material_localizations.dart new file mode 100644 index 0000000000..54a79f2b15 --- /dev/null +++ b/dev/tools/localization/gen_material_localizations.dart @@ -0,0 +1,68 @@ +import 'localizations_utils.dart'; + +HeaderGenerator generateMaterialHeader = (String regenerateInstructions) { + return ''' +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file has been automatically generated. Please do not edit it manually. +// To regenerate the file, use: +// $regenerateInstructions + +import 'dart:collection'; + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart' as intl; + +import '../material_localizations.dart'; + +// The classes defined here encode all of the translations found in the +// `flutter_localizations/lib/src/l10n/*.arb` files. +// +// These classes are constructed by the [getMaterialTranslation] method at the +// bottom of this file, and used by the [_MaterialLocalizationsDelegate.load] +// method defined in `flutter_localizations/lib/src/material_localizations.dart`.'''; +}; + +/// Returns the source of the constructor for a GlobalMaterialLocalizations +/// subclass. +ConstructorGenerator generateMaterialConstructor = (LocaleInfo locale) { + final String localeName = locale.originalString; + return ''' + /// Create an instance of the translation bundle for ${describeLocale(localeName)}. + /// + /// For details on the meaning of the arguments, see [GlobalMaterialLocalizations]. + const MaterialLocalization${camelCase(locale)}({ + String localeName = '$localeName', + @required intl.DateFormat fullYearFormat, + @required intl.DateFormat mediumDateFormat, + @required intl.DateFormat longDateFormat, + @required intl.DateFormat yearMonthFormat, + @required intl.NumberFormat decimalFormat, + @required intl.NumberFormat twoDigitZeroPaddedFormat, + }) : super( + localeName: localeName, + fullYearFormat: fullYearFormat, + mediumDateFormat: mediumDateFormat, + longDateFormat: longDateFormat, + yearMonthFormat: yearMonthFormat, + decimalFormat: decimalFormat, + twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat, + );'''; +}; + +const String materialFactoryDeclaration = ''' +GlobalMaterialLocalizations getMaterialTranslation( + Locale locale, + intl.DateFormat fullYearFormat, + intl.DateFormat mediumDateFormat, + intl.DateFormat longDateFormat, + intl.DateFormat yearMonthFormat, + intl.NumberFormat decimalFormat, + intl.NumberFormat twoDigitZeroPaddedFormat, +) {'''; + +const String materialFactoryArguments = + 'fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat'; diff --git a/dev/tools/localizations_utils.dart b/dev/tools/localization/localizations_utils.dart similarity index 65% rename from dev/tools/localizations_utils.dart rename to dev/tools/localization/localizations_utils.dart index d92fad906a..4d85bd57b0 100644 --- a/dev/tools/localizations_utils.dart +++ b/dev/tools/localization/localizations_utils.dart @@ -9,6 +9,9 @@ import 'dart:io'; import 'package:args/args.dart' as argslib; import 'package:meta/meta.dart'; +typedef HeaderGenerator = String Function(String regenerateInstructions); +typedef ConstructorGenerator = String Function(LocaleInfo locale); + /// Simple data class to hold parsed locale. Does not promise validity of any data. class LocaleInfo implements Comparable { LocaleInfo({ @@ -129,6 +132,75 @@ class LocaleInfo implements Comparable { } } +/// Parse the data for a locale from a file, and store it in the [attributes] +/// and [resources] keys. +void loadMatchingArbsIntoBundleMaps({ + @required Directory directory, + @required RegExp filenamePattern, + @required Map> localeToResources, + @required Map> localeToResourceAttributes, +}) { + assert(directory != null); + assert(filenamePattern != null); + assert(localeToResources != null); + assert(localeToResourceAttributes != null); + + /// Set that holds the locales that were assumed from the existing locales. + /// + /// For example, when the data lacks data for zh_Hant, we will use the data of + /// the first Hant Chinese locale as a default by repeating the data. If an + /// explicit match is later found, we can reference this set to see if we should + /// overwrite the existing assumed data. + final Set assumedLocales = {}; + + for (FileSystemEntity entity in directory.listSync()) { + final String entityPath = entity.path; + if (FileSystemEntity.isFileSync(entityPath) && filenamePattern.hasMatch(entityPath)) { + final String localeString = filenamePattern.firstMatch(entityPath)[1]; + final File arbFile = File(entityPath); + + // Helper method to fill the maps with the correct data from file. + void populateResources(LocaleInfo locale, File file) { + final Map resources = localeToResources[locale]; + final Map attributes = localeToResourceAttributes[locale]; + final Map bundle = json.decode(file.readAsStringSync()); + for (String key in bundle.keys) { + // The ARB file resource "attributes" for foo are called @foo. + if (key.startsWith('@')) + attributes[key.substring(1)] = bundle[key]; + else + resources[key] = bundle[key]; + } + } + // Only pre-assume scriptCode if there is a country or script code to assume off of. + // When we assume scriptCode based on languageCode-only, we want this initial pass + // to use the un-assumed version as a base class. + LocaleInfo locale = LocaleInfo.fromString(localeString, deriveScriptCode: localeString.split('_').length > 1); + // Allow overwrite if the existing data is assumed. + if (assumedLocales.contains(locale)) { + localeToResources[locale] = {}; + localeToResourceAttributes[locale] = {}; + assumedLocales.remove(locale); + } else { + localeToResources[locale] ??= {}; + localeToResourceAttributes[locale] ??= {}; + } + populateResources(locale, arbFile); + // Add an assumed locale to default to when there is no info on scriptOnly locales. + locale = LocaleInfo.fromString(localeString, deriveScriptCode: true); + if (locale.scriptCode != null) { + final LocaleInfo scriptLocale = LocaleInfo.fromString(locale.languageCode + '_' + locale.scriptCode); + if (!localeToResources.containsKey(scriptLocale)) { + assumedLocales.add(scriptLocale); + localeToResources[scriptLocale] ??= {}; + localeToResourceAttributes[scriptLocale] ??= {}; + populateResources(scriptLocale, arbFile); + } + } + } + } +} + void exitWithError(String errorMessage) { assert(errorMessage != null); stderr.writeln('fatal: $errorMessage'); @@ -266,4 +338,50 @@ String describeLocale(String tag) { if (script != null) output += ', using the $script script'; return output; -} \ No newline at end of file +} + +/// Writes the header of each class which corresponds to a locale. +String generateClassDeclaration( + LocaleInfo locale, + String classNamePrefix, + String superClass, +) { + final String camelCaseName = camelCase(locale); + return ''' + +/// The translations for ${describeLocale(locale.originalString)} (`${locale.originalString}`). +class $classNamePrefix$camelCaseName extends $superClass {'''; +} + +/// Return `s` as a Dart-parseable raw string in single or double quotes. +/// +/// Double quotes are expanded: +/// +/// ``` +/// foo => r'foo' +/// foo "bar" => r'foo "bar"' +/// foo 'bar' => r'foo ' "'" r'bar' "'" +/// ``` +String generateString(String s) { + if (!s.contains("'")) + return "r'$s'"; + + final StringBuffer output = StringBuffer(); + bool started = false; // Have we started writing a raw string. + for (int i = 0; i < s.length; i++) { + if (s[i] == "'") { + if (started) + output.write("'"); + output.write(' "\'" '); + started = false; + } else if (!started) { + output.write("r'${s[i]}"); + started = true; + } else { + output.write(s[i]); + } + } + if (started) + output.write("'"); + return output.toString(); +} diff --git a/dev/tools/localizations_validator.dart b/dev/tools/localization/localizations_validator.dart similarity index 99% rename from dev/tools/localizations_validator.dart rename to dev/tools/localization/localizations_validator.dart index bbbb1dee43..9ab33d2052 100644 --- a/dev/tools/localizations_validator.dart +++ b/dev/tools/localization/localizations_validator.dart @@ -19,8 +19,7 @@ class ValidationError implements Exception { String toString() => message; } -/// Sanity checking of the @foo metadata in the English translations, -/// material_en.arb. +/// Sanity checking of the @foo metadata in the English translations, *_en.arb. /// /// - For each foo, resource, there must be a corresponding @foo. /// - For each @foo resource, there must be a corresponding foo, except diff --git a/dev/tools/pubspec.yaml b/dev/tools/pubspec.yaml index 2c9ad1221e..5881312c9e 100644 --- a/dev/tools/pubspec.yaml +++ b/dev/tools/pubspec.yaml @@ -9,12 +9,12 @@ dependencies: archive: 2.0.8 args: 1.5.1 http: 0.12.0+1 - intl: 0.15.7 + intl: 0.15.8 meta: 1.1.6 path: 1.6.2 process: 3.0.9 - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -28,13 +28,13 @@ dependencies: typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" dev_dependencies: - test_api: 0.2.2 + test_api: 0.2.4 mockito: 4.0.0 boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" -# PUBSPEC CHECKSUM: 5473 +# PUBSPEC CHECKSUM: b708 diff --git a/dev/tools/vitool/pubspec.yaml b/dev/tools/vitool/pubspec.yaml index 2468911c63..6c6618fd13 100644 --- a/dev/tools/vitool/pubspec.yaml +++ b/dev/tools/vitool/pubspec.yaml @@ -1,7 +1,7 @@ name: vitool description: A tool for generating Dart vector animation code from SVG sequences. version: 0.0.1 -homepage: https://flutter.io +homepage: https://flutter.dev author: Flutter Authors environment: @@ -23,18 +23,18 @@ dev_dependencies: flutter_test: sdk: flutter - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - quiver: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + quiver: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" -# PUBSPEC CHECKSUM: e7b3 +# PUBSPEC CHECKSUM: b548 diff --git a/examples/README.md b/examples/README.md index 3fa7a31b90..361f2c4314 100644 --- a/examples/README.md +++ b/examples/README.md @@ -3,7 +3,7 @@ Flutter Examples This directory contains several examples of using Flutter. To run an example, use `flutter run` inside that example's directory. See the [getting started -guide](https://flutter.io/getting-started/) to install the `flutter` tool. +guide](https://flutter.dev/getting-started/) to install the `flutter` tool. For additional samples, see the [`flutter/samples`](https://github.com/flutter/samples) repo. @@ -23,7 +23,7 @@ Available examples include: - **Platform Channel** The [platform channel app](platform_channel) demonstrates how to connect a Flutter app to platform-specific APIs. For documentation, see - . + . - **Platform Channel Swift** The [platform channel swift app](platform_channel_swift) is the same as [platform diff --git a/examples/catalog/bin/sample_page.dart b/examples/catalog/bin/sample_page.dart index d2780412f7..9ee4b8a4e3 100644 --- a/examples/catalog/bin/sample_page.dart +++ b/examples/catalog/bin/sample_page.dart @@ -217,10 +217,10 @@ void generate(String commit) { { 'imports': samples.map((SampleInfo page) { return "import '${page.importPath}' show ${page.sampleClass};\n"; - }).toList().join(), + }).join(), 'widgets': samples.map((SampleInfo sample) { return 'new ${sample.sampleClass}(),\n'; - }).toList().join(), + }).join(), }, ); @@ -232,7 +232,7 @@ void generate(String commit) { { 'paths': samples.map((SampleInfo sample) { return "'${outputFile(sample.sourceName + '.png').path}'"; - }).toList().join(',\n'), + }).join(',\n'), }, ); diff --git a/examples/catalog/lib/animated_list.dart b/examples/catalog/lib/animated_list.dart index e9c3084b67..11cbfdeb1a 100644 --- a/examples/catalog/lib/animated_list.dart +++ b/examples/catalog/lib/animated_list.dart @@ -119,7 +119,7 @@ class ListModel { Iterable initialItems, }) : assert(listKey != null), assert(removedItemBuilder != null), - _items = List.from(initialItems ?? []); + _items = initialItems?.toList() ?? []; final GlobalKey listKey; final dynamic removedItemBuilder; diff --git a/examples/catalog/pubspec.yaml b/examples/catalog/pubspec.yaml index 3f90fcdad7..1d896feedc 100644 --- a/examples/catalog/pubspec.yaml +++ b/examples/catalog/pubspec.yaml @@ -20,60 +20,55 @@ dev_dependencies: sdk: flutter flutter_driver: sdk: flutter - test: 1.5.3 + test: 1.6.1 - analyzer: 0.35.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + analyzer: 0.35.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" args: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" file: 5.0.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - front_end: 0.1.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + front_end: 0.1.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - html: 0.13.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http: 0.12.0+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 2.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - intl: 0.15.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl: 0.15.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 0.3.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - json_rpc_2: 2.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - kernel: 0.3.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + json_rpc_2: 2.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + kernel: 0.3.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 0.9.6+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" multi_server_socket: 1.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" node_preamble: 1.4.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" package_config: 1.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" package_resolver: 1.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - plugin: 0.2.0+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - quiver: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + quiver: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf: 0.7.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf_web_socket: 0.2.2+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf_web_socket: 0.2.2+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_map_stack_trace: 1.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_maps: 0.10.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_core: 0.2.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - utf: 0.9.0+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - vm_service_client: 0.2.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_core: 0.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + vm_service_client: 0.2.6+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 0.9.7+10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - web_socket_channel: 1.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + web_socket_channel: 1.0.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" flutter: uses-material-design: true -# PUBSPEC CHECKSUM: 6687 +# PUBSPEC CHECKSUM: ca3b diff --git a/examples/flutter_gallery/README.md b/examples/flutter_gallery/README.md index 13b13a2599..627ba6398e 100644 --- a/examples/flutter_gallery/README.md +++ b/examples/flutter_gallery/README.md @@ -11,7 +11,7 @@ and install it onto your device. ### Prerequisites If you are new to Flutter, please first follow -the [Flutter Setup](https://flutter.io/setup/) guide. +the [Flutter Setup](https://flutter.dev/setup/) guide. ### Building and installing the Flutter app diff --git a/examples/flutter_gallery/android/fastlane/metadata/android/en-US/full_description.txt b/examples/flutter_gallery/android/fastlane/metadata/android/en-US/full_description.txt index 7cbeb3c3b3..6f9203076a 100644 --- a/examples/flutter_gallery/android/fastlane/metadata/android/en-US/full_description.txt +++ b/examples/flutter_gallery/android/fastlane/metadata/android/en-US/full_description.txt @@ -6,4 +6,4 @@ Flutter is Google’s multi-platform mobile app SDK for crafting beautiful nativ This app is open source. Check out the code to see how this app is built: https://github.com/flutter/flutter/tree/master/examples/flutter_gallery -Visit https://flutter.io to learn more. \ No newline at end of file +Visit https://flutter.dev to learn more. \ No newline at end of file diff --git a/examples/flutter_gallery/ios/fastlane/Appfile b/examples/flutter_gallery/ios/fastlane/Appfile index 849b7e1e77..a013fdd5b3 100644 --- a/examples/flutter_gallery/ios/fastlane/Appfile +++ b/examples/flutter_gallery/ios/fastlane/Appfile @@ -1,5 +1,5 @@ app_identifier "io.flutter.demo.gallery" # The bundle identifier of your app -apple_id "stores@flutter.io" # Your Apple email address +apple_id "deploybot@flutter.io" # Your Apple email address itc_team_id "118089806" # iTunes Connect Team ID team_id "S8QB4VV633" # Developer Portal Team ID diff --git a/examples/flutter_gallery/ios/fastlane/Fastfile b/examples/flutter_gallery/ios/fastlane/Fastfile index 5ab932fd95..455e42bf02 100644 --- a/examples/flutter_gallery/ios/fastlane/Fastfile +++ b/examples/flutter_gallery/ios/fastlane/Fastfile @@ -44,14 +44,15 @@ platform :ios do version_number: /\d+\.\d+\.\d+/.match(raw_version)[0] ) - puts 'Retrieving signing certificates and profiles...' # Stop fastlane from echoing back PUBLISHING_MATCH_CERTIFICATE_REPO var. + # Doesn't matter too much since Cirrus doesn't echo back encrypted variables + # anyway. suppress_output { # Retrieves all the necessary certs and provisioning profiles. sync_code_signing( - git_url: ENV['PUBLISHING_MATCH_CERTIFICATE_REPO'], + git_url: "https://x-access-token:#{ENV['PUBLISHING_MATCH_REPO_TOKEN']}@#{ENV['PUBLISHING_MATCH_CERTIFICATE_REPO']}" , type: 'appstore', - readonly: true + readonly: true, ) } puts 'Certificates and profiles installed' @@ -73,7 +74,7 @@ platform :ios do scheme: 'Runner', export_method: 'app-store', # Verify that the right signing identity is used for publishing. - codesigning_identity: 'iPhone Distribution: Store Ladd (S8QB4VV633)', + codesigning_identity: 'iPhone Distribution: FLUTTER.IO LLC (S8QB4VV633)', ) if options[:upload] diff --git a/examples/flutter_gallery/lib/demo/all.dart b/examples/flutter_gallery/lib/demo/all.dart index e2a6d05632..0dfe26be87 100644 --- a/examples/flutter_gallery/lib/demo/all.dart +++ b/examples/flutter_gallery/lib/demo/all.dart @@ -12,5 +12,6 @@ export 'images_demo.dart'; export 'material/material.dart'; export 'pesto_demo.dart'; export 'shrine_demo.dart'; +export 'transformations/transformations_demo.dart'; export 'typography_demo.dart'; export 'video_demo.dart'; diff --git a/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart b/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart index cb0dff826e..44f4680772 100644 --- a/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart @@ -13,7 +13,8 @@ enum LeaveBehindDemoAction { reset, horizontalSwipe, leftSwipe, - rightSwipe + rightSwipe, + confirmDismiss, } class LeaveBehindItem implements Comparable { @@ -43,6 +44,7 @@ class LeaveBehindDemo extends StatefulWidget { class LeaveBehindDemoState extends State { static final GlobalKey _scaffoldKey = GlobalKey(); DismissDirection _dismissDirection = DismissDirection.horizontal; + bool _confirmDismiss = true; List leaveBehindItems; void initListItems() { @@ -77,6 +79,9 @@ class LeaveBehindDemoState extends State { case LeaveBehindDemoAction.rightSwipe: _dismissDirection = DismissDirection.startToEnd; break; + case LeaveBehindDemoAction.confirmDismiss: + _confirmDismiss = !_confirmDismiss; + break; } }); } @@ -128,6 +133,7 @@ class LeaveBehindDemoState extends State { body = ListView( children: leaveBehindItems.map((LeaveBehindItem item) { return _LeaveBehindListItem( + confirmDismiss: _confirmDismiss, item: item, onArchive: _handleArchive, onDelete: _handleDelete, @@ -166,6 +172,11 @@ class LeaveBehindDemoState extends State { checked: _dismissDirection == DismissDirection.startToEnd, child: const Text('Only swipe right'), ), + CheckedPopupMenuItem( + value: LeaveBehindDemoAction.confirmDismiss, + checked: _confirmDismiss, + child: const Text('Confirm dismiss'), + ), ], ), ], @@ -182,12 +193,14 @@ class _LeaveBehindListItem extends StatelessWidget { @required this.onArchive, @required this.onDelete, @required this.dismissDirection, + @required this.confirmDismiss, }) : super(key: key); final LeaveBehindItem item; final DismissDirection dismissDirection; final void Function(LeaveBehindItem) onArchive; final void Function(LeaveBehindItem) onDelete; + final bool confirmDismiss; void _handleArchive() { onArchive(item); @@ -214,6 +227,23 @@ class _LeaveBehindListItem extends StatelessWidget { else _handleDelete(); }, + confirmDismiss: !confirmDismiss ? null : (DismissDirection dismissDirection) async { + switch(dismissDirection) { + case DismissDirection.endToStart: + if (await _showConfirmationDialog(context, 'archive')) + _handleArchive(); + break; + case DismissDirection.startToEnd: + if (await _showConfirmationDialog(context, 'delete')) + _handleDelete(); + break; + case DismissDirection.horizontal: + case DismissDirection.vertical: + case DismissDirection.up: + case DismissDirection.down: + assert(false); + } + }, background: Container( color: theme.primaryColor, child: const ListTile( @@ -240,4 +270,30 @@ class _LeaveBehindListItem extends StatelessWidget { ), ); } + + Future _showConfirmationDialog(BuildContext context, String action) { + return showDialog( + context: context, + barrierDismissible: true, + builder: (BuildContext context) { + return AlertDialog( + title: Text('Do you want to $action this item?'), + actions: [ + FlatButton( + child: const Text('Yes'), + onPressed: () { + Navigator.pop(context, true); // showDialog() returns true + }, + ), + FlatButton( + child: const Text('No'), + onPressed: () { + Navigator.pop(context, false); // showDialog() returns false + }, + ), + ], + ); + }, + ); + } } diff --git a/examples/flutter_gallery/lib/demo/shrine/expanding_bottom_sheet.dart b/examples/flutter_gallery/lib/demo/shrine/expanding_bottom_sheet.dart index 614c67687d..72047eb684 100644 --- a/examples/flutter_gallery/lib/demo/shrine/expanding_bottom_sheet.dart +++ b/examples/flutter_gallery/lib/demo/shrine/expanding_bottom_sheet.dart @@ -613,7 +613,7 @@ class _ListModel { Iterable initialItems, }) : assert(listKey != null), assert(removedItemBuilder != null), - _items = List.from(initialItems ?? []); + _items = initialItems?.toList() ?? []; final GlobalKey listKey; final dynamic removedItemBuilder; diff --git a/examples/flutter_gallery/lib/demo/shrine/supplemental/product_columns.dart b/examples/flutter_gallery/lib/demo/shrine/supplemental/product_columns.dart index 6889716146..589f9c7e68 100644 --- a/examples/flutter_gallery/lib/demo/shrine/supplemental/product_columns.dart +++ b/examples/flutter_gallery/lib/demo/shrine/supplemental/product_columns.dart @@ -31,12 +31,15 @@ class TwoProductCardColumn extends StatelessWidget { const double spacerHeight = 44.0; final double heightOfCards = (constraints.biggest.height - spacerHeight) / 2.0; - final double heightOfImages = heightOfCards - ProductCard.kTextBoxHeight; - final double imageAspectRatio = (heightOfImages >= 0.0 && constraints.biggest.width > heightOfImages) - ? constraints.biggest.width / heightOfImages - : 33 / 49; + final double availableHeightForImages = heightOfCards - ProductCard.kTextBoxHeight; + // Ensure the cards take up the available space as long as the screen is + // sufficiently tall, otherwise fallback on a constant aspect ratio. + final double imageAspectRatio = availableHeightForImages >= 0.0 + ? constraints.biggest.width / availableHeightForImages + : 49.0 / 33.0; return ListView( + physics: const ClampingScrollPhysics(), children: [ Padding( padding: const EdgeInsetsDirectional.only(start: 28.0), @@ -71,6 +74,7 @@ class OneProductCardColumn extends StatelessWidget { @override Widget build(BuildContext context) { return ListView( + physics: const ClampingScrollPhysics(), reverse: true, children: [ const SizedBox( diff --git a/examples/flutter_gallery/lib/demo/transformations/transformations_demo.dart b/examples/flutter_gallery/lib/demo/transformations/transformations_demo.dart new file mode 100644 index 0000000000..4a5bf99339 --- /dev/null +++ b/examples/flutter_gallery/lib/demo/transformations/transformations_demo.dart @@ -0,0 +1,190 @@ +import 'dart:ui' show Vertices; +import 'package:flutter/material.dart'; +import 'transformations_demo_board.dart'; +import 'transformations_demo_edit_board_point.dart'; +import 'transformations_demo_gesture_transformable.dart'; + +class TransformationsDemo extends StatefulWidget { + const TransformationsDemo({ Key key }) : super(key: key); + + static const String routeName = '/transformations'; + + @override _TransformationsDemoState createState() => _TransformationsDemoState(); +} +class _TransformationsDemoState extends State { + // The radius of a hexagon tile in pixels. + static const double _kHexagonRadius = 32.0; + // The margin between hexagons. + static const double _kHexagonMargin = 1.0; + // The radius of the entire board in hexagons, not including the center. + static const int _kBoardRadius = 8; + + bool _reset = false; + Board _board = Board( + boardRadius: _kBoardRadius, + hexagonRadius: _kHexagonRadius, + hexagonMargin: _kHexagonMargin, + ); + + @override + Widget build (BuildContext context) { + final BoardPainter painter = BoardPainter( + board: _board, + ); + + // The scene is drawn by a CustomPaint, but user interaction is handled by + // the GestureTransformable parent widget. + return Scaffold( + appBar: AppBar( + title: const Text('2D Tranformations'), + actions: [ + IconButton( + icon: const Icon(Icons.help), + tooltip: 'Help', + onPressed: () { + showDialog( + context: context, + builder: (BuildContext context) => instructionDialog, + ); + }, + ), + ], + ), + body: LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) { + // Draw the scene as big as is available, but allow the user to + // translate beyond that to a visibleSize that's a bit bigger. + final Size size = Size(constraints.maxWidth, constraints.maxHeight); + final Size visibleSize = Size(size.width * 3, size.height * 2); + return GestureTransformable( + reset: _reset, + onResetEnd: () { + setState(() { + _reset = false; + }); + }, + child: CustomPaint( + painter: painter, + ), + boundaryRect: Rect.fromLTWH( + -visibleSize.width / 2, + -visibleSize.height / 2, + visibleSize.width, + visibleSize.height, + ), + // Center the board in the middle of the screen. It's drawn centered + // at the origin, which is the top left corner of the + // GestureTransformable. + initialTranslation: Offset(size.width / 2, size.height / 2), + onTapUp: _onTapUp, + size: size, + ); + }, + ), + floatingActionButton: _board.selected == null ? resetButton : editButton, + ); + } + + Widget get instructionDialog { + return AlertDialog( + title: const Text('2D Transformations'), + content: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: const [ + Text('Tap to edit hex tiles, and use gestures to move around the scene:\n'), + Text('- Drag to pan.'), + Text('- Pinch to zoom.'), + Text('- Rotate with two fingers.'), + Text('\nYou can always press the home button to return to the starting orientation!'), + ], + ), + actions: [ + FlatButton( + child: const Text('OK'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + } + + FloatingActionButton get resetButton { + return FloatingActionButton( + onPressed: () { + setState(() { + _reset = true; + }); + }, + tooltip: 'Reset Transform', + backgroundColor: Theme.of(context).primaryColor, + child: const Icon(Icons.home), + ); + } + + FloatingActionButton get editButton { + return FloatingActionButton( + onPressed: () { + if (_board.selected == null) { + return; + } + showModalBottomSheet(context: context, builder: (BuildContext context) { + return Container( + width: double.infinity, + height: 150, + padding: const EdgeInsets.all(12.0), + child: EditBoardPoint( + boardPoint: _board.selected, + onColorSelection: (Color color) { + setState(() { + _board = _board.copyWithBoardPointColor(_board.selected, color); + Navigator.pop(context); + }); + }, + ), + ); + }); + }, + tooltip: 'Edit Tile', + child: const Icon(Icons.edit), + ); + } + + void _onTapUp(TapUpDetails details) { + final Offset scenePoint = details.globalPosition; + final BoardPoint boardPoint = _board.pointToBoardPoint(scenePoint); + setState(() { + _board = _board.copyWithSelected(boardPoint); + }); + } +} + +// CustomPainter is what is passed to CustomPaint and actually draws the scene +// when its `paint` method is called. +class BoardPainter extends CustomPainter { + const BoardPainter({ + this.board, + }); + + final Board board; + + @override + void paint(Canvas canvas, Size size) { + void drawBoardPoint(BoardPoint boardPoint) { + final Color color = boardPoint.color.withOpacity( + board.selected == boardPoint ? 0.2 : 1.0, + ); + final Vertices vertices = board.getVerticesForBoardPoint(boardPoint, color); + canvas.drawVertices(vertices, BlendMode.color, Paint()); + } + + board.forEach(drawBoardPoint); + } + + // We should repaint whenever the board changes, such as board.selected. + @override + bool shouldRepaint(BoardPainter oldDelegate) { + return oldDelegate.board != board; + } +} diff --git a/examples/flutter_gallery/lib/demo/transformations/transformations_demo_board.dart b/examples/flutter_gallery/lib/demo/transformations/transformations_demo_board.dart new file mode 100644 index 0000000000..bf74076d4f --- /dev/null +++ b/examples/flutter_gallery/lib/demo/transformations/transformations_demo_board.dart @@ -0,0 +1,286 @@ +import 'dart:collection' show IterableMixin; +import 'dart:math'; +import 'dart:ui' show Vertices; +import 'package:flutter/material.dart' hide Gradient; +import 'package:vector_math/vector_math_64.dart' show Vector3; + +// The entire state of the hex board and abstraction to get information about +// it. Iterable so that all BoardPoints on the board can be iterated over. +@immutable +class Board extends Object with IterableMixin { + Board({ + @required this.boardRadius, + @required this.hexagonRadius, + @required this.hexagonMargin, + this.selected, + List boardPoints, + }) : assert(boardRadius > 0), + assert(hexagonRadius > 0), + assert(hexagonMargin >= 0) { + // Set up the positions for the center hexagon where the entire board is + // centered on the origin. + // Start point of hexagon (top vertex). + final Point hexStart = Point(0, -hexagonRadius); + final double hexagonRadiusPadded = hexagonRadius - hexagonMargin; + final double centerToFlat = sqrt(3) / 2 * hexagonRadiusPadded; + positionsForHexagonAtOrigin.addAll([ + Offset(hexStart.x, hexStart.y), + Offset(hexStart.x + centerToFlat, hexStart.y + 0.5 * hexagonRadiusPadded), + Offset(hexStart.x + centerToFlat, hexStart.y + 1.5 * hexagonRadiusPadded), + Offset(hexStart.x + centerToFlat, hexStart.y + 1.5 * hexagonRadiusPadded), + Offset(hexStart.x, hexStart.y + 2 * hexagonRadiusPadded), + Offset(hexStart.x, hexStart.y + 2 * hexagonRadiusPadded), + Offset(hexStart.x - centerToFlat, hexStart.y + 1.5 * hexagonRadiusPadded), + Offset(hexStart.x - centerToFlat, hexStart.y + 1.5 * hexagonRadiusPadded), + Offset(hexStart.x - centerToFlat, hexStart.y + 0.5 * hexagonRadiusPadded), + ]); + + if (boardPoints != null) { + _boardPoints.addAll(boardPoints); + } else { + // Generate boardPoints for a fresh board. + BoardPoint boardPoint = _getNextBoardPoint(null); + while (boardPoint != null) { + _boardPoints.add(boardPoint); + boardPoint = _getNextBoardPoint(boardPoint); + } + } + } + + final int boardRadius; // Number of hexagons from center to edge. + final double hexagonRadius; // Pixel radius of a hexagon (center to vertex). + final double hexagonMargin; // Margin between hexagons. + final List positionsForHexagonAtOrigin = []; + final BoardPoint selected; + final List _boardPoints = []; + + @override + Iterator get iterator => _BoardIterator(_boardPoints); + + // For a given q axial coordinate, get the range of possible r values + // See the definition of BoardPoint for more information about hex grids and + // axial coordinates. + _Range _getRRangeForQ(int q) { + int rStart; + int rEnd; + if (q <= 0) { + rStart = -boardRadius - q; + rEnd = boardRadius; + } else { + rEnd = boardRadius - q; + rStart = -boardRadius; + } + + return _Range(rStart, rEnd); + } + + // Get the BoardPoint that comes after the given BoardPoint. If given null, + // returns the origin BoardPoint. If given BoardPoint is the last, returns + // null. + BoardPoint _getNextBoardPoint (BoardPoint boardPoint) { + // If before the first element. + if (boardPoint == null) { + return BoardPoint(-boardRadius, 0); + } + + final _Range rRange = _getRRangeForQ(boardPoint.q); + + // If at or after the last element. + if (boardPoint.q >= boardRadius && boardPoint.r >= rRange.max) { + return null; + } + + // If wrapping from one q to the next. + if (boardPoint.r >= rRange.max) { + return BoardPoint(boardPoint.q + 1, _getRRangeForQ(boardPoint.q + 1).min); + } + + // Otherwise we're just incrementing r. + return BoardPoint(boardPoint.q, boardPoint.r + 1); + } + + // Check if the board point is actually on the board. + bool _validateBoardPoint(BoardPoint boardPoint) { + const BoardPoint center = BoardPoint(0, 0); + final int distanceFromCenter = getDistance(center, boardPoint); + return distanceFromCenter <= boardRadius; + } + + // Get the distance between two BoardPoins. + static int getDistance(BoardPoint a, BoardPoint b) { + final Vector3 a3 = a.cubeCoordinates; + final Vector3 b3 = b.cubeCoordinates; + return + ((a3.x - b3.x).abs() + (a3.y - b3.y).abs() + (a3.z - b3.z).abs()) ~/ 2; + } + + // Return the q,r BoardPoint for a point in the scene, where the origin is in + // the center of the board in both coordinate systems. If no BoardPoint at the + // location, return null. + BoardPoint pointToBoardPoint(Offset point) { + final BoardPoint boardPoint = BoardPoint( + ((sqrt(3) / 3 * point.dx - 1 / 3 * point.dy) / hexagonRadius).round(), + ((2 / 3 * point.dy) / hexagonRadius).round(), + ); + + if (!_validateBoardPoint(boardPoint)) { + return null; + } + + return _boardPoints.firstWhere((BoardPoint boardPointI) { + return boardPointI.q == boardPoint.q && boardPointI.r == boardPoint.r; + }); + } + + // Return a scene point for the center of a hexagon given its q,r point. + Point boardPointToPoint(BoardPoint boardPoint) { + return Point( + sqrt(3) * hexagonRadius * boardPoint.q + sqrt(3) / 2 * hexagonRadius * boardPoint.r, + 1.5 * hexagonRadius * boardPoint.r, + ); + } + + // Get Vertices that can be drawn to a Canvas for the given BoardPoint. + Vertices getVerticesForBoardPoint(BoardPoint boardPoint, Color color) { + final Point centerOfHexZeroCenter = boardPointToPoint(boardPoint); + + final List positions = positionsForHexagonAtOrigin.map((Offset offset) { + return offset.translate(centerOfHexZeroCenter.x, centerOfHexZeroCenter.y); + }).toList(); + + return Vertices( + VertexMode.triangleFan, + positions, + colors: List.filled(positions.length, color), + ); + } + + // Return a new board with the given BoardPoint selected. + Board copyWithSelected(BoardPoint boardPoint) { + if (selected == boardPoint) { + return this; + } + final Board nextBoard = Board( + boardRadius: boardRadius, + hexagonRadius: hexagonRadius, + hexagonMargin: hexagonMargin, + selected: boardPoint, + boardPoints: _boardPoints, + ); + return nextBoard; + } + + // Return a new board where boardPoint has the given color. + Board copyWithBoardPointColor(BoardPoint boardPoint, Color color) { + final BoardPoint nextBoardPoint = boardPoint.copyWithColor(color); + final int boardPointIndex = _boardPoints.indexWhere((BoardPoint boardPointI) => + boardPointI.q == boardPoint.q && boardPointI.r == boardPoint.r + ); + + if (elementAt(boardPointIndex) == boardPoint && boardPoint.color == color) { + return this; + } + + final List nextBoardPoints = List.from(_boardPoints); + nextBoardPoints[boardPointIndex] = nextBoardPoint; + final BoardPoint selectedBoardPoint = boardPoint == selected + ? nextBoardPoint + : selected; + return Board( + boardRadius: boardRadius, + hexagonRadius: hexagonRadius, + hexagonMargin: hexagonMargin, + selected: selectedBoardPoint, + boardPoints: nextBoardPoints, + ); + } +} + +class _BoardIterator extends Iterator { + _BoardIterator(this.boardPoints); + + final List boardPoints; + int currentIndex; + + @override + BoardPoint current; + + @override + bool moveNext() { + if (currentIndex == null) { + currentIndex = 0; + } else { + currentIndex++; + } + + if (currentIndex >= boardPoints.length) { + current = null; + return false; + } + + current = boardPoints[currentIndex]; + return true; + } +} + +// A range of q/r board coordinate values. +@immutable +class _Range { + const _Range(this.min, this.max) + : assert(min != null), + assert(max != null), + assert(min <= max); + + final int min; + final int max; +} + +final Set boardPointColors = { + Colors.grey, + Colors.black, + Colors.red, + Colors.blue, +}; + +// A location on the board in axial coordinates. +// Axial coordinates use two integers, q and r, to locate a hexagon on a grid. +// https://www.redblobgames.com/grids/hexagons/#coordinates-axial +@immutable +class BoardPoint { + const BoardPoint(this.q, this.r, { + this.color = Colors.grey, + }); + + final int q; + final int r; + final Color color; + + @override + String toString() { + return 'BoardPoint($q, $r, $color)'; + } + + // Only compares by location. + @override + bool operator ==(dynamic other) { + if (other.runtimeType != runtimeType) { + return false; + } + final BoardPoint boardPoint = other; + return boardPoint.q == q && boardPoint.r == r; + } + + @override + int get hashCode => hashValues(q, r); + + BoardPoint copyWithColor(Color nextColor) => BoardPoint(q, r, color: nextColor); + + // Convert from q,r axial coords to x,y,z cube coords. + Vector3 get cubeCoordinates { + return Vector3( + q.toDouble(), + r.toDouble(), + (-q - r).toDouble(), + ); + } +} diff --git a/examples/flutter_gallery/lib/demo/transformations/transformations_demo_color_picker.dart b/examples/flutter_gallery/lib/demo/transformations/transformations_demo_color_picker.dart new file mode 100644 index 0000000000..ebcaa0d3d0 --- /dev/null +++ b/examples/flutter_gallery/lib/demo/transformations/transformations_demo_color_picker.dart @@ -0,0 +1,70 @@ +import 'package:flutter/material.dart'; + +// A generic widget for a list of selectable colors. +@immutable +class ColorPicker extends StatelessWidget { + const ColorPicker({ + @required this.colors, + @required this.selectedColor, + this.onColorSelection, + }) : assert(colors != null), + assert(selectedColor != null); + + final Set colors; + final Color selectedColor; + final ValueChanged onColorSelection; + + @override + Widget build (BuildContext context) { + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: colors.map((Color color) { + return _ColorPickerSwatch( + color: color, + selected: color == selectedColor, + onTap: () { + if (onColorSelection != null) { + onColorSelection(color); + } + }, + ); + }).toList(), + ); + } +} + +// A single selectable color widget in the ColorPicker. +@immutable +class _ColorPickerSwatch extends StatelessWidget { + const _ColorPickerSwatch({ + @required this.color, + @required this.selected, + this.onTap, + }) : assert(color != null), + assert(selected != null); + + final Color color; + final bool selected; + final Function onTap; + + @override + Widget build (BuildContext context) { + return Container( + width: 60.0, + height: 60.0, + padding: const EdgeInsets.fromLTRB(2.0, 0.0, 2.0, 0.0), + child: RawMaterialButton( + fillColor: color, + onPressed: () { + if (onTap != null) { + onTap(); + } + }, + child: !selected ? null : const Icon( + Icons.check, + color: Colors.white, + ), + ), + ); + } +} diff --git a/examples/flutter_gallery/lib/demo/transformations/transformations_demo_edit_board_point.dart b/examples/flutter_gallery/lib/demo/transformations/transformations_demo_edit_board_point.dart new file mode 100644 index 0000000000..160054b050 --- /dev/null +++ b/examples/flutter_gallery/lib/demo/transformations/transformations_demo_edit_board_point.dart @@ -0,0 +1,36 @@ +import 'package:flutter/material.dart'; +import 'transformations_demo_board.dart'; +import 'transformations_demo_color_picker.dart'; + +// The panel for editing a board point. +@immutable +class EditBoardPoint extends StatelessWidget { + const EditBoardPoint({ + Key key, + @required this.boardPoint, + this.onColorSelection, + }) : assert(boardPoint != null), + super(key: key); + + final BoardPoint boardPoint; + final ValueChanged onColorSelection; + + @override + Widget build (BuildContext context) { + return Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Text( + '${boardPoint.q}, ${boardPoint.r}', + textAlign: TextAlign.right, + style: const TextStyle(fontWeight: FontWeight.bold), + ), + ColorPicker( + colors: boardPointColors, + selectedColor: boardPoint.color, + onColorSelection: onColorSelection, + ), + ], + ); + } +} diff --git a/examples/flutter_gallery/lib/demo/transformations/transformations_demo_gesture_transformable.dart b/examples/flutter_gallery/lib/demo/transformations/transformations_demo_gesture_transformable.dart new file mode 100644 index 0000000000..5f8490cde6 --- /dev/null +++ b/examples/flutter_gallery/lib/demo/transformations/transformations_demo_gesture_transformable.dart @@ -0,0 +1,571 @@ +import 'package:flutter/material.dart'; +import 'package:vector_math/vector_math_64.dart' show Vector3; +import 'transformations_demo_inertial_motion.dart'; + +// This widget allows 2D transform interactions on its child in relation to its +// parent. The user can transform the child by dragging to pan or pinching to +// zoom and rotate. All event callbacks for GestureDetector are supported, and +// the coordinates that are given are untransformed and in relation to the +// original position of the child. +@immutable +class GestureTransformable extends StatefulWidget { + const GestureTransformable({ + Key key, + // The child to perform the transformations on. + @required this.child, + // The desired visible size of the widget and the area that is receptive to + // gestures. If a widget that's as big as possible is desired, then wrap + // this in a LayoutBuilder and pass + // `Size(constraints.maxWidth, constraints.maxHeight)`. + @required this.size, + // The scale will be clamped to between these values. A maxScale of null has + // no bounds. minScale must be greater than zero. + this.maxScale = 2.5, + this.minScale = 0.8, + // Transforms will be limited so that the viewport can not view beyond this + // Rect. The Rect does not rotate with the rest of the scene, so it is + // always aligned with the viewport. A null boundaryRect results in no + // limits to the distance that the viewport can be transformed to see. + this.boundaryRect, + // Initial values for the transform can be provided. + this.initialTranslation, + this.initialScale, + this.initialRotation, + // Any and all of the possible transformations can be disabled. + this.disableTranslation = false, + this.disableScale = false, + this.disableRotation = false, + // If set to true, this widget will animate back to its initial transform + // and call onResetEnd when done. When utilizing reset, onResetEnd should + // also be implemented, and it should set reset to false when called. + this.reset = false, + // Access to event callbacks from GestureDetector. Called with untransformed + // coordinates in an Offset. + this.onTapDown, + this.onTapUp, + this.onTap, + this.onTapCancel, + this.onDoubleTap, + this.onLongPress, + this.onLongPressUp, + this.onVerticalDragDown, + this.onVerticalDragStart, + this.onVerticalDragUpdate, + this.onVerticalDragEnd, + this.onVerticalDragCancel, + this.onHorizontalDragDown, + this.onHorizontalDragStart, + this.onHorizontalDragUpdate, + this.onHorizontalDragEnd, + this.onHorizontalDragCancel, + this.onPanDown, + this.onPanStart, + this.onPanUpdate, + this.onPanEnd, + this.onPanCancel, + this.onResetEnd, + this.onScaleStart, + this.onScaleUpdate, + this.onScaleEnd, + }) : assert(child != null), + assert(size != null), + assert(minScale != null), + assert(minScale > 0), + assert(disableTranslation != null), + assert(disableScale != null), + assert(disableRotation != null), + assert(reset != null), + assert( + !reset || onResetEnd != null, + 'Must implement onResetEnd to use reset.', + ), + super(key: key); + + final Widget child; + final Size size; + final bool reset; + final GestureTapDownCallback onTapDown; + final GestureTapUpCallback onTapUp; + final GestureTapCallback onTap; + final GestureTapCancelCallback onTapCancel; + final GestureTapCallback onDoubleTap; + final GestureLongPressCallback onLongPress; + final GestureLongPressUpCallback onLongPressUp; + final GestureDragDownCallback onVerticalDragDown; + final GestureDragStartCallback onVerticalDragStart; + final GestureDragUpdateCallback onVerticalDragUpdate; + final GestureDragEndCallback onVerticalDragEnd; + final GestureDragCancelCallback onVerticalDragCancel; + final GestureDragDownCallback onHorizontalDragDown; + final GestureDragStartCallback onHorizontalDragStart; + final GestureDragUpdateCallback onHorizontalDragUpdate; + final GestureDragEndCallback onHorizontalDragEnd; + final GestureDragCancelCallback onHorizontalDragCancel; + final GestureDragDownCallback onPanDown; + final GestureDragStartCallback onPanStart; + final GestureDragUpdateCallback onPanUpdate; + final GestureDragEndCallback onPanEnd; + final GestureDragCancelCallback onPanCancel; + final VoidCallback onResetEnd; + final GestureScaleStartCallback onScaleStart; + final GestureScaleUpdateCallback onScaleUpdate; + final GestureScaleEndCallback onScaleEnd; + final double maxScale; + final double minScale; + final Rect boundaryRect; + final bool disableTranslation; + final bool disableScale; + final bool disableRotation; + final Offset initialTranslation; + final double initialScale; + final double initialRotation; + + @override _GestureTransformableState createState() => _GestureTransformableState(); +} + +// A single user event can only represent one of these gestures. The user can't +// do multiple at the same time, which results in more precise transformations. +enum _GestureType { + translate, + scale, + rotate, +} + +// This is public only for access from a unit test. +class _GestureTransformableState extends State with TickerProviderStateMixin { + Animation _animation; + AnimationController _controller; + Animation _animationReset; + AnimationController _controllerReset; + // The translation that will be applied to the scene (not viewport). + // A positive x offset moves the scene right, viewport left. + // A positive y offset moves the scene down, viewport up. + Offset _translateFromScene; // Point where a single translation began. + double _scaleStart; // Scale value at start of scaling gesture. + double _rotationStart = 0.0; // Rotation at start of rotation gesture. + Rect _boundaryRect; + Matrix4 _transform = Matrix4.identity(); + double _currentRotation = 0.0; + _GestureType gestureType; + + // The transformation matrix that gives the initial home position. + Matrix4 get _initialTransform { + Matrix4 matrix = Matrix4.identity(); + if (widget.initialTranslation != null) { + matrix = matrixTranslate(matrix, widget.initialTranslation); + } + if (widget.initialScale != null) { + matrix = matrixScale(matrix, widget.initialScale); + } + if (widget.initialRotation != null) { + matrix = matrixRotate(matrix, widget.initialRotation, Offset.zero); + } + return matrix; + } + + // Return the scene point at the given viewport point. + static Offset fromViewport(Offset viewportPoint, Matrix4 transform) { + // On viewportPoint, perform the inverse transformation of the scene to get + // where the point would be in the scene before the transformation. + final Matrix4 inverseMatrix = Matrix4.inverted(transform); + final Vector3 untransformed = inverseMatrix.transform3(Vector3( + viewportPoint.dx, + viewportPoint.dy, + 0, + )); + return Offset(untransformed.x, untransformed.y); + } + + // Get the offset of the current widget from the global screen coordinates. + // TODO(justinmc): Protect against calling this during first build. + static Offset getOffset(BuildContext context) { + final RenderBox renderObject = context.findRenderObject(); + return renderObject.localToGlobal(Offset.zero); + } + + @override + void initState() { + super.initState(); + _boundaryRect = widget.boundaryRect ?? Offset.zero & widget.size; + _transform = _initialTransform; + _controller = AnimationController( + vsync: this, + ); + _controllerReset = AnimationController( + vsync: this, + ); + if (widget.reset) { + _animateResetInitialize(); + } + } + + @override + void didUpdateWidget(GestureTransformable oldWidget) { + super.didUpdateWidget(oldWidget); + if (widget.reset && !oldWidget.reset && _animationReset == null) { + _animateResetInitialize(); + } else if (!widget.reset && oldWidget.reset && _animationReset != null) { + _animateResetStop(); + } + } + + @override + Widget build(BuildContext context) { + // A GestureDetector allows the detection of panning and zooming gestures on + // its child, which is the CustomPaint. + return GestureDetector( + behavior: HitTestBehavior.opaque, // Necessary when translating off screen + onTapDown: widget.onTapDown == null ? null : (TapDownDetails details) { + widget.onTapDown(TapDownDetails( + globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), + )); + }, + onTapUp: widget.onTapUp == null ? null : (TapUpDetails details) { + widget.onTapUp(TapUpDetails( + globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), + )); + }, + onTap: widget.onTap, + onTapCancel: widget.onTapCancel, + onDoubleTap: widget.onDoubleTap, + onLongPress: widget.onLongPress, + onLongPressUp: widget.onLongPressUp, + onVerticalDragDown: widget.onVerticalDragDown == null ? null : (DragDownDetails details) { + widget.onVerticalDragDown(DragDownDetails( + globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), + )); + }, + onVerticalDragStart: widget.onVerticalDragStart == null ? null : (DragStartDetails details) { + widget.onVerticalDragStart(DragStartDetails( + globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), + )); + }, + onVerticalDragUpdate: widget.onVerticalDragUpdate == null ? null : (DragUpdateDetails details) { + widget.onVerticalDragUpdate(DragUpdateDetails( + globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), + )); + }, + onVerticalDragEnd: widget.onVerticalDragEnd, + onVerticalDragCancel: widget.onVerticalDragCancel, + onHorizontalDragDown: widget.onHorizontalDragDown == null ? null : (DragDownDetails details) { + widget.onHorizontalDragDown(DragDownDetails( + globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), + )); + }, + onHorizontalDragStart: widget.onHorizontalDragStart == null ? null : (DragStartDetails details) { + widget.onHorizontalDragStart(DragStartDetails( + globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), + )); + }, + onHorizontalDragUpdate: widget.onHorizontalDragUpdate == null ? null : (DragUpdateDetails details) { + widget.onHorizontalDragUpdate(DragUpdateDetails( + globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), + )); + }, + onHorizontalDragEnd: widget.onHorizontalDragEnd, + onHorizontalDragCancel: widget.onHorizontalDragCancel, + onPanDown: widget.onPanDown == null ? null : (DragDownDetails details) { + widget.onPanDown(DragDownDetails( + globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), + )); + }, + onPanStart: widget.onPanStart == null ? null : (DragStartDetails details) { + widget.onPanStart(DragStartDetails( + globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), + )); + }, + onPanUpdate: widget.onPanUpdate == null ? null : (DragUpdateDetails details) { + widget.onPanUpdate(DragUpdateDetails( + globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), + )); + }, + onPanEnd: widget.onPanEnd, + onPanCancel: widget.onPanCancel, + onScaleEnd: _onScaleEnd, + onScaleStart: _onScaleStart, + onScaleUpdate: _onScaleUpdate, + child: ClipRect( + // The scene is panned/zoomed/rotated using this Transform widget. + child: Transform( + transform: _transform, + child: Container( + child: widget.child, + height: widget.size.height, + width: widget.size.width, + ), + ), + ), + ); + } + + // Return a new matrix representing the given matrix after applying the given + // translation. + Matrix4 matrixTranslate(Matrix4 matrix, Offset translation) { + if (widget.disableTranslation || translation == Offset.zero) { + return matrix; + } + + // Clamp translation so the viewport remains inside _boundaryRect. + final double scale = _transform.getMaxScaleOnAxis(); + final Size scaledSize = widget.size / scale; + final Rect viewportBoundaries = Rect.fromLTRB( + _boundaryRect.left, + _boundaryRect.top, + _boundaryRect.right - scaledSize.width, + _boundaryRect.bottom - scaledSize.height, + ); + // Translation is reversed (a positive translation moves the scene to the + // right, viewport to the left). + final Rect translationBoundaries = Rect.fromLTRB( + -scale * viewportBoundaries.right, + -scale * viewportBoundaries.bottom, + -scale * viewportBoundaries.left, + -scale * viewportBoundaries.top, + ); + final Matrix4 nextMatrix = matrix.clone()..translate( + translation.dx, + translation.dy, + ); + final Vector3 nextTranslationVector = nextMatrix.getTranslation(); + final Offset nextTranslation = Offset( + nextTranslationVector.x, + nextTranslationVector.y, + ); + final bool inBoundaries = translationBoundaries.contains( + Offset(nextTranslation.dx, nextTranslation.dy), + ); + if (!inBoundaries) { + // TODO(justinmc): Instead of canceling translation when it goes out of + // bounds, stop translation at boundary. + return matrix; + } + + return nextMatrix; + } + + // Return a new matrix representing the given matrix after applying the given + // scale transform. + Matrix4 matrixScale(Matrix4 matrix, double scale) { + if (widget.disableScale || scale == 1) { + return matrix; + } + assert(scale != 0); + + // Don't allow a scale that moves the viewport outside of _boundaryRect. + final Offset tl = fromViewport(const Offset(0, 0), _transform); + final Offset tr = fromViewport(Offset(widget.size.width, 0), _transform); + final Offset bl = fromViewport(Offset(0, widget.size.height), _transform); + final Offset br = fromViewport( + Offset(widget.size.width, widget.size.height), + _transform, + ); + if (!_boundaryRect.contains(tl) + || !_boundaryRect.contains(tr) + || !_boundaryRect.contains(bl) + || !_boundaryRect.contains(br)) { + return matrix; + } + + // Don't allow a scale that results in an overall scale beyond min/max + // scale. + final double currentScale = _transform.getMaxScaleOnAxis(); + final double totalScale = currentScale * scale; + final double clampedTotalScale = totalScale.clamp( + widget.minScale, + widget.maxScale, + ); + final double clampedScale = clampedTotalScale / currentScale; + return matrix..scale(clampedScale); + } + + // Return a new matrix representing the given matrix after applying the given + // rotation transform. + // Rotating the scene cannot cause the viewport to view beyond _boundaryRect. + Matrix4 matrixRotate(Matrix4 matrix, double rotation, Offset focalPoint) { + if (widget.disableRotation || rotation == 0) { + return matrix; + } + final Offset focalPointScene = fromViewport(focalPoint, matrix); + return matrix + ..translate(focalPointScene.dx, focalPointScene.dy) + ..rotateZ(-rotation) + ..translate(-focalPointScene.dx, -focalPointScene.dy); + } + + // Handle the start of a gesture of _GestureType. + void _onScaleStart(ScaleStartDetails details) { + if (widget.onScaleStart != null) { + widget.onScaleStart(details); + } + + if (_controller.isAnimating) { + _controller.stop(); + _controller.reset(); + _animation?.removeListener(_onAnimate); + _animation = null; + } + if (_controllerReset.isAnimating) { + _animateResetStop(); + } + + gestureType = null; + setState(() { + _scaleStart = _transform.getMaxScaleOnAxis(); + _translateFromScene = fromViewport(details.focalPoint, _transform); + _rotationStart = _currentRotation; + }); + } + + // Handle an update to an ongoing gesture of _GestureType. + void _onScaleUpdate(ScaleUpdateDetails details) { + double scale = _transform.getMaxScaleOnAxis(); + if (widget.onScaleUpdate != null) { + widget.onScaleUpdate(ScaleUpdateDetails( + focalPoint: fromViewport(details.focalPoint, _transform), + scale: details.scale, + rotation: details.rotation, + )); + } + final Offset focalPointScene = fromViewport( + details.focalPoint, + _transform, + ); + if (gestureType == null) { + // Decide which type of gesture this is by comparing the amount of scale + // and rotation in the gesture, if any. Scale starts at 1 and rotation + // starts at 0. Translate will have 0 scale and 0 rotation becuase it uses + // only one finger. + if ((details.scale - 1).abs() > details.rotation.abs()) { + gestureType = _GestureType.scale; + } else if (details.rotation != 0) { + gestureType = _GestureType.rotate; + } else { + gestureType = _GestureType.translate; + } + } + setState(() { + if (gestureType == _GestureType.scale && _scaleStart != null) { + // details.scale gives us the amount to change the scale as of the + // start of this gesture, so calculate the amount to scale as of the + // previous call to _onScaleUpdate. + final double desiredScale = _scaleStart * details.scale; + final double scaleChange = desiredScale / scale; + _transform = matrixScale(_transform, scaleChange); + scale = _transform.getMaxScaleOnAxis(); + + // While scaling, translate such that the user's two fingers stay on the + // same places in the scene. That means that the focal point of the + // scale should be on the same place in the scene before and after the + // scale. + final Offset focalPointSceneNext = fromViewport( + details.focalPoint, + _transform, + ); + _transform = matrixTranslate(_transform, focalPointSceneNext - focalPointScene); + } else if (gestureType == _GestureType.rotate && details.rotation != 0.0) { + final double desiredRotation = _rotationStart + details.rotation; + _transform = matrixRotate(_transform, _currentRotation - desiredRotation, details.focalPoint); + _currentRotation = desiredRotation; + } else if (_translateFromScene != null && details.scale == 1.0) { + // Translate so that the same point in the scene is underneath the + // focal point before and after the movement. + final Offset translationChange = focalPointScene - _translateFromScene; + _transform = matrixTranslate(_transform, translationChange); + _translateFromScene = fromViewport(details.focalPoint, _transform); + } + }); + } + + // Handle the end of a gesture of _GestureType. + void _onScaleEnd(ScaleEndDetails details) { + if (widget.onScaleEnd != null) { + widget.onScaleEnd(details); + } + setState(() { + _scaleStart = null; + _rotationStart = null; + _translateFromScene = null; + }); + + _animation?.removeListener(_onAnimate); + _controller.reset(); + + // If the scale ended with velocity, animate inertial movement + final double velocityTotal = details.velocity.pixelsPerSecond.dx.abs() + + details.velocity.pixelsPerSecond.dy.abs(); + if (velocityTotal == 0) { + return; + } + + final Vector3 translationVector = _transform.getTranslation(); + final Offset translation = Offset(translationVector.x, translationVector.y); + final InertialMotion inertialMotion = InertialMotion(details.velocity, translation); + _animation = Tween( + begin: translation, + end: inertialMotion.finalPosition, + ).animate(_controller); + _controller.duration = Duration(milliseconds: inertialMotion.duration.toInt()); + _animation.addListener(_onAnimate); + _controller.fling(); + } + + // Handle inertia drag animation. + void _onAnimate() { + setState(() { + // Translate _transform such that the resulting translation is + // _animation.value. + final Vector3 translationVector = _transform.getTranslation(); + final Offset translation = Offset(translationVector.x, translationVector.y); + final Offset translationScene = fromViewport(translation, _transform); + final Offset animationScene = fromViewport(_animation.value, _transform); + final Offset translationChangeScene = animationScene - translationScene; + _transform = matrixTranslate(_transform, translationChangeScene); + }); + if (!_controller.isAnimating) { + _animation?.removeListener(_onAnimate); + _animation = null; + _controller.reset(); + } + } + + // Handle reset to home transform animation. + void _onAnimateReset() { + setState(() { + _transform = _animationReset.value; + }); + if (!_controllerReset.isAnimating) { + _animationReset?.removeListener(_onAnimateReset); + _animationReset = null; + _controllerReset.reset(); + widget.onResetEnd(); + } + } + + // Initialize the reset to home transform animation. + void _animateResetInitialize() { + _controllerReset.reset(); + _animationReset = Matrix4Tween( + begin: _transform, + end: _initialTransform, + ).animate(_controllerReset); + _controllerReset.duration = const Duration(milliseconds: 400); + _animationReset.addListener(_onAnimateReset); + _controllerReset.forward(); + } + + // Stop a running reset to home transform animation. + void _animateResetStop() { + _controllerReset.stop(); + _animationReset?.removeListener(_onAnimateReset); + _animationReset = null; + _controllerReset.reset(); + widget.onResetEnd(); + } + + @override + void dispose() { + _controller.dispose(); + _controllerReset.dispose(); + super.dispose(); + } +} diff --git a/examples/flutter_gallery/lib/demo/transformations/transformations_demo_inertial_motion.dart b/examples/flutter_gallery/lib/demo/transformations/transformations_demo_inertial_motion.dart new file mode 100644 index 0000000000..8e45c00b25 --- /dev/null +++ b/examples/flutter_gallery/lib/demo/transformations/transformations_demo_inertial_motion.dart @@ -0,0 +1,68 @@ +import 'dart:math'; +import 'package:flutter/material.dart'; +import 'package:vector_math/vector_math.dart' show Vector2; + +// Provides calculations for an object moving with inertia and friction using +// the equation of motion from physics. +// https://en.wikipedia.org/wiki/Equations_of_motion#Constant_translational_acceleration_in_a_straight_line +// TODO(justinmc): Can this be replaced with friction_simulation.dart? +@immutable +class InertialMotion { + const InertialMotion(this._initialVelocity, this._initialPosition); + + static const double _kFrictionalAcceleration = 0.01; // How quickly to stop + final Velocity _initialVelocity; + final Offset _initialPosition; + + // The position when the motion stops. + Offset get finalPosition { + return _getPositionAt(Duration(milliseconds: duration.toInt())); + } + + // The total time that the animation takes start to stop in milliseconds. + double get duration { + return (_initialVelocity.pixelsPerSecond.dx / 1000 / _acceleration.x).abs(); + } + + // The acceleration opposing the initial velocity in x and y components. + Vector2 get _acceleration { + // TODO(justinmc): Find actual velocity instead of summing? + final double velocityTotal = _initialVelocity.pixelsPerSecond.dx.abs() + + _initialVelocity.pixelsPerSecond.dy.abs(); + final double vRatioX = _initialVelocity.pixelsPerSecond.dx / velocityTotal; + final double vRatioY = _initialVelocity.pixelsPerSecond.dy / velocityTotal; + return Vector2( + _kFrictionalAcceleration * vRatioX, + _kFrictionalAcceleration * vRatioY, + ); + } + + // The position at a given time. + Offset _getPositionAt(Duration time) { + final double xf = _getPosition( + r0: _initialPosition.dx, + v0: _initialVelocity.pixelsPerSecond.dx / 1000, + t: time.inMilliseconds, + a: _acceleration.x, + ); + final double yf = _getPosition( + r0: _initialPosition.dy, + v0: _initialVelocity.pixelsPerSecond.dy / 1000, + t: time.inMilliseconds, + a: _acceleration.y, + ); + return Offset(xf, yf); + } + + // Solve the equation of motion to find the position at a given point in time + // in one dimension. + double _getPosition({double r0, double v0, int t, double a}) { + // Stop movement when it would otherwise reverse direction. + final double stopTime = (v0 / a).abs(); + if (t > stopTime) { + t = stopTime.toInt(); + } + + return r0 + v0 * t + 0.5 * a * pow(t, 2); + } +} diff --git a/examples/flutter_gallery/lib/gallery/about.dart b/examples/flutter_gallery/lib/gallery/about.dart index 2e8b451715..0658fdaa47 100644 --- a/examples/flutter_gallery/lib/gallery/about.dart +++ b/examples/flutter_gallery/lib/gallery/about.dart @@ -59,7 +59,7 @@ void showGalleryAboutDialog(BuildContext context) { ), _LinkTextSpan( style: linkStyle, - url: 'https://flutter.io', + url: 'https://flutter.dev', ), TextSpan( style: aboutTextStyle, diff --git a/examples/flutter_gallery/lib/gallery/demo.dart b/examples/flutter_gallery/lib/gallery/demo.dart index 48d4fbfe87..e8bec39e79 100644 --- a/examples/flutter_gallery/lib/gallery/demo.dart +++ b/examples/flutter_gallery/lib/gallery/demo.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:async'; + import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -59,10 +61,28 @@ class TabbedComponentDemoScaffold extends StatelessWidget { } } - void _showApiDocumentation(BuildContext context) { + Future _showApiDocumentation(BuildContext context) async { final String url = demos[DefaultTabController.of(context).index].documentationUrl; - if (url != null) { - launch(url, forceWebView: true); + if (url == null) + return; + + if (await canLaunch(url)) { + await launch(url); + } else { + showDialog( + context: context, + builder: (BuildContext context) { + return SimpleDialog( + title: const Text('Couldn\'t display URL:'), + children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + child: Text(url), + ), + ], + ); + }, + ); } } diff --git a/examples/flutter_gallery/lib/gallery/demos.dart b/examples/flutter_gallery/lib/gallery/demos.dart index fbbb88e135..60aef46eb8 100644 --- a/examples/flutter_gallery/lib/gallery/demos.dart +++ b/examples/flutter_gallery/lib/gallery/demos.dart @@ -123,6 +123,14 @@ List _buildGalleryDemos() { routeName: AnimationDemo.routeName, buildRoute: (BuildContext context) => const AnimationDemo(), ), + GalleryDemo( + title: '2D Transformations', + subtitle: 'Pan, Zoom, Rotate', + icon: GalleryIcons.grid_on, + category: _kDemos, + routeName: TransformationsDemo.routeName, + buildRoute: (BuildContext context) => const TransformationsDemo(), + ), // Style GalleryDemo( diff --git a/examples/flutter_gallery/meta/flutter_gallery.cmx b/examples/flutter_gallery/meta/flutter_gallery.cmx index fb9733104e..e3e3be8758 100644 --- a/examples/flutter_gallery/meta/flutter_gallery.cmx +++ b/examples/flutter_gallery/meta/flutter_gallery.cmx @@ -16,8 +16,7 @@ "fuchsia.testing.runner.TestRunner", "fuchsia.ui.input.ImeService", "fuchsia.ui.policy.Presenter", - "fuchsia.ui.scenic.Scenic", - "fuchsia.ui.viewsv1.ViewManager" + "fuchsia.ui.scenic.Scenic" ] } } diff --git a/examples/flutter_gallery/pubspec.yaml b/examples/flutter_gallery/pubspec.yaml index 3ae5b83a48..11224babda 100644 --- a/examples/flutter_gallery/pubspec.yaml +++ b/examples/flutter_gallery/pubspec.yaml @@ -9,12 +9,12 @@ dependencies: sdk: flutter collection: 1.14.11 device_info: 0.4.0+1 - intl: 0.15.7 + intl: 0.15.8 connectivity: 0.4.2 string_scanner: 1.0.4 - url_launcher: 5.0.1 + url_launcher: 5.0.2 cupertino_icons: 0.1.2 - video_player: 0.10.0+2 + video_player: 0.10.0+4 scoped_model: 1.0.1 shrine_images: 1.1.1 @@ -36,28 +36,25 @@ dev_dependencies: sdk: flutter flutter_goldens: sdk: flutter - test: 1.5.3 + test: 1.6.1 - analyzer: 0.35.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + analyzer: 0.35.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" args: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" file: 5.0.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - front_end: 0.1.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + front_end: 0.1.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - html: 0.13.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http: 0.12.0+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 2.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 0.3.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - json_rpc_2: 2.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - kernel: 0.3.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + json_rpc_2: 2.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + kernel: 0.3.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 0.9.6+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" multi_server_socket: 1.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" node_preamble: 1.4.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -65,25 +62,23 @@ dev_dependencies: package_resolver: 1.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" platform: 2.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - plugin: 0.2.0+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" process: 3.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - quiver: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + quiver: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf: 0.7.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf_web_socket: 0.2.2+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf_web_socket: 0.2.2+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_map_stack_trace: 1.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_maps: 0.10.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_core: 0.2.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - utf: 0.9.0+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - vm_service_client: 0.2.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_core: 0.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + vm_service_client: 0.2.6+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 0.9.7+10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - web_socket_channel: 1.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + web_socket_channel: 1.0.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" flutter: @@ -256,4 +251,4 @@ flutter: - asset: packages/flutter_gallery_assets/fonts/merriweather/Merriweather-Regular.ttf - asset: packages/flutter_gallery_assets/fonts/merriweather/Merriweather-Light.ttf -# PUBSPEC CHECKSUM: d08c +# PUBSPEC CHECKSUM: 3d43 diff --git a/examples/flutter_gallery/test/accessibility_test.dart b/examples/flutter_gallery/test/accessibility_test.dart index ad9ef2e5ca..9fef8bcb90 100644 --- a/examples/flutter_gallery/test/accessibility_test.dart +++ b/examples/flutter_gallery/test/accessibility_test.dart @@ -501,7 +501,7 @@ void main() { await tester.pumpWidget(MaterialApp(theme: theme, home: BottomAppBarDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); - }); + }, skip: theme == ThemeData.light()); testWidgets('bottom_navigation_demo $themeName', (WidgetTester tester) async { tester.binding.addTime(const Duration(seconds: 3)); diff --git a/examples/flutter_view/README.md b/examples/flutter_view/README.md index 30cf0dca99..6c84a2a2d4 100644 --- a/examples/flutter_view/README.md +++ b/examples/flutter_view/README.md @@ -6,7 +6,7 @@ Android, the Android and Flutter components are built with Android Studio or gradle. You can read more about -[accessing platform and third-party services in Flutter](https://flutter.io/platform-services/). +[accessing platform and third-party services in Flutter](https://flutter.dev/platform-services/). ## iOS diff --git a/examples/hello_world/pubspec.yaml b/examples/hello_world/pubspec.yaml index 62ab6b8262..38c42f6c6a 100644 --- a/examples/hello_world/pubspec.yaml +++ b/examples/hello_world/pubspec.yaml @@ -17,18 +17,18 @@ dev_dependencies: flutter_test: sdk: flutter - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - quiver: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + quiver: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" -# PUBSPEC CHECKSUM: 3cc1 +# PUBSPEC CHECKSUM: 1656 diff --git a/examples/layers/pubspec.yaml b/examples/layers/pubspec.yaml index 6acdae5421..9ea64284b4 100644 --- a/examples/layers/pubspec.yaml +++ b/examples/layers/pubspec.yaml @@ -17,23 +17,23 @@ dev_dependencies: flutter_test: sdk: flutter - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - quiver: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + quiver: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" flutter: assets: - services/data.json uses-material-design: true -# PUBSPEC CHECKSUM: 3cc1 +# PUBSPEC CHECKSUM: 1656 diff --git a/examples/layers/widgets/spinning_mixed.dart b/examples/layers/widgets/spinning_mixed.dart index b9f4d1cb3a..9795d642fd 100644 --- a/examples/layers/widgets/spinning_mixed.dart +++ b/examples/layers/widgets/spinning_mixed.dart @@ -53,7 +53,7 @@ void attachWidgetTreeToRenderTree(RenderProxyBox container) { RaisedButton( child: Row( children: [ - Image.network('https://flutter.io/images/favicon.png'), + Image.network('https://flutter.dev/images/favicon.png'), const Text('PRESS ME'), ], ), diff --git a/examples/platform_channel/README.md b/examples/platform_channel/README.md index 0d3906796b..87053b00c7 100644 --- a/examples/platform_channel/README.md +++ b/examples/platform_channel/README.md @@ -3,7 +3,7 @@ This project demonstrates how to connect a Flutter app to platform specific services. You can read more about -[accessing platform and third-party services in Flutter](https://flutter.io/platform-channels/). +[accessing platform and third-party services in Flutter](https://flutter.dev/platform-channels/). ## iOS You can use the commands `flutter build` and `flutter run` from the app's root diff --git a/examples/platform_channel/pubspec.yaml b/examples/platform_channel/pubspec.yaml index d08ee9f37b..0cbd691f4f 100644 --- a/examples/platform_channel/pubspec.yaml +++ b/examples/platform_channel/pubspec.yaml @@ -18,30 +18,27 @@ dev_dependencies: sdk: flutter flutter_driver: sdk: flutter - test: 1.5.3 + test: 1.6.1 - analyzer: 0.35.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + analyzer: 0.35.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" args: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" file: 5.0.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - front_end: 0.1.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + front_end: 0.1.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - html: 0.13.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http: 0.12.0+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 2.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - intl: 0.15.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl: 0.15.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 0.3.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - json_rpc_2: 2.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - kernel: 0.3.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + json_rpc_2: 2.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + kernel: 0.3.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 0.9.6+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" multi_server_socket: 1.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" node_preamble: 1.4.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -49,30 +46,28 @@ dev_dependencies: package_resolver: 1.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - plugin: 0.2.0+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - quiver: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + quiver: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf: 0.7.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf_web_socket: 0.2.2+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf_web_socket: 0.2.2+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_map_stack_trace: 1.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_maps: 0.10.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_core: 0.2.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - utf: 0.9.0+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - vm_service_client: 0.2.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_core: 0.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + vm_service_client: 0.2.6+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 0.9.7+10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - web_socket_channel: 1.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + web_socket_channel: 1.0.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" flutter: uses-material-design: true -# PUBSPEC CHECKSUM: 6687 +# PUBSPEC CHECKSUM: ca3b diff --git a/examples/platform_channel_swift/README.md b/examples/platform_channel_swift/README.md index 561a1abba3..3c541387e3 100644 --- a/examples/platform_channel_swift/README.md +++ b/examples/platform_channel_swift/README.md @@ -5,7 +5,7 @@ specific services on iOS using Swift. The equivalent version of this project in Objective C is found in examples/platform_channel. You can read more about -[accessing platform and third-party services in Flutter](https://flutter.io/platform-channels/). +[accessing platform and third-party services in Flutter](https://flutter.dev/platform-channels/). ## iOS You can use the commands `flutter build` and `flutter run` from the app's root diff --git a/examples/platform_channel_swift/pubspec.yaml b/examples/platform_channel_swift/pubspec.yaml index 71fe4d83ec..aa3ce248f9 100644 --- a/examples/platform_channel_swift/pubspec.yaml +++ b/examples/platform_channel_swift/pubspec.yaml @@ -19,29 +19,29 @@ dev_dependencies: flutter_driver: sdk: flutter - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" file: 5.0.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - intl: 0.15.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - json_rpc_2: 2.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl: 0.15.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + json_rpc_2: 2.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - quiver: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + quiver: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - vm_service_client: 0.2.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - web_socket_channel: 1.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + vm_service_client: 0.2.6+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + web_socket_channel: 1.0.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" flutter: uses-material-design: true -# PUBSPEC CHECKSUM: 1824 +# PUBSPEC CHECKSUM: 4a68 diff --git a/examples/stocks/README.md b/examples/stocks/README.md index 6510167fc2..6ff46abd93 100644 --- a/examples/stocks/README.md +++ b/examples/stocks/README.md @@ -10,7 +10,7 @@ and install it onto your device. ### Prerequisites If you are new to Flutter, please first follow -the [Flutter Setup](https://flutter.io/setup/) guide. +the [Flutter Setup](https://flutter.dev/setup/) guide. ### Building and installing the stocks demo app @@ -26,7 +26,7 @@ This app has been internationalized (just enough to show how it's done). It's an example of how one can do so with the [Dart intl package](https://pub.dartlang.org/packages/intl). -The [Flutter Internationalization Tutorial](https://flutter.io/tutorials/internationalization/) +The [Flutter Internationalization Tutorial](https://flutter.dev/tutorials/internationalization/) covers Flutter app internationalization in general. See [regenerate.md](lib/i18n/regenerate.md) for an explanation diff --git a/examples/stocks/pubspec.yaml b/examples/stocks/pubspec.yaml index 7bca212d4c..e8ed35815c 100644 --- a/examples/stocks/pubspec.yaml +++ b/examples/stocks/pubspec.yaml @@ -9,37 +9,32 @@ dependencies: sdk: flutter flutter_localizations: sdk: flutter - intl: 0.15.7 + intl: 0.15.8 intl_translation: 0.17.3 http: 0.12.0+1 isolate: 2.0.2 - analyzer: 0.35.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + analyzer: 0.35.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" args: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - dart_style: 1.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - front_end: 0.1.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + dart_style: 1.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + front_end: 0.1.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - html: 0.13.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - kernel: 0.3.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + kernel: 0.3.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" package_config: 1.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" petitparser: 2.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - plugin: 0.2.0+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - utf: 0.9.0+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vector_math: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 0.9.7+10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 2.1.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -52,17 +47,17 @@ dev_dependencies: boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" file: 5.0.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - json_rpc_2: 2.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + json_rpc_2: 2.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - quiver: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + quiver: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - vm_service_client: 0.2.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - web_socket_channel: 1.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + vm_service_client: 0.2.6+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + web_socket_channel: 1.0.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" flutter: uses-material-design: true -# PUBSPEC CHECKSUM: 688d +# PUBSPEC CHECKSUM: 4240 diff --git a/flutter_console.bat b/flutter_console.bat index dd790a7355..9271d293ba 100644 --- a/flutter_console.bat +++ b/flutter_console.bat @@ -25,10 +25,10 @@ echo Run "flutter create " to create a new Flutter project. echo. echo Run "flutter help" to see all available commands. echo. -echo Want to use an IDE to interact with Flutter? https://flutter.io/ide-setup/ +echo Want to use an IDE to interact with Flutter? https://flutter.dev/ide-setup/ echo. echo Want to run the "flutter" command from any Command Prompt or PowerShell window? -echo Add Flutter to your PATH: https://flutter.io/setup-windows/#update-your-path +echo Add Flutter to your PATH: https://flutter.dev/setup-windows/#update-your-path echo. echo ================================================================================ diff --git a/packages/flutter/README.md b/packages/flutter/README.md index 349f49acea..730106e3f5 100644 --- a/packages/flutter/README.md +++ b/packages/flutter/README.md @@ -5,5 +5,5 @@ Flutter is a new way to build high-performance, cross-platform mobile apps. Flutter is optimized for today's — and tomorrow's — mobile devices. We are focused on low-latency input and high frame rates on Android and iOS. -See the [getting started guide](https://flutter.io/getting-started/) for +See the [getting started guide](https://flutter.dev/getting-started/) for information about using Flutter. diff --git a/packages/flutter/lib/animation.dart b/packages/flutter/lib/animation.dart index d7b4fcc46f..1f4eaa96f8 100644 --- a/packages/flutter/lib/animation.dart +++ b/packages/flutter/lib/animation.dart @@ -6,7 +6,7 @@ /// /// To use, import `package:flutter/animation.dart`. /// -/// See [flutter.io/animations](https://flutter.io/animations/) for an overview. +/// See [flutter.dev/animations](https://flutter.dev/animations/) for an overview. /// /// This library depends only on core Dart libraries and the `physics.dart` library. library animation; diff --git a/packages/flutter/lib/cupertino.dart b/packages/flutter/lib/cupertino.dart index 0d01e2701b..b16282f7af 100644 --- a/packages/flutter/lib/cupertino.dart +++ b/packages/flutter/lib/cupertino.dart @@ -5,6 +5,8 @@ /// Flutter widgets implementing the current iOS design language. /// /// To use, import `package:flutter/cupertino.dart`. +/// +/// {@youtube 560 315 https://www.youtube.com/watch?v=3PdUaidHc-E} library cupertino; export 'src/cupertino/action_sheet.dart'; diff --git a/packages/flutter/lib/material.dart b/packages/flutter/lib/material.dart index 86c250e525..4bd92d0271 100644 --- a/packages/flutter/lib/material.dart +++ b/packages/flutter/lib/material.dart @@ -6,9 +6,11 @@ /// /// To use, import `package:flutter/material.dart`. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=DL0Ix1lnC4w} +/// /// See also: /// -/// * [flutter.io/widgets](https://flutter.io/widgets/) +/// * [flutter.dev/widgets](https://flutter.dev/widgets/) /// for a catalog of commonly-used Flutter widgets. /// * [material.io/design](https://material.io/design/) /// for an introduction to Material Design. diff --git a/packages/flutter/lib/services.dart b/packages/flutter/lib/services.dart index 3a916fb2ad..4da9445952 100644 --- a/packages/flutter/lib/services.dart +++ b/packages/flutter/lib/services.dart @@ -24,6 +24,7 @@ export 'src/services/platform_views.dart'; export 'src/services/raw_keyboard.dart'; export 'src/services/raw_keyboard_android.dart'; export 'src/services/raw_keyboard_fuchsia.dart'; +export 'src/services/raw_keyboard_linux.dart'; export 'src/services/raw_keyboard_macos.dart'; export 'src/services/system_channels.dart'; export 'src/services/system_chrome.dart'; diff --git a/packages/flutter/lib/src/animation/animation_controller.dart b/packages/flutter/lib/src/animation/animation_controller.dart index a3b7d068fa..9c9cca72ad 100644 --- a/packages/flutter/lib/src/animation/animation_controller.dart +++ b/packages/flutter/lib/src/animation/animation_controller.dart @@ -44,7 +44,7 @@ const Tolerance _kFlingTolerance = Tolerance( /// Configures how an [AnimationController] behaves when animations are disabled. /// /// When [AccessibilityFeatures.disableAnimations] is true, the device is asking -/// flutter to reduce or disable animations as much as possible. To honor this, +/// Flutter to reduce or disable animations as much as possible. To honor this, /// we reduce the duration and the corresponding number of frames for animations. /// This enum is used to allow certain [AnimationController]s to opt out of this /// behavior. @@ -209,7 +209,7 @@ class AnimationController extends Animation with AnimationEagerListenerMixin, AnimationLocalListenersMixin, AnimationLocalStatusListenersMixin { /// Creates an animation controller. /// - /// * [value] is the initial value of the animation. If defaults to the lower + /// * `value` is the initial value of the animation. If defaults to the lower /// bound. /// /// * [duration] is the length of time this animation should last. @@ -524,11 +524,10 @@ class AnimationController extends Animation return _animateToInternal(target, duration: duration, curve: curve); } - TickerFuture _animateToInternal(double target, { Duration duration, Curve curve = Curves.linear, AnimationBehavior animationBehavior }) { - final AnimationBehavior behavior = animationBehavior ?? this.animationBehavior; + TickerFuture _animateToInternal(double target, { Duration duration, Curve curve = Curves.linear }) { double scale = 1.0; if (SemanticsBinding.instance.disableAnimations) { - switch (behavior) { + switch (animationBehavior) { case AnimationBehavior.normal: // Since the framework cannot handle zero duration animations, we run it at 5% of the normal // duration to limit most animations to a single frame. diff --git a/packages/flutter/lib/src/animation/curves.dart b/packages/flutter/lib/src/animation/curves.dart index 0ae42251f3..33e8055cbd 100644 --- a/packages/flutter/lib/src/animation/curves.dart +++ b/packages/flutter/lib/src/animation/curves.dart @@ -111,8 +111,8 @@ class SawTooth extends Curve { } } -/// A curve that is 0.0 until [begin], then curved (according to [curve] from -/// 0.0 to 1.0 at [end], then 1.0. +/// A curve that is 0.0 until [begin], then curved (according to [curve]) from +/// 0.0 at [begin] to 1.0 at [end], then remains 1.0 past [end]. /// /// An [Interval] can be used to delay an animation. For example, a six second /// animation that uses an [Interval] with its [begin] set to 0.5 and its [end] diff --git a/packages/flutter/lib/src/animation/tween_sequence.dart b/packages/flutter/lib/src/animation/tween_sequence.dart index dd78f8efb6..2caa425712 100644 --- a/packages/flutter/lib/src/animation/tween_sequence.dart +++ b/packages/flutter/lib/src/animation/tween_sequence.dart @@ -7,17 +7,16 @@ import 'package:flutter/foundation.dart'; import 'animation.dart'; import 'tween.dart'; -/// Enables creating an [Animation] whose value is defined by a -/// sequence of [Tween]s. +/// Enables creating an [Animation] whose value is defined by a sequence of +/// [Tween]s. /// -/// Each [TweenSequenceItem] has a weight that defines its percentage -/// of the animation's duration. Each tween defines the animation's value -/// during the interval indicated by its weight. +/// Each [TweenSequenceItem] has a weight that defines its percentage of the +/// animation's duration. Each tween defines the animation's value during the +/// interval indicated by its weight. /// -/// For example, to define an animation that uses an easing curve to -/// interpolate between 5.0 and 10.0 during the first 40% of the -/// animation, remain at 10.0 for the next 20%, and then return to -/// 10.0 for the final 40%: +/// For example, to define an animation that uses an easing curve to interpolate +/// between 5.0 and 10.0 during the first 40% of the animation, remain at 10.0 +/// for the next 20%, and then return to 10.0 for the final 40%: /// /// ```dart /// final Animation animation = TweenSequence( @@ -42,12 +41,11 @@ import 'tween.dart'; class TweenSequence extends Animatable { /// Construct a TweenSequence. /// - /// The [items] parameter must be a list of one or more - /// [TweenSequenceItem]s. + /// The [items] parameter must be a list of one or more [TweenSequenceItem]s. /// - /// There's a small cost associated with building a `TweenSequence` so - /// it's best to reuse one, rather than rebuilding it on every frame, - /// when that's possible. + /// There's a small cost associated with building a `TweenSequence` so it's + /// best to reuse one, rather than rebuilding it on every frame, when that's + /// possible. TweenSequence(List> items) : assert(items != null), assert(items.isNotEmpty) { @@ -124,8 +122,8 @@ class TweenSequenceItem { /// An arbitrary value that indicates the relative percentage of a /// [TweenSequence] animation's duration when [tween] will be used. /// - /// The percentage for an individual item is the item's weight divided - /// by the sum of all of the items' weights. + /// The percentage for an individual item is the item's weight divided by the + /// sum of all of the items' weights. final double weight; } diff --git a/packages/flutter/lib/src/cupertino/app.dart b/packages/flutter/lib/src/cupertino/app.dart index 47656d1229..fa4968350a 100644 --- a/packages/flutter/lib/src/cupertino/app.dart +++ b/packages/flutter/lib/src/cupertino/app.dart @@ -175,7 +175,7 @@ class CupertinoApp extends StatefulWidget { /// /// See also: /// - /// * + /// * final bool showPerformanceOverlay; /// Turns on checkerboarding of raster cache images. diff --git a/packages/flutter/lib/src/cupertino/date_picker.dart b/packages/flutter/lib/src/cupertino/date_picker.dart index b1ba3110f4..0bd31f4f0e 100644 --- a/packages/flutter/lib/src/cupertino/date_picker.dart +++ b/packages/flutter/lib/src/cupertino/date_picker.dart @@ -540,7 +540,7 @@ class _CupertinoDatePickerDateTimeState extends State { Widget _buildMinutePicker(double offAxisFraction, TransitionBuilder itemPositioningBuilder) { return CupertinoPicker( - scrollController: FixedExtentScrollController(initialItem: selectedMinute), + scrollController: FixedExtentScrollController(initialItem: selectedMinute ~/ widget.minuteInterval), offAxisFraction: offAxisFraction, itemExtent: _kItemExtent, useMagnifier: _kUseMagnifier, diff --git a/packages/flutter/lib/src/cupertino/dialog.dart b/packages/flutter/lib/src/cupertino/dialog.dart index eea7ce9aa8..0adee6f3e4 100644 --- a/packages/flutter/lib/src/cupertino/dialog.dart +++ b/packages/flutter/lib/src/cupertino/dialog.dart @@ -125,6 +125,7 @@ bool _isInAccessibilityMode(BuildContext context) { /// * [CupertinoPopupSurface], which is a generic iOS-style popup surface that /// holds arbitrary content to create custom popups. /// * [CupertinoDialogAction], which is an iOS-style dialog button. +/// * [AlertDialog], a Material Design alert dialog. /// * class CupertinoAlertDialog extends StatelessWidget { /// Creates an iOS-style alert dialog. diff --git a/packages/flutter/lib/src/cupertino/nav_bar.dart b/packages/flutter/lib/src/cupertino/nav_bar.dart index e6d84441bd..d7394ab251 100644 --- a/packages/flutter/lib/src/cupertino/nav_bar.dart +++ b/packages/flutter/lib/src/cupertino/nav_bar.dart @@ -1231,7 +1231,7 @@ class CupertinoNavigationBarBackButton extends StatelessWidget { Widget build(BuildContext context) { final ModalRoute currentRoute = ModalRoute.of(context); assert( - currentRoute.canPop, + currentRoute?.canPop == true, 'CupertinoNavigationBarBackButton should only be used in routes that can be popped', ); diff --git a/packages/flutter/lib/src/cupertino/page_scaffold.dart b/packages/flutter/lib/src/cupertino/page_scaffold.dart index d9f0b07412..a45cb22f99 100644 --- a/packages/flutter/lib/src/cupertino/page_scaffold.dart +++ b/packages/flutter/lib/src/cupertino/page_scaffold.dart @@ -16,7 +16,7 @@ import 'theme.dart'; /// * [CupertinoTabScaffold], a similar widget for tabbed applications. /// * [CupertinoPageRoute], a modal page route that typically hosts a /// [CupertinoPageScaffold] with support for iOS-style page transitions. -class CupertinoPageScaffold extends StatelessWidget { +class CupertinoPageScaffold extends StatefulWidget { /// Creates a layout for pages with a navigation bar at the top. const CupertinoPageScaffold({ Key key, @@ -34,7 +34,8 @@ class CupertinoPageScaffold extends StatelessWidget { /// If translucent, the main content may slide behind it. /// Otherwise, the main content's top margin will be offset by its height. /// - /// The scaffold assumes the navigation bar will consume the [MediaQuery] top padding. + /// The scaffold assumes the navigation bar will account for the [MediaQuery] top padding, + /// also consume it if the navigation bar is opaque. // TODO(xster): document its page transition animation when ready final ObstructingPreferredSizeWidget navigationBar; @@ -60,44 +61,66 @@ class CupertinoPageScaffold extends StatelessWidget { /// Defaults to true and cannot be null. final bool resizeToAvoidBottomInset; + @override + _CupertinoPageScaffoldState createState() => _CupertinoPageScaffoldState(); +} + +class _CupertinoPageScaffoldState extends State { + final ScrollController _primaryScrollController = ScrollController(); + + void _handleStatusBarTap() { + // Only act on the scroll controller if it has any attached scroll positions. + if (_primaryScrollController.hasClients) { + _primaryScrollController.animateTo( + 0.0, + // Eyeballed from iOS. + duration: const Duration(milliseconds: 500), + curve: Curves.linearToEaseOut, + ); + } + } + @override Widget build(BuildContext context) { final List stacked = []; - Widget paddedContent = child; - if (navigationBar != null) { - final MediaQueryData existingMediaQuery = MediaQuery.of(context); + Widget paddedContent = widget.child; + final MediaQueryData existingMediaQuery = MediaQuery.of(context); + if (widget.navigationBar != null) { // TODO(xster): Use real size after partial layout instead of preferred size. // https://github.com/flutter/flutter/issues/12912 final double topPadding = - navigationBar.preferredSize.height + existingMediaQuery.padding.top; + widget.navigationBar.preferredSize.height + existingMediaQuery.padding.top; // Propagate bottom padding and include viewInsets if appropriate - final double bottomPadding = resizeToAvoidBottomInset + final double bottomPadding = widget.resizeToAvoidBottomInset ? existingMediaQuery.viewInsets.bottom : 0.0; - final EdgeInsets newViewInsets = resizeToAvoidBottomInset + final EdgeInsets newViewInsets = widget.resizeToAvoidBottomInset // The insets are consumed by the scaffolds and no longer exposed to // the descendant subtree. ? existingMediaQuery.viewInsets.copyWith(bottom: 0.0) : existingMediaQuery.viewInsets; final bool fullObstruction = - navigationBar.fullObstruction ?? CupertinoTheme.of(context).barBackgroundColor.alpha == 0xFF; + widget.navigationBar.fullObstruction ?? CupertinoTheme.of(context).barBackgroundColor.alpha == 0xFF; // If navigation bar is opaquely obstructing, directly shift the main content // down. If translucent, let main content draw behind navigation bar but hint the // obstructed area. if (fullObstruction) { paddedContent = MediaQuery( - data: existingMediaQuery.copyWith( + data: existingMediaQuery + // If the navigation bar is opaque, the top media query padding is fully consumed by the navigation bar. + .removePadding(removeTop: true) + .copyWith( viewInsets: newViewInsets, ), child: Padding( padding: EdgeInsets.only(top: topPadding, bottom: bottomPadding), - child: child, + child: paddedContent, ), ); } else { @@ -110,27 +133,44 @@ class CupertinoPageScaffold extends StatelessWidget { ), child: Padding( padding: EdgeInsets.only(bottom: bottomPadding), - child: child, + child: paddedContent, ), ); } } // The main content being at the bottom is added to the stack first. - stacked.add(paddedContent); + stacked.add(PrimaryScrollController( + controller: _primaryScrollController, + child: paddedContent, + )); - if (navigationBar != null) { + if (widget.navigationBar != null) { stacked.add(Positioned( top: 0.0, left: 0.0, right: 0.0, - child: navigationBar, + child: widget.navigationBar, )); } + // Add a touch handler the size of the status bar on top of all contents + // to handle scroll to top by status bar taps. + stacked.add(Positioned( + top: 0.0, + left: 0.0, + right: 0.0, + height: existingMediaQuery.padding.top, + child: GestureDetector( + excludeFromSemantics: true, + onTap: _handleStatusBarTap, + ), + ), + ); + return DecoratedBox( decoration: BoxDecoration( - color: backgroundColor ?? CupertinoTheme.of(context).scaffoldBackgroundColor, + color: widget.backgroundColor ?? CupertinoTheme.of(context).scaffoldBackgroundColor, ), child: Stack( children: stacked, diff --git a/packages/flutter/lib/src/cupertino/route.dart b/packages/flutter/lib/src/cupertino/route.dart index eba6a78794..ad4993ac62 100644 --- a/packages/flutter/lib/src/cupertino/route.dart +++ b/packages/flutter/lib/src/cupertino/route.dart @@ -180,22 +180,19 @@ class CupertinoPageRoute extends PageRoute { return nextRoute is CupertinoPageRoute && !nextRoute.fullscreenDialog; } - @override - void dispose() { - _popGestureInProgress.remove(this); - super.dispose(); - } - - /// True if a Cupertino pop gesture is currently underway for [route]. + /// True if an iOS-style back swipe pop gesture is currently underway for [route]. + /// + /// This just check the route's [NavigatorState.userGestureInProgress]. /// /// See also: /// /// * [popGestureEnabled], which returns true if a user-triggered pop gesture /// would be allowed. - static bool isPopGestureInProgress(PageRoute route) => _popGestureInProgress.contains(route); - static final Set> _popGestureInProgress = >{}; + static bool isPopGestureInProgress(PageRoute route) { + return route.navigator.userGestureInProgress; + } - /// True if a Cupertino pop gesture is currently underway for this route. + /// True if an iOS-style back swipe pop gesture is currently underway for this route. /// /// See also: /// @@ -233,10 +230,15 @@ class CupertinoPageRoute extends PageRoute { if (route.fullscreenDialog) return false; // If we're in an animation already, we cannot be manually swiped. - if (route.controller.status != AnimationStatus.completed) + if (route.animation.status != AnimationStatus.completed) + return false; + // If we're being popped into, we also cannot be swiped until the pop above + // it completes. This translates to our secondary animation being + // dismissed. + if (route.secondaryAnimation.status != AnimationStatus.dismissed) return false; // If we're in a gesture already, we cannot start another. - if (_popGestureInProgress.contains(route)) + if (isPopGestureInProgress(route)) return false; // Looks like a back gesture would be welcome! @@ -266,9 +268,7 @@ class CupertinoPageRoute extends PageRoute { // gesture is detected. The returned controller handles all of the subsequent // drag events. static _CupertinoBackGestureController _startPopGesture(PageRoute route) { - assert(!_popGestureInProgress.contains(route)); assert(_isPopGestureEnabled(route)); - _popGestureInProgress.add(route); _CupertinoBackGestureController backController; backController = _CupertinoBackGestureController( @@ -277,7 +277,6 @@ class CupertinoPageRoute extends PageRoute { onEnded: () { backController?.dispose(); backController = null; - _popGestureInProgress.remove(route); }, ); return backController; @@ -313,9 +312,12 @@ class CupertinoPageRoute extends PageRoute { return CupertinoPageTransition( primaryRouteAnimation: animation, secondaryRouteAnimation: secondaryAnimation, + // Check if the route has an animation that's currently participating + // in a back swipe gesture. + // // In the middle of a back gesture drag, let the transition be linear to // match finger motions. - linearTransition: _popGestureInProgress.contains(route), + linearTransition: isPopGestureInProgress(route), child: _CupertinoBackGestureDetector( enabledCallback: () => _isPopGestureEnabled(route), onStartPopGesture: () => _startPopGesture(route), @@ -354,28 +356,38 @@ class CupertinoPageTransition extends StatelessWidget { @required this.child, @required bool linearTransition, }) : assert(linearTransition != null), - _primaryPositionAnimation = (linearTransition ? primaryRouteAnimation : - // The curves below have been rigorously derived from plots of native - // iOS animation frames. Specifically, a video was taken of a page - // transition animation and the distance in each frame that the page - // moved was measured. A best fit bezier curve was the fitted to the - // point set, which is linearToEaseIn. Conversely, easeInToLinear is the - // reflection over the origin of linearToEaseIn. - CurvedAnimation( - parent: primaryRouteAnimation, - curve: Curves.linearToEaseOut, - reverseCurve: Curves.easeInToLinear, - ) - ).drive(_kRightMiddleTween), - _secondaryPositionAnimation = CurvedAnimation( - parent: secondaryRouteAnimation, - curve: Curves.linearToEaseOut, - reverseCurve: Curves.easeInToLinear, - ).drive(_kMiddleLeftTween), - _primaryShadowAnimation = CurvedAnimation( - parent: primaryRouteAnimation, - curve: Curves.linearToEaseOut, - ).drive(_kGradientShadowTween), + _primaryPositionAnimation = + (linearTransition + ? primaryRouteAnimation + : CurvedAnimation( + // The curves below have been rigorously derived from plots of native + // iOS animation frames. Specifically, a video was taken of a page + // transition animation and the distance in each frame that the page + // moved was measured. A best fit bezier curve was the fitted to the + // point set, which is linearToEaseIn. Conversely, easeInToLinear is the + // reflection over the origin of linearToEaseIn. + parent: primaryRouteAnimation, + curve: Curves.linearToEaseOut, + reverseCurve: Curves.easeInToLinear, + ) + ).drive(_kRightMiddleTween), + _secondaryPositionAnimation = + (linearTransition + ? secondaryRouteAnimation + : CurvedAnimation( + parent: secondaryRouteAnimation, + curve: Curves.linearToEaseOut, + reverseCurve: Curves.easeInToLinear, + ) + ).drive(_kMiddleLeftTween), + _primaryShadowAnimation = + (linearTransition + ? primaryRouteAnimation + : CurvedAnimation( + parent: primaryRouteAnimation, + curve: Curves.linearToEaseOut, + ) + ).drive(_kGradientShadowTween), super(key: key); // When this page is coming in to cover another page. @@ -618,7 +630,6 @@ class _CupertinoBackGestureController { animateForward = velocity > 0 ? false : true; else animateForward = controller.value > 0.5 ? true : false; - if (animateForward) { // The closer the panel is to dismissing, the shorter the animation is. // We want to cap the animation time, but we want to use a linear curve @@ -650,9 +661,9 @@ class _CupertinoBackGestureController { controller.removeStatusListener(_handleStatusChanged); } _animating = false; + onEnded(); if (status == AnimationStatus.dismissed) - route.navigator.removeRoute(route); // this will cause the route to get disposed, which will dispose us - onEnded(); // this will call dispose if popping the route failed to do so + route.navigator.removeRoute(route); // This also disposes the route. } void dispose() { diff --git a/packages/flutter/lib/src/cupertino/switch.dart b/packages/flutter/lib/src/cupertino/switch.dart index 9ba6a6b4d0..cb6a42c2d3 100644 --- a/packages/flutter/lib/src/cupertino/switch.dart +++ b/packages/flutter/lib/src/cupertino/switch.dart @@ -54,17 +54,21 @@ import 'thumb_painter.dart'; class CupertinoSwitch extends StatefulWidget { /// Creates an iOS-style switch. /// - /// [dragStartBehavior] must not be null. + /// The [value] parameter must not be null. + /// The [dragStartBehavior] parameter defaults to [DragStartBehavior.start] and must not be null. const CupertinoSwitch({ Key key, @required this.value, @required this.onChanged, this.activeColor, this.dragStartBehavior = DragStartBehavior.start, - }) : assert(dragStartBehavior != null), + }) : assert(value != null), + assert(dragStartBehavior != null), super(key: key); /// Whether this switch is on or off. + /// + /// Must not be null. final bool value; /// Called when the user toggles with switch on or off. @@ -73,7 +77,7 @@ class CupertinoSwitch extends StatefulWidget { /// change state until the parent widget rebuilds the switch with the new /// value. /// - /// If null, the switch will be displayed as disabled. + /// If null, the switch will be displayed as disabled, which has a reduced opacity. /// /// The callback provided to onChanged should update the state of the parent /// [StatefulWidget] using the [State.setState] method, so that the parent @@ -131,12 +135,15 @@ class CupertinoSwitch extends StatefulWidget { class _CupertinoSwitchState extends State with TickerProviderStateMixin { @override Widget build(BuildContext context) { - return _CupertinoSwitchRenderObjectWidget( - value: widget.value, - activeColor: widget.activeColor ?? CupertinoColors.activeGreen, - onChanged: widget.onChanged, - vsync: this, - dragStartBehavior: widget.dragStartBehavior, + return Opacity( + opacity: widget.onChanged == null ? _kCupertinoSwitchDisabledOpacity : 1.0, + child: _CupertinoSwitchRenderObjectWidget( + value: widget.value, + activeColor: widget.activeColor ?? CupertinoColors.activeGreen, + onChanged: widget.onChanged, + vsync: this, + dragStartBehavior: widget.dragStartBehavior, + ), ); } } @@ -189,6 +196,8 @@ const double _kTrackInnerEnd = _kTrackWidth - _kTrackInnerStart; const double _kTrackInnerLength = _kTrackInnerEnd - _kTrackInnerStart; const double _kSwitchWidth = 59.0; const double _kSwitchHeight = 39.0; +// Opacity of a disabled switch, as eye-balled from iOS Simulator on Mac. +const double _kCupertinoSwitchDisabledOpacity = 0.5; const Color _kTrackColor = CupertinoColors.lightBackgroundGray; const Duration _kReactionDuration = Duration(milliseconds: 300); diff --git a/packages/flutter/lib/src/cupertino/text_field.dart b/packages/flutter/lib/src/cupertino/text_field.dart index 2badd43762..ab51638b01 100644 --- a/packages/flutter/lib/src/cupertino/text_field.dart +++ b/packages/flutter/lib/src/cupertino/text_field.dart @@ -152,6 +152,10 @@ class CupertinoTextField extends StatefulWidget { this.decoration = _kDefaultRoundedBorderDecoration, this.padding = const EdgeInsets.all(6.0), this.placeholder, + this.placeholderStyle = const TextStyle( + fontWeight: FontWeight.w300, + color: _kInactiveTextColor + ), this.prefix, this.prefixMode = OverlayVisibilityMode.always, this.suffix, @@ -238,6 +242,17 @@ class CupertinoTextField extends StatefulWidget { /// main text entry except a lighter font weight and a grey font color. final String placeholder; + /// The style to use for the placeholder text. + /// + /// The [placeholderStyle] is merged with the [style] [TextStyle] when applied + /// to the [placeholder] text. To avoid merging with [style], specify + /// [TextStyle.inherit] as false. + /// + /// Defaults to the [style] property with w300 font weight and grey color. + /// + /// If specifically set to null, placeholder's style will be the same as [style]. + final TextStyle placeholderStyle; + /// An optional [Widget] to display before the text. final Widget prefix; @@ -422,6 +437,7 @@ class CupertinoTextField extends StatefulWidget { properties.add(DiagnosticsProperty('decoration', decoration)); properties.add(DiagnosticsProperty('padding', padding)); properties.add(StringProperty('placeholder', placeholder)); + properties.add(DiagnosticsProperty('placeholderStyle', placeholderStyle)); properties.add(DiagnosticsProperty('prefix', prefix == null ? null : prefixMode)); properties.add(DiagnosticsProperty('suffix', suffix == null ? null : suffixMode)); properties.add(DiagnosticsProperty('clearButtonMode', clearButtonMode)); @@ -603,9 +619,10 @@ class _CupertinoTextFieldState extends State with AutomaticK ); } - Widget _addTextDependentAttachments(Widget editableText, TextStyle textStyle) { + Widget _addTextDependentAttachments(Widget editableText, TextStyle textStyle, TextStyle placeholderStyle) { assert(editableText != null); assert(textStyle != null); + assert(placeholderStyle != null); // If there are no surrounding widgets, just return the core editable text // part. if (widget.placeholder == null && @@ -640,12 +657,7 @@ class _CupertinoTextFieldState extends State with AutomaticK widget.placeholder, maxLines: 1, overflow: TextOverflow.ellipsis, - style: textStyle.merge( - const TextStyle( - color: _kInactiveTextColor, - fontWeight: FontWeight.w300, - ), - ), + style: placeholderStyle ), ), ); @@ -698,6 +710,7 @@ class _CupertinoTextFieldState extends State with AutomaticK } final CupertinoThemeData themeData = CupertinoTheme.of(context); final TextStyle textStyle = themeData.textTheme.textStyle.merge(widget.style); + final TextStyle placeholderStyle = textStyle.merge(widget.placeholderStyle); final Brightness keyboardAppearance = widget.keyboardAppearance ?? themeData.brightness; final Color cursorColor = widget.cursorColor ?? themeData.primaryColor; @@ -773,7 +786,7 @@ class _CupertinoTextFieldState extends State with AutomaticK onDragSelectionUpdate: _handleMouseDragSelectionUpdate, onDragSelectionEnd: _handleMouseDragSelectionEnd, behavior: HitTestBehavior.translucent, - child: _addTextDependentAttachments(paddedEditable, textStyle), + child: _addTextDependentAttachments(paddedEditable, textStyle, placeholderStyle), ), ), ), diff --git a/packages/flutter/lib/src/cupertino/theme.dart b/packages/flutter/lib/src/cupertino/theme.dart index 38fe2f2b82..06acc54979 100644 --- a/packages/flutter/lib/src/cupertino/theme.dart +++ b/packages/flutter/lib/src/cupertino/theme.dart @@ -24,38 +24,68 @@ const Color _kDefaultBarDarkBackgroundColor = Color(0xB7212121); /// [CupertinoTheme.of]. An [InheritedWidget] dependency is created when /// an ancestor [CupertinoThemeData] is retrieved via [CupertinoTheme.of]. /// +/// The [CupertinoTheme] widget implies an [IconTheme] widget, whose +/// [IconTheme.data] has the same color as [CupertinoThemeData.primaryColor] +/// /// See also: /// /// * [CupertinoThemeData], specifies the theme's visual styling. /// * [CupertinoApp], which will automatically add a [CupertinoTheme]. /// * [Theme], a Material theme which will automatically add a [CupertinoTheme] /// with a [CupertinoThemeData] derived from the Material [ThemeData]. -class CupertinoTheme extends InheritedWidget { +class CupertinoTheme extends StatelessWidget { /// Creates a [CupertinoTheme] to change descendant Cupertino widgets' styling. /// /// The [data] and [child] parameters must not be null. const CupertinoTheme({ Key key, @required this.data, - @required Widget child, + @required this.child, }) : assert(child != null), assert(data != null), - super(key: key, child: child); + super(key: key); /// The [CupertinoThemeData] styling for this theme. final CupertinoThemeData data; - @override - bool updateShouldNotify(CupertinoTheme oldWidget) => data != oldWidget.data; - /// Retrieve the [CupertinoThemeData] from an ancestor [CupertinoTheme] widget. /// /// Returns a default [CupertinoThemeData] if no [CupertinoTheme] widgets /// exist in the ancestry tree. static CupertinoThemeData of(BuildContext context) { - final CupertinoTheme theme = context.inheritFromWidgetOfExactType(CupertinoTheme); - return theme?.data ?? const CupertinoThemeData(); + final _InheritedCupertinoTheme inheritedTheme = context.inheritFromWidgetOfExactType(_InheritedCupertinoTheme); + return inheritedTheme?.theme?.data ?? const CupertinoThemeData(); } + + /// The widget below this widget in the tree. + /// + /// {@macro flutter.widgets.child} + final Widget child; + + @override + Widget build(BuildContext context) { + return _InheritedCupertinoTheme( + theme: this, + child: IconTheme( + data: IconThemeData(color: data.primaryColor), + child: child, + ) + ); + } +} + +class _InheritedCupertinoTheme extends InheritedWidget { + const _InheritedCupertinoTheme({ + Key key, + @required this.theme, + @required Widget child, + }) : assert(theme != null), + super(key: key, child: child); + + final CupertinoTheme theme; + + @override + bool updateShouldNotify(_InheritedCupertinoTheme old) => theme.data != old.theme.data; } /// Styling specifications for a [CupertinoTheme]. diff --git a/packages/flutter/lib/src/foundation/change_notifier.dart b/packages/flutter/lib/src/foundation/change_notifier.dart index 4c906f1f51..47de62c028 100644 --- a/packages/flutter/lib/src/foundation/change_notifier.dart +++ b/packages/flutter/lib/src/foundation/change_notifier.dart @@ -248,14 +248,18 @@ class _MergingListenable extends Listenable { /// A [ChangeNotifier] that holds a single value. /// -/// When [value] is replaced, this class notifies its listeners. +/// When [value] is replaced with something that is not equal to the old +/// value as evaluated by the equality operator ==, this class notifies its +/// listeners. class ValueNotifier extends ChangeNotifier implements ValueListenable { /// Creates a [ChangeNotifier] that wraps this value. ValueNotifier(this._value); /// The current value stored in this notifier. /// - /// When the value is replaced, this class notifies its listeners. + /// When the value is replaced with something that is not equal to the old + /// value as evaluated by the equality operator ==, this class notifies its + /// listeners. @override T get value => _value; T _value; diff --git a/packages/flutter/lib/src/foundation/collections.dart b/packages/flutter/lib/src/foundation/collections.dart index b335f0ba0e..09a5968d1c 100644 --- a/packages/flutter/lib/src/foundation/collections.dart +++ b/packages/flutter/lib/src/foundation/collections.dart @@ -45,3 +45,26 @@ bool listEquals(List a, List b) { } return true; } + +/// Returns the position of `value` in the `sortedList`, if it exists. +/// +/// Returns `-1` if the `value` is not in the list. Requires the list items +/// to implement [Comparable] and the `sortedList` to already be ordered. +int binarySearch>(List sortedList, T value) { + int min = 0; + int max = sortedList.length; + while (min < max) { + final int mid = min + ((max - min) >> 1); + final T element = sortedList[mid]; + final int comp = element.compareTo(value); + if (comp == 0) { + return mid; + } + if (comp < 0) { + min = mid + 1; + } else { + max = mid; + } + } + return -1; +} diff --git a/packages/flutter/lib/src/foundation/isolates.dart b/packages/flutter/lib/src/foundation/isolates.dart index a7bd1a3d13..8afeb866a4 100644 --- a/packages/flutter/lib/src/foundation/isolates.dart +++ b/packages/flutter/lib/src/foundation/isolates.dart @@ -18,7 +18,7 @@ import 'constants.dart'; /// of classes, not closures or instance methods of objects. /// /// {@macro flutter.foundation.compute.limitations} -typedef ComputeCallback = R Function(Q message); +typedef ComputeCallback = FutureOr Function(Q message); /// Spawn an isolate, run `callback` on that isolate, passing it `message`, and /// (eventually) return the value returned by `callback`. @@ -53,9 +53,9 @@ Future compute(ComputeCallback callback, Q message, { String debu final ReceivePort resultPort = ReceivePort(); final ReceivePort errorPort = ReceivePort(); Timeline.finishSync(); - final Isolate isolate = await Isolate.spawn<_IsolateConfiguration>( + final Isolate isolate = await Isolate.spawn<_IsolateConfiguration>>( _spawn, - _IsolateConfiguration( + _IsolateConfiguration>( callback, message, resultPort.sendPort, @@ -110,11 +110,11 @@ class _IsolateConfiguration { R apply() => callback(message); } -void _spawn(_IsolateConfiguration configuration) { +Future _spawn(_IsolateConfiguration> configuration) async { R result; - Timeline.timeSync( + await Timeline.timeSync( '${configuration.debugLabel}', - () { result = configuration.apply(); }, + () async { result = await configuration.apply(); }, flow: Flow.step(configuration.flowId), ); Timeline.timeSync( diff --git a/packages/flutter/lib/src/foundation/key.dart b/packages/flutter/lib/src/foundation/key.dart index 27fbb32fb7..cd4e7b1838 100644 --- a/packages/flutter/lib/src/foundation/key.dart +++ b/packages/flutter/lib/src/foundation/key.dart @@ -11,6 +11,8 @@ import 'package:meta/meta.dart'; /// A new widget will only be used to update an existing element if its key is /// the same as the key of the current widget associated with the element. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=kn0EOS-ZiIc} +/// /// Keys must be unique amongst the [Element]s with the same parent. /// /// Subclasses of [Key] should either subclass [LocalKey] or [GlobalKey]. diff --git a/packages/flutter/lib/src/gestures/arena.dart b/packages/flutter/lib/src/gestures/arena.dart index 60b612b8ec..ff7827b05d 100644 --- a/packages/flutter/lib/src/gestures/arena.dart +++ b/packages/flutter/lib/src/gestures/arena.dart @@ -94,7 +94,7 @@ class _GestureArena { /// The first member to accept or the last member to not reject wins. /// -/// See for more +/// See for more /// information about the role this class plays in the gesture system. /// /// To debug problems with gestures, consider using diff --git a/packages/flutter/lib/src/gestures/converter.dart b/packages/flutter/lib/src/gestures/converter.dart index 0364c59489..fc71a6816c 100644 --- a/packages/flutter/lib/src/gestures/converter.dart +++ b/packages/flutter/lib/src/gestures/converter.dart @@ -32,12 +32,30 @@ class _PointerState { Offset lastPosition; + Offset deltaTo(Offset to) => to - lastPosition; + @override String toString() { return '_PointerState(pointer: $pointer, down: $down, lastPosition: $lastPosition)'; } } +// Add `kPrimaryButton` to [buttons] when a pointer of certain devices is down. +// +// TODO(tongmu): This patch is supposed to be done by embedders. Patching it +// in framework is a workaround before [PointerEventConverter] is moved to embedders. +// https://github.com/flutter/flutter/issues/30454 +int _synthesiseDownButtons(int buttons, PointerDeviceKind kind) { + switch (kind) { + case PointerDeviceKind.touch: + case PointerDeviceKind.stylus: + case PointerDeviceKind.invertedStylus: + return buttons | kPrimaryButton; + default: + return buttons; + } +} + /// Converts from engine pointer data to framework pointer events. /// /// This takes [PointerDataPacket] objects, as received from the engine via @@ -126,14 +144,12 @@ class PointerEventConverter { tilt: datum.tilt, ); } - final Offset offset = position - state.lastPosition; - state.lastPosition = position; yield PointerHoverEvent( timeStamp: timeStamp, kind: kind, device: datum.device, position: position, - delta: offset, + delta: state.deltaTo(position), buttons: datum.buttons, obscured: datum.obscured, pressureMin: datum.pressureMin, @@ -176,14 +192,12 @@ class PointerEventConverter { // Not all sources of pointer packets respect the invariant that // they hover the pointer to the down location before sending the // down event. We restore the invariant here for our clients. - final Offset offset = position - state.lastPosition; - state.lastPosition = position; yield PointerHoverEvent( timeStamp: timeStamp, kind: kind, device: datum.device, position: position, - delta: offset, + delta: state.deltaTo(position), buttons: datum.buttons, obscured: datum.obscured, pressureMin: datum.pressureMin, @@ -209,7 +223,7 @@ class PointerEventConverter { kind: kind, device: datum.device, position: position, - buttons: datum.buttons, + buttons: _synthesiseDownButtons(datum.buttons, kind), obscured: datum.obscured, pressure: datum.pressure, pressureMin: datum.pressureMin, @@ -231,16 +245,14 @@ class PointerEventConverter { assert(_pointers.containsKey(datum.device)); final _PointerState state = _pointers[datum.device]; assert(state.down); - final Offset offset = position - state.lastPosition; - state.lastPosition = position; yield PointerMoveEvent( timeStamp: timeStamp, pointer: state.pointer, kind: kind, device: datum.device, position: position, - delta: offset, - buttons: datum.buttons, + delta: state.deltaTo(position), + buttons: _synthesiseDownButtons(datum.buttons, kind), obscured: datum.obscured, pressure: datum.pressure, pressureMin: datum.pressureMin, @@ -255,6 +267,7 @@ class PointerEventConverter { tilt: datum.tilt, platformData: datum.platformData, ); + state.lastPosition = position; break; case ui.PointerChange.up: case ui.PointerChange.cancel: @@ -267,16 +280,14 @@ class PointerEventConverter { // event. For example, in the iOS simulator, of you drag outside the // window, you'll get a stream of pointers that violates that // invariant. We restore the invariant here for our clients. - final Offset offset = position - state.lastPosition; - state.lastPosition = position; yield PointerMoveEvent( timeStamp: timeStamp, pointer: state.pointer, kind: kind, device: datum.device, position: position, - delta: offset, - buttons: datum.buttons, + delta: state.deltaTo(position), + buttons: _synthesiseDownButtons(datum.buttons, kind), obscured: datum.obscured, pressure: datum.pressure, pressureMin: datum.pressureMin, @@ -326,6 +337,7 @@ class PointerEventConverter { position: position, buttons: datum.buttons, obscured: datum.obscured, + pressure: datum.pressure, pressureMin: datum.pressureMin, pressureMax: datum.pressureMax, distance: datum.distance, @@ -349,8 +361,31 @@ class PointerEventConverter { pointer: state.pointer, kind: kind, device: datum.device, + position: state.lastPosition, // Change position in Hover + buttons: datum.buttons, + obscured: datum.obscured, + pressure: datum.pressure, + pressureMin: datum.pressureMin, + pressureMax: datum.pressureMax, + distance: datum.distance, + distanceMax: datum.distanceMax, + size: datum.size, + radiusMajor: radiusMajor, + radiusMinor: radiusMinor, + radiusMin: radiusMin, + radiusMax: radiusMax, + orientation: datum.orientation, + tilt: datum.tilt, + ); + } + if (position != state.lastPosition) { + yield PointerHoverEvent( + timeStamp: timeStamp, + kind: kind, + device: datum.device, position: position, buttons: datum.buttons, + delta: state.deltaTo(position), obscured: datum.obscured, pressureMin: datum.pressureMin, pressureMax: datum.pressureMax, @@ -363,6 +398,7 @@ class PointerEventConverter { radiusMax: radiusMax, orientation: datum.orientation, tilt: datum.tilt, + synthesized: true, ); } _pointers.remove(datum.device); @@ -390,8 +426,6 @@ class PointerEventConverter { // before sending the scroll event, if necessary, so that clients // don't have to worry about native ordering of hover and scroll // events. - final Offset offset = position - state.lastPosition; - state.lastPosition = position; if (state.down) { yield PointerMoveEvent( timeStamp: timeStamp, @@ -399,9 +433,10 @@ class PointerEventConverter { kind: kind, device: datum.device, position: position, - delta: offset, - buttons: datum.buttons, + delta: state.deltaTo(position), + buttons: _synthesiseDownButtons(datum.buttons, kind), obscured: datum.obscured, + pressure: datum.pressure, pressureMin: datum.pressureMin, pressureMax: datum.pressureMax, distanceMax: datum.distanceMax, @@ -420,7 +455,7 @@ class PointerEventConverter { kind: kind, device: datum.device, position: position, - delta: offset, + delta: state.deltaTo(position), buttons: datum.buttons, obscured: datum.obscured, pressureMin: datum.pressureMin, @@ -437,6 +472,7 @@ class PointerEventConverter { synthesized: true, ); } + state.lastPosition = position; } final Offset scrollDelta = Offset(datum.scrollDeltaX, datum.scrollDeltaY) / devicePixelRatio; diff --git a/packages/flutter/lib/src/gestures/events.dart b/packages/flutter/lib/src/gestures/events.dart index e75608e838..d9b50f0f17 100644 --- a/packages/flutter/lib/src/gestures/events.dart +++ b/packages/flutter/lib/src/gestures/events.dart @@ -8,11 +8,21 @@ import 'package:flutter/foundation.dart'; export 'dart:ui' show Offset, PointerDeviceKind; +/// The bit of [PointerEvent.buttons] that corresponds to a unified behavior of +/// "basic operation". +/// +/// It is equivalent to: +/// +/// * [kTouchContact]: The pointer contacts the touch screen. +/// * [kStylusContact]: The stylus contacts the screen. +/// * [kPrimaryMouseButton]: The primary mouse button. +const int kPrimaryButton = 0x01; + /// The bit of [PointerEvent.buttons] that corresponds to the primary mouse button. /// /// The primary mouse button is typically the left button on the top of the /// mouse but can be reconfigured to be a different physical button. -const int kPrimaryMouseButton = 0x01; +const int kPrimaryMouseButton = kPrimaryButton; /// The bit of [PointerEvent.buttons] that corresponds to the secondary mouse button. /// @@ -20,6 +30,10 @@ const int kPrimaryMouseButton = 0x01; /// mouse but can be reconfigured to be a different physical button. const int kSecondaryMouseButton = 0x02; +/// The bit of [PointerEvent.buttons] that corresponds to when a stylus +/// contacting the screen. +const int kStylusContact = kPrimaryButton; + /// The bit of [PointerEvent.buttons] that corresponds to the primary stylus button. /// /// The primary stylus button is typically the top of the stylus and near the @@ -51,6 +65,10 @@ const int kBackMouseButton = 0x08; /// be reconfigured to be a different physical button. const int kForwardMouseButton = 0x10; +/// The bit of [PointerEvent.buttons] that corresponds to the pointer contacting +/// a touch screen. +const int kTouchContact = kPrimaryButton; + /// The bit of [PointerEvent.buttons] that corresponds to the nth mouse button. /// /// The `number` argument can be at most 62. @@ -346,21 +364,21 @@ class PointerAddedEvent extends PointerEvent { double orientation = 0.0, double tilt = 0.0, }) : super( - timeStamp: timeStamp, - kind: kind, - device: device, - position: position, - obscured: obscured, - pressure: pressure, - pressureMin: pressureMin, - pressureMax: pressureMax, - distance: distance, - distanceMax: distanceMax, - radiusMin: radiusMin, - radiusMax: radiusMax, - orientation: orientation, - tilt: tilt - ); + timeStamp: timeStamp, + kind: kind, + device: device, + position: position, + obscured: obscured, + pressure: pressure, + pressureMin: pressureMin, + pressureMax: pressureMax, + distance: distance, + distanceMax: distanceMax, + radiusMin: radiusMin, + radiusMax: radiusMax, + orientation: orientation, + tilt: tilt, + ); } /// The device is no longer tracking the pointer. @@ -383,18 +401,18 @@ class PointerRemovedEvent extends PointerEvent { double radiusMin = 0.0, double radiusMax = 0.0, }) : super( - timeStamp: timeStamp, - kind: kind, - device: device, - position: null, - obscured: obscured, - pressure: pressure, - pressureMin: pressureMin, - pressureMax: pressureMax, - distanceMax: distanceMax, - radiusMin: radiusMin, - radiusMax: radiusMax, - ); + timeStamp: timeStamp, + kind: kind, + device: device, + position: null, + obscured: obscured, + pressure: pressure, + pressureMin: pressureMin, + pressureMax: pressureMax, + distanceMax: distanceMax, + radiusMin: radiusMin, + radiusMax: radiusMax, + ); } /// The pointer has moved with respect to the device while the pointer is not @@ -433,28 +451,28 @@ class PointerHoverEvent extends PointerEvent { double tilt = 0.0, bool synthesized = false, }) : super( - timeStamp: timeStamp, - kind: kind, - device: device, - position: position, - delta: delta, - buttons: buttons, - down: false, - obscured: obscured, - pressure: pressure, - pressureMin: pressureMin, - pressureMax: pressureMax, - distance: distance, - distanceMax: distanceMax, - size: size, - radiusMajor: radiusMajor, - radiusMinor: radiusMinor, - radiusMin: radiusMin, - radiusMax: radiusMax, - orientation: orientation, - tilt: tilt, - synthesized: synthesized, - ); + timeStamp: timeStamp, + kind: kind, + device: device, + position: position, + delta: delta, + buttons: buttons, + down: false, + obscured: obscured, + pressure: pressure, + pressureMin: pressureMin, + pressureMax: pressureMax, + distance: distance, + distanceMax: distanceMax, + size: size, + radiusMajor: radiusMajor, + radiusMinor: radiusMinor, + radiusMin: radiusMin, + radiusMax: radiusMax, + orientation: orientation, + tilt: tilt, + synthesized: synthesized, + ); } /// The pointer has moved with respect to the device while the pointer is not @@ -493,55 +511,60 @@ class PointerEnterEvent extends PointerEvent { double tilt = 0.0, bool synthesized = false, }) : super( - timeStamp: timeStamp, - kind: kind, - device: device, - position: position, - delta: delta, - buttons: buttons, - down: false, - obscured: obscured, - pressure: pressure, - pressureMin: pressureMin, - pressureMax: pressureMax, - distance: distance, - distanceMax: distanceMax, - size: size, - radiusMajor: radiusMajor, - radiusMinor: radiusMinor, - radiusMin: radiusMin, - radiusMax: radiusMax, - orientation: orientation, - tilt: tilt, - synthesized: synthesized, - ); + timeStamp: timeStamp, + kind: kind, + device: device, + position: position, + delta: delta, + buttons: buttons, + down: false, + obscured: obscured, + pressure: pressure, + pressureMin: pressureMin, + pressureMax: pressureMax, + distance: distance, + distanceMax: distanceMax, + size: size, + radiusMajor: radiusMajor, + radiusMinor: radiusMinor, + radiusMin: radiusMin, + radiusMax: radiusMax, + orientation: orientation, + tilt: tilt, + synthesized: synthesized, + ); /// Creates an enter event from a [PointerHoverEvent]. /// - /// This is used by the [MouseTracker] to synthesize enter events, since it - /// only actually receives hover events. - PointerEnterEvent.fromHoverEvent(PointerHoverEvent hover) : super( - timeStamp: hover?.timeStamp, - kind: hover?.kind, - device: hover?.device, - position: hover?.position, - delta: hover?.delta, - buttons: hover?.buttons, - down: hover?.down, - obscured: hover?.obscured, - pressure: hover?.pressure, - pressureMin: hover?.pressureMin, - pressureMax: hover?.pressureMax, - distance: hover?.distance, - distanceMax: hover?.distanceMax, - size: hover?.size, - radiusMajor: hover?.radiusMajor, - radiusMinor: hover?.radiusMinor, - radiusMin: hover?.radiusMin, - radiusMax: hover?.radiusMax, - orientation: hover?.orientation, - tilt: hover?.tilt, - synthesized: hover?.synthesized, + /// Deprecated. Please use [PointerEnterEvent.fromMouseEvent] instead. + @Deprecated('use PointerEnterEvent.fromMouseEvent instead') + PointerEnterEvent.fromHoverEvent(PointerHoverEvent event) : this.fromMouseEvent(event); + + /// Creates an enter event from a [PointerEvent]. + /// + /// This is used by the [MouseTracker] to synthesize enter events. + PointerEnterEvent.fromMouseEvent(PointerEvent event) : super( + timeStamp: event?.timeStamp, + kind: event?.kind, + device: event?.device, + position: event?.position, + delta: event?.delta, + buttons: event?.buttons, + down: event?.down, + obscured: event?.obscured, + pressure: event?.pressure, + pressureMin: event?.pressureMin, + pressureMax: event?.pressureMax, + distance: event?.distance, + distanceMax: event?.distanceMax, + size: event?.size, + radiusMajor: event?.radiusMajor, + radiusMinor: event?.radiusMinor, + radiusMin: event?.radiusMin, + radiusMax: event?.radiusMax, + orientation: event?.orientation, + tilt: event?.tilt, + synthesized: event?.synthesized, ); } @@ -581,55 +604,60 @@ class PointerExitEvent extends PointerEvent { double tilt = 0.0, bool synthesized = false, }) : super( - timeStamp: timeStamp, - kind: kind, - device: device, - position: position, - delta: delta, - buttons: buttons, - down: false, - obscured: obscured, - pressure: pressure, - pressureMin: pressureMin, - pressureMax: pressureMax, - distance: distance, - distanceMax: distanceMax, - size: size, - radiusMajor: radiusMajor, - radiusMinor: radiusMinor, - radiusMin: radiusMin, - radiusMax: radiusMax, - orientation: orientation, - tilt: tilt, - synthesized: synthesized, - ); + timeStamp: timeStamp, + kind: kind, + device: device, + position: position, + delta: delta, + buttons: buttons, + down: false, + obscured: obscured, + pressure: pressure, + pressureMin: pressureMin, + pressureMax: pressureMax, + distance: distance, + distanceMax: distanceMax, + size: size, + radiusMajor: radiusMajor, + radiusMinor: radiusMinor, + radiusMin: radiusMin, + radiusMax: radiusMax, + orientation: orientation, + tilt: tilt, + synthesized: synthesized, + ); /// Creates an exit event from a [PointerHoverEvent]. /// - /// This is used by the [MouseTracker] to synthesize exit events, since it - /// only actually receives hover events. - PointerExitEvent.fromHoverEvent(PointerHoverEvent hover) : super( - timeStamp: hover?.timeStamp, - kind: hover?.kind, - device: hover?.device, - position: hover?.position, - delta: hover?.delta, - buttons: hover?.buttons, - down: hover?.down, - obscured: hover?.obscured, - pressure: hover?.pressure, - pressureMin: hover?.pressureMin, - pressureMax: hover?.pressureMax, - distance: hover?.distance, - distanceMax: hover?.distanceMax, - size: hover?.size, - radiusMajor: hover?.radiusMajor, - radiusMinor: hover?.radiusMinor, - radiusMin: hover?.radiusMin, - radiusMax: hover?.radiusMax, - orientation: hover?.orientation, - tilt: hover?.tilt, - synthesized: hover?.synthesized, + /// Deprecated. Please use [PointerExitEvent.fromMouseEvent] instead. + @Deprecated('use PointerExitEvent.fromMouseEvent instead') + PointerExitEvent.fromHoverEvent(PointerHoverEvent event) : this.fromMouseEvent(event); + + /// Creates an exit event from a [PointerEvent]. + /// + /// This is used by the [MouseTracker] to synthesize exit events. + PointerExitEvent.fromMouseEvent(PointerEvent event) : super( + timeStamp: event?.timeStamp, + kind: event?.kind, + device: event?.device, + position: event?.position, + delta: event?.delta, + buttons: event?.buttons, + down: event?.down, + obscured: event?.obscured, + pressure: event?.pressure, + pressureMin: event?.pressureMin, + pressureMax: event?.pressureMax, + distance: event?.distance, + distanceMax: event?.distanceMax, + size: event?.size, + radiusMajor: event?.radiusMajor, + radiusMinor: event?.radiusMinor, + radiusMin: event?.radiusMin, + radiusMax: event?.radiusMax, + orientation: event?.orientation, + tilt: event?.tilt, + synthesized: event?.synthesized, ); } @@ -658,27 +686,27 @@ class PointerDownEvent extends PointerEvent { double orientation = 0.0, double tilt = 0.0, }) : super( - timeStamp: timeStamp, - pointer: pointer, - kind: kind, - device: device, - position: position, - buttons: buttons, - down: true, - obscured: obscured, - pressure: pressure, - pressureMin: pressureMin, - pressureMax: pressureMax, - distance: 0.0, - distanceMax: distanceMax, - size: size, - radiusMajor: radiusMajor, - radiusMinor: radiusMinor, - radiusMin: radiusMin, - radiusMax: radiusMax, - orientation: orientation, - tilt: tilt - ); + timeStamp: timeStamp, + pointer: pointer, + kind: kind, + device: device, + position: position, + buttons: buttons, + down: true, + obscured: obscured, + pressure: pressure, + pressureMin: pressureMin, + pressureMax: pressureMax, + distance: 0.0, + distanceMax: distanceMax, + size: size, + radiusMajor: radiusMajor, + radiusMinor: radiusMinor, + radiusMin: radiusMin, + radiusMax: radiusMax, + orientation: orientation, + tilt: tilt, + ); } /// The pointer has moved with respect to the device while the pointer is in @@ -715,30 +743,30 @@ class PointerMoveEvent extends PointerEvent { int platformData = 0, bool synthesized = false, }) : super( - timeStamp: timeStamp, - pointer: pointer, - kind: kind, - device: device, - position: position, - delta: delta, - buttons: buttons, - down: true, - obscured: obscured, - pressure: pressure, - pressureMin: pressureMin, - pressureMax: pressureMax, - distance: 0.0, - distanceMax: distanceMax, - size: size, - radiusMajor: radiusMajor, - radiusMinor: radiusMinor, - radiusMin: radiusMin, - radiusMax: radiusMax, - orientation: orientation, - tilt: tilt, - platformData: platformData, - synthesized: synthesized, - ); + timeStamp: timeStamp, + pointer: pointer, + kind: kind, + device: device, + position: position, + delta: delta, + buttons: buttons, + down: true, + obscured: obscured, + pressure: pressure, + pressureMin: pressureMin, + pressureMax: pressureMax, + distance: 0.0, + distanceMax: distanceMax, + size: size, + radiusMajor: radiusMajor, + radiusMinor: radiusMinor, + radiusMin: radiusMin, + radiusMax: radiusMax, + orientation: orientation, + tilt: tilt, + platformData: platformData, + synthesized: synthesized, + ); } /// The pointer has stopped making contact with the device. @@ -767,27 +795,27 @@ class PointerUpEvent extends PointerEvent { double orientation = 0.0, double tilt = 0.0, }) : super( - timeStamp: timeStamp, - pointer: pointer, - kind: kind, - device: device, - position: position, - buttons: buttons, - down: false, - obscured: obscured, - pressure: pressure, - pressureMin: pressureMin, - pressureMax: pressureMax, - distance: distance, - distanceMax: distanceMax, - size: size, - radiusMajor: radiusMajor, - radiusMinor: radiusMinor, - radiusMin: radiusMin, - radiusMax: radiusMax, - orientation: orientation, - tilt: tilt - ); + timeStamp: timeStamp, + pointer: pointer, + kind: kind, + device: device, + position: position, + buttons: buttons, + down: false, + obscured: obscured, + pressure: pressure, + pressureMin: pressureMin, + pressureMax: pressureMax, + distance: distance, + distanceMax: distanceMax, + size: size, + radiusMajor: radiusMajor, + radiusMinor: radiusMinor, + radiusMin: radiusMin, + radiusMax: radiusMax, + orientation: orientation, + tilt: tilt, + ); } /// An event that corresponds to a discrete pointer signal. @@ -805,12 +833,12 @@ abstract class PointerSignalEvent extends PointerEvent { int device = 0, Offset position = Offset.zero, }) : super( - timeStamp: timeStamp, - pointer: pointer, - kind: kind, - device: device, - position: position, - ); + timeStamp: timeStamp, + pointer: pointer, + kind: kind, + device: device, + position: position, + ); } /// The pointer issued a scroll event. @@ -833,11 +861,11 @@ class PointerScrollEvent extends PointerSignalEvent { assert(position != null), assert(scrollDelta != null), super( - timeStamp: timeStamp, - kind: kind, - device: device, - position: position, - ); + timeStamp: timeStamp, + kind: kind, + device: device, + position: position, + ); /// The amount to scroll, in logical pixels. final Offset scrollDelta; @@ -875,25 +903,25 @@ class PointerCancelEvent extends PointerEvent { double orientation = 0.0, double tilt = 0.0, }) : super( - timeStamp: timeStamp, - pointer: pointer, - kind: kind, - device: device, - position: position, - buttons: buttons, - down: false, - obscured: obscured, - pressure: pressure, - pressureMin: pressureMin, - pressureMax: pressureMax, - distance: distance, - distanceMax: distanceMax, - size: size, - radiusMajor: radiusMajor, - radiusMinor: radiusMinor, - radiusMin: radiusMin, - radiusMax: radiusMax, - orientation: orientation, - tilt: tilt - ); + timeStamp: timeStamp, + pointer: pointer, + kind: kind, + device: device, + position: position, + buttons: buttons, + down: false, + obscured: obscured, + pressure: pressure, + pressureMin: pressureMin, + pressureMax: pressureMax, + distance: distance, + distanceMax: distanceMax, + size: size, + radiusMajor: radiusMajor, + radiusMinor: radiusMinor, + radiusMin: radiusMin, + radiusMax: radiusMax, + orientation: orientation, + tilt: tilt, + ); } diff --git a/packages/flutter/lib/src/gestures/monodrag.dart b/packages/flutter/lib/src/gestures/monodrag.dart index 245f8050db..f582e06493 100644 --- a/packages/flutter/lib/src/gestures/monodrag.dart +++ b/packages/flutter/lib/src/gestures/monodrag.dart @@ -69,7 +69,7 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer { /// first detected. /// /// For more information about the gesture arena: - /// https://flutter.io/docs/development/ui/advanced/gestures#gesture-disambiguation + /// https://flutter.dev/docs/development/ui/advanced/gestures#gesture-disambiguation /// /// By default, the drag start behavior is [DragStartBehavior.start]. /// diff --git a/packages/flutter/lib/src/gestures/mouse_tracking.dart b/packages/flutter/lib/src/gestures/mouse_tracking.dart index 90a28b5b4d..b181c0d70f 100644 --- a/packages/flutter/lib/src/gestures/mouse_tracking.dart +++ b/packages/flutter/lib/src/gestures/mouse_tracking.dart @@ -120,9 +120,10 @@ class MouseTracker { /// [collectMousePositions] will assert the next time it is called. void detachAnnotation(MouseTrackerAnnotation annotation) { final _TrackedAnnotation trackedAnnotation = _findAnnotation(annotation); - assert(trackedAnnotation != null, "Tried to detach an annotation that wasn't attached: $annotation"); for (int deviceId in trackedAnnotation.activeDevices) { - annotation.onExit(PointerExitEvent.fromHoverEvent(_lastMouseEvent[deviceId])); + if (annotation.onExit != null) { + annotation.onExit(PointerExitEvent.fromMouseEvent(_lastMouseEvent[deviceId])); + } } _trackedAnnotations.remove(annotation); } @@ -178,7 +179,7 @@ class MouseTracker { /// MouseTracker. Do not call in other contexts. @visibleForTesting bool isAnnotationAttached(MouseTrackerAnnotation annotation) { - return _trackedAnnotations[annotation] != null; + return _trackedAnnotations.containsKey(annotation); } /// Tells interested objects that a mouse has entered, exited, or moved, given @@ -194,7 +195,7 @@ class MouseTracker { void collectMousePositions() { void exitAnnotation(_TrackedAnnotation trackedAnnotation, int deviceId) { if (trackedAnnotation.annotation?.onExit != null && trackedAnnotation.activeDevices.contains(deviceId)) { - trackedAnnotation.annotation.onExit(PointerExitEvent.fromHoverEvent(_lastMouseEvent[deviceId])); + trackedAnnotation.annotation.onExit(PointerExitEvent.fromMouseEvent(_lastMouseEvent[deviceId])); trackedAnnotation.activeDevices.remove(deviceId); } } @@ -236,10 +237,10 @@ class MouseTracker { // event sent to it. hitAnnotation.activeDevices.add(deviceId); if (hitAnnotation.annotation?.onEnter != null) { - hitAnnotation.annotation.onEnter(PointerEnterEvent.fromHoverEvent(lastEvent)); + hitAnnotation.annotation.onEnter(PointerEnterEvent.fromMouseEvent(lastEvent)); } } - if (hitAnnotation.annotation?.onHover != null) { + if (hitAnnotation.annotation?.onHover != null && lastEvent is PointerHoverEvent) { hitAnnotation.annotation.onHover(lastEvent); } @@ -251,7 +252,7 @@ class MouseTracker { } if (trackedAnnotation.activeDevices.contains(deviceId)) { if (trackedAnnotation.annotation?.onExit != null) { - trackedAnnotation.annotation.onExit(PointerExitEvent.fromHoverEvent(lastEvent)); + trackedAnnotation.annotation.onExit(PointerExitEvent.fromMouseEvent(lastEvent)); } trackedAnnotation.activeDevices.remove(deviceId); } diff --git a/packages/flutter/lib/src/gestures/tap.dart b/packages/flutter/lib/src/gestures/tap.dart index 82123507d8..d5672255ad 100644 --- a/packages/flutter/lib/src/gestures/tap.dart +++ b/packages/flutter/lib/src/gestures/tap.dart @@ -172,7 +172,10 @@ class TapGestureRecognizer extends PrimaryPointerGestureRecognizer { void handlePrimaryPointer(PointerEvent event) { if (event is PointerUpEvent) { _finalPosition = event.position; - _checkUp(); + if (_wonArenaForPrimaryPointer) { + resolve(GestureDisposition.accepted); + _checkUp(); + } } else if (event is PointerCancelEvent) { if (_sentTapDown && onTapCancel != null) { invokeCallback('onTapCancel', onTapCancel); @@ -230,16 +233,7 @@ class TapGestureRecognizer extends PrimaryPointerGestureRecognizer { } void _checkUp() { - if (_wonArenaForPrimaryPointer && _finalPosition != null) { - resolve(GestureDisposition.accepted); - if (!_wonArenaForPrimaryPointer || _finalPosition == null) { - // It is possible that resolve has just recursively called _checkUp - // (see https://github.com/flutter/flutter/issues/12470). - // In that case _wonArenaForPrimaryPointer will be false (as _checkUp - // calls _reset) and we return here to avoid double invocation of the - // tap callbacks. - return; - } + if (_finalPosition != null) { if (onTapUp != null) invokeCallback('onTapUp', () { onTapUp(TapUpDetails(globalPosition: _finalPosition)); }); if (onTap != null) diff --git a/packages/flutter/lib/src/material/app.dart b/packages/flutter/lib/src/material/app.dart index f86fb35189..e1b0771e37 100644 --- a/packages/flutter/lib/src/material/app.dart +++ b/packages/flutter/lib/src/material/app.dart @@ -71,7 +71,7 @@ const TextStyle _errorTextStyle = TextStyle( /// * [MaterialPageRoute], which defines an app page that transitions in a material-specific way. /// * [WidgetsApp], which defines the basic app elements but does not depend on the material library. /// * The Flutter Internationalization Tutorial, -/// . +/// . class MaterialApp extends StatefulWidget { /// Creates a MaterialApp. /// @@ -300,7 +300,7 @@ class MaterialApp extends StatefulWidget { /// * [GlobalMaterialLocalizations], a [localizationsDelegates] value /// which provides material localizations for many languages. /// * The Flutter Internationalization Tutorial, - /// . + /// . final Iterable> localizationsDelegates; /// {@macro flutter.widgets.widgetsApp.localeListResolutionCallback} @@ -324,14 +324,14 @@ class MaterialApp extends StatefulWidget { /// * [GlobalMaterialLocalizations], a [localizationsDelegates] value /// which provides material localizations for many languages. /// * The Flutter Internationalization Tutorial, - /// . + /// . final Iterable supportedLocales; /// Turns on a performance overlay. /// /// See also: /// - /// * + /// * final bool showPerformanceOverlay; /// Turns on checkerboarding of raster cache images. @@ -419,7 +419,7 @@ class _MaterialAppState extends State { _navigatorObservers = List.from(widget.navigatorObservers) ..add(_heroController); } else { - _navigatorObservers = null; + _navigatorObservers = const []; } } diff --git a/packages/flutter/lib/src/material/app_bar.dart b/packages/flutter/lib/src/material/app_bar.dart index f92bb2bc1e..a35e8bb9bc 100644 --- a/packages/flutter/lib/src/material/app_bar.dart +++ b/packages/flutter/lib/src/material/app_bar.dart @@ -800,6 +800,8 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate { /// common actions with [IconButton]s which are optionally followed by a /// [PopupMenuButton] for less common operations. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=R9C5KMJKluE} +/// /// Sliver app bars are typically used as the first child of a /// [CustomScrollView], which lets the app bar integrate with the scroll view so /// that it can vary in height according to the scroll offset or float above the diff --git a/packages/flutter/lib/src/material/bottom_navigation_bar.dart b/packages/flutter/lib/src/material/bottom_navigation_bar.dart index 7458be9032..061457fa71 100644 --- a/packages/flutter/lib/src/material/bottom_navigation_bar.dart +++ b/packages/flutter/lib/src/material/bottom_navigation_bar.dart @@ -65,16 +65,29 @@ enum BottomNavigationBarType { /// {@tool snippet --template=stateful_widget_material} /// This example shows a [BottomNavigationBar] as it is used within a [Scaffold] /// widget. The [BottomNavigationBar] has three [BottomNavigationBarItem] -/// widgets and the [currentIndex] is set to index 1. The selected item is -/// purple. The `_onItemTapped` function changes the selected item's index +/// widgets and the [currentIndex] is set to index 0. The selected item is +/// amber. The `_onItemTapped` function changes the selected item's index /// and displays a corresponding message in the center of the [Scaffold]. /// +/// ![A scaffold with a bottom navigation bar containing three bottom navigation +/// bar items. The first one is selected.](https://flutter.github.io/assets-for-api-docs/assets/material/bottom_navigation_bar.png) +/// /// ```dart -/// int _selectedIndex = 1; -/// static const List _widgetOptions = const [ -/// Text('Index 0: Home'), -/// Text('Index 1: Business'), -/// Text('Index 2: School'), +/// int _selectedIndex = 0; +/// static const TextStyle optionStyle = TextStyle(fontSize: 30, fontWeight: FontWeight.bold); +/// static const List _widgetOptions = [ +/// Text( +/// 'Index 0: Home', +/// style: optionStyle, +/// ), +/// Text( +/// 'Index 1: Business', +/// style: optionStyle, +/// ), +/// Text( +/// 'Index 2: School', +/// style: optionStyle, +/// ), /// ]; /// /// void _onItemTapped(int index) { @@ -87,19 +100,28 @@ enum BottomNavigationBarType { /// Widget build(BuildContext context) { /// return Scaffold( /// appBar: AppBar( -/// title: Text('BottomNavigationBar Sample'), +/// title: const Text('BottomNavigationBar Sample'), /// ), /// body: Center( /// child: _widgetOptions.elementAt(_selectedIndex), /// ), /// bottomNavigationBar: BottomNavigationBar( -/// items: [ -/// BottomNavigationBarItem(icon: Icon(Icons.home), title: Text('Home')), -/// BottomNavigationBarItem(icon: Icon(Icons.business), title: Text('Business')), -/// BottomNavigationBarItem(icon: Icon(Icons.school), title: Text('School')), +/// items: const [ +/// BottomNavigationBarItem( +/// icon: Icon(Icons.home), +/// title: Text('Home'), +/// ), +/// BottomNavigationBarItem( +/// icon: Icon(Icons.business), +/// title: Text('Business'), +/// ), +/// BottomNavigationBarItem( +/// icon: Icon(Icons.school), +/// title: Text('School'), +/// ), /// ], /// currentIndex: _selectedIndex, -/// selectedItemColor: Colors.deepPurple, +/// selectedItemColor: Colors.amber[800], /// onTap: _onItemTapped, /// ), /// ); diff --git a/packages/flutter/lib/src/material/button_theme.dart b/packages/flutter/lib/src/material/button_theme.dart index e7359316fe..253b603b14 100644 --- a/packages/flutter/lib/src/material/button_theme.dart +++ b/packages/flutter/lib/src/material/button_theme.dart @@ -491,7 +491,7 @@ class ButtonThemeData extends Diagnosticable { if (fillColor != null) return fillColor; - if (button is FlatButton || button is OutlineButton) + if (button is FlatButton || button is OutlineButton || button.runtimeType == MaterialButton) return null; if (button.enabled && button is RaisedButton && _buttonColor != null) diff --git a/packages/flutter/lib/src/material/dialog.dart b/packages/flutter/lib/src/material/dialog.dart index 642d0f0918..36f0209edc 100644 --- a/packages/flutter/lib/src/material/dialog.dart +++ b/packages/flutter/lib/src/material/dialog.dart @@ -189,6 +189,7 @@ class Dialog extends StatelessWidget { /// /// * [SimpleDialog], which handles the scrolling of the contents but has no [actions]. /// * [Dialog], on which [AlertDialog] and [SimpleDialog] are based. +/// * [CupertinoAlertDialog], an iOS-styled alert dialog. /// * [showDialog], which actually displays the dialog and returns its result. /// * class AlertDialog extends StatelessWidget { @@ -699,11 +700,12 @@ Future showDialog({ }) { assert(child == null || builder == null); assert(debugCheckHasMaterialLocalizations(context)); + + final ThemeData theme = Theme.of(context, shadowThemeOnly: true); return showGeneralDialog( context: context, pageBuilder: (BuildContext buildContext, Animation animation, Animation secondaryAnimation) { - final ThemeData theme = Theme.of(context, shadowThemeOnly: true); - final Widget pageChild = child ?? Builder(builder: builder); + final Widget pageChild = child ?? Builder(builder: builder); return SafeArea( child: Builder( builder: (BuildContext context) { diff --git a/packages/flutter/lib/src/material/expansion_panel.dart b/packages/flutter/lib/src/material/expansion_panel.dart index b64b19a027..a50975998c 100644 --- a/packages/flutter/lib/src/material/expansion_panel.dart +++ b/packages/flutter/lib/src/material/expansion_panel.dart @@ -56,12 +56,15 @@ typedef ExpansionPanelHeaderBuilder = Widget Function(BuildContext context, bool /// Expansion panels are only intended to be used as children for /// [ExpansionPanelList]. /// +/// See [ExpansionPanelList] for a sample implementation. +/// /// See also: /// /// * [ExpansionPanelList] /// * class ExpansionPanel { /// Creates an expansion panel to be used as a child for [ExpansionPanelList]. + /// See [ExpansionPanelList] for an example on how to use this widget. /// /// The [headerBuilder], [body], and [isExpanded] arguments must not be null. ExpansionPanel({ @@ -88,8 +91,14 @@ class ExpansionPanel { } /// An expansion panel that allows for radio-like functionality. +/// This means that at any given time, at most, one [ExpansionPanelRadio] +/// can remain expanded. /// /// A unique identifier [value] must be assigned to each panel. +/// This identifier allows the [ExpansionPanelList] to determine +/// which [ExpansionPanelRadio] instance should be expanded. +/// +/// See [ExpansionPanelList.radio] for a sample implementation. class ExpansionPanelRadio extends ExpansionPanel { /// An expansion panel that allows for radio functionality. @@ -111,9 +120,82 @@ class ExpansionPanelRadio extends ExpansionPanel { /// A material expansion panel list that lays out its children and animates /// expansions. /// +/// {@tool snippet --template=stateful_widget_scaffold} +/// +/// Here is a simple example of how to implement ExpansionPanelList. +/// +/// ```dart preamble +/// // stores ExpansionPanel state information +/// class Item { +/// Item({ +/// this.expandedValue, +/// this.headerValue, +/// this.isExpanded = false, +/// }); +/// +/// String expandedValue; +/// String headerValue; +/// bool isExpanded; +/// } +/// +/// List generateItems(int numberOfItems) { +/// return List.generate(numberOfItems, (int index) { +/// return Item( +/// headerValue: 'Panel $index', +/// expandedValue: 'This is item number $index', +/// ); +/// }); +/// } +/// ``` +/// +/// ```dart +/// List _data = generateItems(8); +/// +/// @override +/// Widget build(BuildContext context) { +/// return SingleChildScrollView( +/// child: Container( +/// child: _buildPanel(), +/// ), +/// ); +/// } +/// +/// Widget _buildPanel() { +/// return ExpansionPanelList( +/// expansionCallback: (int index, bool isExpanded) { +/// setState(() { +/// _data[index].isExpanded = !isExpanded; +/// }); +/// }, +/// children: _data.map((Item item) { +/// return ExpansionPanel( +/// headerBuilder: (BuildContext context, bool isExpanded) { +/// return ListTile( +/// title: Text(item.headerValue), +/// ); +/// }, +/// body: ListTile( +/// title: Text(item.expandedValue), +/// subtitle: Text('To delete this panel, tap the trash can icon'), +/// trailing: Icon(Icons.delete), +/// onTap: () { +/// setState(() { +/// _data.removeWhere((currentItem) => item == currentItem); +/// }); +/// } +/// ), +/// isExpanded: item.isExpanded, +/// ); +/// }).toList(), +/// ); +/// } +/// ``` +/// {@end-tool} +/// /// See also: /// /// * [ExpansionPanel] +/// * [ExpansionPanelList.radio] /// * class ExpansionPanelList extends StatefulWidget { /// Creates an expansion panel list widget. The [expansionCallback] is @@ -138,6 +220,75 @@ class ExpansionPanelList extends StatefulWidget { /// expand/collapse button is pushed. The [children] and [animationDuration] /// arguments must not be null. The [children] objects must be instances /// of [ExpansionPanelRadio]. + /// + /// {@tool snippet --template=stateful_widget_scaffold} + /// + /// Here is a simple example of how to implement ExpansionPanelList.radio. + /// + /// ```dart preamble + /// // stores ExpansionPanel state information + /// class Item { + /// Item({ + /// this.id, + /// this.expandedValue, + /// this.headerValue, + /// }); + /// + /// int id; + /// String expandedValue; + /// String headerValue; + /// } + /// + /// List generateItems(int numberOfItems) { + /// return List.generate(numberOfItems, (int index) { + /// return Item( + /// id: index, + /// headerValue: 'Panel $index', + /// expandedValue: 'This is item number $index', + /// ); + /// }); + /// } + /// ``` + /// + /// ```dart + /// List _data = generateItems(8); + /// + /// @override + /// Widget build(BuildContext context) { + /// return SingleChildScrollView( + /// child: Container( + /// child: _buildPanel(), + /// ), + /// ); + /// } + /// + /// Widget _buildPanel() { + /// return ExpansionPanelList.radio( + /// initialOpenPanelValue: 2, + /// children: _data.map((Item item) { + /// return ExpansionPanelRadio( + /// value: item.id, + /// headerBuilder: (BuildContext context, bool isExpanded) { + /// return ListTile( + /// title: Text(item.headerValue), + /// ); + /// }, + /// body: ListTile( + /// title: Text(item.expandedValue), + /// subtitle: Text('To delete this panel, tap the trash can icon'), + /// trailing: Icon(Icons.delete), + /// onTap: () { + /// setState(() { + /// _data.removeWhere((currentItem) => item == currentItem); + /// }); + /// } + /// ) + /// ); + /// }).toList(), + /// ); + /// } + /// ``` + /// {@end-tool} const ExpansionPanelList.radio({ Key key, this.children = const [], diff --git a/packages/flutter/lib/src/material/floating_action_button.dart b/packages/flutter/lib/src/material/floating_action_button.dart index a0ee70c654..646581401f 100644 --- a/packages/flutter/lib/src/material/floating_action_button.dart +++ b/packages/flutter/lib/src/material/floating_action_button.dart @@ -42,6 +42,8 @@ class _DefaultHeroTag { /// to promote a primary action in the application. Floating action buttons are /// most commonly used in the [Scaffold.floatingActionButton] field. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=2uaoEDOgk_I} +/// /// Use at most a single floating action button per screen. Floating action /// buttons should be used for positive actions such as "create", "share", or /// "navigate". (If more than one floating action button is used within a diff --git a/packages/flutter/lib/src/material/flutter_logo.dart b/packages/flutter/lib/src/material/flutter_logo.dart index bfb025e772..8f0b369989 100644 --- a/packages/flutter/lib/src/material/flutter_logo.dart +++ b/packages/flutter/lib/src/material/flutter_logo.dart @@ -7,7 +7,7 @@ import 'package:flutter/widgets.dart'; import 'colors.dart'; /// The Flutter logo, in widget form. This widget respects the [IconTheme]. -/// For guidelines on using the Flutter logo, visit https://flutter.io/brand. +/// For guidelines on using the Flutter logo, visit https://flutter.dev/brand. /// /// See also: /// diff --git a/packages/flutter/lib/src/material/input_border.dart b/packages/flutter/lib/src/material/input_border.dart index fbfa167f50..fa1866c284 100644 --- a/packages/flutter/lib/src/material/input_border.dart +++ b/packages/flutter/lib/src/material/input_border.dart @@ -412,7 +412,7 @@ class OutlineInputBorder extends InputBorder { const double cornerArcSweep = math.pi / 2.0; final double tlCornerArcSweep = start < center.tlRadiusX - ? math.asin(start / center.tlRadiusX) + ? math.asin((start / center.tlRadiusX).clamp(-1.0, 1.0)) : math.pi / 2.0; final Path path = Path() @@ -474,12 +474,12 @@ class OutlineInputBorder extends InputBorder { final double extent = lerpDouble(0.0, gapExtent + gapPadding * 2.0, gapPercentage); switch (textDirection) { case TextDirection.rtl: { - final Path path = _gapBorderPath(canvas, center, gapStart + gapPadding - extent, extent); + final Path path = _gapBorderPath(canvas, center, math.max(0.0, gapStart + gapPadding - extent), extent); canvas.drawPath(path, paint); break; } case TextDirection.ltr: { - final Path path = _gapBorderPath(canvas, center, gapStart - gapPadding, extent); + final Path path = _gapBorderPath(canvas, center, math.max(0.0, gapStart - gapPadding), extent); canvas.drawPath(path, paint); break; } diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index 3208563300..d34d84f58c 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -1058,8 +1058,7 @@ class _RenderDecoration extends RenderBox { @override double computeDistanceToActualBaseline(TextBaseline baseline) { - assert(false, 'not implemented'); - return 0.0; + return _boxParentData(input).offset.dy + input.computeDistanceToActualBaseline(baseline); } // Records where the label was painted. diff --git a/packages/flutter/lib/src/material/list_tile.dart b/packages/flutter/lib/src/material/list_tile.dart index d57acd7d89..0500bc4ae4 100644 --- a/packages/flutter/lib/src/material/list_tile.dart +++ b/packages/flutter/lib/src/material/list_tile.dart @@ -164,6 +164,16 @@ enum ListTileControlAffinity { /// and to ensure that [subtitle] doesn't wrap (if [isThreeLine] is false) or /// wraps to two lines (if it is true). /// +/// The heights of the [leading] and [trailing] widgets are constrained +/// according to the +/// [Material spec](https://material.io/design/components/lists.html). +/// An exception is made for one-line ListTiles for accessibility. Please +/// see the example below to see how to adhere to both Material spec and +/// accessibility requirements. +/// +/// Note that [leading] and [trailing] widgets can expand as far as they wish +/// horizontally, so ensure that they are properly constrained. +/// /// List tiles are typically used in [ListView]s, or arranged in [Column]s in /// [Drawer]s and [Card]s. /// @@ -171,12 +181,60 @@ enum ListTileControlAffinity { /// /// {@tool sample} /// -/// Here is a simple tile with an icon and some text. +/// This example uses a [ListView] to demonstrate different configurations of +/// [ListTile]s in [Card]s. +/// +/// ![Different variations of ListTile](https://flutter.github.io/assets-for-api-docs/assets/material/list_tile.png) /// /// ```dart -/// ListTile( -/// leading: const Icon(Icons.event_seat), -/// title: const Text('The seat for the narrator'), +/// ListView( +/// children: const [ +/// Card(child: ListTile(title: Text('One-line ListTile'))), +/// Card( +/// child: ListTile( +/// leading: FlutterLogo(), +/// title: Text('One-line with leading widget'), +/// ), +/// ), +/// Card( +/// child: ListTile( +/// title: Text('One-line with trailing widget'), +/// trailing: Icon(Icons.more_vert), +/// ), +/// ), +/// Card( +/// child: ListTile( +/// leading: FlutterLogo(), +/// title: Text('One-line with both widgets'), +/// trailing: Icon(Icons.more_vert), +/// ), +/// ), +/// Card( +/// child: ListTile( +/// title: Text('One-line dense ListTile'), +/// dense: true, +/// ), +/// ), +/// Card( +/// child: ListTile( +/// leading: FlutterLogo(size: 56.0), +/// title: Text('Two-line ListTile'), +/// subtitle: Text('Here is a second line'), +/// trailing: Icon(Icons.more_vert), +/// ), +/// ), +/// Card( +/// child: ListTile( +/// leading: FlutterLogo(size: 72.0), +/// title: Text('Three-line ListTile'), +/// subtitle: Text( +/// 'A sufficiently long subtitle warrants three lines.' +/// ), +/// trailing: Icon(Icons.more_vert), +/// isThreeLine: true, +/// ), +/// ), +/// ], /// ) /// ``` /// {@end-tool} @@ -199,6 +257,339 @@ enum ListTileControlAffinity { /// ``` /// {@end-tool} /// +/// To be accessible, tappable [leading] and [trailing] widgets have to +/// be at least 48x48 in size. However, to adhere to the Material spec, +/// [trailing] and [leading] widgets in one-line ListTiles should visually be +/// at most 32 ([dense]: true) or 40 ([dense]: false) in height, which may +/// conflict with the accessibility requirement. +/// +/// For this reason, a one-line ListTile allows the height of [leading] +/// and [trailing] widgets to be constrained by the height of the ListTile. +/// This allows for the creation of tappable [leading] and [trailing] widgets +/// that are large enough, but it is up to the developer to ensure that +/// their widgets follow the Material spec. +/// +/// {@tool sample} +/// +/// Here is an example of a one-line, non-[dense] ListTile with a +/// tappable leading widget that adheres to accessibility requirements and +/// the Material spec. To adjust the use case below for a one-line, [dense] +/// ListTile, adjust the vertical padding to 8.0. +/// +/// ```dart +/// ListTile( +/// leading: GestureDetector( +/// behavior: HitTestBehavior.translucent, +/// onTap: () {}, +/// child: Container( +/// width: 48, +/// height: 48, +/// padding: EdgeInsets.symmetric(vertical: 4.0), +/// alignment: Alignment.center, +/// child: CircleAvatar(), +/// ), +/// ), +/// title: Text('title'), +/// dense: false, +/// ), +/// ``` +/// {@end-tool} +/// +/// ## The ListTile layout isn't exactly what I want +/// +/// If the way ListTile pads and positions its elements isn't quite what +/// you're looking for, it's easy to create custom list items with a +/// combination of other widgets, such as [Row]s and [Column]s. +/// +/// {@tool snippet --template=stateless_widget_scaffold} +/// +/// Here is an example of a custom list item that resembles a Youtube related +/// video list item created with [Expanded] and [Container] widgets. +/// +/// ![Custom list item a](https://flutter.github.io/assets-for-api-docs/assets/widgets/custom_list_item_a.png) +/// +/// ```dart preamble +/// class CustomListItem extends StatelessWidget { +/// const CustomListItem({ +/// this.thumbnail, +/// this.title, +/// this.user, +/// this.viewCount, +/// }); +/// +/// final Widget thumbnail; +/// final String title; +/// final String user; +/// final int viewCount; +/// +/// @override +/// Widget build(BuildContext context) { +/// return Padding( +/// padding: const EdgeInsets.symmetric(vertical: 5.0), +/// child: Row( +/// crossAxisAlignment: CrossAxisAlignment.start, +/// children: [ +/// Expanded( +/// flex: 2, +/// child: thumbnail, +/// ), +/// Expanded( +/// flex: 3, +/// child: _VideoDescription( +/// title: title, +/// user: user, +/// viewCount: viewCount, +/// ), +/// ), +/// const Icon( +/// Icons.more_vert, +/// size: 16.0, +/// ), +/// ], +/// ), +/// ); +/// } +/// } +/// +/// class _VideoDescription extends StatelessWidget { +/// const _VideoDescription({ +/// Key key, +/// this.title, +/// this.user, +/// this.viewCount, +/// }) : super(key: key); +/// +/// final String title; +/// final String user; +/// final int viewCount; +/// +/// @override +/// Widget build(BuildContext context) { +/// return Padding( +/// padding: const EdgeInsets.fromLTRB(5.0, 0.0, 0.0, 0.0), +/// child: Column( +/// crossAxisAlignment: CrossAxisAlignment.start, +/// children: [ +/// Text( +/// title, +/// style: const TextStyle( +/// fontWeight: FontWeight.w500, +/// fontSize: 14.0, +/// ), +/// ), +/// const Padding(padding: EdgeInsets.symmetric(vertical: 2.0)), +/// Text( +/// user, +/// style: const TextStyle(fontSize: 10.0), +/// ), +/// const Padding(padding: EdgeInsets.symmetric(vertical: 1.0)), +/// Text( +/// '$viewCount views', +/// style: const TextStyle(fontSize: 10.0), +/// ), +/// ], +/// ), +/// ); +/// } +/// } +/// ``` +/// +/// ```dart +/// Widget build(BuildContext context) { +/// return ListView( +/// padding: const EdgeInsets.all(8.0), +/// itemExtent: 106.0, +/// children: [ +/// CustomListItem( +/// user: 'Flutter', +/// viewCount: 999000, +/// thumbnail: Container( +/// decoration: const BoxDecoration(color: Colors.blue), +/// ), +/// title: 'The Flutter YouTube Channel', +/// ), +/// CustomListItem( +/// user: 'Dash', +/// viewCount: 884000, +/// thumbnail: Container( +/// decoration: const BoxDecoration(color: Colors.yellow), +/// ), +/// title: 'Announcing Flutter 1.0', +/// ), +/// ], +/// ); +/// } +/// ``` +/// {@end-tool} +/// +/// {@tool snippet --template=stateless_widget_scaffold} +/// +/// Here is an example of an article list item with multi-line titles and +/// subtitles. It utilizes [Row]s and [Column]s, as well as [Expanded] and +/// [AspectRatio] widgets to organize its layout. +/// +/// ![Custom list item b](https://flutter.github.io/assets-for-api-docs/assets/widgets/custom_list_item_b.png) +/// +/// ```dart preamble +/// class _ArticleDescription extends StatelessWidget { +/// _ArticleDescription({ +/// Key key, +/// this.title, +/// this.subtitle, +/// this.author, +/// this.publishDate, +/// this.readDuration, +/// }) : super(key: key); +/// +/// final String title; +/// final String subtitle; +/// final String author; +/// final String publishDate; +/// final String readDuration; +/// +/// @override +/// Widget build(BuildContext context) { +/// return Column( +/// crossAxisAlignment: CrossAxisAlignment.start, +/// children: [ +/// Expanded( +/// flex: 2, +/// child: Column( +/// crossAxisAlignment: CrossAxisAlignment.start, +/// children: [ +/// Text( +/// '$title', +/// maxLines: 2, +/// overflow: TextOverflow.ellipsis, +/// style: const TextStyle( +/// fontWeight: FontWeight.bold, +/// ), +/// ), +/// const Padding(padding: EdgeInsets.only(bottom: 2.0)), +/// Text( +/// '$subtitle', +/// maxLines: 2, +/// overflow: TextOverflow.ellipsis, +/// style: const TextStyle( +/// fontSize: 12.0, +/// color: Colors.black54, +/// ), +/// ), +/// ], +/// ), +/// ), +/// Expanded( +/// flex: 1, +/// child: Column( +/// crossAxisAlignment: CrossAxisAlignment.start, +/// mainAxisAlignment: MainAxisAlignment.end, +/// children: [ +/// Text( +/// '$author', +/// style: const TextStyle( +/// fontSize: 12.0, +/// color: Colors.black87, +/// ), +/// ), +/// Text( +/// '$publishDate · $readDuration ★', +/// style: const TextStyle( +/// fontSize: 12.0, +/// color: Colors.black54, +/// ), +/// ), +/// ], +/// ), +/// ), +/// ], +/// ); +/// } +/// } +/// +/// class CustomListItemTwo extends StatelessWidget { +/// CustomListItemTwo({ +/// Key key, +/// this.thumbnail, +/// this.title, +/// this.subtitle, +/// this.author, +/// this.publishDate, +/// this.readDuration, +/// }) : super(key: key); +/// +/// final Widget thumbnail; +/// final String title; +/// final String subtitle; +/// final String author; +/// final String publishDate; +/// final String readDuration; +/// +/// @override +/// Widget build(BuildContext context) { +/// return Padding( +/// padding: const EdgeInsets.symmetric(vertical: 10.0), +/// child: SizedBox( +/// height: 100, +/// child: Row( +/// crossAxisAlignment: CrossAxisAlignment.start, +/// children: [ +/// AspectRatio( +/// aspectRatio: 1.0, +/// child: thumbnail, +/// ), +/// Expanded( +/// child: Padding( +/// padding: const EdgeInsets.fromLTRB(20.0, 0.0, 2.0, 0.0), +/// child: _ArticleDescription( +/// title: title, +/// subtitle: subtitle, +/// author: author, +/// publishDate: publishDate, +/// readDuration: readDuration, +/// ), +/// ), +/// ) +/// ], +/// ), +/// ), +/// ); +/// } +/// } +/// ``` +/// +/// ```dart +/// Widget build(BuildContext context) { +/// return ListView( +/// padding: const EdgeInsets.all(10.0), +/// children: [ +/// CustomListItemTwo( +/// thumbnail: Container( +/// decoration: const BoxDecoration(color: Colors.pink), +/// ), +/// title: 'Flutter 1.0 Launch', +/// subtitle: +/// 'Flutter continues to improve and expand its horizons.' +/// 'This text should max out at two lines and clip', +/// author: 'Dash', +/// publishDate: 'Dec 28', +/// readDuration: '5 mins', +/// ), +/// CustomListItemTwo( +/// thumbnail: Container( +/// decoration: const BoxDecoration(color: Colors.blue), +/// ), +/// title: 'Flutter 1.2 Release - Continual updates to the framework', +/// subtitle: 'Flutter once again improves and makes updates.', +/// author: 'Flutter', +/// publishDate: 'Feb 26', +/// readDuration: '12 mins', +/// ), +/// ], +/// ); +/// } +/// ``` +/// {@end-tool} +/// /// See also: /// /// * [ListTileTheme], which defines visual properties for [ListTile]s. @@ -924,11 +1315,29 @@ class _RenderListTile extends RenderBox { final bool hasTrailing = trailing != null; final bool isTwoLine = !isThreeLine && hasSubtitle; final bool isOneLine = !isThreeLine && !hasSubtitle; + + final BoxConstraints maxIconHeightConstraint = BoxConstraints( + // One-line trailing and leading widget heights do not follow + // Material specifications, but this sizing is required to adhere + // to accessibility requirements for smallest tappable widget. + // Two- and three-line trailing widget heights are constrained + // properly according to the Material spec. + maxHeight: isDense ? 48.0 : 56.0, + ); final BoxConstraints looseConstraints = constraints.loosen(); + final BoxConstraints iconConstraints = looseConstraints.enforce(maxIconHeightConstraint); final double tileWidth = looseConstraints.maxWidth; - final Size leadingSize = _layoutBox(leading, looseConstraints); - final Size trailingSize = _layoutBox(trailing, looseConstraints); + final Size leadingSize = _layoutBox(leading, iconConstraints); + final Size trailingSize = _layoutBox(trailing, iconConstraints); + assert( + tileWidth != leadingSize.width, + 'Leading widget consumes entire tile width. Please use a sized widget.' + ); + assert( + tileWidth != trailingSize.width, + 'Trailing widget consumes entire tile width. Please use a sized widget.' + ); final double titleStart = hasLeading ? math.max(_minLeadingWidth, leadingSize.width) + _horizontalTitleGap diff --git a/packages/flutter/lib/src/material/material.dart b/packages/flutter/lib/src/material/material.dart index cb958216b8..82bcaa421c 100644 --- a/packages/flutter/lib/src/material/material.dart +++ b/packages/flutter/lib/src/material/material.dart @@ -320,7 +320,13 @@ class _MaterialState extends State with TickerProviderStateMixin { @override Widget build(BuildContext context) { final Color backgroundColor = _getBackgroundColor(context); - assert(backgroundColor != null || widget.type == MaterialType.transparency); + assert( + backgroundColor != null || widget.type == MaterialType.transparency, + 'If Material type is not MaterialType.transparency, a color must ' + 'either be passed in through the `color` property, or be defined ' + 'in the theme (ex. canvasColor != null if type is set to ' + 'MaterialType.canvas)' + ); Widget contents = widget.child; if (contents != null) { contents = AnimatedDefaultTextStyle( diff --git a/packages/flutter/lib/src/material/material_button.dart b/packages/flutter/lib/src/material/material_button.dart index c25ab3b93e..506f6f4b1d 100644 --- a/packages/flutter/lib/src/material/material_button.dart +++ b/packages/flutter/lib/src/material/material_button.dart @@ -263,7 +263,7 @@ class MaterialButton extends StatelessWidget { return RawMaterialButton( onPressed: onPressed, onHighlightChanged: onHighlightChanged, - fillColor: color, + fillColor: buttonTheme.getFillColor(this), textStyle: theme.textTheme.button.copyWith(color: buttonTheme.getTextColor(this)), highlightColor: highlightColor ?? theme.highlightColor, splashColor: splashColor ?? theme.splashColor, diff --git a/packages/flutter/lib/src/material/material_localizations.dart b/packages/flutter/lib/src/material/material_localizations.dart index 2550de41ac..82aaf0080b 100644 --- a/packages/flutter/lib/src/material/material_localizations.dart +++ b/packages/flutter/lib/src/material/material_localizations.dart @@ -31,8 +31,8 @@ import 'typography.dart'; // you must add it to every other language (all the other *.arb files in that // same directory), listing the translation as `TBD`. After that you have to // re-generate lib/src/l10n/localizations.dart by running -// `dart dev/tools/gen_localizations.dart --overwrite`. There is a README -// file with further information in the lib/src/l10n/ directory. +// `dart dev/tools/localization/gen_localizations.dart --overwrite`. There is +// a README file with further information in the lib/src/l10n/ directory. // // 5. If you are a Google employee, you should then also follow the instructions // at go/flutter-l10n. If you're not, don't worry about it. diff --git a/packages/flutter/lib/src/material/popup_menu.dart b/packages/flutter/lib/src/material/popup_menu.dart index b1b47fc950..400e56cde8 100644 --- a/packages/flutter/lib/src/material/popup_menu.dart +++ b/packages/flutter/lib/src/material/popup_menu.dart @@ -712,13 +712,14 @@ class _PopupMenuRoute extends PopupRoute { /// semantics. Future showMenu({ @required BuildContext context, - RelativeRect position, + @required RelativeRect position, @required List> items, T initialValue, double elevation = 8.0, String semanticLabel, }) { assert(context != null); + assert(position != null); assert(items != null && items.isNotEmpty); assert(debugCheckHasMaterialLocalizations(context)); String label = semanticLabel; diff --git a/packages/flutter/lib/src/material/raised_button.dart b/packages/flutter/lib/src/material/raised_button.dart index 6209bfd945..f12583a071 100644 --- a/packages/flutter/lib/src/material/raised_button.dart +++ b/packages/flutter/lib/src/material/raised_button.dart @@ -36,37 +36,53 @@ import 'theme_data.dart'; /// This sample shows how to render a disabled RaisedButton, an enabled RaisedButton /// and lastly a RaisedButton with gradient background. /// +/// ![Three raised buttons, one enabled, another disabled, and the last one +/// styled with a blue gradient background](https://flutter.github.io/assets-for-api-docs/assets/material/raised_button.png) +/// /// ```dart /// Widget build(BuildContext context) { -/// return Scaffold( -/// body: Center( -/// child: Column( -/// mainAxisSize: MainAxisSize.min, -/// children: [ -/// RaisedButton( -/// onPressed: null, -/// child: const Text('Disabled Button'), +/// return Center( +/// child: Column( +/// mainAxisSize: MainAxisSize.min, +/// children: [ +/// const RaisedButton( +/// onPressed: null, +/// child: Text( +/// 'Disabled Button', +/// style: TextStyle(fontSize: 20) /// ), -/// RaisedButton( -/// onPressed: () {}, -/// child: const Text('Enabled Button'), +/// ), +/// const SizedBox(height: 30), +/// RaisedButton( +/// onPressed: () {}, +/// child: const Text( +/// 'Enabled Button', +/// style: TextStyle(fontSize: 20) /// ), -/// RaisedButton( -/// onPressed: () {}, -/// textColor: Colors.white, -/// padding: const EdgeInsets.all(0.0), -/// child: Container( -/// decoration: const BoxDecoration( -/// gradient: LinearGradient( -/// colors: [Colors.red, Colors.green, Colors.blue], -/// ), +/// ), +/// const SizedBox(height: 30), +/// RaisedButton( +/// onPressed: () {}, +/// textColor: Colors.white, +/// padding: const EdgeInsets.all(0.0), +/// child: Container( +/// decoration: const BoxDecoration( +/// gradient: LinearGradient( +/// colors: [ +/// Color(0xFF0D47A1), +/// Color(0xFF1976D2), +/// Color(0xFF42A5F5), +/// ], /// ), -/// padding: const EdgeInsets.all(10.0), -/// child: Text('Gradient Button'), +/// ), +/// padding: const EdgeInsets.all(10.0), +/// child: const Text( +/// 'Gradient Button', +/// style: TextStyle(fontSize: 20) /// ), /// ), -/// ], -/// ), +/// ), +/// ], /// ), /// ); /// } diff --git a/packages/flutter/lib/src/material/theme.dart b/packages/flutter/lib/src/material/theme.dart index cb62caeea4..0cea75d669 100644 --- a/packages/flutter/lib/src/material/theme.dart +++ b/packages/flutter/lib/src/material/theme.dart @@ -142,18 +142,18 @@ class Theme extends StatelessWidget { Widget build(BuildContext context) { return _InheritedTheme( theme: this, - child: IconTheme( - data: data.iconTheme, - child: CupertinoTheme( - // We're using a MaterialBasedCupertinoThemeData here instead of a - // CupertinoThemeData because it defers some properties to the Material - // ThemeData. - data: MaterialBasedCupertinoThemeData( - materialTheme: data, - ), + child: CupertinoTheme( + // We're using a MaterialBasedCupertinoThemeData here instead of a + // CupertinoThemeData because it defers some properties to the Material + // ThemeData. + data: MaterialBasedCupertinoThemeData( + materialTheme: data, + ), + child: IconTheme( + data: data.iconTheme, child: child, ), - ), + ) ); } diff --git a/packages/flutter/lib/src/material/tooltip.dart b/packages/flutter/lib/src/material/tooltip.dart index 8341b24f35..46a20b1b6e 100644 --- a/packages/flutter/lib/src/material/tooltip.dart +++ b/packages/flutter/lib/src/material/tooltip.dart @@ -22,6 +22,8 @@ const Duration _kShowDuration = Duration(milliseconds: 1500); /// show a label when the widget long pressed (or when the user takes some /// other appropriate action). /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=EeEfD5fI-5Q} +/// /// Many widgets, such as [IconButton], [FloatingActionButton], and /// [PopupMenuButton] have a `tooltip` property that, when non-null, causes the /// widget to include a [Tooltip] in its build. diff --git a/packages/flutter/lib/src/material/user_accounts_drawer_header.dart b/packages/flutter/lib/src/material/user_accounts_drawer_header.dart index 0efde2baef..0f88add36e 100644 --- a/packages/flutter/lib/src/material/user_accounts_drawer_header.dart +++ b/packages/flutter/lib/src/material/user_accounts_drawer_header.dart @@ -113,8 +113,12 @@ class _AccountDetailsState extends State<_AccountDetails> with SingleTickerProvi @override void didUpdateWidget (_AccountDetails oldWidget) { super.didUpdateWidget(oldWidget); - if (_animation.status == AnimationStatus.dismissed || - _animation.status == AnimationStatus.reverse) { + // If the state of the arrow did not change, there is no need to trigger the animation + if (oldWidget.isOpen == widget.isOpen) { + return; + } + + if (widget.isOpen) { _controller.forward(); } else { _controller.reverse(); diff --git a/packages/flutter/lib/src/painting/box_border.dart b/packages/flutter/lib/src/painting/box_border.dart index e367d7af2b..375013b4f7 100644 --- a/packages/flutter/lib/src/painting/box_border.dart +++ b/packages/flutter/lib/src/painting/box_border.dart @@ -314,6 +314,16 @@ class Border extends BoxBorder { assert(bottom != null), assert(left != null); + /// Creates a border whose sides are all the same. + /// + /// The `side` argument must not be null. + const Border.uniform(BorderSide side) + : assert(side != null), + top = side, + right = side, + bottom = side, + left = side; + /// A uniform border with all sides the same color and width. /// /// The sides default to black solid borders, one logical pixel wide. @@ -323,7 +333,7 @@ class Border extends BoxBorder { BorderStyle style = BorderStyle.solid, }) { final BorderSide side = BorderSide(color: color, width: width, style: style); - return Border(top: side, right: side, bottom: side, left: side); + return Border.uniform(side); } /// Creates a [Border] that represents the addition of the two given diff --git a/packages/flutter/lib/src/painting/flutter_logo.dart b/packages/flutter/lib/src/painting/flutter_logo.dart index 4673335891..fa84292023 100644 --- a/packages/flutter/lib/src/painting/flutter_logo.dart +++ b/packages/flutter/lib/src/painting/flutter_logo.dart @@ -53,7 +53,7 @@ class FlutterLogoDecoration extends Decoration { assert(textColor != null), assert(style != null), assert(margin != null), - _position = style == FlutterLogoStyle.markOnly ? 0.0 : style == FlutterLogoStyle.horizontal ? 1.0 : -1.0, // ignore: CONST_EVAL_TYPE_BOOL_NUM_STRING + _position = identical(style, FlutterLogoStyle.markOnly) ? 0.0 : identical(style, FlutterLogoStyle.horizontal) ? 1.0 : -1.0, // (see https://github.com/dart-lang/sdk/issues/26980 for details about that ignore statement) _opacity = 1.0; diff --git a/packages/flutter/lib/src/painting/image_provider.dart b/packages/flutter/lib/src/painting/image_provider.dart index 39233aa47c..b414d6ccb8 100644 --- a/packages/flutter/lib/src/painting/image_provider.dart +++ b/packages/flutter/lib/src/painting/image_provider.dart @@ -262,7 +262,12 @@ abstract class ImageProvider { assert(configuration != null); final ImageStream stream = ImageStream(); T obtainedKey; + bool didError = false; Future handleError(dynamic exception, StackTrace stack) async { + if (didError) { + return; + } + didError = true; await null; // wait an event turn in case a listener has been added to the image stream. final _ErrorImageCompleter imageCompleter = _ErrorImageCompleter(); stream.setCompleter(imageCompleter); @@ -281,27 +286,38 @@ abstract class ImageProvider { ); } - // `obtainKey` can throw both sync and async errors. - // `catchError` handles cases where async errors are thrown and the try block is for sync errors. - // - // `onError` callback on [ImageCache] handles the cases where `obtainKey` is a sync future and `load` throws. - Future key; - try { - key = obtainKey(configuration); - } catch (error, stackTrace) { - handleError(error, stackTrace); - return stream; - } - - key.then((T key) { - obtainedKey = key; - final ImageStreamCompleter completer = PaintingBinding.instance - .imageCache.putIfAbsent(key, () => load(key), onError: handleError); - if (completer != null) { - stream.setCompleter(completer); + // If an error is added to a synchronous completer before a listener has been + // added, it can throw an error both into the zone and up the stack. Thus, it + // looks like the error has been caught, but it is in fact also bubbling to the + // zone. Since we cannot prevent all usage of Completer.sync here, or rather + // that changing them would be too breaking, we instead hook into the same + // zone mechanism to intercept the uncaught error and deliver it to the + // image stream's error handler. Note that these errors may be duplicated, + // hence the need for the `didError` flag. + final Zone dangerZone = Zone.current.fork( + specification: ZoneSpecification( + handleUncaughtError: (Zone zone, ZoneDelegate delegate, Zone parent, Object error, StackTrace stackTrace) { + handleError(error, stackTrace); + } + ) + ); + dangerZone.runGuarded(() { + Future key; + try { + key = obtainKey(configuration); + } catch (error, stackTrace) { + handleError(error, stackTrace); + return; } - }).catchError(handleError); - + key.then((T key) { + obtainedKey = key; + final ImageStreamCompleter completer = PaintingBinding.instance + .imageCache.putIfAbsent(key, () => load(key), onError: handleError); + if (completer != null) { + stream.setCompleter(completer); + } + }).catchError(handleError); + }); return stream; } diff --git a/packages/flutter/lib/src/painting/image_stream.dart b/packages/flutter/lib/src/painting/image_stream.dart index 792852a189..c560f874f2 100644 --- a/packages/flutter/lib/src/painting/image_stream.dart +++ b/packages/flutter/lib/src/painting/image_stream.dart @@ -508,9 +508,7 @@ class MultiFrameImageStreamCompleter extends ImageStreamCompleter { InformationCollector informationCollector, }) : assert(codec != null), _informationCollector = informationCollector, - _scale = scale, - _framesEmitted = 0, - _timer = null { + _scale = scale { codec.then(_handleCodecReady, onError: (dynamic error, StackTrace stack) { reportError( context: 'resolving an image codec', @@ -531,17 +529,23 @@ class MultiFrameImageStreamCompleter extends ImageStreamCompleter { // The requested duration for the current frame; Duration _frameDuration; // How many frames have been emitted so far. - int _framesEmitted; + int _framesEmitted = 0; Timer _timer; + // Used to guard against registering multiple _handleAppFrame callbacks for the same frame. + bool _frameCallbackScheduled = false; + void _handleCodecReady(ui.Codec codec) { _codec = codec; assert(_codec != null); - _decodeNextFrameAndSchedule(); + if (hasListeners) { + _decodeNextFrameAndSchedule(); + } } void _handleAppFrame(Duration timestamp) { + _frameCallbackScheduled = false; if (!hasListeners) return; if (_isFirstFrame() || _hasFrameDurationPassed(timestamp)) { @@ -557,7 +561,7 @@ class MultiFrameImageStreamCompleter extends ImageStreamCompleter { } final Duration delay = _frameDuration - (timestamp - _shownTimestamp); _timer = Timer(delay * timeDilation, () { - SchedulerBinding.instance.scheduleFrameCallback(_handleAppFrame); + _scheduleAppFrame(); }); } @@ -589,6 +593,14 @@ class MultiFrameImageStreamCompleter extends ImageStreamCompleter { _emitFrame(ImageInfo(image: _nextFrame.image, scale: _scale)); return; } + _scheduleAppFrame(); + } + + void _scheduleAppFrame() { + if (_frameCallbackScheduled) { + return; + } + _frameCallbackScheduled = true; SchedulerBinding.instance.scheduleFrameCallback(_handleAppFrame); } diff --git a/packages/flutter/lib/src/painting/shader_warm_up.dart b/packages/flutter/lib/src/painting/shader_warm_up.dart index f5202c0d72..b6ab733b70 100644 --- a/packages/flutter/lib/src/painting/shader_warm_up.dart +++ b/packages/flutter/lib/src/painting/shader_warm_up.dart @@ -87,9 +87,8 @@ abstract class ShaderWarmUp { final ui.Picture picture = recorder.endRecording(); final TimelineTask shaderWarmUpTask = TimelineTask(); shaderWarmUpTask.start('Warm-up shader'); - picture.toImage(size.width.ceil(), size.height.ceil()).then((ui.Image image) { - shaderWarmUpTask.finish(); - }); + await picture.toImage(size.width.ceil(), size.height.ceil()); + shaderWarmUpTask.finish(); } } diff --git a/packages/flutter/lib/src/painting/text_painter.dart b/packages/flutter/lib/src/painting/text_painter.dart index 9c922a98ba..c558b588df 100644 --- a/packages/flutter/lib/src/painting/text_painter.dart +++ b/packages/flutter/lib/src/painting/text_painter.dart @@ -15,6 +15,16 @@ import 'text_span.dart'; export 'package:flutter/services.dart' show TextRange, TextSelection; +class _CaretMetrics { + const _CaretMetrics({this.offset, this.fullHeight}); + /// The offset of the top left corner of the caret from the top left + /// corner of the paragraph. + final Offset offset; + + /// The full height of the glyph at the caret position. + final double fullHeight; +} + /// An object that paints a [TextSpan] tree into a [Canvas]. /// /// To use a [TextPainter], follow these steps: @@ -444,11 +454,11 @@ class TextPainter { // Unicode value for a zero width joiner character. static const int _zwjUtf16 = 0x200d; - // Get the Offset of the cursor (in logical pixels) based off the near edge + // Get the Rect of the cursor (in logical pixels) based off the near edge // of the character upstream from the given string offset. // TODO(garyq): Use actual extended grapheme cluster length instead of // an increasing cluster length amount to achieve deterministic performance. - Offset _getOffsetFromUpstream(int offset, Rect caretPrototype) { + Rect _getRectFromUpstream(int offset, Rect caretPrototype) { final String flattenedText = _text.toPlainText(); final int prevCodeUnit = _text.codeUnitAt(max(0, offset - 1)); if (prevCodeUnit == null) @@ -481,21 +491,21 @@ class TextPainter { // If the upstream character is a newline, cursor is at start of next line const int NEWLINE_CODE_UNIT = 10; if (prevCodeUnit == NEWLINE_CODE_UNIT) { - return Offset(_emptyOffset.dx, box.bottom); + return Rect.fromLTRB(_emptyOffset.dx, box.bottom, _emptyOffset.dx, box.bottom + box.bottom - box.top); } final double caretEnd = box.end; final double dx = box.direction == TextDirection.rtl ? caretEnd - caretPrototype.width : caretEnd; - return Offset(dx, box.top); + return Rect.fromLTRB(min(dx, width), box.top, min(dx, width), box.bottom); } return null; } - // Get the Offset of the cursor (in logical pixels) based off the near edge + // Get the Rect of the cursor (in logical pixels) based off the near edge // of the character downstream from the given string offset. // TODO(garyq): Use actual extended grapheme cluster length instead of // an increasing cluster length amount to achieve deterministic performance. - Offset _getOffsetFromDownstream(int offset, Rect caretPrototype) { + Rect _getRectFromDownstream(int offset, Rect caretPrototype) { final String flattenedText = _text.toPlainText(); // We cap the offset at the final index of the _text. final int nextCodeUnit = _text.codeUnitAt(min(offset, flattenedText == null ? 0 : flattenedText.length - 1)); @@ -526,7 +536,7 @@ class TextPainter { final TextBox box = boxes.last; final double caretStart = box.start; final double dx = box.direction == TextDirection.rtl ? caretStart - caretPrototype.width : caretStart; - return Offset(dx, box.top); + return Rect.fromLTRB(min(dx, width), box.top, min(dx, width), box.bottom); } return null; } @@ -568,20 +578,52 @@ class TextPainter { /// /// Valid only after [layout] has been called. Offset getOffsetForCaret(TextPosition position, Rect caretPrototype) { + _computeCaretMetrics(position, caretPrototype); + return _caretMetrics.offset; + } + + /// Returns the tight bounded height of the glyph at the given [position]. + /// + /// Valid only after [layout] has been called. + double getFullHeightForCaret(TextPosition position, Rect caretPrototype) { + _computeCaretMetrics(position, caretPrototype); + return _caretMetrics.fullHeight; + } + + // Cached caret metrics. This allows multiple invokes of [getOffsetForCaret] and + // [getFullHeightForCaret] in a row without performing redundant and expensive + // get rect calls to the paragraph. + _CaretMetrics _caretMetrics; + + // Holds the TextPosition and caretPrototype the last caret metrics were + // computed with. When new values are passed in, we recompute the caret metrics. + // only as nessecary. + TextPosition _previousCaretPosition; + Rect _previousCaretPrototype; + + // Checks if the [position] and [caretPrototype] have changed from the cached + // version and recomputes the metrics required to position the caret. + void _computeCaretMetrics(TextPosition position, Rect caretPrototype) { assert(!_needsLayout); + if (position == _previousCaretPosition && caretPrototype == _previousCaretPrototype) + return; final int offset = position.offset; assert(position.affinity != null); + Rect rect; switch (position.affinity) { - case TextAffinity.upstream: - return _getOffsetFromUpstream(offset, caretPrototype) - ?? _getOffsetFromDownstream(offset, caretPrototype) - ?? _emptyOffset; - case TextAffinity.downstream: - return _getOffsetFromDownstream(offset, caretPrototype) - ?? _getOffsetFromUpstream(offset, caretPrototype) - ?? _emptyOffset; + case TextAffinity.upstream: { + rect = _getRectFromUpstream(offset, caretPrototype) ?? _getRectFromDownstream(offset, caretPrototype); + break; + } + case TextAffinity.downstream: { + rect = _getRectFromDownstream(offset, caretPrototype) ?? _getRectFromUpstream(offset, caretPrototype); + break; + } } - return null; + _caretMetrics = _CaretMetrics( + offset: rect != null ? Offset(rect.left, rect.top) : _emptyOffset, + fullHeight: rect != null ? rect.bottom - rect.top : null, + ); } /// Returns a list of rects that bound the given selection. diff --git a/packages/flutter/lib/src/painting/text_span.dart b/packages/flutter/lib/src/painting/text_span.dart index d139783b68..bba61a7d09 100644 --- a/packages/flutter/lib/src/painting/text_span.dart +++ b/packages/flutter/lib/src/painting/text_span.dart @@ -58,6 +58,7 @@ class TextSpan extends DiagnosticableTree { this.text, this.children, this.recognizer, + this.semanticsLabel, }); /// The style to apply to the [text] and the [children]. @@ -156,6 +157,19 @@ class TextSpan extends DiagnosticableTree { /// {@end-tool} final GestureRecognizer recognizer; + /// An alternative semantics label for this text. + /// + /// If present, the semantics of this span will contain this value instead + /// of the actual text. + /// + /// This is useful for replacing abbreviations or shorthands with the full + /// text value: + /// + /// ```dart + /// TextSpan(text: r'$$', semanticsLabel: 'Double dollars') + /// ``` + final String semanticsLabel; + /// Apply the [style], [text], and [children] of this object to the /// given [ParagraphBuilder], from which a [Paragraph] can be obtained. /// [Paragraph] objects can be drawn on [Canvas] objects. @@ -220,12 +234,18 @@ class TextSpan extends DiagnosticableTree { /// Flattens the [TextSpan] tree into a single string. /// - /// Styles are not honored in this process. - String toPlainText() { + /// Styles are not honored in this process. If `includeSemanticsLabels` is + /// true, then the text returned will include the [semanticsLabel]s instead of + /// the text contents when they are present. + String toPlainText({bool includeSemanticsLabels = true}) { assert(debugAssertIsValid()); final StringBuffer buffer = StringBuffer(); visitTextSpan((TextSpan span) { - buffer.write(span.text); + if (span.semanticsLabel != null && includeSemanticsLabels) { + buffer.write(span.semanticsLabel); + } else { + buffer.write(span.text); + } return true; }); return buffer.toString(); @@ -324,11 +344,12 @@ class TextSpan extends DiagnosticableTree { return typedOther.text == text && typedOther.style == style && typedOther.recognizer == recognizer + && typedOther.semanticsLabel == semanticsLabel && listEquals(typedOther.children, children); } @override - int get hashCode => hashValues(style, text, recognizer, hashList(children)); + int get hashCode => hashValues(style, text, recognizer, semanticsLabel, hashList(children)); @override String toStringShort() => '$runtimeType'; @@ -348,6 +369,12 @@ class TextSpan extends DiagnosticableTree { defaultValue: null, )); + + if (semanticsLabel != null) { + properties.add(StringProperty('semanticsLabel', semanticsLabel)); + } + + properties.add(StringProperty('text', text, showName: false, defaultValue: null)); if (style == null && text == null && children == null) properties.add(DiagnosticsNode.message('(empty)')); diff --git a/packages/flutter/lib/src/rendering/binding.dart b/packages/flutter/lib/src/rendering/binding.dart index 7b8a044f18..261b5669fb 100644 --- a/packages/flutter/lib/src/rendering/binding.dart +++ b/packages/flutter/lib/src/rendering/binding.dart @@ -87,6 +87,17 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture return Future.value(); }, ); + registerBoolServiceExtension( + name: 'debugCheckElevationsEnabled', + getter: () async => debugCheckElevationsEnabled, + setter: (bool value) { + if (debugCheckElevationsEnabled == value) { + return Future.value(); + } + debugCheckElevationsEnabled = value; + return _forceRepaint(); + } + ); registerSignalServiceExtension( name: 'debugDumpLayerTree', callback: () { diff --git a/packages/flutter/lib/src/rendering/box.dart b/packages/flutter/lib/src/rendering/box.dart index 283d734b9b..a23a2347ae 100644 --- a/packages/flutter/lib/src/rendering/box.dart +++ b/packages/flutter/lib/src/rendering/box.dart @@ -1756,7 +1756,7 @@ abstract class RenderBox extends RenderObject { ' $constraints\n' 'The exact size it was given was:\n' ' $_size\n' - 'See https://flutter.io/layout/ for more information.' + 'See https://flutter.dev/layout/ for more information.' ); } // verify that the size is within the constraints diff --git a/packages/flutter/lib/src/rendering/custom_paint.dart b/packages/flutter/lib/src/rendering/custom_paint.dart index a8c24f8812..f8a9e461b2 100644 --- a/packages/flutter/lib/src/rendering/custom_paint.dart +++ b/packages/flutter/lib/src/rendering/custom_paint.dart @@ -39,6 +39,8 @@ typedef SemanticsBuilderCallback = List Function(Size si /// is provided, to check if the new instance actually represents different /// information. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=vvI_NUXK00s} +/// /// The most efficient way to trigger a repaint is to either: /// /// * Extend this class and supply a `repaint` argument to the constructor of diff --git a/packages/flutter/lib/src/rendering/debug.dart b/packages/flutter/lib/src/rendering/debug.dart index ebdded6928..86a384111b 100644 --- a/packages/flutter/lib/src/rendering/debug.dart +++ b/packages/flutter/lib/src/rendering/debug.dart @@ -50,6 +50,44 @@ bool debugRepaintRainbowEnabled = false; /// Overlay a rotating set of colors when repainting text in checked mode. bool debugRepaintTextRainbowEnabled = false; +/// Causes [PhysicalModelLayer]s to paint a red rectangle around themselves if +/// they are overlapping and painted out of order with regard to their elevation. +/// +/// Android and iOS will show the last painted layer on top, whereas Fuchsia +/// will show the layer with the highest elevation on top. +/// +/// For example, a rectangular elevation at 3.0 that is painted before an +/// overlapping rectangular elevation at 2.0 would render this way on Android +/// and iOS (with fake shadows): +/// ``` +/// ┌───────────────────┐ +/// │ │ +/// │ 3.0 │ +/// │ ┌───────────────────┐ +/// │ │ │ +/// └────────────│ │ +/// │ 2.0 │ +/// │ │ +/// └───────────────────┘ +/// ``` +/// +/// But this way on Fuchsia (with real shadows): +/// ``` +/// ┌───────────────────┐ +/// │ │ +/// │ 3.0 │ +/// │ │────────────┐ +/// │ │ │ +/// └───────────────────┘ │ +/// │ 2.0 │ +/// │ │ +/// └───────────────────┘ +/// ``` +/// +/// This check helps developers that want a consistent look and feel detect +/// where this inconsistency would occur. +bool debugCheckElevationsEnabled = false; + /// The current color to overlay when repainting a layer. /// /// This is used by painting debug code that implements diff --git a/packages/flutter/lib/src/rendering/editable.dart b/packages/flutter/lib/src/rendering/editable.dart index eb0190bae5..92381fc775 100644 --- a/packages/flutter/lib/src/rendering/editable.dart +++ b/packages/flutter/lib/src/rendering/editable.dart @@ -196,7 +196,6 @@ class RenderEditable extends RenderBox { _cursorColor = cursorColor, _backgroundCursorColor = backgroundCursorColor, _showCursor = showCursor ?? ValueNotifier(false), - _hasFocus = hasFocus ?? false, _maxLines = maxLines, _minLines = minLines, _expands = expands, @@ -213,6 +212,7 @@ class RenderEditable extends RenderBox { _obscureText = obscureText { assert(_showCursor != null); assert(!_showCursor.value || cursorColor != null); + this.hasFocus = hasFocus ?? false; _tap = TapGestureRecognizer(debugOwner: this) ..onTapDown = _handleTapDown ..onTap = _handleTap; @@ -707,7 +707,7 @@ class RenderEditable extends RenderBox { /// Whether the editable is currently focused. bool get hasFocus => _hasFocus; - bool _hasFocus; + bool _hasFocus = false; bool _listenerAttached = false; set hasFocus(bool value) { assert(value != null); @@ -723,7 +723,6 @@ class RenderEditable extends RenderBox { RawKeyboard.instance.removeListener(_handleKeyEvent); _listenerAttached = false; } - markNeedsSemanticsUpdate(); } @@ -1477,6 +1476,13 @@ class RenderEditable extends RenderBox { _textLayoutLastWidth = constraintWidth; } + // TODO(garyq): This is no longer producing the highest-fidelity caret + // heights for Android, especially when non-alphabetic languages + // are involved. The current implementation overrides the height set + // here with the full measured height of the text on Android which looks + // superior (subjectively and in terms of fidelity). We should rework + // this properly to once again match the platform. + // /// On iOS, the cursor is taller than the the cursor on Android. The height /// of the cursor for iOS is approximate and obtained through an eyeball /// comparison. @@ -1521,17 +1527,28 @@ class RenderEditable extends RenderBox { void _paintCaret(Canvas canvas, Offset effectiveOffset, TextPosition textPosition) { assert(_textLayoutLastWidth == constraints.maxWidth); - final Offset caretOffset = _textPainter.getOffsetForCaret(textPosition, _caretPrototype); // If the floating cursor is enabled, the text cursor's color is [backgroundCursorColor] while // the floating cursor's color is _cursorColor; final Paint paint = Paint() ..color = _floatingCursorOn ? backgroundCursorColor : _cursorColor; - Rect caretRect = _caretPrototype.shift(caretOffset + effectiveOffset); + Rect caretRect = _caretPrototype.shift(_textPainter.getOffsetForCaret(textPosition, _caretPrototype) + effectiveOffset); if (_cursorOffset != null) caretRect = caretRect.shift(_cursorOffset); + // Override the height to take the full height of the glyph at the TextPosition + // when not on iOS. iOS has special handling that creates a taller caret. + // TODO(garyq): See the TODO for _getCaretPrototype. + if (defaultTargetPlatform != TargetPlatform.iOS && _textPainter.getFullHeightForCaret(textPosition, _caretPrototype) != null) { + caretRect = Rect.fromLTRB( + caretRect.left, + (caretRect.bottom + caretRect.top) / 2 - (_textPainter.getFullHeightForCaret(textPosition, _caretPrototype) / 2), + caretRect.right, + (caretRect.bottom + caretRect.top) / 2 + (_textPainter.getFullHeightForCaret(textPosition, _caretPrototype) / 2), + ); + } + caretRect = caretRect.shift(_getPixelPerfectCursorOffset(caretRect)); if (cursorRadius == null) { diff --git a/packages/flutter/lib/src/rendering/flex.dart b/packages/flutter/lib/src/rendering/flex.dart index 5468ee3b8f..3208df716d 100644 --- a/packages/flutter/lib/src/rendering/flex.dart +++ b/packages/flutter/lib/src/rendering/flex.dart @@ -508,7 +508,6 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin 0 || crossAxisAlignment == CrossAxisAlignment.baseline) { final double spacePerFlex = canFlex && totalFlex > 0 ? (freeSpace / totalFlex) : double.nan; child = firstChild; + double maxSizeAboveBaseline = 0; + double maxSizeBelowBaseline = 0; while (child != null) { final int flex = _getFlex(child); if (flex > 0) { @@ -809,8 +810,18 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin _processConflictingPhysicalLayers(PhysicalModelLayer predecessor, PhysicalModelLayer child) { + FlutterError.reportError(FlutterErrorDetails( + exception: FlutterError('Painting order is out of order with respect to elevation.\n' + 'See https://api.flutter.dev/flutter/rendering/debugCheckElevations.html ' + 'for more details.'), + library: 'rendering library', + context: 'during compositing', + informationCollector: (StringBuffer buffer) { + buffer.writeln('Attempted to composite layer:'); + buffer.writeln(child); + buffer.writeln('after layer:'); + buffer.writeln(predecessor); + buffer.writeln('which occupies the same area at a higher elevation.'); + } + )); + return [ + _highlightConflictingLayer(predecessor), + _highlightConflictingLayer(child), + ]; + } + + /// Checks that no [PhysicalModelLayer] would paint after another overlapping + /// [PhysicalModelLayer] that has a higher elevation. + /// + /// Returns a list of [PictureLayer] objects it added to the tree to highlight + /// bad nodes. These layers should be removed from the tree after building the + /// [Scene]. + List _debugCheckElevations() { + final List physicalModelLayers = depthFirstIterateChildren().whereType().toList(); + final List addedLayers = []; + + for (int i = 0; i < physicalModelLayers.length; i++) { + final PhysicalModelLayer physicalModelLayer = physicalModelLayers[i]; + assert( + physicalModelLayer.lastChild?.debugCreator != physicalModelLayer, + 'debugCheckElevations has either already visited this layer or failed ' + 'to remove the added picture from it.', + ); + double accumulatedElevation = physicalModelLayer.elevation; + Layer ancestor = physicalModelLayer.parent; + while (ancestor != null) { + if (ancestor is PhysicalModelLayer) { + accumulatedElevation += ancestor.elevation; + } + ancestor = ancestor.parent; + } + for (int j = 0; j <= i; j++) { + final PhysicalModelLayer predecessor = physicalModelLayers[j]; + double predecessorAccumulatedElevation = predecessor.elevation; + ancestor = predecessor.parent; + while (ancestor != null) { + if (ancestor == predecessor) { + continue; + } + if (ancestor is PhysicalModelLayer) { + predecessorAccumulatedElevation += ancestor.elevation; + } + ancestor = ancestor.parent; + } + if (predecessorAccumulatedElevation <= accumulatedElevation) { + continue; + } + final Path intersection = Path.combine( + PathOperation.intersect, + predecessor._debugTransformedClipPath, + physicalModelLayer._debugTransformedClipPath, + ); + if (intersection != null && intersection.computeMetrics().any((ui.PathMetric metric) => metric.length > 0)) { + addedLayers.addAll(_processConflictingPhysicalLayers(predecessor, physicalModelLayer)); + } + } + } + return addedLayers; + } + @override void updateSubtreeNeedsAddToScene() { super.updateSubtreeNeedsAddToScene(); @@ -679,6 +774,23 @@ class ContainerLayer extends Layer { assert(transform != null); } + /// Returns the descendants of this layer in depth first order. + @visibleForTesting + List depthFirstIterateChildren() { + if (firstChild == null) + return []; + final List children = []; + Layer child = firstChild; + while(child != null) { + children.add(child); + if (child is ContainerLayer) { + children.addAll(child.depthFirstIterateChildren()); + } + child = child.nextSibling; + } + return children; + } + @override List debugDescribeChildren() { final List children = []; @@ -744,9 +856,29 @@ class OffsetLayer extends ContainerLayer { /// Consider this layer as the root and build a scene (a tree of layers) /// in the engine. ui.Scene buildScene(ui.SceneBuilder builder) { + List temporaryLayers; + assert(() { + if (debugCheckElevationsEnabled) { + temporaryLayers = _debugCheckElevations(); + } + return true; + }()); updateSubtreeNeedsAddToScene(); addToScene(builder); - return builder.build(); + final ui.Scene scene = builder.build(); + assert(() { + // We should remove any layers that got added to highlight the incorrect + // PhysicalModelLayers. If we don't, we'll end up adding duplicate layers + // or potentially leaving a physical model that is now correct highlighted + // in red. + if (temporaryLayers != null) { + for (PictureLayer temporaryLayer in temporaryLayers) { + temporaryLayer.remove(); + } + } + return true; + }()); + return scene; } @override @@ -1090,7 +1222,12 @@ class TransformLayer extends OffsetLayer { void applyTransform(Layer child, Matrix4 transform) { assert(child != null); assert(transform != null); - transform.multiply(_lastEffectiveTransform); + assert(_lastEffectiveTransform != null || this.transform != null); + if (_lastEffectiveTransform == null) { + transform.multiply(this.transform); + } else { + transform.multiply(_lastEffectiveTransform); + } } @override @@ -1309,6 +1446,16 @@ class PhysicalModelLayer extends ContainerLayer { } } + Path get _debugTransformedClipPath { + ContainerLayer ancestor = parent; + final Matrix4 matrix = Matrix4.identity(); + while (ancestor != null && ancestor.parent != null) { + ancestor.applyTransform(this, matrix); + ancestor = ancestor.parent; + } + return clipPath.transform(matrix.storage); + } + /// {@macro flutter.widgets.Clip} Clip get clipBehavior => _clipBehavior; Clip _clipBehavior; diff --git a/packages/flutter/lib/src/rendering/object.dart b/packages/flutter/lib/src/rendering/object.dart index b490143860..b2d45c5928 100644 --- a/packages/flutter/lib/src/rendering/object.dart +++ b/packages/flutter/lib/src/rendering/object.dart @@ -2663,6 +2663,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im @protected @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); properties.add(DiagnosticsProperty('creator', debugCreator, defaultValue: null, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty('parentData', parentData, tooltip: _debugCanParentUseSize == true ? 'can use size' : null, missingIfNull: true)); properties.add(DiagnosticsProperty('constraints', constraints, missingIfNull: true)); diff --git a/packages/flutter/lib/src/rendering/paragraph.dart b/packages/flutter/lib/src/rendering/paragraph.dart index a8d205c9c8..2145f2c809 100644 --- a/packages/flutter/lib/src/rendering/paragraph.dart +++ b/packages/flutter/lib/src/rendering/paragraph.dart @@ -475,8 +475,9 @@ class RenderParagraph extends RenderBox { int offset = 0; text.visitTextSpan((TextSpan span) { if (span.recognizer != null && (span.recognizer is TapGestureRecognizer || span.recognizer is LongPressGestureRecognizer)) { + final int length = span.semanticsLabel?.length ?? span.text.length; _recognizerOffsets.add(offset); - _recognizerOffsets.add(offset + span.text.length); + _recognizerOffsets.add(offset + length); _recognizers.add(span.recognizer); } offset += span.text.length; diff --git a/packages/flutter/lib/src/rendering/platform_view.dart b/packages/flutter/lib/src/rendering/platform_view.dart index f596db5ff4..cf4568e646 100644 --- a/packages/flutter/lib/src/rendering/platform_view.dart +++ b/packages/flutter/lib/src/rendering/platform_view.dart @@ -311,8 +311,12 @@ class RenderUiKitView extends RenderBox { UiKitViewController _viewController; set viewController(UiKitViewController viewController) { assert(viewController != null); + final bool needsSemanticsUpdate = _viewController.id != viewController.id; _viewController = viewController; markNeedsPaint(); + if (needsSemanticsUpdate) { + markNeedsSemanticsUpdate(); + } } /// How to behave during hit testing. @@ -399,6 +403,13 @@ class RenderUiKitView extends RenderBox { _lastPointerDownEvent = null; } + @override + void describeSemanticsConfiguration (SemanticsConfiguration config) { + super.describeSemanticsConfiguration(config); + config.isSemanticBoundary = true; + config.platformViewId = _viewController.id; + } + @override void attach(PipelineOwner owner) { super.attach(owner); @@ -715,4 +726,3 @@ class _MotionEventsDispatcher { bool isSinglePointerAction(PointerEvent event) => !(event is PointerDownEvent) && !(event is PointerUpEvent); } - diff --git a/packages/flutter/lib/src/rendering/proxy_box.dart b/packages/flutter/lib/src/rendering/proxy_box.dart index 4062eb6af3..2f0275b6bb 100644 --- a/packages/flutter/lib/src/rendering/proxy_box.dart +++ b/packages/flutter/lib/src/rendering/proxy_box.dart @@ -1709,6 +1709,10 @@ class RenderPhysicalModel extends _RenderPhysicalModelBase { color: color, shadowColor: shadowColor, ); + assert(() { + physicalModel.debugCreator = debugCreator; + return true; + }()); context.pushLayer(physicalModel, super.paint, offset, childPaintBounds: offsetBounds); } } @@ -1799,6 +1803,10 @@ class RenderPhysicalShape extends _RenderPhysicalModelBase { color: color, shadowColor: shadowColor, ); + assert(() { + physicalModel.debugCreator = debugCreator; + return true; + }()); context.pushLayer(physicalModel, super.paint, offset, childPaintBounds: offsetBounds); } } @@ -2535,7 +2543,7 @@ class RenderPointerListener extends RenderProxyBoxWithHitTestBehavior { /// no longer directed towards this receiver. PointerCancelEventListener onPointerCancel; - /// Called when a pointer signal occures over this object. + /// Called when a pointer signal occurs over this object. PointerSignalEventListener onPointerSignal; // Object used for annotation of the layer used for hover hit detection. @@ -2549,6 +2557,8 @@ class RenderPointerListener extends RenderProxyBoxWithHitTestBehavior { MouseTrackerAnnotation get hoverAnnotation => _hoverAnnotation; void _updateAnnotations() { + assert(_onPointerEnter != _hoverAnnotation.onEnter || _onPointerHover != _hoverAnnotation.onHover || _onPointerExit != _hoverAnnotation.onExit, + "Shouldn't call _updateAnnotations if nothing has changed."); if (_hoverAnnotation != null && attached) { RendererBinding.instance.mouseTracker.detachAnnotation(_hoverAnnotation); } @@ -2564,6 +2574,9 @@ class RenderPointerListener extends RenderProxyBoxWithHitTestBehavior { } else { _hoverAnnotation = null; } + // Needs to paint in any case, in order to insert/remove the annotation + // layer associated with the updated _hoverAnnotation. + markNeedsPaint(); } @override diff --git a/packages/flutter/lib/src/rendering/sliver.dart b/packages/flutter/lib/src/rendering/sliver.dart index 3bb9d90c04..4076adb253 100644 --- a/packages/flutter/lib/src/rendering/sliver.dart +++ b/packages/flutter/lib/src/rendering/sliver.dart @@ -686,7 +686,8 @@ class SliverGeometry extends Diagnosticable { /// * [RenderViewport.cacheExtent] for a description of a viewport's cache area. final double cacheExtent; - static const double _epsilon = 1e-10; + /// The epsilon of tolerable double precision error. + static const double precisionErrorTolerance = 1e-10; /// Asserts that this geometry is internally consistent. /// @@ -719,8 +720,8 @@ class SliverGeometry extends Diagnosticable { } verify(maxPaintExtent != null, 'The "maxPaintExtent" is null.'); // If the paintExtent is slightly more than the maxPaintExtent, but the difference is still less - // than epsilon, we will not throw the assert below. - if (paintExtent - maxPaintExtent > _epsilon) { + // than precisionErrorTolerance, we will not throw the assert below. + if (paintExtent - maxPaintExtent > precisionErrorTolerance) { verify(false, 'The "maxPaintExtent" is less than the "paintExtent".\n' + _debugCompareFloats('maxPaintExtent', maxPaintExtent, 'paintExtent', paintExtent) + diff --git a/packages/flutter/lib/src/rendering/sliver_list.dart b/packages/flutter/lib/src/rendering/sliver_list.dart index 801df27873..6baf760d03 100644 --- a/packages/flutter/lib/src/rendering/sliver_list.dart +++ b/packages/flutter/lib/src/rendering/sliver_list.dart @@ -119,7 +119,8 @@ class RenderSliverList extends RenderSliverMultiBoxAdaptor { } final double firstChildScrollOffset = earliestScrollOffset - paintExtentOf(firstChild); - if (firstChildScrollOffset < 0.0) { + // firstChildScrollOffset may contain double precision error + if (firstChildScrollOffset < -SliverGeometry.precisionErrorTolerance) { // The first child doesn't fit within the viewport (underflow) and // there may be additional children above it. Find the real first child // and then correct the scroll position so that there's room for all and diff --git a/packages/flutter/lib/src/rendering/table.dart b/packages/flutter/lib/src/rendering/table.dart index bb0c7d64d5..15468c134b 100644 --- a/packages/flutter/lib/src/rendering/table.dart +++ b/packages/flutter/lib/src/rendering/table.dart @@ -958,8 +958,8 @@ class RenderTable extends RenderBox { deficit -= widths[x] - minWidths[x]; widths[x] = minWidths[x]; } else { - deficit -= availableDelta; - widths[x] -= availableDelta; + deficit -= delta; + widths[x] -= delta; newAvailableColumns += 1; } } diff --git a/packages/flutter/lib/src/rendering/view.dart b/packages/flutter/lib/src/rendering/view.dart index 2d079911e8..0296b98a18 100644 --- a/packages/flutter/lib/src/rendering/view.dart +++ b/packages/flutter/lib/src/rendering/view.dart @@ -250,6 +250,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin } @override + // ignore: MUST_CALL_SUPER void debugFillProperties(DiagnosticPropertiesBuilder properties) { // call to ${super.debugFillProperties(description)} is omitted because the // root superclasses don't include any interesting information for this diff --git a/packages/flutter/lib/src/scheduler/binding.dart b/packages/flutter/lib/src/scheduler/binding.dart index bee7c34d6b..2ede21d5de 100644 --- a/packages/flutter/lib/src/scheduler/binding.dart +++ b/packages/flutter/lib/src/scheduler/binding.dart @@ -74,13 +74,17 @@ class _TaskEntry { Completer completer; void run() { - Timeline.timeSync( - debugLabel ?? 'Scheduled Task', - () { - completer.complete(task()); - }, - flow: flow != null ? Flow.step(flow.id) : null, - ); + if (!kReleaseMode) { + Timeline.timeSync( + debugLabel ?? 'Scheduled Task', + () { + completer.complete(task()); + }, + flow: flow != null ? Flow.step(flow.id) : null, + ); + } else { + completer.complete(task()); + } } } diff --git a/packages/flutter/lib/src/semantics/semantics.dart b/packages/flutter/lib/src/semantics/semantics.dart index 7d5241d1d9..19bc64c643 100644 --- a/packages/flutter/lib/src/semantics/semantics.dart +++ b/packages/flutter/lib/src/semantics/semantics.dart @@ -2048,6 +2048,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); bool hideOwner = true; if (_dirty) { final bool inDirtyNodes = owner != null && owner._dirtyNodes.contains(this); diff --git a/packages/flutter/lib/src/services/keyboard_key.dart b/packages/flutter/lib/src/services/keyboard_key.dart index d04c35b31a..2064013dc8 100644 --- a/packages/flutter/lib/src/services/keyboard_key.dart +++ b/packages/flutter/lib/src/services/keyboard_key.dart @@ -283,11 +283,6 @@ class LogicalKeyboardKey extends Diagnosticable { /// See the function [RawKeyEvent.logicalKey] for more information. static const LogicalKeyboardKey turbo = LogicalKeyboardKey(0x00100000016, debugName: kReleaseMode ? null : 'Turbo'); - /// Represents the logical "Launch Assistant" key on the keyboard. - /// - /// See the function [RawKeyEvent.logicalKey] for more information. - static const LogicalKeyboardKey launchAssistant = LogicalKeyboardKey(0x00100000017, debugName: kReleaseMode ? null : 'Launch Assistant'); - /// Represents the logical "Sleep" key on the keyboard. /// /// See the function [RawKeyEvent.logicalKey] for more information. @@ -298,6 +293,11 @@ class LogicalKeyboardKey extends Diagnosticable { /// See the function [RawKeyEvent.logicalKey] for more information. static const LogicalKeyboardKey wakeUp = LogicalKeyboardKey(0x00100010083, debugName: kReleaseMode ? null : 'Wake Up'); + /// Represents the logical "Display Toggle Int Ext" key on the keyboard. + /// + /// See the function [RawKeyEvent.logicalKey] for more information. + static const LogicalKeyboardKey displayToggleIntExt = LogicalKeyboardKey(0x001000100b5, debugName: kReleaseMode ? null : 'Display Toggle Int Ext'); + /// Represents the logical "Usb Reserved" key on the keyboard. /// /// See the function [RawKeyEvent.logicalKey] for more information. @@ -1303,6 +1303,11 @@ class LogicalKeyboardKey extends Diagnosticable { /// See the function [RawKeyEvent.logicalKey] for more information. static const LogicalKeyboardKey launchScreenSaver = LogicalKeyboardKey(0x001000c01b1, debugName: kReleaseMode ? null : 'Launch Screen Saver'); + /// Represents the logical "Launch Assistant" key on the keyboard. + /// + /// See the function [RawKeyEvent.logicalKey] for more information. + static const LogicalKeyboardKey launchAssistant = LogicalKeyboardKey(0x001000c01cb, debugName: kReleaseMode ? null : 'Launch Assistant'); + /// Represents the logical "Launch Audio Browser" key on the keyboard. /// /// See the function [RawKeyEvent.logicalKey] for more information. @@ -1398,6 +1403,11 @@ class LogicalKeyboardKey extends Diagnosticable { /// See the function [RawKeyEvent.logicalKey] for more information. static const LogicalKeyboardKey mailSend = LogicalKeyboardKey(0x001000c028c, debugName: kReleaseMode ? null : 'Mail Send'); + /// Represents the logical "Show All Windows" key on the keyboard. + /// + /// See the function [RawKeyEvent.logicalKey] for more information. + static const LogicalKeyboardKey showAllWindows = LogicalKeyboardKey(0x001000c029f, debugName: kReleaseMode ? null : 'Show All Windows'); + // A list of all predefined constant LogicalKeyboardKeys so they can be // searched. static const Map _knownLogicalKeys = { @@ -1409,9 +1419,9 @@ class LogicalKeyboardKey extends Diagnosticable { 0x0100000014: suspend, 0x0100000015: resume, 0x0100000016: turbo, - 0x0100000017: launchAssistant, 0x0100010082: sleep, 0x0100010083: wakeUp, + 0x01000100b5: displayToggleIntExt, 0x0100070000: usbReserved, 0x0100070001: usbErrorRollOver, 0x0100070002: usbPostFail, @@ -1613,6 +1623,7 @@ class LogicalKeyboardKey extends Diagnosticable { 0x01000c01ab: spellCheck, 0x01000c01ae: launchKeyboardLayout, 0x01000c01b1: launchScreenSaver, + 0x01000c01cb: launchAssistant, 0x01000c01b7: launchAudioBrowser, 0x01000c0201: newKey, 0x01000c0203: close, @@ -1632,6 +1643,7 @@ class LogicalKeyboardKey extends Diagnosticable { 0x01000c0289: mailReply, 0x01000c028b: mailForward, 0x01000c028c: mailSend, + 0x01000c029f: showAllWindows, }; } @@ -1822,12 +1834,6 @@ class PhysicalKeyboardKey extends Diagnosticable { /// See the function [RawKeyEvent.physicalKey] for more information. static const PhysicalKeyboardKey turbo = PhysicalKeyboardKey(0x00000016, debugName: kReleaseMode ? null : 'Turbo'); - /// Represents the location of the "Launch Assistant" key on a generalized - /// keyboard. - /// - /// See the function [RawKeyEvent.physicalKey] for more information. - static const PhysicalKeyboardKey launchAssistant = PhysicalKeyboardKey(0x00000017, debugName: kReleaseMode ? null : 'Launch Assistant'); - /// Represents the location of the "Sleep" key on a generalized keyboard. /// /// See the function [RawKeyEvent.physicalKey] for more information. @@ -1838,6 +1844,12 @@ class PhysicalKeyboardKey extends Diagnosticable { /// See the function [RawKeyEvent.physicalKey] for more information. static const PhysicalKeyboardKey wakeUp = PhysicalKeyboardKey(0x00010083, debugName: kReleaseMode ? null : 'Wake Up'); + /// Represents the location of the "Display Toggle Int Ext" key on a + /// generalized keyboard. + /// + /// See the function [RawKeyEvent.physicalKey] for more information. + static const PhysicalKeyboardKey displayToggleIntExt = PhysicalKeyboardKey(0x000100b5, debugName: kReleaseMode ? null : 'Display Toggle Int Ext'); + /// Represents the location of the "Usb Reserved" key on a generalized /// keyboard. /// @@ -2912,6 +2924,12 @@ class PhysicalKeyboardKey extends Diagnosticable { /// See the function [RawKeyEvent.physicalKey] for more information. static const PhysicalKeyboardKey launchScreenSaver = PhysicalKeyboardKey(0x000c01b1, debugName: kReleaseMode ? null : 'Launch Screen Saver'); + /// Represents the location of the "Launch Assistant" key on a generalized + /// keyboard. + /// + /// See the function [RawKeyEvent.physicalKey] for more information. + static const PhysicalKeyboardKey launchAssistant = PhysicalKeyboardKey(0x000c01cb, debugName: kReleaseMode ? null : 'Launch Assistant'); + /// Represents the location of the "Launch Audio Browser" key on a generalized /// keyboard. /// @@ -3017,6 +3035,12 @@ class PhysicalKeyboardKey extends Diagnosticable { /// See the function [RawKeyEvent.physicalKey] for more information. static const PhysicalKeyboardKey mailSend = PhysicalKeyboardKey(0x000c028c, debugName: kReleaseMode ? null : 'Mail Send'); + /// Represents the location of the "Show All Windows" key on a generalized + /// keyboard. + /// + /// See the function [RawKeyEvent.physicalKey] for more information. + static const PhysicalKeyboardKey showAllWindows = PhysicalKeyboardKey(0x000c029f, debugName: kReleaseMode ? null : 'Show All Windows'); + // A list of all the predefined constant PhysicalKeyboardKeys so that they // can be searched. static const Map _knownPhysicalKeys = { @@ -3028,9 +3052,9 @@ class PhysicalKeyboardKey extends Diagnosticable { 0x00000014: suspend, 0x00000015: resume, 0x00000016: turbo, - 0x00000017: launchAssistant, 0x00010082: sleep, 0x00010083: wakeUp, + 0x000100b5: displayToggleIntExt, 0x00070000: usbReserved, 0x00070001: usbErrorRollOver, 0x00070002: usbPostFail, @@ -3232,6 +3256,7 @@ class PhysicalKeyboardKey extends Diagnosticable { 0x000c01ab: spellCheck, 0x000c01ae: launchKeyboardLayout, 0x000c01b1: launchScreenSaver, + 0x000c01cb: launchAssistant, 0x000c01b7: launchAudioBrowser, 0x000c0201: newKey, 0x000c0203: close, @@ -3251,5 +3276,6 @@ class PhysicalKeyboardKey extends Diagnosticable { 0x000c0289: mailReply, 0x000c028b: mailForward, 0x000c028c: mailSend, + 0x000c029f: showAllWindows, }; } diff --git a/packages/flutter/lib/src/services/keyboard_maps.dart b/packages/flutter/lib/src/services/keyboard_maps.dart index 0e03e08393..21f0be593e 100644 --- a/packages/flutter/lib/src/services/keyboard_maps.dart +++ b/packages/flutter/lib/src/services/keyboard_maps.dart @@ -15,7 +15,6 @@ import 'keyboard_key.dart'; const Map kAndroidToLogicalKey = { 0: LogicalKeyboardKey.none, 119: LogicalKeyboardKey.fn, - 219: LogicalKeyboardKey.launchAssistant, 223: LogicalKeyboardKey.sleep, 224: LogicalKeyboardKey.wakeUp, 29: LogicalKeyboardKey.keyA, @@ -155,6 +154,7 @@ const Map kAndroidToLogicalKey = kFuchsiaToLogicalKey = kFuchsiaToLogicalKey = kFuchsiaToLogicalKey = kFuchsiaToPhysicalKey = kFuchsiaToPhysicalKey = kFuchsiaToPhysicalKey = kMacOsToPhysicalKey = { 0x00000000: PhysicalKeyboardKey.keyA, @@ -989,3 +993,356 @@ const Map kMacOsNumPadMap = { 0x00000051: LogicalKeyboardKey.numpadEqual, 0x0000005f: LogicalKeyboardKey.numpadComma, }; + +/// Maps GLFW-specific key codes to the matching [LogicalKeyboardKey]. +const Map kGlfwToLogicalKey = { + 65: LogicalKeyboardKey.keyA, + 66: LogicalKeyboardKey.keyB, + 67: LogicalKeyboardKey.keyC, + 68: LogicalKeyboardKey.keyD, + 69: LogicalKeyboardKey.keyE, + 70: LogicalKeyboardKey.keyF, + 71: LogicalKeyboardKey.keyG, + 72: LogicalKeyboardKey.keyH, + 73: LogicalKeyboardKey.keyI, + 74: LogicalKeyboardKey.keyJ, + 75: LogicalKeyboardKey.keyK, + 76: LogicalKeyboardKey.keyL, + 77: LogicalKeyboardKey.keyM, + 78: LogicalKeyboardKey.keyN, + 79: LogicalKeyboardKey.keyO, + 80: LogicalKeyboardKey.keyP, + 81: LogicalKeyboardKey.keyQ, + 82: LogicalKeyboardKey.keyR, + 83: LogicalKeyboardKey.keyS, + 84: LogicalKeyboardKey.keyT, + 85: LogicalKeyboardKey.keyU, + 86: LogicalKeyboardKey.keyV, + 87: LogicalKeyboardKey.keyW, + 88: LogicalKeyboardKey.keyX, + 89: LogicalKeyboardKey.keyY, + 90: LogicalKeyboardKey.keyZ, + 49: LogicalKeyboardKey.digit1, + 50: LogicalKeyboardKey.digit2, + 51: LogicalKeyboardKey.digit3, + 52: LogicalKeyboardKey.digit4, + 53: LogicalKeyboardKey.digit5, + 54: LogicalKeyboardKey.digit6, + 55: LogicalKeyboardKey.digit7, + 56: LogicalKeyboardKey.digit8, + 57: LogicalKeyboardKey.digit9, + 48: LogicalKeyboardKey.digit0, + 257: LogicalKeyboardKey.enter, + 256: LogicalKeyboardKey.escape, + 259: LogicalKeyboardKey.backspace, + 258: LogicalKeyboardKey.tab, + 32: LogicalKeyboardKey.space, + 45: LogicalKeyboardKey.minus, + 61: LogicalKeyboardKey.equal, + 91: LogicalKeyboardKey.bracketLeft, + 93: LogicalKeyboardKey.bracketRight, + 92: LogicalKeyboardKey.backslash, + 59: LogicalKeyboardKey.semicolon, + 39: LogicalKeyboardKey.quote, + 96: LogicalKeyboardKey.backquote, + 44: LogicalKeyboardKey.comma, + 46: LogicalKeyboardKey.period, + 47: LogicalKeyboardKey.slash, + 280: LogicalKeyboardKey.capsLock, + 290: LogicalKeyboardKey.f1, + 291: LogicalKeyboardKey.f2, + 292: LogicalKeyboardKey.f3, + 293: LogicalKeyboardKey.f4, + 294: LogicalKeyboardKey.f5, + 295: LogicalKeyboardKey.f6, + 296: LogicalKeyboardKey.f7, + 297: LogicalKeyboardKey.f8, + 298: LogicalKeyboardKey.f9, + 299: LogicalKeyboardKey.f10, + 300: LogicalKeyboardKey.f11, + 301: LogicalKeyboardKey.f12, + 283: LogicalKeyboardKey.printScreen, + 284: LogicalKeyboardKey.pause, + 260: LogicalKeyboardKey.insert, + 268: LogicalKeyboardKey.home, + 266: LogicalKeyboardKey.pageUp, + 261: LogicalKeyboardKey.delete, + 269: LogicalKeyboardKey.end, + 267: LogicalKeyboardKey.pageDown, + 262: LogicalKeyboardKey.arrowRight, + 263: LogicalKeyboardKey.arrowLeft, + 264: LogicalKeyboardKey.arrowDown, + 265: LogicalKeyboardKey.arrowUp, + 282: LogicalKeyboardKey.numLock, + 331: LogicalKeyboardKey.numpadDivide, + 332: LogicalKeyboardKey.numpadMultiply, + 334: LogicalKeyboardKey.numpadAdd, + 335: LogicalKeyboardKey.numpadEnter, + 321: LogicalKeyboardKey.numpad1, + 322: LogicalKeyboardKey.numpad2, + 323: LogicalKeyboardKey.numpad3, + 324: LogicalKeyboardKey.numpad4, + 325: LogicalKeyboardKey.numpad5, + 326: LogicalKeyboardKey.numpad6, + 327: LogicalKeyboardKey.numpad7, + 328: LogicalKeyboardKey.numpad8, + 329: LogicalKeyboardKey.numpad9, + 320: LogicalKeyboardKey.numpad0, + 330: LogicalKeyboardKey.numpadDecimal, + 348: LogicalKeyboardKey.contextMenu, + 336: LogicalKeyboardKey.numpadEqual, + 302: LogicalKeyboardKey.f13, + 303: LogicalKeyboardKey.f14, + 304: LogicalKeyboardKey.f15, + 305: LogicalKeyboardKey.f16, + 306: LogicalKeyboardKey.f17, + 307: LogicalKeyboardKey.f18, + 308: LogicalKeyboardKey.f19, + 309: LogicalKeyboardKey.f20, + 310: LogicalKeyboardKey.f21, + 311: LogicalKeyboardKey.f22, + 312: LogicalKeyboardKey.f23, + 341: LogicalKeyboardKey.controlLeft, + 340: LogicalKeyboardKey.shiftLeft, + 342: LogicalKeyboardKey.altLeft, + 345: LogicalKeyboardKey.controlRight, + 344: LogicalKeyboardKey.shiftRight, + 346: LogicalKeyboardKey.altRight, +}; + +/// A map of GLFW key codes which have printable representations, but appear +/// on the number pad. Used to provide different key objects for keys like +/// KEY_EQUALS and NUMPAD_EQUALS. +const Map kGlfwNumpadMap = { + 331: LogicalKeyboardKey.numpadDivide, + 332: LogicalKeyboardKey.numpadMultiply, + 334: LogicalKeyboardKey.numpadAdd, + 321: LogicalKeyboardKey.numpad1, + 322: LogicalKeyboardKey.numpad2, + 323: LogicalKeyboardKey.numpad3, + 324: LogicalKeyboardKey.numpad4, + 325: LogicalKeyboardKey.numpad5, + 326: LogicalKeyboardKey.numpad6, + 327: LogicalKeyboardKey.numpad7, + 328: LogicalKeyboardKey.numpad8, + 329: LogicalKeyboardKey.numpad9, + 320: LogicalKeyboardKey.numpad0, + 330: LogicalKeyboardKey.numpadDecimal, + 336: LogicalKeyboardKey.numpadEqual, +}; + +/// Maps XKB specific key code values representing [PhysicalKeyboardKey]. +const Map kLinuxToPhysicalKey = { + 0x00000096: PhysicalKeyboardKey.sleep, + 0x00000097: PhysicalKeyboardKey.wakeUp, + 0x000000eb: PhysicalKeyboardKey.displayToggleIntExt, + 0x00000026: PhysicalKeyboardKey.keyA, + 0x00000038: PhysicalKeyboardKey.keyB, + 0x00000036: PhysicalKeyboardKey.keyC, + 0x00000028: PhysicalKeyboardKey.keyD, + 0x0000001a: PhysicalKeyboardKey.keyE, + 0x00000029: PhysicalKeyboardKey.keyF, + 0x0000002a: PhysicalKeyboardKey.keyG, + 0x0000002b: PhysicalKeyboardKey.keyH, + 0x0000001f: PhysicalKeyboardKey.keyI, + 0x0000002c: PhysicalKeyboardKey.keyJ, + 0x0000002d: PhysicalKeyboardKey.keyK, + 0x0000002e: PhysicalKeyboardKey.keyL, + 0x0000003a: PhysicalKeyboardKey.keyM, + 0x00000039: PhysicalKeyboardKey.keyN, + 0x00000020: PhysicalKeyboardKey.keyO, + 0x00000021: PhysicalKeyboardKey.keyP, + 0x00000018: PhysicalKeyboardKey.keyQ, + 0x0000001b: PhysicalKeyboardKey.keyR, + 0x00000027: PhysicalKeyboardKey.keyS, + 0x0000001c: PhysicalKeyboardKey.keyT, + 0x0000001e: PhysicalKeyboardKey.keyU, + 0x00000037: PhysicalKeyboardKey.keyV, + 0x00000019: PhysicalKeyboardKey.keyW, + 0x00000035: PhysicalKeyboardKey.keyX, + 0x0000001d: PhysicalKeyboardKey.keyY, + 0x00000034: PhysicalKeyboardKey.keyZ, + 0x0000000a: PhysicalKeyboardKey.digit1, + 0x0000000b: PhysicalKeyboardKey.digit2, + 0x0000000c: PhysicalKeyboardKey.digit3, + 0x0000000d: PhysicalKeyboardKey.digit4, + 0x0000000e: PhysicalKeyboardKey.digit5, + 0x0000000f: PhysicalKeyboardKey.digit6, + 0x00000010: PhysicalKeyboardKey.digit7, + 0x00000011: PhysicalKeyboardKey.digit8, + 0x00000012: PhysicalKeyboardKey.digit9, + 0x00000013: PhysicalKeyboardKey.digit0, + 0x00000024: PhysicalKeyboardKey.enter, + 0x00000009: PhysicalKeyboardKey.escape, + 0x00000016: PhysicalKeyboardKey.backspace, + 0x00000017: PhysicalKeyboardKey.tab, + 0x00000041: PhysicalKeyboardKey.space, + 0x00000014: PhysicalKeyboardKey.minus, + 0x00000015: PhysicalKeyboardKey.equal, + 0x00000022: PhysicalKeyboardKey.bracketLeft, + 0x00000023: PhysicalKeyboardKey.bracketRight, + 0x00000033: PhysicalKeyboardKey.backslash, + 0x0000002f: PhysicalKeyboardKey.semicolon, + 0x00000030: PhysicalKeyboardKey.quote, + 0x00000031: PhysicalKeyboardKey.backquote, + 0x0000003b: PhysicalKeyboardKey.comma, + 0x0000003c: PhysicalKeyboardKey.period, + 0x0000003d: PhysicalKeyboardKey.slash, + 0x00000042: PhysicalKeyboardKey.capsLock, + 0x00000043: PhysicalKeyboardKey.f1, + 0x00000044: PhysicalKeyboardKey.f2, + 0x00000045: PhysicalKeyboardKey.f3, + 0x00000046: PhysicalKeyboardKey.f4, + 0x00000047: PhysicalKeyboardKey.f5, + 0x00000048: PhysicalKeyboardKey.f6, + 0x00000049: PhysicalKeyboardKey.f7, + 0x0000004a: PhysicalKeyboardKey.f8, + 0x0000004b: PhysicalKeyboardKey.f9, + 0x0000004c: PhysicalKeyboardKey.f10, + 0x0000005f: PhysicalKeyboardKey.f11, + 0x00000060: PhysicalKeyboardKey.f12, + 0x0000006b: PhysicalKeyboardKey.printScreen, + 0x0000004e: PhysicalKeyboardKey.scrollLock, + 0x0000007f: PhysicalKeyboardKey.pause, + 0x00000076: PhysicalKeyboardKey.insert, + 0x0000006e: PhysicalKeyboardKey.home, + 0x00000070: PhysicalKeyboardKey.pageUp, + 0x00000077: PhysicalKeyboardKey.delete, + 0x00000073: PhysicalKeyboardKey.end, + 0x00000075: PhysicalKeyboardKey.pageDown, + 0x00000072: PhysicalKeyboardKey.arrowRight, + 0x00000071: PhysicalKeyboardKey.arrowLeft, + 0x00000074: PhysicalKeyboardKey.arrowDown, + 0x0000006f: PhysicalKeyboardKey.arrowUp, + 0x0000004d: PhysicalKeyboardKey.numLock, + 0x0000006a: PhysicalKeyboardKey.numpadDivide, + 0x0000003f: PhysicalKeyboardKey.numpadMultiply, + 0x00000052: PhysicalKeyboardKey.numpadSubtract, + 0x00000056: PhysicalKeyboardKey.numpadAdd, + 0x00000068: PhysicalKeyboardKey.numpadEnter, + 0x00000057: PhysicalKeyboardKey.numpad1, + 0x00000058: PhysicalKeyboardKey.numpad2, + 0x00000059: PhysicalKeyboardKey.numpad3, + 0x00000053: PhysicalKeyboardKey.numpad4, + 0x00000054: PhysicalKeyboardKey.numpad5, + 0x00000055: PhysicalKeyboardKey.numpad6, + 0x0000004f: PhysicalKeyboardKey.numpad7, + 0x00000050: PhysicalKeyboardKey.numpad8, + 0x00000051: PhysicalKeyboardKey.numpad9, + 0x0000005a: PhysicalKeyboardKey.numpad0, + 0x0000005b: PhysicalKeyboardKey.numpadDecimal, + 0x0000005e: PhysicalKeyboardKey.intlBackslash, + 0x00000087: PhysicalKeyboardKey.contextMenu, + 0x0000007c: PhysicalKeyboardKey.power, + 0x0000007d: PhysicalKeyboardKey.numpadEqual, + 0x000000bf: PhysicalKeyboardKey.f13, + 0x000000c0: PhysicalKeyboardKey.f14, + 0x000000c1: PhysicalKeyboardKey.f15, + 0x000000c2: PhysicalKeyboardKey.f16, + 0x000000c3: PhysicalKeyboardKey.f17, + 0x000000c4: PhysicalKeyboardKey.f18, + 0x000000c5: PhysicalKeyboardKey.f19, + 0x000000c6: PhysicalKeyboardKey.f20, + 0x000000c7: PhysicalKeyboardKey.f21, + 0x000000c8: PhysicalKeyboardKey.f22, + 0x000000c9: PhysicalKeyboardKey.f23, + 0x000000ca: PhysicalKeyboardKey.f24, + 0x0000008e: PhysicalKeyboardKey.open, + 0x00000092: PhysicalKeyboardKey.help, + 0x0000008c: PhysicalKeyboardKey.select, + 0x00000089: PhysicalKeyboardKey.again, + 0x0000008b: PhysicalKeyboardKey.undo, + 0x00000091: PhysicalKeyboardKey.cut, + 0x0000008d: PhysicalKeyboardKey.copy, + 0x0000008f: PhysicalKeyboardKey.paste, + 0x00000090: PhysicalKeyboardKey.find, + 0x00000079: PhysicalKeyboardKey.audioVolumeMute, + 0x0000007b: PhysicalKeyboardKey.audioVolumeUp, + 0x0000007a: PhysicalKeyboardKey.audioVolumeDown, + 0x00000081: PhysicalKeyboardKey.numpadComma, + 0x00000061: PhysicalKeyboardKey.intlRo, + 0x00000065: PhysicalKeyboardKey.kanaMode, + 0x00000084: PhysicalKeyboardKey.intlYen, + 0x00000064: PhysicalKeyboardKey.convert, + 0x00000066: PhysicalKeyboardKey.nonConvert, + 0x00000082: PhysicalKeyboardKey.lang1, + 0x00000083: PhysicalKeyboardKey.lang2, + 0x00000062: PhysicalKeyboardKey.lang3, + 0x00000063: PhysicalKeyboardKey.lang4, + 0x0000005d: PhysicalKeyboardKey.lang5, + 0x000000bb: PhysicalKeyboardKey.numpadParenLeft, + 0x000000bc: PhysicalKeyboardKey.numpadParenRight, + 0x0000007e: PhysicalKeyboardKey.numpadSignChange, + 0x00000025: PhysicalKeyboardKey.controlLeft, + 0x00000032: PhysicalKeyboardKey.shiftLeft, + 0x00000040: PhysicalKeyboardKey.altLeft, + 0x00000085: PhysicalKeyboardKey.metaLeft, + 0x00000069: PhysicalKeyboardKey.controlRight, + 0x0000003e: PhysicalKeyboardKey.shiftRight, + 0x0000006c: PhysicalKeyboardKey.altRight, + 0x00000086: PhysicalKeyboardKey.metaRight, + 0x0000016e: PhysicalKeyboardKey.info, + 0x0000017a: PhysicalKeyboardKey.closedCaptionToggle, + 0x000000e9: PhysicalKeyboardKey.brightnessUp, + 0x000000e8: PhysicalKeyboardKey.brightnessDown, + 0x000001b7: PhysicalKeyboardKey.brightnessToggle, + 0x00000258: PhysicalKeyboardKey.brightnessMinimum, + 0x00000259: PhysicalKeyboardKey.brightnessMaximum, + 0x000000fc: PhysicalKeyboardKey.brightnessAuto, + 0x0000019d: PhysicalKeyboardKey.mediaLast, + 0x000000b1: PhysicalKeyboardKey.launchPhone, + 0x00000172: PhysicalKeyboardKey.programGuide, + 0x000000b6: PhysicalKeyboardKey.exit, + 0x000001a2: PhysicalKeyboardKey.channelUp, + 0x000001a3: PhysicalKeyboardKey.channelDown, + 0x000000d7: PhysicalKeyboardKey.mediaPlay, + 0x000000af: PhysicalKeyboardKey.mediaRecord, + 0x000000d8: PhysicalKeyboardKey.mediaFastForward, + 0x000000b0: PhysicalKeyboardKey.mediaRewind, + 0x000000ab: PhysicalKeyboardKey.mediaTrackNext, + 0x000000ad: PhysicalKeyboardKey.mediaTrackPrevious, + 0x000000ae: PhysicalKeyboardKey.mediaStop, + 0x000000a9: PhysicalKeyboardKey.eject, + 0x000000ac: PhysicalKeyboardKey.mediaPlayPause, + 0x0000024e: PhysicalKeyboardKey.speechInputToggle, + 0x000000d9: PhysicalKeyboardKey.bassBoost, + 0x000000b3: PhysicalKeyboardKey.mediaSelect, + 0x000001ad: PhysicalKeyboardKey.launchWordProcessor, + 0x000001af: PhysicalKeyboardKey.launchSpreadsheet, + 0x000000a3: PhysicalKeyboardKey.launchMail, + 0x000001b5: PhysicalKeyboardKey.launchContacts, + 0x00000195: PhysicalKeyboardKey.launchCalendar, + 0x00000094: PhysicalKeyboardKey.launchApp2, + 0x00000098: PhysicalKeyboardKey.launchApp1, + 0x0000009e: PhysicalKeyboardKey.launchInternetBrowser, + 0x000001b9: PhysicalKeyboardKey.logOff, + 0x000000a0: PhysicalKeyboardKey.lockScreen, + 0x0000024b: PhysicalKeyboardKey.launchControlPanel, + 0x0000024c: PhysicalKeyboardKey.selectTask, + 0x000000f3: PhysicalKeyboardKey.launchDocuments, + 0x000001b8: PhysicalKeyboardKey.spellCheck, + 0x0000017e: PhysicalKeyboardKey.launchKeyboardLayout, + 0x0000024d: PhysicalKeyboardKey.launchScreenSaver, + 0x0000024f: PhysicalKeyboardKey.launchAssistant, + 0x00000190: PhysicalKeyboardKey.launchAudioBrowser, + 0x000000bd: PhysicalKeyboardKey.newKey, + 0x000000d6: PhysicalKeyboardKey.close, + 0x000000f2: PhysicalKeyboardKey.save, + 0x000000da: PhysicalKeyboardKey.print, + 0x000000e1: PhysicalKeyboardKey.browserSearch, + 0x000000b4: PhysicalKeyboardKey.browserHome, + 0x000000a6: PhysicalKeyboardKey.browserBack, + 0x000000a7: PhysicalKeyboardKey.browserForward, + 0x00000088: PhysicalKeyboardKey.browserStop, + 0x000000b5: PhysicalKeyboardKey.browserRefresh, + 0x000000a4: PhysicalKeyboardKey.browserFavorites, + 0x000001aa: PhysicalKeyboardKey.zoomIn, + 0x000001ab: PhysicalKeyboardKey.zoomOut, + 0x0000017c: PhysicalKeyboardKey.zoomToggle, + 0x000000be: PhysicalKeyboardKey.redo, + 0x000000f0: PhysicalKeyboardKey.mailReply, + 0x000000f1: PhysicalKeyboardKey.mailForward, + 0x000000ef: PhysicalKeyboardKey.mailSend, + 0x00000080: PhysicalKeyboardKey.showAllWindows, +}; + diff --git a/packages/flutter/lib/src/services/platform_channel.dart b/packages/flutter/lib/src/services/platform_channel.dart index d5037bf6a9..6fcaca5ada 100644 --- a/packages/flutter/lib/src/services/platform_channel.dart +++ b/packages/flutter/lib/src/services/platform_channel.dart @@ -27,7 +27,7 @@ import 'platform_messages.dart'; /// The logical identity of the channel is given by its name. Identically named /// channels will interfere with each other's communication. /// -/// See: +/// See: class BasicMessageChannel { /// Creates a [BasicMessageChannel] with the specified [name] and [codec]. /// @@ -105,7 +105,7 @@ class BasicMessageChannel { /// The logical identity of the channel is given by its name. Identically named /// channels will interfere with each other's communication. /// -/// See: +/// See: class MethodChannel { /// Creates a [MethodChannel] with the specified [name]. /// @@ -148,7 +148,7 @@ class MethodChannel { /// {@tool sample} /// /// The code might be packaged up as a musical plugin, see - /// : + /// : /// /// ```dart /// class Music { @@ -314,7 +314,7 @@ class MethodChannel { /// * [invokeMethod], which this call delegates to. Future> invokeListMethod(String method, [ dynamic arguments ]) async { final List result = await invokeMethod>(method, arguments); - return result.cast(); + return result?.cast(); } /// An implementation of [invokeMethod] that can return typed maps. @@ -328,7 +328,7 @@ class MethodChannel { /// * [invokeMethod], which this call delegates to. Future> invokeMapMethod(String method, [ dynamic arguments ]) async { final Map result = await invokeMethod>(method, arguments); - return result.cast(); + return result?.cast(); } /// Sets a callback for receiving method calls on this channel. @@ -441,7 +441,7 @@ class OptionalMethodChannel extends MethodChannel { /// The logical identity of the channel is given by its name. Identically named /// channels will interfere with each other's communication. /// -/// See: +/// See: class EventChannel { /// Creates an [EventChannel] with the specified [name]. /// diff --git a/packages/flutter/lib/src/services/platform_messages.dart b/packages/flutter/lib/src/services/platform_messages.dart index 5e83b911b8..1aa026291c 100644 --- a/packages/flutter/lib/src/services/platform_messages.dart +++ b/packages/flutter/lib/src/services/platform_messages.dart @@ -23,7 +23,7 @@ typedef _MessageHandler = Future Function(ByteData message); /// * [MethodChannel], which provides platform communication using asynchronous /// method calls. /// * [EventChannel], which provides platform communication using event streams. -/// * +/// * class BinaryMessages { BinaryMessages._(); diff --git a/packages/flutter/lib/src/services/raw_keyboard.dart b/packages/flutter/lib/src/services/raw_keyboard.dart index 6c46d12577..cf449ab275 100644 --- a/packages/flutter/lib/src/services/raw_keyboard.dart +++ b/packages/flutter/lib/src/services/raw_keyboard.dart @@ -9,6 +9,7 @@ import 'package:flutter/foundation.dart'; import 'keyboard_key.dart'; import 'raw_keyboard_android.dart'; import 'raw_keyboard_fuchsia.dart'; +import 'raw_keyboard_linux.dart'; import 'raw_keyboard_macos.dart'; import 'system_channels.dart'; @@ -272,6 +273,14 @@ abstract class RawKeyEvent { keyCode: message['keyCode'] ?? 0, modifiers: message['modifiers'] ?? 0); break; + case 'linux': + data = RawKeyEventDataLinux( + keyHelper: KeyHelper(message['toolkit'] ?? ''), + codePoint: message['codePoint'] ?? 0, + keyCode: message['keyCode'] ?? 0, + scanCode: message['scanCode'] ?? 0, + modifiers: message['modifiers'] ?? 0); + break; default: // We don't yet implement raw key events on iOS or other platforms, but // we don't hit this exception because the engine never sends us these diff --git a/packages/flutter/lib/src/services/raw_keyboard_linux.dart b/packages/flutter/lib/src/services/raw_keyboard_linux.dart new file mode 100644 index 0000000000..f1350a25a1 --- /dev/null +++ b/packages/flutter/lib/src/services/raw_keyboard_linux.dart @@ -0,0 +1,258 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/foundation.dart'; + +import 'keyboard_key.dart'; +import 'keyboard_maps.dart'; +import 'raw_keyboard.dart'; + +/// Platform-specific key event data for Linux. +/// +/// Different window toolkit implementations can map to different key codes. This class +/// will use the correct mapping depending on the [toolkit] provided. +/// +/// See also: +/// +/// * [RawKeyboard], which uses this interface to expose key data. +class RawKeyEventDataLinux extends RawKeyEventData { + /// Creates a key event data structure specific for macOS. + /// + /// The [toolkit], [scanCode], [codePoint], [keyCode], and [modifiers], arguments + /// must not be null. + const RawKeyEventDataLinux({ + @required this.keyHelper, + this.scanCode = 0, + this.codePoint = 0, + this.keyCode = 0, + this.modifiers = 0, + }) : assert(scanCode != null), + assert(codePoint != null), + assert(keyCode != null), + assert(modifiers != null), + assert(keyHelper != null); + + /// A helper class that abstracts the fetching of the toolkit-specific mappings. + /// + /// There is no real concept of a "native" window toolkit on Linux, and each implementation + /// (GLFW, GTK, QT, etc) may have a different key code mapping. + final KeyHelper keyHelper; + + /// The hardware scan code id corresponding to this key event. + /// + /// These values are not reliable and vary from device to device, so this + /// information is mainly useful for debugging. + final int scanCode; + + /// The Unicode code point represented by the key event, if any. + /// + /// If there is no Unicode code point, this value is zero. + /// + /// Dead keys are represented as Unicode combining characters. + final int codePoint; + + /// The hardware key code corresponding to this key event. + /// + /// This is the physical key that was pressed, not the Unicode character. + /// See [codePoint] for the Unicode character. This value may be different depending + /// on the window toolkit used (See [toolkit]). + final int keyCode; + + /// A mask of the current modifiers using the values in Modifier Flags. + /// This value may be different depending on the window toolkit used (See [toolkit]). + final int modifiers; + + @override + String get keyLabel => codePoint == 0 ? null : String.fromCharCode(codePoint); + + @override + PhysicalKeyboardKey get physicalKey => kLinuxToPhysicalKey[scanCode] ?? PhysicalKeyboardKey.none; + + @override + LogicalKeyboardKey get logicalKey { + // Look to see if the keyCode is a printable number pad key, so that a + // difference between regular keys (e.g. "=") and the number pad version + // (e.g. the "=" on the number pad) can be determined. + final LogicalKeyboardKey numPadKey = keyHelper.numpadKey(keyCode); + if (numPadKey != null) { + return numPadKey; + } + + // If it has a non-control-character label, then either return the existing + // constant, or construct a new Unicode-based key from it. Don't mark it as + // autogenerated, since the label uniquely identifies an ID from the Unicode + // plane. + if (keyLabel != null && + !LogicalKeyboardKey.isControlCharacter(keyLabel)) { + final int keyId = LogicalKeyboardKey.unicodePlane | (codePoint & LogicalKeyboardKey.valueMask); + return LogicalKeyboardKey.findKeyByKeyId(keyId) ?? LogicalKeyboardKey( + keyId, + keyLabel: keyLabel, + debugName: kReleaseMode ? null : 'Key ${keyLabel.toUpperCase()}', + ); + } + + // Look to see if the keyCode is one we know about and have a mapping for. + LogicalKeyboardKey newKey = keyHelper.logicalKey(keyCode); + if (newKey != null) { + return newKey; + } + + const int linuxKeyIdPlane = 0x00600000000; + + // This is a non-printable key that we don't know about, so we mint a new + // code with the autogenerated bit set. + newKey ??= LogicalKeyboardKey( + linuxKeyIdPlane | keyCode | LogicalKeyboardKey.autogeneratedMask, + debugName: kReleaseMode ? null : 'Unknown key code $keyCode', + ); + return newKey; + } + + @override + bool isModifierPressed(ModifierKey key, {KeyboardSide side = KeyboardSide.any}) { + return keyHelper.isModifierPressed(key, modifiers, side: side); + } + + @override + KeyboardSide getModifierSide(ModifierKey key) { + return keyHelper.getModifierSide(key); + } + + @override + String toString() { + return '$runtimeType(keyLabel: $keyLabel, keyCode: $keyCode, scanCode: $scanCode,' + ' codePoint: $codePoint, modifiers: $modifiers, ' + 'modifiers down: $modifiersPressed)'; + } +} + +/// Abstract class for window-specific key mappings. +/// +/// Given that there might be multiple window toolkit implementations (GLFW, +/// GTK, QT, etc), this creates a common interface for each of the +/// different toolkits. +abstract class KeyHelper { + /// Create a KeyHelper implementation depending on the given toolkit. + factory KeyHelper(String toolkit) { + if (toolkit == 'glfw') { + return GLFWKeyHelper(); + } else { + throw FlutterError('Window toolkit not recognized: $toolkit'); + } + } + + /// Returns a [KeyboardSide] enum value that describes which side or sides of + /// the given keyboard modifier key were pressed at the time of this event. + KeyboardSide getModifierSide(ModifierKey key); + + /// Returns true if the given [ModifierKey] was pressed at the time of this + /// event. + bool isModifierPressed(ModifierKey key, int modifiers, {KeyboardSide side = KeyboardSide.any}); + + /// The numpad key from the specific key code mapping. + LogicalKeyboardKey numpadKey(int keyCode); + + /// The logical key key from the specific key code mapping. + LogicalKeyboardKey logicalKey(int keyCode); +} + +/// Helper class that uses GLFW-specific key mappings. +class GLFWKeyHelper with KeyHelper { + /// This mask is used to check the [modifiers] field to test whether the CAPS + /// LOCK modifier key is on. + /// + /// {@template flutter.services.logicalKeyboardKey.modifiers} + /// Use this value if you need to decode the [modifiers] field yourself, but + /// it's much easier to use [isModifierPressed] if you just want to know if + /// a modifier is pressed. + /// {@endtemplate} + static const int modifierCapsLock = 0x0010; + + /// This mask is used to check the [modifiers] field to test whether one of the + /// SHIFT modifier keys is pressed. + /// + /// {@macro flutter.services.logicalKeyboardKey.modifiers} + static const int modifierShift = 0x0001; + + /// This mask is used to check the [modifiers] field to test whether one of the + /// CTRL modifier keys is pressed. + /// + /// {@macro flutter.services.logicalKeyboardKey.modifiers} + static const int modifierControl = 0x0002; + + /// This mask is used to check the [modifiers] field to test whether one of the + /// ALT modifier keys is pressed. + /// + /// {@macro flutter.services.logicalKeyboardKey.modifiers} + static const int modifierAlt = 0x0004; + + /// This mask is used to check the [modifiers] field to test whether one of the + /// Meta(SUPER) modifier keys is pressed. + /// + /// {@macro flutter.services.logicalKeyboardKey.modifiers} + static const int modifierMeta = 0x0008; + + + /// This mask is used to check the [modifiers] field to test whether any key in + /// the numeric keypad is pressed. + /// + /// {@macro flutter.services.logicalKeyboardKey.modifiers} + static const int modifierNumericPad = 0x0020; + + @override + bool isModifierPressed(ModifierKey key, int modifiers, {KeyboardSide side = KeyboardSide.any}) { + switch (key) { + case ModifierKey.controlModifier: + return modifiers & modifierControl != 0; + case ModifierKey.shiftModifier: + return modifiers & modifierShift != 0; + case ModifierKey.altModifier: + return modifiers & modifierAlt != 0; + case ModifierKey.metaModifier: + return modifiers & modifierMeta != 0; + case ModifierKey.capsLockModifier: + return modifiers & modifierCapsLock != 0; + case ModifierKey.numLockModifier: + return modifiers & modifierNumericPad != 0; + case ModifierKey.functionModifier: + case ModifierKey.symbolModifier: + case ModifierKey.scrollLockModifier: + // These are not used in GLFW keyboards. + return false; + } + return false; + } + + @override + KeyboardSide getModifierSide(ModifierKey key) { + switch (key) { + case ModifierKey.controlModifier: + case ModifierKey.shiftModifier: + case ModifierKey.altModifier: + case ModifierKey.metaModifier: + // Neither GLFW or X11 provide a distiction between left and right modifiers, so defaults to KeyboardSide.any. + // https://code.woboq.org/qt5/include/X11/X.h.html#_M/ShiftMask + return KeyboardSide.any; + case ModifierKey.capsLockModifier: + case ModifierKey.numLockModifier: + case ModifierKey.functionModifier: + case ModifierKey.symbolModifier: + case ModifierKey.scrollLockModifier: + return KeyboardSide.all; + } + assert(false, 'Not handling $key type properly.'); + return null; + } + + @override + LogicalKeyboardKey numpadKey(int keyCode) { + return kGlfwNumpadMap[keyCode]; + } + + @override + LogicalKeyboardKey logicalKey(int keyCode) { + return kGlfwToLogicalKey[keyCode]; + } +} diff --git a/packages/flutter/lib/src/widgets/animated_list.dart b/packages/flutter/lib/src/widgets/animated_list.dart index 2d55174bc7..73a251bca7 100644 --- a/packages/flutter/lib/src/widgets/animated_list.dart +++ b/packages/flutter/lib/src/widgets/animated_list.dart @@ -2,9 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:collection/collection.dart' show binarySearch; - import 'package:flutter/animation.dart'; +import 'package:flutter/foundation.dart'; import 'basic.dart'; import 'framework.dart'; diff --git a/packages/flutter/lib/src/widgets/app.dart b/packages/flutter/lib/src/widgets/app.dart index 15d4468fd7..43a5d2bca2 100644 --- a/packages/flutter/lib/src/widgets/app.dart +++ b/packages/flutter/lib/src/widgets/app.dart @@ -625,7 +625,7 @@ class WidgetsApp extends StatefulWidget { /// /// See also: /// - /// * + /// * final bool showPerformanceOverlay; /// Checkerboards raster cache images. @@ -1068,7 +1068,7 @@ class _WidgetsAppState extends State implements WidgetsBindingObserv ); } message.writeln( - 'See https://flutter.io/tutorials/internationalization/ for more\n' + 'See https://flutter.dev/tutorials/internationalization/ for more\n' 'information about configuring an app\'s locale, supportedLocales,\n' 'and localizationsDelegates parameters.' ); diff --git a/packages/flutter/lib/src/widgets/async.dart b/packages/flutter/lib/src/widgets/async.dart index 3e833d0472..7491908925 100644 --- a/packages/flutter/lib/src/widgets/async.dart +++ b/packages/flutter/lib/src/widgets/async.dart @@ -294,6 +294,8 @@ typedef AsyncWidgetBuilder = Widget Function(BuildContext context, AsyncSnaps /// Widget that builds itself based on the latest snapshot of interaction with /// a [Stream]. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=MkKEWHfy99Y} +/// /// Widget rebuilding is scheduled by each interaction, using [State.setState], /// but is otherwise decoupled from the timing of the stream. The [builder] /// is called at the discretion of the Flutter pipeline, and will thus receive a @@ -436,6 +438,8 @@ class StreamBuilder extends StreamBuilderBase> { /// A general guideline is to assume that every `build` method could get called /// every frame, and to treat omitted calls as an optimization. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=ek8ZPdWj4Qo} +/// /// ## Timing /// /// Widget rebuilding is scheduled by the completion of the future, using diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index 64b7adcba1..a1c0e2a3bb 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -133,6 +133,8 @@ class Directionality extends InheritedWidget { /// buffer. For the value 0.0, the child is simply not painted at all. For the /// value 1.0, the child is painted immediately without an intermediate buffer. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=9hltevOHQBw} +/// /// {@tool sample} /// /// This example shows some [Text] when the `_visible` member field is true, and @@ -340,6 +342,8 @@ class ShaderMask extends SingleChildRenderObjectWidget { /// widget's clip. If there's no clip, the filter will be applied to the full /// screen. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=dYRs7Q1vfYI} +/// /// {@tool sample} /// If the [BackdropFilter] needs to be applied to an area that exactly matches /// its child, wraps the [BackdropFilter] with a clip widget that clips exactly @@ -419,6 +423,8 @@ class BackdropFilter extends SingleChildRenderObjectWidget { /// /// Painters are implemented by subclassing [CustomPainter]. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=kp14Y4uHpHs} +/// /// Because custom paint calls its painters during paint, you cannot call /// `setState` or `markNeedsLayout` during the callback (the layout for this /// frame has already happened). @@ -607,6 +613,8 @@ class ClipRect extends SingleChildRenderObjectWidget { /// clip, but the size and location of the clip can be customized using a custom /// [clipper]. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=eI43jkQkrvs} +/// /// See also: /// /// * [CustomClipper], for information about creating custom clips. @@ -983,6 +991,8 @@ class PhysicalShape extends SingleChildRenderObjectWidget { /// A widget that applies a transformation before painting its child. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=9z_YNlRlWfA} +/// /// {@tool sample} /// /// This example rotates and skews an orange box containing text, keeping the @@ -1305,11 +1315,13 @@ class CompositedTransformFollower extends SingleChildRenderObjectWidget { /// Scales and positions its child within itself according to [fit]. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=T4Uehk3_wlY} +/// /// See also: /// /// * [Transform], which applies an arbitrary transform to its child widget at /// paint time. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class FittedBox extends SingleChildRenderObjectWidget { /// Creates a widget that scales and positions its child within itself according to [fit]. /// @@ -1383,7 +1395,7 @@ class FittedBox extends SingleChildRenderObjectWidget { /// paint time. /// * [new Transform.translate], which applies an absolute offset translation /// transformation instead of an offset scaled to the child. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class FractionalTranslation extends SingleChildRenderObjectWidget { /// Creates a widget that translates its child's painting. /// @@ -1445,7 +1457,7 @@ class FractionalTranslation extends SingleChildRenderObjectWidget { /// * [Transform], which is a paint effect that allows you to apply an /// arbitrary transform to a child. /// * [new Transform.rotate], which applies a rotation paint effect. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class RotatedBox extends SingleChildRenderObjectWidget { /// A widget that rotates its child. /// @@ -1512,7 +1524,7 @@ class RotatedBox extends SingleChildRenderObjectWidget { /// See also: /// /// * [EdgeInsets], the class that is used to describe the padding dimensions. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class Padding extends SingleChildRenderObjectWidget { /// Creates a widget that insets its child. /// @@ -1556,6 +1568,8 @@ class Padding extends SingleChildRenderObjectWidget { /// tight constraint that is bigger than the child's natural size, /// with an alignment of [Alignment.bottomRight]. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=g2E7yl3MwMk} +/// /// This widget will be as big as possible if its dimensions are constrained and /// [widthFactor] and [heightFactor] are null. If a dimension is unconstrained /// and the corresponding size factor is null then the widget will match its @@ -1576,6 +1590,8 @@ class Padding extends SingleChildRenderObjectWidget { /// [Alignment], [topRight]. This places the [FlutterLogo] in the top right corner /// of the parent blue [Container]. /// +/// ![A blue square container with the Flutter logo in the top right corner.](https://flutter.github.io/assets-for-api-docs/assets/widgets/align_constant.png) +/// /// ```dart /// Center( /// child: Container( @@ -1600,8 +1616,12 @@ class Padding extends SingleChildRenderObjectWidget { /// of [FlutterLogo]/2 + height of [FlutterLogo]/2) = (36.0, 48.0). /// /// The [Alignment] class uses a coordinate system with an origin in the center -/// of the [Container], and so [Align] will place the [FlutterLogo] at (36.0, 48.0) -/// according to this system. +/// of the [Container], as shown with the [Icon] above. [Align] will place the +/// [FlutterLogo] at (36.0, 48.0) according to this coordinate system. +/// +/// ![A blue square container with the Flutter logo positioned according to the +/// Alignment specified above. A point is marked at the center of the container +/// for the origin of the Alignment coordinate system.](https://flutter.github.io/assets-for-api-docs/assets/widgets/align_alignment.png) /// /// ```dart /// Center( @@ -1637,6 +1657,10 @@ class Padding extends SingleChildRenderObjectWidget { /// corner of the [Container] in difference to the center-oriented system used in /// the example above with [Alignment]. /// +/// ![A blue square container with the Flutter logo positioned according to the +/// FractionalOffset specified above. A point is marked at the top left corner +/// of the container for the origin of the FractionalOffset coordinate system.](https://flutter.github.io/assets-for-api-docs/assets/widgets/align_fractional_offset.png) +/// /// ```dart /// Center( /// child: Container( @@ -1662,7 +1686,7 @@ class Padding extends SingleChildRenderObjectWidget { /// set to [Alignment.center]. /// * [FractionallySizedBox], which sizes its child based on a fraction of its /// own size and positions the child according to an [Alignment] value. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class Align extends SingleChildRenderObjectWidget { /// Creates an alignment widget. /// @@ -1752,7 +1776,7 @@ class Align extends SingleChildRenderObjectWidget { /// * [Column], a widget that displays its children in a vertical array. /// * [Container], a convenience widget that combines common painting, /// positioning, and sizing widgets. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class Center extends Align { /// Creates a widget that centers its child. const Center({ Key key, double widthFactor, double heightFactor, Widget child }) @@ -1932,7 +1956,7 @@ class CustomMultiChildLayout extends MultiChildRenderObjectWidget { /// constraints while also sizing its child to match a given aspect ratio. /// * [FittedBox], which sizes and positions its child widget to fit the parent /// according to a given [BoxFit] discipline. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class SizedBox extends SingleChildRenderObjectWidget { /// Creates a fixed size box. The [width] and [height] parameters can be null /// to indicate that the size of the box should not be constrained in @@ -2040,7 +2064,7 @@ class SizedBox extends SingleChildRenderObjectWidget { /// own size and positions the child according to an [Alignment] value. /// * [AspectRatio], a widget that attempts to fit within the parent's /// constraints while also sizing its child to match a given aspect ratio. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class ConstrainedBox extends SingleChildRenderObjectWidget { /// Creates a widget that imposes additional constraints on its child. /// @@ -2168,7 +2192,7 @@ class UnconstrainedBox extends SingleChildRenderObjectWidget { /// * [OverflowBox], a widget that imposes different constraints on its child /// than it gets from its parent, possibly allowing the child to overflow the /// parent. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class FractionallySizedBox extends SingleChildRenderObjectWidget { /// Creates a widget that sizes its child to a fraction of the total available space. /// @@ -2273,7 +2297,7 @@ class FractionallySizedBox extends SingleChildRenderObjectWidget { /// when the incoming constraints are unbounded. /// * [SizedBox], which lets you specify tight constraints by explicitly /// specifying the height or width. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class LimitedBox extends SingleChildRenderObjectWidget { /// Creates a box that limits its size only when it's unconstrained. /// @@ -2333,7 +2357,7 @@ class LimitedBox extends SingleChildRenderObjectWidget { /// * [UnconstrainedBox], a container that tries to let its child draw without /// constraints. /// * [SizedBox], a box with a specified size. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class OverflowBox extends SingleChildRenderObjectWidget { /// Creates a widget that lets its child overflow itself. const OverflowBox({ @@ -2428,7 +2452,7 @@ class OverflowBox extends SingleChildRenderObjectWidget { /// child. /// * [UnconstrainedBox], a container that tries to let its child draw without /// constraints. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class SizedOverflowBox extends SingleChildRenderObjectWidget { /// Creates a widget of a given size that lets its child overflow. /// @@ -2507,7 +2531,7 @@ class SizedOverflowBox extends SingleChildRenderObjectWidget { /// * [Visibility], which can hide a child more efficiently (albeit less /// subtly). /// * [TickerMode], which can be used to disable animations in a subtree. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class Offstage extends SingleChildRenderObjectWidget { /// Creates a widget that visually hides its child. const Offstage({ Key key, this.offstage = true, Widget child }) @@ -2589,7 +2613,7 @@ class _OffstageElement extends SingleChildRenderObjectElement { /// child. /// * [UnconstrainedBox], a container that tries to let its child draw without /// constraints. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class AspectRatio extends SingleChildRenderObjectWidget { /// Creates a widget with a specific aspect ratio. /// @@ -2640,7 +2664,7 @@ class AspectRatio extends SingleChildRenderObjectWidget { /// /// See also: /// -/// * [The catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * [The catalog of layout widgets](https://flutter.dev/widgets/layout/). class IntrinsicWidth extends SingleChildRenderObjectWidget { /// Creates a widget that sizes its child to the child's intrinsic width. /// @@ -2699,7 +2723,7 @@ class IntrinsicWidth extends SingleChildRenderObjectWidget { /// /// See also: /// -/// * [The catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * [The catalog of layout widgets](https://flutter.dev/widgets/layout/). class IntrinsicHeight extends SingleChildRenderObjectWidget { /// Creates a widget that sizes its child to the child's intrinsic height. /// @@ -2724,7 +2748,7 @@ class IntrinsicHeight extends SingleChildRenderObjectWidget { /// * [Align], a widget that aligns its child within itself and optionally /// sizes itself based on the child's size. /// * [Center], a widget that centers its child within itself. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class Baseline extends SingleChildRenderObjectWidget { /// Creates a widget that positions its child according to the child's baseline. /// @@ -3056,7 +3080,7 @@ class ListBody extends MultiChildRenderObjectWidget { /// children. /// * [Flow], which provides paint-time control of its children using transform /// matrices. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class Stack extends MultiChildRenderObjectWidget { /// Creates a stack layout widget. /// @@ -3151,7 +3175,7 @@ class Stack extends MultiChildRenderObjectWidget { /// See also: /// /// * [Stack], for more details about stacks. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class IndexedStack extends Stack { /// Creates a [Stack] widget that paints a single child. /// @@ -3193,6 +3217,8 @@ class IndexedStack extends Stack { /// [StatelessWidget]s or [StatefulWidget]s (not other kinds of widgets, like /// [RenderObjectWidget]s). /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=EgtPleVwxBQ} +/// /// If a widget is wrapped in a [Positioned], then it is a _positioned_ widget /// in its [Stack]. If the [top] property is non-null, the top edge of this child /// will be positioned [top] layout units from the top of the stack widget. The @@ -3625,7 +3651,7 @@ class PositionedDirectional extends StatelessWidget { /// * [Flexible], to indicate children that should share the remaining room. /// * [Spacer], a widget that takes up space proportional to it's flex value. /// that may be sized smaller (leaving some remaining room unused). -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class Flex extends MultiChildRenderObjectWidget { /// Creates a flex layout. /// @@ -3963,7 +3989,7 @@ class Flex extends MultiChildRenderObjectWidget { /// * [Flexible], to indicate children that should share the remaining room but /// that may by sized smaller (leaving some remaining room unused). /// * [Spacer], a widget that takes up space proportional to it's flex value. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class Row extends Flex { /// Creates a horizontal array of children. /// @@ -4161,7 +4187,7 @@ class Row extends Flex { /// * [SingleChildScrollView], whose documentation discusses some ways to /// use a [Column] inside a scrolling container. /// * [Spacer], a widget that takes up space proportional to it's flex value. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class Column extends Flex { /// Creates a vertical array of children. /// @@ -4213,7 +4239,7 @@ class Column extends Flex { /// /// * [Expanded], which forces the child to expand to fill the available space. /// * [Spacer], a widget that takes up space proportional to it's flex value. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class Flexible extends ParentDataWidget { /// Creates a widget that controls how a child of a [Row], [Column], or [Flex] /// flexes. @@ -4271,10 +4297,11 @@ class Flexible extends ParentDataWidget { } } -/// A widget that expands a child of a [Row], [Column], or [Flex]. +/// A widget that expands a child of a [Row], [Column], or [Flex] +/// so that the child fills the available space. /// /// Using an [Expanded] widget makes a child of a [Row], [Column], or [Flex] -/// expand to fill the available space in the main axis (e.g., horizontally for +/// expand to fill the available space along the main axis (e.g., horizontally for /// a [Row] or vertically for a [Column]). If multiple children are expanded, /// the available space is divided among them according to the [flex] factor. /// @@ -4283,6 +4310,8 @@ class Flexible extends ParentDataWidget { /// [Flex] must contain only [StatelessWidget]s or [StatefulWidget]s (not other /// kinds of widgets, like [RenderObjectWidget]s). /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=_rnZaagadyo} +/// /// {@tool snippet --template=stateless_widget_material} /// This example shows how to use an [Expanded] widget in a [Column] so that /// it's middle child, a [Container] here, expands to fill the space. @@ -4364,10 +4393,11 @@ class Flexible extends ParentDataWidget { /// /// * [Flexible], which does not force the child to fill the available space. /// * [Spacer], a widget that takes up space proportional to it's flex value. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class Expanded extends Flexible { /// Creates a widget that expands a child of a [Row], [Column], or [Flex] - /// expand to fill the available space in the main axis. + /// so that the child fills the available space along the flex widget's + /// main axis. const Expanded({ Key key, int flex = 1, @@ -4389,6 +4419,8 @@ class Expanded extends Flexible { /// The runs themselves are then positioned in the cross axis according to the /// [runSpacing] and [runAlignment]. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=z5iw2SeFx2M} +/// /// {@tool sample} /// /// This example renders some [Chip]s representing four contacts in a [Wrap] so @@ -4424,7 +4456,7 @@ class Expanded extends Flexible { /// /// * [Row], which places children in one line, and gives control over their /// alignment and spacing. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class Wrap extends MultiChildRenderObjectWidget { /// Creates a wrap layout. /// @@ -4655,7 +4687,7 @@ class Wrap extends MultiChildRenderObjectWidget { /// a single child. /// * [CustomMultiChildLayout], which uses a delegate to position multiple /// children. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class Flow extends MultiChildRenderObjectWidget { /// Creates a flow layout. /// @@ -5550,6 +5582,8 @@ class IgnorePointer extends SingleChildRenderObjectWidget { /// from being the target of located events, because it returns true from /// [RenderBox.hitTest]. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=65HoWqBboI8} +/// /// See also: /// /// * [IgnorePointer], which also prevents its children from receiving pointer diff --git a/packages/flutter/lib/src/widgets/binding.dart b/packages/flutter/lib/src/widgets/binding.dart index 70f25ffc5d..0599fe0131 100644 --- a/packages/flutter/lib/src/widgets/binding.dart +++ b/packages/flutter/lib/src/widgets/binding.dart @@ -302,6 +302,16 @@ mixin WidgetsBinding on BindingBase, SchedulerBinding, GestureBinding, RendererB }; }, ); + + // Expose the ability to send Widget rebuilds as [Timeline] events. + registerBoolServiceExtension( + name: 'profileWidgetBuilds', + getter: () async => debugProfileBuildsEnabled, + setter: (bool value) async { + if (debugProfileBuildsEnabled != value) + debugProfileBuildsEnabled = value; + }, + ); } assert(() { @@ -316,16 +326,6 @@ mixin WidgetsBinding on BindingBase, SchedulerBinding, GestureBinding, RendererB }, ); - // Expose the ability to send Widget rebuilds as [Timeline] events. - registerBoolServiceExtension( - name: 'profileWidgetBuilds', - getter: () async => debugProfileBuildsEnabled, - setter: (bool value) async { - if (debugProfileBuildsEnabled != value) - debugProfileBuildsEnabled = value; - }, - ); - // This service extension is deprecated and will be removed by 12/1/2018. // Use ext.flutter.inspector.show instead. registerBoolServiceExtension( diff --git a/packages/flutter/lib/src/widgets/container.dart b/packages/flutter/lib/src/widgets/container.dart index e02faebfb0..99fa1769f9 100644 --- a/packages/flutter/lib/src/widgets/container.dart +++ b/packages/flutter/lib/src/widgets/container.dart @@ -183,12 +183,13 @@ class DecoratedBox extends SingleChildRenderObjectWidget { /// see [Decoration.padding]. /// /// {@tool sample} -/// /// This example shows a 48x48 amber square (placed inside a [Center] widget in /// case the parent widget has its own opinions regarding the size that the /// [Container] should take), with a margin so that it stays away from /// neighboring widgets: /// +/// ![An amber colored container with the dimensions of 48 square pixels.](https://flutter.github.io/assets-for-api-docs/assets/widgets/container_a.png) +/// /// ```dart /// Center( /// child: Container( @@ -200,6 +201,7 @@ class DecoratedBox extends SingleChildRenderObjectWidget { /// ) /// ``` /// {@end-tool} +/// /// {@tool sample} /// /// This example shows how to use many of the features of [Container] at once. @@ -210,6 +212,9 @@ class DecoratedBox extends SingleChildRenderObjectWidget { /// centered in the box. Finally, the [transform] applies a slight rotation to the /// entire contraption to complete the effect. /// +/// ![A blue rectangular container with 'Hello World' in the center, rotated +/// slightly in the z axis.](https://flutter.github.io/assets-for-api-docs/assets/widgets/container_b.png) +/// /// ```dart /// Container( /// constraints: BoxConstraints.expand( @@ -235,7 +240,7 @@ class DecoratedBox extends SingleChildRenderObjectWidget { /// * [Border], which has a sample which uses [Container] heavily. /// * [Ink], which paints a [Decoration] on a [Material], allowing /// [InkResponse] and [InkWell] splashes to paint over them. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). class Container extends StatelessWidget { /// Creates a widget that combines common painting, positioning, and sizing widgets. /// diff --git a/packages/flutter/lib/src/widgets/dismissible.dart b/packages/flutter/lib/src/widgets/dismissible.dart index a275aa4887..a95475a07c 100644 --- a/packages/flutter/lib/src/widgets/dismissible.dart +++ b/packages/flutter/lib/src/widgets/dismissible.dart @@ -60,6 +60,8 @@ enum DismissDirection { /// non-null, the Dismissible widget animates its height (or width, whichever is /// perpendicular to the dismiss direction) to zero over the [resizeDuration]. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=iEMgjrfuc58} +/// /// Backgrounds can be used to implement the "leave-behind" idiom. If a background /// is specified it is stacked behind the Dismissible's child and is exposed when /// the child moves. diff --git a/packages/flutter/lib/src/widgets/draggable_scrollable_sheet.dart b/packages/flutter/lib/src/widgets/draggable_scrollable_sheet.dart new file mode 100644 index 0000000000..89f2e70384 --- /dev/null +++ b/packages/flutter/lib/src/widgets/draggable_scrollable_sheet.dart @@ -0,0 +1,375 @@ +// Copyright 2019 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/gestures.dart'; + +import 'basic.dart'; +import 'framework.dart'; +import 'layout_builder.dart'; +import 'scroll_context.dart'; +import 'scroll_controller.dart'; +import 'scroll_physics.dart'; +import 'scroll_position.dart'; +import 'scroll_position_with_single_context.dart'; +import 'scroll_simulation.dart'; + +/// The signature of a method that provides a [BuildContext] and +/// [ScrollController] for building a widget that may overflow the draggable +/// [Axis] of the containing [DraggableScrollSheet]. +/// +/// Users should apply the [scrollController] to a [ScrollView] subclass, such +/// as a [SingleChildScrollView], [ListView] or [GridView], to have the whole +/// sheet be draggable. +typedef ScrollableWidgetBuilder = Widget Function( + BuildContext context, + ScrollController scrollController, +); + +/// A container for a [Scrollable] that responds to drag gestures by resizing +/// the scrollable until a limit is reached, and then scrolling. +/// +/// This widget can be dragged along the vertical axis between its +/// [minChildSize], which defaults to `0.25` and [maxChildSize], which defaults +/// to `1.0`. These sizes are percentages of the height of the parent container. +/// +/// The widget coordinates resizing and scrolling of the widget returned by +/// builder as the user drags along the horizontal axis. +/// +/// The widget will initially be displayed at its initialChildSize which +/// defaults to `0.5`, meaning half the height of its parent. Dragging will work +/// between the range of minChildSize and maxChildSize (as percentages of the +/// parent container's height) as long as the builder creates a widget which +/// uses the provided [ScrollController]. If the widget created by the +/// [ScrollableWidgetBuilder] does not use provided [ScrollController], the +/// sheet will remain at the initialChildSize. +/// +/// {@tool sample} +/// +/// This is a sample widget which shows a [ListView] that has 25 [ListTile]s. +/// It starts out as taking up half the body of the [Scaffold], and can be +/// dragged up to the full height of the scaffold or down to 25% of the height +/// of the scaffold. Upon reaching full height, the list contents will be +/// scrolled up or down, until they reach the top of the list again and the user +/// drags the sheet back down. +/// +/// ```dart +/// class HomePage extends StatelessWidget { +/// @override +/// Widget build(BuildContext context) { +/// return Scaffold( +/// appBar: AppBar( +/// title: const Text('DraggableScrollableSheet'), +/// ), +/// body: SizedBox.expand( +/// child: DraggableScrollableSheet( +/// builder: (BuildContext context, ScrollController scrollController) { +/// return Container( +/// color: Colors.blue[100], +/// child: ListView.builder( +/// controller: scrollController, +/// itemCount: 25, +/// itemBuilder: (BuildContext context, int index) { +/// return ListTile(title: Text('Item $index')); +/// }, +/// ), +/// ); +/// }, +/// ), +/// ), +/// ); +/// } +/// } +/// ``` +/// {@end-tool} +class DraggableScrollableSheet extends StatefulWidget { + /// Creates a widget that can be dragged and scrolled in a single gesture. + /// + /// The [builder], [initialChildSize], [minChildSize], and [maxChildSize] + /// parameters must not be null. + const DraggableScrollableSheet({ + Key key, + this.initialChildSize = 0.5, + this.minChildSize = 0.25, + this.maxChildSize = 1.0, + @required this.builder, + }) : assert(initialChildSize != null), + assert(minChildSize != null), + assert(maxChildSize != null), + assert(minChildSize >= 0.0), + assert(maxChildSize <= 1.0), + assert(minChildSize <= initialChildSize), + assert(initialChildSize <= maxChildSize), + assert(builder != null), + super(key: key); + + /// The initial fractional value of the parent container's height to use when + /// displaying the widget. + /// + /// The default value is `0.5`. + final double initialChildSize; + + /// The minimum fractional value of the parent container's height to use when + /// displaying the widget. + /// + /// The default value is `0.25`. + final double minChildSize; + + /// The maximum fractional value of the parent container's height to use when + /// displaying the widget. + /// + /// The default value is `1.0`. + final double maxChildSize; + + /// The builder that creates a child to display in this widget, which will + /// use the provided [ScrollController] to enable dragging and scrolling + /// of the contents. + final ScrollableWidgetBuilder builder; + + @override + _DraggableScrollableSheetState createState() => _DraggableScrollableSheetState(); +} + +/// Manages state between [_DraggableScrollableSheetState], +/// [_DraggableScrollableSheetScrollController], and +/// [_DraggableScrollableSheetScrollPosition]. +/// +/// The State knows the pixels available along the axis the widget wants to +/// scroll, but expects to get a fraction of those pixels to render the sheet. +/// +/// The ScrollPosition knows the number of pixels a user wants to move the sheet. +/// +/// The [currentExtent] will never be null. +/// The [availablePixels] will never be null, but may be `double.infinity`. +class _DraggableSheetExtent { + _DraggableSheetExtent({ + @required this.minExtent, + @required this.maxExtent, + @required this.initialExtent, + @required VoidCallback listener, + }) : assert(minExtent != null), + assert(maxExtent != null), + assert(initialExtent != null), + assert(minExtent >= 0), + assert(maxExtent <= 1), + assert(minExtent <= initialExtent), + assert(initialExtent <= maxExtent), + _currentExtent = ValueNotifier(initialExtent)..addListener(listener), + availablePixels = double.infinity; + + final double minExtent; + final double maxExtent; + final double initialExtent; + final ValueNotifier _currentExtent; + double availablePixels; + + bool get isAtMin => minExtent >= _currentExtent.value; + bool get isAtMax => maxExtent <= _currentExtent.value; + + set currentExtent(double value) { + assert(value != null); + _currentExtent.value = value.clamp(minExtent, maxExtent); + } + double get currentExtent => _currentExtent.value; + + /// The scroll position gets inputs in terms of pixels, but the extent is + /// expected to be expressed as a number between 0..1. + void addPixelDelta(double delta) { + currentExtent += delta / availablePixels; + } +} + +class _DraggableScrollableSheetState extends State { + _DraggableScrollableSheetScrollController _scrollController; + _DraggableSheetExtent _extent; + + @override + void initState() { + super.initState(); + _extent = _DraggableSheetExtent( + minExtent: widget.minChildSize, + maxExtent: widget.maxChildSize, + initialExtent: widget.initialChildSize, + listener: _setExtent, + ); + _scrollController = _DraggableScrollableSheetScrollController(extent: _extent); + } + + void _setExtent() { + setState(() { + // _extent has been updated when this is called. + }); + } + + @override + Widget build(BuildContext context) { + return LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) { + _extent.availablePixels = widget.maxChildSize * constraints.biggest.height; + return SizedBox.expand( + child: FractionallySizedBox( + heightFactor: _extent.currentExtent, + child: widget.builder(context, _scrollController), + alignment: Alignment.bottomCenter, + ), + ); + }, + ); + } + + @override + void dispose() { + _scrollController.dispose(); + super.dispose(); + } +} + +/// A [ScrollController] suitable for use in a [ScrollableWidgetBuilder] created +/// by a [DraggableScrollableSheet]. +/// +/// If a [DraggableScrollableSheet] contains content that is exceeds the height +/// of its container, this controller will allow the sheet to both be dragged to +/// fill the container and then scroll the child content. +/// +/// See also: +/// +/// * [_DraggableScrollableSheetScrollPosition], which manages the positioning logic for +/// this controller. +/// * [PrimaryScrollController], which can be used to establish a +/// [_DraggableScrollableSheetScrollController] as the primary controller for +/// descendants. +class _DraggableScrollableSheetScrollController extends ScrollController { + _DraggableScrollableSheetScrollController({ + double initialScrollOffset = 0.0, + String debugLabel, + @required this.extent, + }) : assert(extent != null), + super( + debugLabel: debugLabel, + initialScrollOffset: initialScrollOffset, + ); + + final _DraggableSheetExtent extent; + + @override + _DraggableScrollableSheetScrollPosition createScrollPosition( + ScrollPhysics physics, + ScrollContext context, + ScrollPosition oldPosition, + ) { + return _DraggableScrollableSheetScrollPosition( + physics: physics, + context: context, + oldPosition: oldPosition, + extent: extent, + ); + } + + @override + void debugFillDescription(List description) { + super.debugFillDescription(description); + description.add('extent: $extent'); + } +} + +/// A scroll position that manages scroll activities for +/// [_DraggableScrollableSheetScrollController]. +/// +/// This class is a concrete subclass of [ScrollPosition] logic that handles a +/// single [ScrollContext], such as a [Scrollable]. An instance of this class +/// manages [ScrollActivity] instances, which changes the +/// [_DraggableSheetExtent.currentExtent] or visible content offset in the +/// [Scrollable]'s [Viewport] +/// +/// See also: +/// +/// * [_DraggableScrollableSheetScrollController], which uses this as its [ScrollPosition]. +class _DraggableScrollableSheetScrollPosition + extends ScrollPositionWithSingleContext { + _DraggableScrollableSheetScrollPosition({ + @required ScrollPhysics physics, + @required ScrollContext context, + double initialPixels = 0.0, + bool keepScrollOffset = true, + ScrollPosition oldPosition, + String debugLabel, + @required this.extent, + }) : assert(extent != null), + super( + physics: physics, + context: context, + initialPixels: initialPixels, + keepScrollOffset: keepScrollOffset, + oldPosition: oldPosition, + debugLabel: debugLabel, + ); + + VoidCallback _dragCancelCallback; + final _DraggableSheetExtent extent; + bool get listShouldScroll => pixels > 0.0; + + @override + void applyUserOffset(double delta) { + if (!listShouldScroll && + !(extent.isAtMin || extent.isAtMax) || + (extent.isAtMin && delta < 0) || + (extent.isAtMax && delta > 0)) { + extent.addPixelDelta(-delta); + } else { + super.applyUserOffset(delta); + } + } + + @override + void goBallistic(double velocity) { + if (velocity == 0.0 || + (velocity < 0.0 && listShouldScroll) || + (velocity > 0.0 && extent.isAtMax)) { + super.goBallistic(velocity); + return; + } + // Scrollable expects that we will dispose of its current _dragCancelCallback + _dragCancelCallback?.call(); + _dragCancelCallback = null; + + // The iOS bouncing simulation just isn't right here - once we delegate + // the ballistic back to the ScrollView, it will use the right simulation. + final Simulation simulation = ClampingScrollSimulation( + position: extent.currentExtent, + velocity: velocity, + tolerance: physics.tolerance, + ); + + final AnimationController ballisticController = AnimationController.unbounded( + debugLabel: '$runtimeType', + vsync: context.vsync, + ); + double lastDelta = 0; + void _tick() { + final double delta = ballisticController.value - lastDelta; + lastDelta = ballisticController.value; + extent.addPixelDelta(delta); + if ((velocity > 0 && extent.isAtMax) || (velocity < 0 && extent.isAtMin)) { + // Make sure we pass along enough velocity to keep scrolling - otherwise + // we just "bounce" off the top making it look like the list doesn't + // have more to scroll. + velocity = ballisticController.velocity + (physics.tolerance.velocity * ballisticController.velocity.sign); + super.goBallistic(velocity); + ballisticController.stop(); + } + } + + ballisticController + ..addListener(_tick) + ..animateWith(simulation).whenCompleteOrCancel( + ballisticController.dispose, + ); + } + + @override + Drag drag(DragStartDetails details, VoidCallback dragCancelCallback) { + // Save this so we can call it later if we have to [goBallistic] on our own. + _dragCancelCallback = dragCancelCallback; + return super.drag(details, dragCancelCallback); + } +} diff --git a/packages/flutter/lib/src/widgets/editable_text.dart b/packages/flutter/lib/src/widgets/editable_text.dart index 92d7b8f844..3b98b0ebca 100644 --- a/packages/flutter/lib/src/widgets/editable_text.dart +++ b/packages/flutter/lib/src/widgets/editable_text.dart @@ -596,7 +596,7 @@ class EditableText extends StatefulWidget { /// Called when the user initiates a change to the TextField's /// value: when they have inserted or deleted text. /// - /// This callback does run not when the TextField's text is changed + /// This callback doesn't run when the TextField's text is changed /// programmatically, via the TextField's [controller]. Typically it /// isn't necessary to be notified of such changes, since they're /// initiated by the app itself. @@ -914,6 +914,10 @@ class EditableTextState extends State with AutomaticKeepAliveClien void updateFloatingCursor(RawFloatingCursorPoint point) { switch(point.state){ case FloatingCursorDragState.Start: + if (_floatingCursorResetController.isAnimating) { + _floatingCursorResetController.stop(); + _onFloatingCursorResetTick(); + } final TextPosition currentTextPosition = TextPosition(offset: renderEditable.selection.baseOffset); _startCaretRect = renderEditable.getLocalRectForCaret(currentTextPosition); renderEditable.setFloatingCursor(point.state, _startCaretRect.center - _floatingCursorOffset, currentTextPosition); diff --git a/packages/flutter/lib/src/widgets/fade_in_image.dart b/packages/flutter/lib/src/widgets/fade_in_image.dart index f5b121e2e0..75e260fa06 100644 --- a/packages/flutter/lib/src/widgets/fade_in_image.dart +++ b/packages/flutter/lib/src/widgets/fade_in_image.dart @@ -22,6 +22,8 @@ import 'ticker_provider.dart'; /// so that the image appears on screen with a graceful animation rather than /// abruptly pops onto the screen. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=pK738Pg9cxc} +/// /// If the [image] emits an [ImageInfo] synchronously, such as when the image /// has been loaded and cached, the [image] is displayed immediately and the /// [placeholder] is never displayed. diff --git a/packages/flutter/lib/src/widgets/form.dart b/packages/flutter/lib/src/widgets/form.dart index d9aff5544a..4c3b120387 100644 --- a/packages/flutter/lib/src/widgets/form.dart +++ b/packages/flutter/lib/src/widgets/form.dart @@ -229,6 +229,9 @@ class _FormScope extends InheritedWidget { /// Signature for validating a form field. /// +/// Returns an error string to display if the input is invalid, or null +/// otherwise. +/// /// Used by [FormField.validator]. typedef FormFieldValidator = String Function(T value); @@ -288,6 +291,13 @@ class FormField extends StatefulWidget { /// The returned value is exposed by the [FormFieldState.errorText] property. /// The [TextFormField] uses this to override the [InputDecoration.errorText] /// value. + /// + /// Alternating between error and normal state can cause the height of the + /// [TextFormField] to change if no other subtext decoration is set on the + /// field. To create a field whose height is fixed regardless of whether or + /// not an error is displayed, either wrap the [TextFormField] in a fixed + /// height parent like [SizedBox], or set the [TextFormField.helperText] + /// parameter to a space. final FormFieldValidator validator; /// Function that returns the widget representing this form field. It is @@ -355,10 +365,9 @@ class FormFieldState extends State> { return !hasError; } - bool _validate() { + void _validate() { if (widget.validator != null) _errorText = widget.validator(_value); - return !hasError; } /// Updates this field's state to the new value. Useful for responding to diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index 8676911341..31d34f272d 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -439,6 +439,8 @@ abstract class Widget extends DiagnosticableTree { /// description of the user interface is fully concrete (e.g., consists /// entirely of [RenderObjectWidget]s, which describe concrete [RenderObject]s). /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=wE7khGHVkYY} +/// /// Stateless widget are useful when the part of the user interface you are /// describing does not depend on anything other than the configuration /// information in the object itself and the [BuildContext] in which the widget @@ -488,7 +490,10 @@ abstract class Widget extends DiagnosticableTree { /// /// {@tool sample} /// -/// The following is a skeleton of a stateless widget subclass called `GreenFrog`: +/// The following is a skeleton of a stateless widget subclass called `GreenFrog`. +/// +/// Normally, widgets have more constructor arguments, each of which corresponds +/// to a `final` property. /// /// ```dart /// class GreenFrog extends StatelessWidget { @@ -501,22 +506,21 @@ abstract class Widget extends DiagnosticableTree { /// } /// ``` /// {@end-tool} +/// /// {@tool sample} /// -/// Normally widgets have more constructor arguments, each of which corresponds -/// to a `final` property. The next example shows the more generic widget `Frog` -/// which can be given a color and a child: +/// This next example shows the more generic widget `Frog` which can be given +/// a color and a child: /// /// ```dart /// class Frog extends StatelessWidget { /// const Frog({ /// Key key, -/// this.color: const Color(0xFF2DBD3A), +/// this.color = const Color(0xFF2DBD3A), /// this.child, /// }) : super(key: key); /// /// final Color color; -/// /// final Widget child; /// /// @override @@ -608,6 +612,8 @@ abstract class StatelessWidget extends Widget { /// [BuildContext] in which the widget is inflated, consider using /// [StatelessWidget]. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=AqCMFXEmf3w} +/// /// [StatefulWidget] instances themselves are immutable and store their mutable /// state either in separate [State] objects that are created by the /// [createState] method, or in objects to which that [State] subscribes, for @@ -698,7 +704,11 @@ abstract class StatelessWidget extends Widget { /// /// {@tool sample} /// -/// The following is a skeleton of a stateful widget subclass called `YellowBird`: +/// This is a skeleton of a stateful widget subclass called `YellowBird`. +/// +/// In this example. the [State] has no actual state. State is normally +/// represented as private member fields. Also, normally widgets have more +/// constructor arguments, each of which corresponds to a `final` property. /// /// ```dart /// class YellowBird extends StatefulWidget { @@ -718,11 +728,7 @@ abstract class StatelessWidget extends Widget { /// {@end-tool} /// {@tool sample} /// -/// In this example. the [State] has no actual state. State is normally -/// represented as private member fields. Also, normally widgets have more -/// constructor arguments, each of which corresponds to a `final` property. -/// -/// The next example shows the more generic widget `Bird` which can be given a +/// This example shows the more generic widget `Bird` which can be given a /// color and a child, and which has some internal state with a method that /// can be called to mutate it: /// @@ -730,12 +736,11 @@ abstract class StatelessWidget extends Widget { /// class Bird extends StatefulWidget { /// const Bird({ /// Key key, -/// this.color: const Color(0xFFFFE306), +/// this.color = const Color(0xFFFFE306), /// this.child, /// }) : super(key: key); /// /// final Color color; -/// /// final Widget child; /// /// _BirdState createState() => _BirdState(); @@ -1484,6 +1489,8 @@ abstract class ParentDataWidget extends ProxyWidge /// Inherited widgets, when referenced in this way, will cause the consumer to /// rebuild when the inherited widget itself changes state. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=Zbm3hjPjQMk} +/// /// {@tool sample} /// /// The following is a skeleton of an inherited widget called `FrogColor`: @@ -3723,11 +3730,8 @@ abstract class ComponentElement extends Element { /// [rebuild] when the element needs updating. @override void performRebuild() { - assert(() { - if (debugProfileBuildsEnabled) - Timeline.startSync('${widget.runtimeType}', arguments: timelineWhitelistArguments); - return true; - }()); + if (!kReleaseMode && debugProfileBuildsEnabled) + Timeline.startSync('${widget.runtimeType}', arguments: timelineWhitelistArguments); assert(_debugSetAllowIgnoredCallsToMarkNeedsBuild(true)); Widget built; @@ -3750,11 +3754,8 @@ abstract class ComponentElement extends Element { _child = updateChild(null, built, slot); } - assert(() { - if (debugProfileBuildsEnabled) - Timeline.finishSync(); - return true; - }()); + if (!kReleaseMode && debugProfileBuildsEnabled) + Timeline.finishSync(); } /// Subclasses should override this function to actually call the appropriate diff --git a/packages/flutter/lib/src/widgets/gesture_detector.dart b/packages/flutter/lib/src/widgets/gesture_detector.dart index f0da9d4054..32d3212d5c 100644 --- a/packages/flutter/lib/src/widgets/gesture_detector.dart +++ b/packages/flutter/lib/src/widgets/gesture_detector.dart @@ -119,7 +119,7 @@ class GestureRecognizerFactoryWithHandlers extends /// them to the callbacks. To ignore accessibility events, set /// [excludeFromSemantics] to true. /// -/// See for additional information. +/// See for additional information. /// /// Material design applications typically react to touches with ink splash /// effects. The [InkWell] class implements this effect and can be used in place diff --git a/packages/flutter/lib/src/widgets/heroes.dart b/packages/flutter/lib/src/widgets/heroes.dart index 00fb36f7c3..c95967018e 100644 --- a/packages/flutter/lib/src/widgets/heroes.dart +++ b/packages/flutter/lib/src/widgets/heroes.dart @@ -60,7 +60,8 @@ Rect _globalBoundingBoxFor(BuildContext context) { return MatrixUtils.transformRect(box.getTransformTo(null), Offset.zero & box.size); } -/// A widget that marks its child as being a candidate for hero animations. +/// A widget that marks its child as being a candidate for +/// [hero animations](https://flutter.dev/docs/development/ui/animations/hero-animations). /// /// When a [PageRoute] is pushed or popped with the [Navigator], the entire /// screen's content is replaced. An old route disappears and a new route @@ -77,13 +78,17 @@ Rect _globalBoundingBoxFor(BuildContext context) { /// same tag, a hero animation is triggered. /// /// If a [Hero] is already in flight when navigation occurs, its -/// flight animation will be redirected to its new destination. - -/// The widget shown in-flight during the transition is, by default, the +/// flight animation will be redirected to its new destination. The +/// widget shown in-flight during the transition is, by default, the /// destination route's [Hero]'s child. /// +/// For a Hero animation to trigger, the Hero has to exist on the very first +/// frame of the new page's animation. +/// /// Routes must not contain more than one [Hero] for each [tag]. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=Be9UH1kXFDw} +/// /// ## Discussion /// /// Heroes and the [Navigator]'s [Overlay] [Stack] must be axis-aligned for @@ -618,6 +623,15 @@ class HeroController extends NavigatorObserver { _maybeStartHeroTransition(route, previousRoute, HeroFlightDirection.pop, false); } + @override + void didReplace({ Route newRoute, Route oldRoute }) { + assert(navigator != null); + if (newRoute?.isCurrent == true) { + // Only run hero animations if the top-most route got replaced. + _maybeStartHeroTransition(oldRoute, newRoute, HeroFlightDirection.push, false); + } + } + @override void didStartUserGesture(Route route, Route previousRoute) { assert(navigator != null); diff --git a/packages/flutter/lib/src/widgets/image.dart b/packages/flutter/lib/src/widgets/image.dart index 8fc167caa3..ae0046bc63 100644 --- a/packages/flutter/lib/src/widgets/image.dart +++ b/packages/flutter/lib/src/widgets/image.dart @@ -386,7 +386,7 @@ class Image extends StatefulWidget { /// omitted. /// * [ExactAssetImage], which is used to implement the behavior when the /// scale is present. - /// * , an introduction to assets in + /// * , an introduction to assets in /// Flutter. Image.asset( String name, { diff --git a/packages/flutter/lib/src/widgets/implicit_animations.dart b/packages/flutter/lib/src/widgets/implicit_animations.dart index 169354ba58..a222be5340 100644 --- a/packages/flutter/lib/src/widgets/implicit_animations.dart +++ b/packages/flutter/lib/src/widgets/implicit_animations.dart @@ -452,6 +452,8 @@ abstract class AnimatedWidgetBaseState exten /// [AnimatedWidget] such as the [DecoratedBoxTransition] or use your own /// [AnimationController]. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=yI-8QHpGIP4} +/// /// Here's an illustration of what using this widget looks like, using a [curve] /// of [Curves.fastOutSlowIn]. /// {@animation 250 266 https://flutter.github.io/assets-for-api-docs/assets/widgets/animated_container.mp4} @@ -460,7 +462,7 @@ abstract class AnimatedWidgetBaseState exten /// /// * [AnimatedPadding], which is a subset of this widget that only /// supports animating the [padding]. -/// * The [catalog of layout widgets](https://flutter.io/widgets/layout/). +/// * The [catalog of layout widgets](https://flutter.dev/widgets/layout/). /// * [AnimatedPositioned], which, as a child of a [Stack], automatically /// transitions its child's position over a given duration whenever the given /// position changes. diff --git a/packages/flutter/lib/src/widgets/inherited_model.dart b/packages/flutter/lib/src/widgets/inherited_model.dart index d666c91f9c..f03fae4a01 100644 --- a/packages/flutter/lib/src/widgets/inherited_model.dart +++ b/packages/flutter/lib/src/widgets/inherited_model.dart @@ -25,6 +25,8 @@ import 'framework.dart'; /// /// The type parameter `T` is the type of the model aspect objects. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=ml5uefGgkaA} +/// /// Widgets create a dependency on an [InheritedModel] with a static method: /// [InheritedModel.inheritFrom]. This method's `context` parameter /// defines the subtree that will be rebuilt when the model changes. diff --git a/packages/flutter/lib/src/widgets/layout_builder.dart b/packages/flutter/lib/src/widgets/layout_builder.dart index 3c16754861..ab7f34dad3 100644 --- a/packages/flutter/lib/src/widgets/layout_builder.dart +++ b/packages/flutter/lib/src/widgets/layout_builder.dart @@ -19,6 +19,8 @@ typedef LayoutWidgetBuilder = Widget Function(BuildContext context, BoxConstrain /// the child's intrinsic size. The [LayoutBuilder]'s final size will match its /// child's size. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=IYDVcriKjsw} +/// /// If the child should be smaller than the parent, consider wrapping the child /// in an [Align] widget. If the child might want to be bigger, consider /// wrapping it in a [SingleChildScrollView]. diff --git a/packages/flutter/lib/src/widgets/overlay.dart b/packages/flutter/lib/src/widgets/overlay.dart index 70a1212754..55d009471e 100644 --- a/packages/flutter/lib/src/widgets/overlay.dart +++ b/packages/flutter/lib/src/widgets/overlay.dart @@ -272,26 +272,71 @@ class OverlayState extends State with TickerProviderStateMixin { insertAll(widget.initialEntries); } + int _insertionIndex(OverlayEntry below, OverlayEntry above) { + assert(above == null || below == null); + if (below != null) + return _entries.indexOf(below); + if (above != null) + return _entries.indexOf(above) + 1; + return _entries.length; + } + /// Insert the given entry into the overlay. /// + /// If `below` is non-null, the entry is inserted just below `below`. /// If `above` is non-null, the entry is inserted just above `above`. /// Otherwise, the entry is inserted on top. - void insert(OverlayEntry entry, { OverlayEntry above }) { - assert(entry._overlay == null); - assert(above == null || (above._overlay == this && _entries.contains(above))); + /// + /// It is an error to specify both `above` and `below`. + void insert(OverlayEntry entry, { OverlayEntry below, OverlayEntry above }) { + assert( + above == null || below == null, + 'Only one of `above` and `below` may be specified.', + ); + assert( + above == null || (above._overlay == this && _entries.contains(above)), + 'The provided entry for `above` is not present in the Overlay.', + ); + assert( + below == null || (below._overlay == this && _entries.contains(below)), + 'The provided entry for `below` is not present in the Overlay.', + ); + assert(!_entries.contains(entry), 'The specified entry is already present in the Overlay.'); + assert(entry._overlay == null, 'The specified entry is already present in another Overlay.'); entry._overlay = this; setState(() { - final int index = above == null ? _entries.length : _entries.indexOf(above) + 1; - _entries.insert(index, entry); + _entries.insert(_insertionIndex(below, above), entry); }); } /// Insert all the entries in the given iterable. /// + /// If `below` is non-null, the entries are inserted just below `below`. /// If `above` is non-null, the entries are inserted just above `above`. /// Otherwise, the entries are inserted on top. - void insertAll(Iterable entries, { OverlayEntry above }) { - assert(above == null || (above._overlay == this && _entries.contains(above))); + /// + /// It is an error to specify both `above` and `below`. + void insertAll(Iterable entries, { OverlayEntry below, OverlayEntry above }) { + assert( + above == null || below == null, + 'Only one of `above` and `below` may be specified.', + ); + assert( + above == null || (above._overlay == this && _entries.contains(above)), + 'The provided entry for `above` is not present in the Overlay.', + ); + assert( + below == null || (below._overlay == this && _entries.contains(below)), + 'The provided entry for `below` is not present in the Overlay.', + ); + assert( + entries.every((OverlayEntry entry) => !_entries.contains(entry)), + 'One or more of the specified entries are already present in the Overlay.' + ); + assert( + entries.every((OverlayEntry entry) => entry._overlay == null), + 'One or more of the specified entries are already present in another Overlay.' + ); if (entries.isEmpty) return; for (OverlayEntry entry in entries) { @@ -299,8 +344,62 @@ class OverlayState extends State with TickerProviderStateMixin { entry._overlay = this; } setState(() { - final int index = above == null ? _entries.length : _entries.indexOf(above) + 1; - _entries.insertAll(index, entries); + _entries.insertAll(_insertionIndex(below, above), entries); + }); + } + + /// Remove all the entries listed in the given iterable, then reinsert them + /// into the overlay in the given order. + /// + /// Entries mention in `newEntries` but absent from the overlay are inserted + /// as if with [insertAll]. + /// + /// Entries not mentioned in `newEntries` but present in the overlay are + /// positioned as a group in the resulting list relative to the entries that + /// were moved, as specified by one of `below` or `above`, which, if + /// specified, must be one of the entries in `newEntries`: + /// + /// If `below` is non-null, the group is positioned just below `below`. + /// If `above` is non-null, the group is positioned just above `above`. + /// Otherwise, the group is left on top, with all the rearranged entries + /// below. + /// + /// It is an error to specify both `above` and `below`. + void rearrange(Iterable newEntries, { OverlayEntry below, OverlayEntry above }) { + final List newEntriesList = newEntries is List ? newEntries : newEntries.toList(growable: false); + assert( + above == null || below == null, + 'Only one of `above` and `below` may be specified.', + ); + assert( + above == null || (above._overlay == this && _entries.contains(above) && newEntriesList.contains(above)), + 'The entry used for `above` must be in the Overlay and in the `newEntriesList`.' + ); + assert( + below == null || (below._overlay == this && _entries.contains(below) && newEntriesList.contains(below)), + 'The entry used for `below` must be in the Overlay and in the `newEntriesList`.' + ); + assert( + newEntriesList.every((OverlayEntry entry) => entry._overlay == null || entry._overlay == this), + 'One or more of the specified entries are already present in another Overlay.' + ); + assert( + newEntriesList.every((OverlayEntry entry) => _entries.indexOf(entry) == _entries.lastIndexOf(entry)), + 'One or more of the specified entries are specified multiple times.' + ); + if (newEntriesList.isEmpty) + return; + if (listEquals(_entries, newEntriesList)) + return; + final LinkedHashSet old = LinkedHashSet.from(_entries); + for (OverlayEntry entry in newEntriesList) { + entry._overlay ??= this; + } + setState(() { + _entries.clear(); + _entries.addAll(newEntriesList); + old.removeAll(newEntriesList); + _entries.insertAll(_insertionIndex(below, above), old); }); } diff --git a/packages/flutter/lib/src/widgets/page_view.dart b/packages/flutter/lib/src/widgets/page_view.dart index 9193ed20cf..07531e2de1 100644 --- a/packages/flutter/lib/src/widgets/page_view.dart +++ b/packages/flutter/lib/src/widgets/page_view.dart @@ -400,6 +400,8 @@ const PageScrollPhysics _kPagePhysics = PageScrollPhysics(); /// [PageView] is first constructed, and the [PageController.viewportFraction], /// which determines the size of the pages as a fraction of the viewport size. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=J1gE9xvph-A} +/// /// See also: /// /// * [PageController], which controls which page is visible in the view. diff --git a/packages/flutter/lib/src/widgets/routes.dart b/packages/flutter/lib/src/widgets/routes.dart index eb23e0095f..798d960d8c 100644 --- a/packages/flutter/lib/src/widgets/routes.dart +++ b/packages/flutter/lib/src/widgets/routes.dart @@ -114,6 +114,12 @@ abstract class TransitionRoute extends OverlayRoute { AnimationController get controller => _controller; AnimationController _controller; + /// The animation for the route being pushed on top of this route. This + /// animation lets this route coordinate with the entrance and exit transition + /// of route pushed on top of this route. + Animation get secondaryAnimation => _secondaryAnimation; + final ProxyAnimation _secondaryAnimation = ProxyAnimation(kAlwaysDismissedAnimation); + /// Called to create the animation controller that will drive the transitions to /// this route from the previous one, and back to the previous route from this /// one. @@ -164,12 +170,6 @@ abstract class TransitionRoute extends OverlayRoute { changedInternalState(); } - /// The animation for the route being pushed on top of this route. This - /// animation lets this route coordinate with the entrance and exit transition - /// of routes pushed on top of this route. - Animation get secondaryAnimation => _secondaryAnimation; - final ProxyAnimation _secondaryAnimation = ProxyAnimation(kAlwaysDismissedAnimation); - @override void install(OverlayEntry insertionPoint) { assert(!_transitionCompleter.isCompleted, 'Cannot install a $runtimeType after disposing it.'); diff --git a/packages/flutter/lib/src/widgets/safe_area.dart b/packages/flutter/lib/src/widgets/safe_area.dart index 2c847db91d..8a5645764c 100644 --- a/packages/flutter/lib/src/widgets/safe_area.dart +++ b/packages/flutter/lib/src/widgets/safe_area.dart @@ -23,6 +23,8 @@ import 'media_query.dart'; /// When a [minimum] padding is specified, the greater of the minimum padding /// or the safe area padding will be applied. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=lkF0TQJO0bA} +/// /// See also: /// /// * [SliverSafeArea], for insetting slivers to avoid operating system diff --git a/packages/flutter/lib/src/widgets/scroll_view.dart b/packages/flutter/lib/src/widgets/scroll_view.dart index 0f28527e21..45d18578cb 100644 --- a/packages/flutter/lib/src/widgets/scroll_view.dart +++ b/packages/flutter/lib/src/widgets/scroll_view.dart @@ -608,6 +608,8 @@ abstract class BoxScrollView extends ScrollView { /// explicit [List] of children. This [ListView]'s children are made up /// of [Container]s with [Text]. /// +/// ![A ListView of 3 amber colored containers with sample text.](https://flutter.github.io/assets-for-api-docs/assets/widgets/list_view.png) +/// /// ```dart /// ListView( /// padding: const EdgeInsets.all(8.0), @@ -631,11 +633,14 @@ abstract class BoxScrollView extends ScrollView { /// ) /// ``` /// {@end-tool} +/// /// {@tool sample} /// This example mirrors the previous one, creating the same list using the /// [ListView.builder] constructor. Using the [IndexedWidgetBuilder], children /// are built lazily and can be infinite in number. /// +/// ![A ListView of 3 amber colored containers with sample text.](https://flutter.github.io/assets-for-api-docs/assets/widgets/list_view_builder.png) +/// /// ```dart /// final List entries = ['A', 'B', 'C']; /// final List colorCodes = [600, 500, 100]; @@ -653,11 +658,15 @@ abstract class BoxScrollView extends ScrollView { /// ); /// ``` /// {@end-tool} +/// /// {@tool sample} /// This example continues to build from our the previous ones, creating a /// similar list using [ListView.separated]. Here, a [Divider] is used as a /// separator. /// +/// ![A ListView of 3 amber colored containers with sample text and a Divider +/// between each of them.](https://flutter.github.io/assets-for-api-docs/assets/widgets/list_view_separated.png) +/// /// ```dart /// final List entries = ['A', 'B', 'C']; /// final List colorCodes = [600, 500, 100]; diff --git a/packages/flutter/lib/src/widgets/sliver.dart b/packages/flutter/lib/src/widgets/sliver.dart index cf28841b47..d551a0986c 100644 --- a/packages/flutter/lib/src/widgets/sliver.dart +++ b/packages/flutter/lib/src/widgets/sliver.dart @@ -656,6 +656,8 @@ abstract class SliverMultiBoxAdaptorWidget extends SliverWithKeepAliveWidget { /// means [SliverList] cannot learn their main axis extent. Instead, newly /// materialized children are placed adjacent to existing children. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=ORiTTaVY6mM} +/// /// If the children have a fixed extent in the main axis, consider using /// [SliverFixedExtentList] rather than [SliverList] because /// [SliverFixedExtentList] does not need to perform layout on its children to @@ -762,6 +764,8 @@ class SliverFixedExtentList extends SliverMultiBoxAdaptorWidget { /// The main axis direction of a grid is the direction in which it scrolls; the /// cross axis direction is the orthogonal direction. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=ORiTTaVY6mM} +/// /// {@tool sample} /// /// This example, which would be inserted into a [CustomScrollView.slivers] @@ -1287,8 +1291,8 @@ class KeepAlive extends ParentDataWidget { } } -// Return an ErrorWidget for the given Exception -ErrorWidget _createErrorWidget(dynamic exception, StackTrace stackTrace) { +// Return a Widget for the given Exception +Widget _createErrorWidget(dynamic exception, StackTrace stackTrace) { final FlutterErrorDetails details = FlutterErrorDetails( exception: exception, stack: stackTrace, diff --git a/packages/flutter/lib/src/widgets/table.dart b/packages/flutter/lib/src/widgets/table.dart index e71b2a7457..d5f9564f13 100644 --- a/packages/flutter/lib/src/widgets/table.dart +++ b/packages/flutter/lib/src/widgets/table.dart @@ -79,6 +79,8 @@ class _TableElementRow { /// A widget that uses the table layout algorithm for its children. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=_lbE0wsVZSw} +/// /// If you only have one row, the [Row] widget is more appropriate. If you only /// have one column, the [SliverList] or [Column] widgets will be more /// appropriate. diff --git a/packages/flutter/lib/src/widgets/text.dart b/packages/flutter/lib/src/widgets/text.dart index 99b76f4d04..e3c7042d07 100644 --- a/packages/flutter/lib/src/widgets/text.dart +++ b/packages/flutter/lib/src/widgets/text.dart @@ -348,7 +348,8 @@ class Text extends StatelessWidget { /// An alternative semantics label for this text. /// /// If present, the semantics of this widget will contain this value instead - /// of the actual text. + /// of the actual text. This will overwrite any of the semantics labels applied + /// directly to the [TextSpan]s. /// /// This is useful for replacing abbreviations or shorthands with the full /// text value: diff --git a/packages/flutter/lib/src/widgets/transitions.dart b/packages/flutter/lib/src/widgets/transitions.dart index 358c229c61..86e2513de6 100644 --- a/packages/flutter/lib/src/widgets/transitions.dart +++ b/packages/flutter/lib/src/widgets/transitions.dart @@ -441,6 +441,8 @@ class SizeTransition extends AnimatedWidget { /// For a widget that automatically animates between the sizes of two children, /// fading between them, see [AnimatedCrossFade]. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=rLwWVbv3xDQ} +/// /// Here's an illustration of the [FadeTransition] widget, with it's [opacity] /// animated by a [CurvedAnimation] set to [Curves.fastOutSlowIn]: /// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/fade_transition.mp4} @@ -812,6 +814,8 @@ class DefaultTextStyleTransition extends AnimatedWidget { /// For simple cases without additional state, consider using /// [AnimatedWidget]. /// +/// {@youtube 560 315 https://www.youtube.com/watch?v=N-RiyZlv8v8} +/// /// ## Performance optimizations /// /// If your [builder] function contains a subtree that does not depend on the diff --git a/packages/flutter/lib/src/widgets/value_listenable_builder.dart b/packages/flutter/lib/src/widgets/value_listenable_builder.dart index 01a2889181..30a397425e 100644 --- a/packages/flutter/lib/src/widgets/value_listenable_builder.dart +++ b/packages/flutter/lib/src/widgets/value_listenable_builder.dart @@ -38,6 +38,65 @@ typedef ValueWidgetBuilder = Widget Function(BuildContext context, T value, W /// Using this pre-built child is entirely optional, but can improve /// performance significantly in some cases and is therefore a good practice. /// +/// {@tool sample} +/// +/// This sample shows how you could use a [ValueListenableBuilder] instead of +/// setting state on the whole [Scaffold] in the default `flutter create` app. +/// +/// ```dart +/// class MyHomePage extends StatefulWidget { +/// MyHomePage({Key key, this.title}) : super(key: key); +/// final String title; +/// +/// @override +/// _MyHomePageState createState() => _MyHomePageState(); +/// } +/// +/// class _MyHomePageState extends State { +/// final ValueNotifier _counter = ValueNotifier(0); +/// final Widget goodJob = const Text('Good job!'); +/// @override +/// Widget build(BuildContext context) { +/// return Scaffold( +/// appBar: AppBar( +/// title: Text(widget.title) +/// ), +/// body: Center( +/// child: Column( +/// mainAxisAlignment: MainAxisAlignment.center, +/// children: [ +/// Text('You have pushed the button this many times:'), +/// ValueListenableBuilder( +/// builder: (BuildContext context, int value, Widget child) { +/// // This builder will only get called when the _counter +/// // is updated. +/// return Row( +/// mainAxisAlignment: MainAxisAlignment.spaceEvenly, +/// children: [ +/// Text('$value'), +/// child, +/// ], +/// ); +/// }, +/// valueListenable: _counter, +/// // The child parameter is most helpful if the child is +/// // expensive to build and does not depend on the value from +/// // the notifier. +/// child: goodJob, +/// ) +/// ], +/// ), +/// ), +/// floatingActionButton: FloatingActionButton( +/// child: Icon(Icons.plus_one), +/// onPressed: () => _counter.value += 1, +/// ), +/// ); +/// } +/// } +/// ``` +/// {@end-tool} +/// /// See also: /// /// * [AnimatedBuilder], which also triggers rebuilds from a [Listenable] diff --git a/packages/flutter/lib/widgets.dart b/packages/flutter/lib/widgets.dart index 1bf6388b7f..bcd5ed5bc2 100644 --- a/packages/flutter/lib/widgets.dart +++ b/packages/flutter/lib/widgets.dart @@ -8,7 +8,7 @@ /// /// See also: /// -/// * [flutter.io/widgets](https://flutter.io/widgets/) +/// * [flutter.dev/widgets](https://flutter.dev/widgets/) /// for a catalog of commonly-used Flutter widgets. library widgets; @@ -30,6 +30,7 @@ export 'src/widgets/container.dart'; export 'src/widgets/debug.dart'; export 'src/widgets/dismissible.dart'; export 'src/widgets/drag_target.dart'; +export 'src/widgets/draggable_scrollable_sheet.dart'; export 'src/widgets/editable_text.dart'; export 'src/widgets/fade_in_image.dart'; export 'src/widgets/focus_manager.dart'; diff --git a/packages/flutter/pubspec.yaml b/packages/flutter/pubspec.yaml index 2ed520a45b..60541d6e60 100644 --- a/packages/flutter/pubspec.yaml +++ b/packages/flutter/pubspec.yaml @@ -1,7 +1,7 @@ name: flutter author: Flutter Authors description: A framework for writing Flutter applications -homepage: http://flutter.io +homepage: http://flutter.dev environment: # The pub client defaults to an <2.0.0 sdk constraint which we need to explicitly overwrite. @@ -24,22 +24,22 @@ dev_dependencies: sdk: flutter mockito: 4.0.0 - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" file: 5.0.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - intl: 0.15.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl: 0.15.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" platform: 2.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" process: 3.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - quiver: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + quiver: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" -# PUBSPEC CHECKSUM: 6541 +# PUBSPEC CHECKSUM: 79d6 diff --git a/packages/flutter/test/cupertino/date_picker_test.dart b/packages/flutter/test/cupertino/date_picker_test.dart index 37377ec443..e387d0b81f 100644 --- a/packages/flutter/test/cupertino/date_picker_test.dart +++ b/packages/flutter/test/cupertino/date_picker_test.dart @@ -1,6 +1,8 @@ // Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + +import 'dart:io' show Platform; import 'dart:ui'; import 'package:flutter/cupertino.dart'; @@ -264,6 +266,31 @@ void main() { expect(picker.initialDateTime, isNotNull); }); + testWidgets('initial date honors minuteInterval', (WidgetTester tester) async { + DateTime newDateTime; + await tester.pumpWidget( + CupertinoApp( + home: SizedBox( + width: 400, + height: 400, + child: CupertinoDatePicker( + onDateTimeChanged: (DateTime d) => newDateTime = d, + initialDateTime: DateTime(2018, 10, 10, 10, 3), + minuteInterval: 3, + ) + ) + ) + ); + + // Drag the minute picker to the next slot (03 -> 06). + // The `initialDateTime` and the `minuteInterval` values are specifically choosen + // so that `find.text` finds exactly one widget. + await tester.drag(find.text('03'), _kRowOffset); + await tester.pump(); + + expect(newDateTime.minute, 6); + }); + testWidgets('changing initialDateTime after first build does not do anything', (WidgetTester tester) async { DateTime selectedDateTime; await tester.pumpWidget( @@ -811,6 +838,37 @@ void main() { expect(lastSelectedItem, 1); handle.dispose(); }); + + testWidgets('DatePicker golden tests', (WidgetTester tester) async { + await tester.pumpWidget( + CupertinoApp( + home: SizedBox( + width: 200, + child: CupertinoDatePicker( + mode: CupertinoDatePickerMode.dateAndTime, + initialDateTime: DateTime(2019, 1, 1, 4), + onDateTimeChanged: (_) {}, + ) + ) + ) + ); + + await expectLater( + find.byType(CupertinoDatePicker), + matchesGoldenFile('date_picker_test.datetime.initial.png'), + skip: !Platform.isLinux + ); + + // Slightly drag the hour component to make the current hour off-center. + await tester.drag(find.text('4'), Offset(0, _kRowOffset.dy / 2)); + await tester.pump(); + + await expectLater( + find.byType(CupertinoDatePicker), + matchesGoldenFile('date_picker_test.datetime.drag.png'), + skip: !Platform.isLinux + ); + }); } Widget _buildPicker({ FixedExtentScrollController controller, ValueChanged onSelectedItemChanged }) { diff --git a/packages/flutter/test/cupertino/nav_bar_test.dart b/packages/flutter/test/cupertino/nav_bar_test.dart index 4493f78021..09419a0393 100644 --- a/packages/flutter/test/cupertino/nav_bar_test.dart +++ b/packages/flutter/test/cupertino/nav_bar_test.dart @@ -883,6 +883,28 @@ void main() { ); expect(SystemChrome.latestStyle, SystemUiOverlayStyle.dark); }); + + testWidgets('CupertinoNavigationBarBackButton shows an error when manually added outside a route', (WidgetTester tester) async { + await tester.pumpWidget( + const CupertinoNavigationBarBackButton() + ); + + final dynamic exception = tester.takeException(); + expect(exception, isAssertionError); + expect(exception.toString(), contains('CupertinoNavigationBarBackButton should only be used in routes that can be popped')); + }); + + testWidgets('CupertinoNavigationBarBackButton shows an error when placed in a route that cannot be popped', (WidgetTester tester) async { + await tester.pumpWidget( + const CupertinoApp( + home: CupertinoNavigationBarBackButton(), + ), + ); + + final dynamic exception = tester.takeException(); + expect(exception, isAssertionError); + expect(exception.toString(), contains('CupertinoNavigationBarBackButton should only be used in routes that can be popped')); + }); } class _ExpectStyles extends StatelessWidget { diff --git a/packages/flutter/test/cupertino/route_test.dart b/packages/flutter/test/cupertino/route_test.dart index dd152840ae..4250fcd9dd 100644 --- a/packages/flutter/test/cupertino/route_test.dart +++ b/packages/flutter/test/cupertino/route_test.dart @@ -309,9 +309,8 @@ void main() { expect(find.text('route'), findsNothing); - // Run the dismiss animation 75%, which exposes the route "push" button, - // and then press the button. MaterialPageTransition duration is 300ms, - // 275 = 300 * 0.75. + // Run the dismiss animation 60%, which exposes the route "push" button, + // and then press the button. await tester.tap(find.text('push')); await tester.pumpAndSettle(); @@ -319,10 +318,27 @@ void main() { expect(find.text('push'), findsNothing); gesture = await tester.startGesture(const Offset(5, 300)); - await gesture.moveBy(const Offset(400, 0)); // drag halfway + await gesture.moveBy(const Offset(400, 0)); // Drag halfway. await gesture.up(); - await tester.pump(const Duration(milliseconds: 275)); // partially dismiss "route" - expect(find.text('route'), findsOneWidget); + // Trigger the snapping animation. + // Since the back swipe drag was brought to >=50% of the screen, it will + // self snap to finish the pop transition as the gesture is lifted. + // + // This drag drop animation is 400ms when dropped exactly halfway + // (800 / [pixel distance remaining], see + // _CupertinoBackGestureController.dragEnd). It follows a curve that is very + // steep initially. + await tester.pump(); + expect( + tester.getTopLeft(find.ancestor(of: find.text('route'), matching: find.byType(CupertinoPageScaffold))), + const Offset(400, 0), + ); + // Let the dismissing snapping animation go 60%. + await tester.pump(const Duration(milliseconds: 240)); + expect( + tester.getTopLeft(find.ancestor(of: find.text('route'), matching: find.byType(CupertinoPageScaffold))).dx, + moreOrLessEquals(798, epsilon: 1), + ); await tester.tap(find.text('push')); await tester.pumpAndSettle(); expect(find.text('route'), findsOneWidget); @@ -431,4 +447,181 @@ void main() { await tester.pump(const Duration(milliseconds: 40)); expect(tester.getTopLeft(find.byType(Placeholder)).dy, closeTo(600.0, 0.1)); }); + + testWidgets('Animated push/pop is not linear', (WidgetTester tester) async { + await tester.pumpWidget( + const CupertinoApp( + home: Text('1'), + ), + ); + + final CupertinoPageRoute route2 = CupertinoPageRoute( + builder: (BuildContext context) { + return const CupertinoPageScaffold( + child: Text('2'), + ); + } + ); + + tester.state(find.byType(Navigator)).push(route2); + // The whole transition is 400ms based on CupertinoPageRoute.transitionDuration. + // Break it up into small chunks. + + await tester.pump(); + await tester.pump(const Duration(milliseconds: 50)); + expect(tester.getTopLeft(find.text('1')).dx, moreOrLessEquals(-87, epsilon: 1)); + expect(tester.getTopLeft(find.text('2')).dx, moreOrLessEquals(537, epsilon: 1)); + + await tester.pump(const Duration(milliseconds: 50)); + expect(tester.getTopLeft(find.text('1')).dx, moreOrLessEquals(-166, epsilon: 1)); + expect(tester.getTopLeft(find.text('2')).dx, moreOrLessEquals(301, epsilon: 1)); + + await tester.pump(const Duration(milliseconds: 50)); + // Translation slows down as time goes on. + expect(tester.getTopLeft(find.text('1')).dx, moreOrLessEquals(-220, epsilon: 1)); + expect(tester.getTopLeft(find.text('2')).dx, moreOrLessEquals(141, epsilon: 1)); + + // Finish the rest of the animation + await tester.pump(const Duration(milliseconds: 250)); + + tester.state(find.byType(Navigator)).pop(); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 50)); + expect(tester.getTopLeft(find.text('1')).dx, moreOrLessEquals(-179, epsilon: 1)); + expect(tester.getTopLeft(find.text('2')).dx, moreOrLessEquals(262, epsilon: 1)); + + await tester.pump(const Duration(milliseconds: 50)); + expect(tester.getTopLeft(find.text('1')).dx, moreOrLessEquals(-100, epsilon: 1)); + expect(tester.getTopLeft(find.text('2')).dx, moreOrLessEquals(499, epsilon: 1)); + + await tester.pump(const Duration(milliseconds: 50)); + // Translation slows down as time goes on. + expect(tester.getTopLeft(find.text('1')).dx, moreOrLessEquals(-47, epsilon: 1)); + expect(tester.getTopLeft(find.text('2')).dx, moreOrLessEquals(659, epsilon: 1)); + }); + + testWidgets('Dragged pop gesture is linear', (WidgetTester tester) async { + await tester.pumpWidget( + const CupertinoApp( + home: Text('1'), + ), + ); + + final CupertinoPageRoute route2 = CupertinoPageRoute( + builder: (BuildContext context) { + return const CupertinoPageScaffold( + child: Text('2'), + ); + } + ); + + tester.state(find.byType(Navigator)).push(route2); + + await tester.pumpAndSettle(); + + expect(find.text('1'), findsNothing); + expect(tester.getTopLeft(find.text('2')).dx, moreOrLessEquals(0)); + + final TestGesture swipeGesture = await tester.startGesture(const Offset(5, 100)); + + await swipeGesture.moveBy(const Offset(100, 0)); + await tester.pump(); + expect(tester.getTopLeft(find.text('1')).dx, moreOrLessEquals(-233, epsilon: 1)); + expect(tester.getTopLeft(find.text('2')).dx, moreOrLessEquals(100)); + + await swipeGesture.moveBy(const Offset(100, 0)); + await tester.pump(); + expect(tester.getTopLeft(find.text('1')).dx, moreOrLessEquals(-200)); + expect(tester.getTopLeft(find.text('2')).dx, moreOrLessEquals(200)); + + // Moving by the same distance each time produces linear movements on both + // routes. + await swipeGesture.moveBy(const Offset(100, 0)); + await tester.pump(); + expect(tester.getTopLeft(find.text('1')).dx, moreOrLessEquals(-166, epsilon: 1)); + expect(tester.getTopLeft(find.text('2')).dx, moreOrLessEquals(300)); + }); + + testWidgets('Pop gesture snapping is not linear', (WidgetTester tester) async { + await tester.pumpWidget( + const CupertinoApp( + home: Text('1'), + ), + ); + + final CupertinoPageRoute route2 = CupertinoPageRoute( + builder: (BuildContext context) { + return const CupertinoPageScaffold( + child: Text('2'), + ); + } + ); + + tester.state(find.byType(Navigator)).push(route2); + + await tester.pumpAndSettle(); + + final TestGesture swipeGesture = await tester.startGesture(const Offset(5, 100)); + + await swipeGesture.moveBy(const Offset(500, 0)); + await swipeGesture.up(); + await tester.pump(); + expect(tester.getTopLeft(find.text('1')).dx, moreOrLessEquals(-100)); + expect(tester.getTopLeft(find.text('2')).dx, moreOrLessEquals(500)); + + await tester.pump(const Duration(milliseconds: 50)); + expect(tester.getTopLeft(find.text('1')).dx, moreOrLessEquals(-19, epsilon: 1)); + expect(tester.getTopLeft(find.text('2')).dx, moreOrLessEquals(744, epsilon: 1)); + + await tester.pump(const Duration(milliseconds: 50)); + // Rate of change is slowing down. + expect(tester.getTopLeft(find.text('1')).dx, moreOrLessEquals(-4, epsilon: 1)); + expect(tester.getTopLeft(find.text('2')).dx, moreOrLessEquals(787, epsilon: 1)); + }); + + testWidgets('Snapped drags forwards and backwards should signal didStopUserGesture', (WidgetTester tester) async { + final GlobalKey navigatorKey = GlobalKey(); + await tester.pumpWidget( + CupertinoApp( + navigatorKey: navigatorKey, + home: const Text('1'), + ), + ); + + final CupertinoPageRoute route2 = CupertinoPageRoute( + builder: (BuildContext context) { + return const CupertinoPageScaffold( + child: Text('2'), + ); + } + ); + + navigatorKey.currentState.push(route2); + await tester.pumpAndSettle(); + + await tester.dragFrom(const Offset(5, 100), const Offset(100, 0)); + await tester.pump(); + expect(tester.getTopLeft(find.text('2')).dx, moreOrLessEquals(100)); + expect(navigatorKey.currentState.userGestureInProgress, true); + + // Didn't drag far enough to snap into dismissing this route. + // Each 100px distance takes 100ms to snap back. + await tester.pump(const Duration(milliseconds: 101)); + // Back to the page covering the whole screen. + expect(tester.getTopLeft(find.text('2')).dx, moreOrLessEquals(0)); + expect(navigatorKey.currentState.userGestureInProgress, false); + + await tester.dragFrom(const Offset(5, 100), const Offset(500, 0)); + await tester.pump(); + expect(tester.getTopLeft(find.text('2')).dx, moreOrLessEquals(500)); + expect(navigatorKey.currentState.userGestureInProgress, true); + + // Did go far enough to snap out of this route. + await tester.pump(const Duration(milliseconds: 301)); + // Back to the page covering the whole screen. + expect(find.text('2'), findsNothing); + // First route covers the whole screen. + expect(tester.getTopLeft(find.text('1')).dx, moreOrLessEquals(0)); + expect(navigatorKey.currentState.userGestureInProgress, false); + }); } diff --git a/packages/flutter/test/cupertino/scaffold_test.dart b/packages/flutter/test/cupertino/scaffold_test.dart index e42ec03fab..90bc50a46c 100644 --- a/packages/flutter/test/cupertino/scaffold_test.dart +++ b/packages/flutter/test/cupertino/scaffold_test.dart @@ -25,6 +25,34 @@ void main() { expect(tester.getTopLeft(find.byType(Center)), const Offset(0.0, 0.0)); }); +testWidgets('Opaque bar pushes contents down', (WidgetTester tester) async { + BuildContext childContext; + await tester.pumpWidget(Directionality( + textDirection: TextDirection.ltr, + child: MediaQuery( + data: const MediaQueryData(viewInsets: EdgeInsets.only(top: 20)), + child: CupertinoPageScaffold( + navigationBar: const CupertinoNavigationBar( + middle: Text('Opaque'), + backgroundColor: Color(0xFFF8F8F8), + ), + child: Builder( + builder: (BuildContext context) { + childContext = context; + return Container(); + }, + ), + ), + ), + )); + + expect(MediaQuery.of(childContext).padding.top, 0); + // The top of the [Container] is 44 px from the top of the screen because + // it's pushed down by the opaque navigation bar whose height is 44 px, + // and the 20 px [MediaQuery] top padding is fully absorbed by the navigation bar. + expect(tester.getRect(find.byType(Container)), Rect.fromLTRB(0, 44, 800, 600)); + }); + testWidgets('Contents padding from viewInsets', (WidgetTester tester) async { await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, @@ -315,4 +343,56 @@ void main() { final BoxDecoration decoration = decoratedBox.decoration; expect(decoration.color, const Color(0xFF010203)); }); + + testWidgets('Lists in CupertinoPageScaffold scroll to the top when status bar tapped', (WidgetTester tester) async { + await tester.pumpWidget( + CupertinoApp( + builder: (BuildContext context, Widget child) { + // Acts as a 20px status bar at the root of the app. + return MediaQuery( + data: MediaQuery.of(context).copyWith(padding: const EdgeInsets.only(top: 20)), + child: child, + ); + }, + home: CupertinoPageScaffold( + // Default nav bar is translucent. + navigationBar: const CupertinoNavigationBar( + middle: Text('Title'), + ), + child: ListView.builder( + itemExtent: 50, + itemBuilder: (BuildContext context, int index) => Text(index.toString()), + ), + ), + ), + ); + // Top media query padding 20 + translucent nav bar 44. + expect(tester.getTopLeft(find.text('0')).dy, 64); + expect(tester.getTopLeft(find.text('6')).dy, 364); + + await tester.fling( + find.text('5'), // Find some random text on the screen. + const Offset(0, -200), + 20, + ); + + await tester.pumpAndSettle(); + + expect(tester.getTopLeft(find.text('6')).dy, moreOrLessEquals(166.833, epsilon: 0.1)); + expect(tester.getTopLeft(find.text('12')).dy, moreOrLessEquals(466.8333333333334, epsilon: 0.1)); + + // The media query top padding is 20. Tapping at 20 should do nothing. + await tester.tapAt(const Offset(400, 20)); + await tester.pumpAndSettle(); + expect(tester.getTopLeft(find.text('6')).dy, moreOrLessEquals(166.833, epsilon: 0.1)); + expect(tester.getTopLeft(find.text('12')).dy, moreOrLessEquals(466.8333333333334, epsilon: 0.1)); + + // Tap 1 pixel higher. + await tester.tapAt(const Offset(400, 19)); + await tester.pump(); + await tester.pump(const Duration(milliseconds: 500)); + expect(tester.getTopLeft(find.text('0')).dy, 64); + expect(tester.getTopLeft(find.text('6')).dy, 364); + expect(find.text('12'), findsNothing); + }); } diff --git a/packages/flutter/test/cupertino/segmented_control_test.dart b/packages/flutter/test/cupertino/segmented_control_test.dart index 3a2a89a827..1214541640 100644 --- a/packages/flutter/test/cupertino/segmented_control_test.dart +++ b/packages/flutter/test/cupertino/segmented_control_test.dart @@ -247,20 +247,20 @@ void main() { ); DefaultTextStyle textStyle = tester.widget(find.widgetWithText(DefaultTextStyle, 'Child 1').first); - IconTheme iconTheme = tester.widget(find.widgetWithIcon(IconTheme, const IconData(1))); + IconThemeData iconTheme = IconTheme.of(tester.element(find.byIcon(const IconData(1)))); expect(textStyle.style.color, CupertinoColors.black); - expect(iconTheme.data.color, CupertinoColors.activeOrange); + expect(iconTheme.color, CupertinoColors.activeOrange); - await tester.tap(find.widgetWithIcon(IconTheme, const IconData(1))); + await tester.tap(find.byIcon(const IconData(1))); await tester.pump(); await tester.pump(const Duration(milliseconds: 500)); textStyle = tester.widget(find.widgetWithText(DefaultTextStyle, 'Child 1').first); - iconTheme = tester.widget(find.widgetWithIcon(IconTheme, const IconData(1))); + iconTheme = IconTheme.of(tester.element(find.byIcon(const IconData(1)))); expect(textStyle.style.color, CupertinoColors.activeOrange); - expect(iconTheme.data.color, CupertinoColors.black); + expect(iconTheme.color, CupertinoColors.black); }, ); diff --git a/packages/flutter/test/cupertino/switch_test.dart b/packages/flutter/test/cupertino/switch_test.dart index 7980226aa5..6f7d89b6fa 100644 --- a/packages/flutter/test/cupertino/switch_test.dart +++ b/packages/flutter/test/cupertino/switch_test.dart @@ -415,4 +415,102 @@ void main() { expect(value, isFalse); }); + testWidgets('Switch is translucent when disabled', (WidgetTester tester) async { + await tester.pumpWidget( + const Directionality( + textDirection: TextDirection.ltr, + child: Center( + child: CupertinoSwitch( + value: false, + dragStartBehavior: DragStartBehavior.down, + onChanged: null, + ), + ) + ), + ); + + expect(find.byType(Opacity), findsOneWidget); + expect(tester.widget(find.byType(Opacity).first).opacity, 0.5); + }); + + testWidgets('Switch is opaque when enabled', (WidgetTester tester) async { + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: Center( + child: CupertinoSwitch( + value: false, + dragStartBehavior: DragStartBehavior.down, + onChanged: (bool newValue) {}, + ), + ) + ), + ); + + expect(find.byType(Opacity), findsOneWidget); + expect(tester.widget(find.byType(Opacity).first).opacity, 1.0); + }); + + testWidgets('Switch turns translucent after becoming disabled', (WidgetTester tester) async { + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: Center( + child: CupertinoSwitch( + value: false, + dragStartBehavior: DragStartBehavior.down, + onChanged: (bool newValue) {}, + ), + ) + ), + ); + + await tester.pumpWidget( + const Directionality( + textDirection: TextDirection.ltr, + child: Center( + child: CupertinoSwitch( + value: false, + dragStartBehavior: DragStartBehavior.down, + onChanged: null, + ), + ) + ), + ); + + expect(find.byType(Opacity), findsOneWidget); + expect(tester.widget(find.byType(Opacity).first).opacity, 0.5); + }); + + testWidgets('Switch turns opaque after becoming enabled', (WidgetTester tester) async { + await tester.pumpWidget( + const Directionality( + textDirection: TextDirection.ltr, + child: Center( + child: CupertinoSwitch( + value: false, + dragStartBehavior: DragStartBehavior.down, + onChanged: null, + ), + ) + ), + ); + + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: Center( + child: CupertinoSwitch( + value: false, + dragStartBehavior: DragStartBehavior.down, + onChanged: (bool newValue) {}, + ), + ) + ), + ); + + expect(find.byType(Opacity), findsOneWidget); + expect(tester.widget(find.byType(Opacity).first).opacity, 1.0); + }); + } diff --git a/packages/flutter/test/cupertino/text_field_test.dart b/packages/flutter/test/cupertino/text_field_test.dart index fc20441a30..5f427db91b 100644 --- a/packages/flutter/test/cupertino/text_field_test.dart +++ b/packages/flutter/test/cupertino/text_field_test.dart @@ -399,6 +399,40 @@ void main() { }, ); + testWidgets( + "placeholderStyle modifies placeholder's style and doesn't affect text's style", + (WidgetTester tester) async { + await tester.pumpWidget( + const CupertinoApp( + home: Center( + child: CupertinoTextField( + placeholder: 'placeholder', + style: TextStyle( + color: Color(0X00FFFFFF), + fontWeight: FontWeight.w300, + ), + placeholderStyle: TextStyle( + color: Color(0XAAFFFFFF), + fontWeight: FontWeight.w600 + ), + ), + ), + ), + ); + + final Text placeholder = tester.widget(find.text('placeholder')); + expect(placeholder.style.color, const Color(0XAAFFFFFF)); + expect(placeholder.style.fontWeight, FontWeight.w600); + + await tester.enterText(find.byType(CupertinoTextField), 'input'); + await tester.pump(); + + final EditableText inputText = tester.widget(find.text('input')); + expect(inputText.style.color, const Color(0X00FFFFFF)); + expect(inputText.style.fontWeight, FontWeight.w300); + }, + ); + testWidgets( 'prefix widget is in front of the text', (WidgetTester tester) async { diff --git a/packages/flutter/test/cupertino/theme_test.dart b/packages/flutter/test/cupertino/theme_test.dart index de9166ff74..05ea115a37 100644 --- a/packages/flutter/test/cupertino/theme_test.dart +++ b/packages/flutter/test/cupertino/theme_test.dart @@ -9,11 +9,13 @@ import 'package:flutter_test/flutter_test.dart'; int buildCount; CupertinoThemeData actualTheme; +IconThemeData actualIconTheme; final Widget singletonThemeSubtree = Builder( builder: (BuildContext context) { buildCount++; actualTheme = CupertinoTheme.of(context); + actualIconTheme = IconTheme.of(context); return const Placeholder(); }, ); @@ -28,6 +30,16 @@ Future testTheme(WidgetTester tester, CupertinoThemeData the return actualTheme; } +Future testIconTheme(WidgetTester tester, CupertinoThemeData theme) async { + await tester.pumpWidget( + CupertinoTheme( + data: theme, + child: singletonThemeSubtree, + ), + ); + return actualIconTheme; +} + void main() { setUp(() { buildCount = 0; @@ -123,4 +135,24 @@ void main() { expect(theme.scaffoldBackgroundColor, CupertinoColors.black); }, ); + + testWidgets("Theme has default IconThemeData, which is derived from the theme's primary color", (WidgetTester tester) async { + const Color primaryColor = CupertinoColors.destructiveRed; + const CupertinoThemeData themeData = CupertinoThemeData(primaryColor: primaryColor); + + final IconThemeData resultingIconTheme = await testIconTheme(tester, themeData); + + expect(resultingIconTheme.color, themeData.primaryColor); + }); + + testWidgets('IconTheme.of creates a dependency on iconTheme', (WidgetTester tester) async { + IconThemeData iconTheme = await testIconTheme(tester, const CupertinoThemeData(primaryColor: CupertinoColors.destructiveRed)); + + expect(buildCount, 1); + expect(iconTheme.color, CupertinoColors.destructiveRed); + + iconTheme = await testIconTheme(tester, const CupertinoThemeData(primaryColor: CupertinoColors.activeOrange)); + expect(buildCount, 2); + expect(iconTheme.color, CupertinoColors.activeOrange); + }); } diff --git a/packages/flutter/test/foundation/binary_search_test.dart b/packages/flutter/test/foundation/binary_search_test.dart new file mode 100644 index 0000000000..cc1e26db21 --- /dev/null +++ b/packages/flutter/test/foundation/binary_search_test.dart @@ -0,0 +1,17 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/src/foundation/collections.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + test('binarySearch', () { + final List items = [1, 2, 3]; + + expect(binarySearch(items, 1), 0); + expect(binarySearch(items, 2), 1); + expect(binarySearch(items, 3), 2); + expect(binarySearch(items, 12), -1); + }); +} diff --git a/packages/flutter/test/foundation/diagnostics_test.dart b/packages/flutter/test/foundation/diagnostics_test.dart index de30978b19..5582b7e15b 100644 --- a/packages/flutter/test/foundation/diagnostics_test.dart +++ b/packages/flutter/test/foundation/diagnostics_test.dart @@ -35,6 +35,7 @@ class TestTree extends Object with DiagnosticableTreeMixin { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); if (style != null) properties.defaultDiagnosticsTreeStyle = style; diff --git a/packages/flutter/test/foundation/isolates_test.dart b/packages/flutter/test/foundation/isolates_test.dart index 88dabcebcf..25c6962268 100644 --- a/packages/flutter/test/foundation/isolates_test.dart +++ b/packages/flutter/test/foundation/isolates_test.dart @@ -14,9 +14,20 @@ int test2(int value) { throw 2; } +Future test1Async(int value) async { + return value + 1; +} + +Future test2Async(int value) async { + throw 2; +} + void main() { test('compute()', () async { expect(await compute(test1, 0), 1); expect(compute(test2, 0), throwsA(isInstanceOf())); + + expect(await compute(test1Async, 0), 1); + expect(compute(test2Async, 0), throwsA(isInstanceOf())); }); } diff --git a/packages/flutter/test/foundation/service_extensions_test.dart b/packages/flutter/test/foundation/service_extensions_test.dart index 5fac145f33..9edf792c37 100644 --- a/packages/flutter/test/foundation/service_extensions_test.dart +++ b/packages/flutter/test/foundation/service_extensions_test.dart @@ -117,7 +117,7 @@ Future> hasReassemble(Future> pendingR void main() { final List console = []; - test('Service extensions - pretest', () async { + setUpAll(() async { binding = TestServiceExtensionsBinding(); expect(binding.frameScheduled, isTrue); @@ -142,10 +142,25 @@ void main() { }; }); + tearDownAll(() async { + // See widget_inspector_test.dart for tests of the ext.flutter.inspector + // service extensions included in this count. + int widgetInspectorExtensionCount = 15; + if (WidgetInspectorService.instance.isWidgetCreationTracked()) { + // Some inspector extensions are only exposed if widget creation locations + // are tracked. + widgetInspectorExtensionCount += 2; + } + + // If you add a service extension... TEST IT! :-) + // ...then increment this number. + expect(binding.extensions.length, 26 + widgetInspectorExtensionCount); + + expect(console, isEmpty); + debugPrint = debugPrintThrottled; + }); + // The following list is alphabetical, one test per extension. - // - // The order doesn't really matter except that the pretest and posttest tests - // must be first and last respectively. test('Service extensions - debugAllowBanner', () async { Map result; @@ -170,6 +185,34 @@ void main() { expect(binding.frameScheduled, isFalse); }); + test('Service extensions - debugCheckElevationsEnabled', () async { + expect(binding.frameScheduled, isFalse); + expect(debugCheckElevationsEnabled, false); + + bool lastValue = false; + Future _updateAndCheck(bool newValue) async { + Map result; + binding.testExtension( + 'debugCheckElevationsEnabled', + {'enabled': '$newValue'} + ).then((Map answer) => result = answer); + await binding.flushMicrotasks(); + expect(binding.frameScheduled, lastValue != newValue); + await binding.doFrame(); + await binding.flushMicrotasks(); + expect(result, {'enabled': '$newValue'}); + expect(debugCheckElevationsEnabled, newValue); + lastValue = newValue; + } + + await _updateAndCheck(false); + await _updateAndCheck(true); + await _updateAndCheck(true); + await _updateAndCheck(false); + await _updateAndCheck(false); + expect(binding.frameScheduled, isFalse); + }); + test('Service extensions - debugDumpApp', () async { Map result; @@ -617,22 +660,4 @@ void main() { expect(trace, contains('package:test_api/test_api.dart,::,test\n')); expect(trace, contains('service_extensions_test.dart,::,main\n')); }); - - test('Service extensions - posttest', () async { - // See widget_inspector_test.dart for tests of the ext.flutter.inspector - // service extensions included in this count. - int widgetInspectorExtensionCount = 15; - if (WidgetInspectorService.instance.isWidgetCreationTracked()) { - // Some inspector extensions are only exposed if widget creation locations - // are tracked. - widgetInspectorExtensionCount += 2; - } - - // If you add a service extension... TEST IT! :-) - // ...then increment this number. - expect(binding.extensions.length, 25 + widgetInspectorExtensionCount); - - expect(console, isEmpty); - debugPrint = debugPrintThrottled; - }); } diff --git a/packages/flutter/test/gestures/gesture_binding_test.dart b/packages/flutter/test/gestures/gesture_binding_test.dart index 31f1477f86..37dfbabf83 100644 --- a/packages/flutter/test/gestures/gesture_binding_test.dart +++ b/packages/flutter/test/gestures/gesture_binding_test.dart @@ -195,13 +195,14 @@ void main() { final List events = PointerEventConverter.expand( packet.data, ui.window.devicePixelRatio).toList(); - expect(events.length, 5); + expect(events.length, 6); expect(events[0].runtimeType, equals(PointerAddedEvent)); expect(events[1].runtimeType, equals(PointerHoverEvent)); expect(events[1].delta, equals(const Offset(5.0, 7.0))); expect(events[2].runtimeType, equals(PointerDownEvent)); expect(events[3].runtimeType, equals(PointerCancelEvent)); - expect(events[4].runtimeType, equals(PointerRemovedEvent)); + expect(events[4].runtimeType, equals(PointerHoverEvent)); + expect(events[5].runtimeType, equals(PointerRemovedEvent)); }); test('Can expand pointer scroll events', () { @@ -249,4 +250,105 @@ void main() { expect(events[5].delta, equals(unexpectedOffset)); expect(events[6].runtimeType, equals(PointerScrollEvent)); }); + + test('Should synthesise kPrimaryButton for touch', () { + final Offset location = const Offset(10.0, 10.0) * ui.window.devicePixelRatio; + const PointerDeviceKind kind = PointerDeviceKind.touch; + final ui.PointerDataPacket packet = ui.PointerDataPacket( + data: [ + ui.PointerData(change: ui.PointerChange.add, kind: kind, physicalX: location.dx, physicalY: location.dy), + ui.PointerData(change: ui.PointerChange.hover, kind: kind, physicalX: location.dx, physicalY: location.dy), + ui.PointerData(change: ui.PointerChange.down, kind: kind, physicalX: location.dx, physicalY: location.dy), + ui.PointerData(change: ui.PointerChange.move, kind: kind, physicalX: location.dx, physicalY: location.dy), + ui.PointerData(change: ui.PointerChange.up, kind: kind, physicalX: location.dx, physicalY: location.dy), + ] + ); + + final List events = PointerEventConverter.expand( + packet.data, ui.window.devicePixelRatio).toList(); + + expect(events.length, 5); + expect(events[0].runtimeType, equals(PointerAddedEvent)); + expect(events[0].buttons, equals(0)); + expect(events[1].runtimeType, equals(PointerHoverEvent)); + expect(events[1].buttons, equals(0)); + expect(events[2].runtimeType, equals(PointerDownEvent)); + expect(events[2].buttons, equals(kPrimaryButton)); + expect(events[3].runtimeType, equals(PointerMoveEvent)); + expect(events[3].buttons, equals(kPrimaryButton)); + expect(events[4].runtimeType, equals(PointerUpEvent)); + expect(events[4].buttons, equals(0)); + + PointerEventConverter.clearPointers(); + }); + + test('Should synthesise kPrimaryButton for stylus', () { + final Offset location = const Offset(10.0, 10.0) * ui.window.devicePixelRatio; + for (PointerDeviceKind kind in [ + PointerDeviceKind.stylus, + PointerDeviceKind.invertedStylus, + ]) { + + final ui.PointerDataPacket packet = ui.PointerDataPacket( + data: [ + ui.PointerData(change: ui.PointerChange.add, kind: kind, physicalX: location.dx, physicalY: location.dy), + ui.PointerData(change: ui.PointerChange.hover, kind: kind, physicalX: location.dx, physicalY: location.dy), + ui.PointerData(change: ui.PointerChange.down, kind: kind, physicalX: location.dx, physicalY: location.dy), + ui.PointerData(change: ui.PointerChange.move, buttons: kSecondaryStylusButton, kind: kind, physicalX: location.dx, physicalY: location.dy), + ui.PointerData(change: ui.PointerChange.up, kind: kind, physicalX: location.dx, physicalY: location.dy), + ] + ); + + final List events = PointerEventConverter.expand( + packet.data, ui.window.devicePixelRatio).toList(); + + expect(events.length, 5); + expect(events[0].runtimeType, equals(PointerAddedEvent)); + expect(events[0].buttons, equals(0)); + expect(events[1].runtimeType, equals(PointerHoverEvent)); + expect(events[1].buttons, equals(0)); + expect(events[2].runtimeType, equals(PointerDownEvent)); + expect(events[2].buttons, equals(kPrimaryButton)); + expect(events[3].runtimeType, equals(PointerMoveEvent)); + expect(events[3].buttons, equals(kPrimaryButton | kSecondaryStylusButton)); + expect(events[4].runtimeType, equals(PointerUpEvent)); + expect(events[4].buttons, equals(0)); + + PointerEventConverter.clearPointers(); + } + }); + + test('Should not synthesise kPrimaryButton for certain devices', () { + final Offset location = const Offset(10.0, 10.0) * ui.window.devicePixelRatio; + for (PointerDeviceKind kind in [ + PointerDeviceKind.mouse, + ]) { + final ui.PointerDataPacket packet = ui.PointerDataPacket( + data: [ + ui.PointerData(change: ui.PointerChange.add, kind: kind, physicalX: location.dx, physicalY: location.dy), + ui.PointerData(change: ui.PointerChange.hover, kind: kind, physicalX: location.dx, physicalY: location.dy), + ui.PointerData(change: ui.PointerChange.down, kind: kind, buttons: kMiddleMouseButton, physicalX: location.dx, physicalY: location.dy), + ui.PointerData(change: ui.PointerChange.move, kind: kind, buttons: kMiddleMouseButton | kSecondaryMouseButton, physicalX: location.dx, physicalY: location.dy), + ui.PointerData(change: ui.PointerChange.up, kind: kind, physicalX: location.dx, physicalY: location.dy), + ] + ); + + final List events = PointerEventConverter.expand( + packet.data, ui.window.devicePixelRatio).toList(); + + expect(events.length, 5); + expect(events[0].runtimeType, equals(PointerAddedEvent)); + expect(events[0].buttons, equals(0)); + expect(events[1].runtimeType, equals(PointerHoverEvent)); + expect(events[1].buttons, equals(0)); + expect(events[2].runtimeType, equals(PointerDownEvent)); + expect(events[2].buttons, equals(kMiddleMouseButton)); + expect(events[3].runtimeType, equals(PointerMoveEvent)); + expect(events[3].buttons, equals(kMiddleMouseButton | kSecondaryMouseButton)); + expect(events[4].runtimeType, equals(PointerUpEvent)); + expect(events[4].buttons, equals(0)); + + PointerEventConverter.clearPointers(); + } + }); } diff --git a/packages/flutter/test/gestures/mouse_tracking_test.dart b/packages/flutter/test/gestures/mouse_tracking_test.dart index 3afe3355a9..c2483ac7e2 100644 --- a/packages/flutter/test/gestures/mouse_tracking_test.dart +++ b/packages/flutter/test/gestures/mouse_tracking_test.dart @@ -44,7 +44,13 @@ void main() { onHover: (PointerHoverEvent event) => move.add(event), onExit: (PointerExitEvent event) => exit.add(event), ); - bool isInHitRegion; + // Only respond to some mouse events. + final MouseTrackerAnnotation partialAnnotation = MouseTrackerAnnotation( + onEnter: (PointerEnterEvent event) => enter.add(event), + onHover: (PointerHoverEvent event) => move.add(event), + ); + bool isInHitRegionOne; + bool isInHitRegionTwo; MouseTracker tracker; void clear() { @@ -55,10 +61,17 @@ void main() { setUp(() { clear(); - isInHitRegion = true; + isInHitRegionOne = true; + isInHitRegionTwo = false; tracker = MouseTracker( GestureBinding.instance.pointerRouter, - (Offset _) => isInHitRegion ? annotation : null, + (Offset _) { + if (isInHitRegionOne) + return annotation; + else if (isInHitRegionTwo) + return partialAnnotation; + return null; + }, ); }); @@ -103,7 +116,7 @@ void main() { ), ]); tracker.attachAnnotation(annotation); - isInHitRegion = true; + isInHitRegionOne = true; ui.window.onPointerDataPacket(packet1); tracker.collectMousePositions(); expect(enter.length, equals(1), reason: 'enter contains $enter'); @@ -189,7 +202,7 @@ void main() { kind: PointerDeviceKind.mouse, ), ]); - isInHitRegion = true; + isInHitRegionOne = true; tracker.attachAnnotation(annotation); ui.window.onPointerDataPacket(packet1); @@ -205,7 +218,7 @@ void main() { expect(exit.length, equals(0), reason: 'exit contains $exit'); // Simulate layer going away by detaching it. clear(); - isInHitRegion = false; + isInHitRegionOne = false; ui.window.onPointerDataPacket(packet2); tracker.collectMousePositions(); @@ -215,6 +228,37 @@ void main() { expect(exit.first.position, const Offset(1.0, 201.0)); expect(exit.first.device, equals(0)); expect(exit.first.runtimeType, equals(PointerExitEvent)); + + // Actually detatch annotation. Shouldn't receive hit. + tracker.detachAnnotation(annotation); + clear(); + isInHitRegionOne = false; + + ui.window.onPointerDataPacket(packet2); + tracker.collectMousePositions(); + expect(enter.length, equals(0), reason: 'enter contains $enter'); + expect(move.length, equals(0), reason: 'enter contains $move'); + expect(exit.length, equals(0), reason: 'enter contains $exit'); + }); + + test("don't flip out if not all mouse events are listened to", () { + final ui.PointerDataPacket packet = ui.PointerDataPacket(data: [ + ui.PointerData( + change: ui.PointerChange.hover, + physicalX: 1.0 * ui.window.devicePixelRatio, + physicalY: 101.0 * ui.window.devicePixelRatio, + kind: PointerDeviceKind.mouse, + ), + ]); + + isInHitRegionOne = false; + isInHitRegionTwo = true; + tracker.attachAnnotation(partialAnnotation); + + ui.window.onPointerDataPacket(packet); + tracker.collectMousePositions(); + tracker.detachAnnotation(partialAnnotation); + isInHitRegionTwo = false; }); test('detects exit when mouse goes away', () { final ui.PointerDataPacket packet1 = ui.PointerDataPacket(data: [ @@ -237,7 +281,7 @@ void main() { kind: PointerDeviceKind.mouse, ), ]); - isInHitRegion = true; + isInHitRegionOne = true; tracker.attachAnnotation(annotation); ui.window.onPointerDataPacket(packet1); tracker.collectMousePositions(); @@ -256,5 +300,50 @@ void main() { expect(exit.first.device, isNull); expect(exit.first.runtimeType, equals(PointerExitEvent)); }); + test('handles mouse down and move', () { + final ui.PointerDataPacket packet1 = ui.PointerDataPacket(data: [ + ui.PointerData( + change: ui.PointerChange.hover, + physicalX: 0.0 * ui.window.devicePixelRatio, + physicalY: 0.0 * ui.window.devicePixelRatio, + kind: PointerDeviceKind.mouse, + ), + ui.PointerData( + change: ui.PointerChange.hover, + physicalX: 1.0 * ui.window.devicePixelRatio, + physicalY: 101.0 * ui.window.devicePixelRatio, + kind: PointerDeviceKind.mouse, + ), + ]); + final ui.PointerDataPacket packet2 = ui.PointerDataPacket(data: [ + ui.PointerData( + change: ui.PointerChange.down, + physicalX: 1.0 * ui.window.devicePixelRatio, + physicalY: 101.0 * ui.window.devicePixelRatio, + kind: PointerDeviceKind.mouse, + ), + ui.PointerData( + change: ui.PointerChange.move, + physicalX: 1.0 * ui.window.devicePixelRatio, + physicalY: 201.0 * ui.window.devicePixelRatio, + kind: PointerDeviceKind.mouse, + ), + ]); + isInHitRegionOne = true; + tracker.attachAnnotation(annotation); + ui.window.onPointerDataPacket(packet1); + tracker.collectMousePositions(); + ui.window.onPointerDataPacket(packet2); + tracker.collectMousePositions(); + expect(enter.length, equals(1), reason: 'enter contains $enter'); + expect(enter.first.position, equals(const Offset(1.0, 101.0))); + expect(enter.first.device, equals(0)); + expect(enter.first.runtimeType, equals(PointerEnterEvent)); + expect(move.length, equals(1), reason: 'move contains $move'); + expect(move.first.position, equals(const Offset(1.0, 101.0))); + expect(move.first.device, equals(0)); + expect(move.first.runtimeType, equals(PointerHoverEvent)); + expect(exit.length, equals(0), reason: 'exit contains $exit'); + }); }); } diff --git a/packages/flutter/test/material/app_test.dart b/packages/flutter/test/material/app_test.dart index 5cc30aa0f0..56c9fa7659 100644 --- a/packages/flutter/test/material/app_test.dart +++ b/packages/flutter/test/material/app_test.dart @@ -381,6 +381,17 @@ void main() { expect(log, ['onGenerateRoute /', 'onUnknownRoute /']); }); + testWidgets('MaterialApp with builder and no route information works.', (WidgetTester tester) async { + // Regression test for https://github.com/flutter/flutter/issues/18904 + await tester.pumpWidget( + MaterialApp( + builder: (BuildContext context, Widget child) { + return const SizedBox(); + }, + ), + ); + }); + testWidgets('Can get text scale from media query', (WidgetTester tester) async { double textScaleFactor; await tester.pumpWidget(MaterialApp( diff --git a/packages/flutter/test/material/buttons_test.dart b/packages/flutter/test/material/buttons_test.dart index 03312c86ad..5862e223ba 100644 --- a/packages/flutter/test/material/buttons_test.dart +++ b/packages/flutter/test/material/buttons_test.dart @@ -15,6 +15,312 @@ void main() { debugResetSemanticsIdCounter(); }); + testWidgets('MaterialButton defaults', (WidgetTester tester) async { + final Finder rawButtonMaterial = find.descendant( + of: find.byType(MaterialButton), + matching: find.byType(Material), + ); + + // Enabled MaterialButton + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: MaterialButton( + onPressed: () { }, + child: const Text('button'), + ), + ), + ); + Material material = tester.widget(rawButtonMaterial); + expect(material.animationDuration, const Duration(milliseconds: 200)); + expect(material.borderOnForeground, true); + expect(material.borderRadius, null); + expect(material.clipBehavior, Clip.none); + expect(material.color, null); + expect(material.elevation, 2.0); + expect(material.shadowColor, const Color(0xff000000)); + expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(2.0))); + expect(material.textStyle.color, const Color(0xdd000000)); + expect(material.textStyle.fontFamily, 'Roboto'); + expect(material.textStyle.fontSize, 14); + expect(material.textStyle.fontWeight, FontWeight.w500); + expect(material.type, MaterialType.transparency); + + final Offset center = tester.getCenter(find.byType(MaterialButton)); + await tester.startGesture(center); + await tester.pumpAndSettle(); + + // Only elevation changes when enabled and pressed. + material = tester.widget(rawButtonMaterial); + expect(material.animationDuration, const Duration(milliseconds: 200)); + expect(material.borderOnForeground, true); + expect(material.borderRadius, null); + expect(material.clipBehavior, Clip.none); + expect(material.color, null); + expect(material.elevation, 8.0); + expect(material.shadowColor, const Color(0xff000000)); + expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(2.0))); + expect(material.textStyle.color, const Color(0xdd000000)); + expect(material.textStyle.fontFamily, 'Roboto'); + expect(material.textStyle.fontSize, 14); + expect(material.textStyle.fontWeight, FontWeight.w500); + expect(material.type, MaterialType.transparency); + + + // Disabled MaterialButton + await tester.pumpWidget( + const Directionality( + textDirection: TextDirection.ltr, + child: MaterialButton( + onPressed: null, + child: Text('button'), + ), + ), + ); + material = tester.widget(rawButtonMaterial); + expect(material.animationDuration, const Duration(milliseconds: 200)); + expect(material.borderOnForeground, true); + expect(material.borderRadius, null); + expect(material.clipBehavior, Clip.none); + expect(material.color, null); + expect(material.elevation, 0.0); + expect(material.shadowColor, const Color(0xff000000)); + expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(2.0))); + expect(material.textStyle.color, const Color(0x61000000)); + expect(material.textStyle.fontFamily, 'Roboto'); + expect(material.textStyle.fontSize, 14); + expect(material.textStyle.fontWeight, FontWeight.w500); + expect(material.type, MaterialType.transparency); + }); + + testWidgets('FlatButton defaults', (WidgetTester tester) async { + final Finder rawButtonMaterial = find.descendant( + of: find.byType(FlatButton), + matching: find.byType(Material), + ); + + // Enabled FlatButton + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: FlatButton( + onPressed: () { }, + child: const Text('button'), + ), + ), + ); + Material material = tester.widget(rawButtonMaterial); + expect(material.animationDuration, const Duration(milliseconds: 200)); + expect(material.borderOnForeground, true); + expect(material.borderRadius, null); + expect(material.clipBehavior, Clip.none); + expect(material.color, null); + expect(material.elevation, 0.0); + expect(material.shadowColor, const Color(0xff000000)); + expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(2.0))); + expect(material.textStyle.color, const Color(0xdd000000)); + expect(material.textStyle.fontFamily, 'Roboto'); + expect(material.textStyle.fontSize, 14); + expect(material.textStyle.fontWeight, FontWeight.w500); + expect(material.type, MaterialType.transparency); + + final Offset center = tester.getCenter(find.byType(FlatButton)); + await tester.startGesture(center); + await tester.pumpAndSettle(); + + material = tester.widget(rawButtonMaterial); + // No change vs enabled and not pressed. + expect(material.animationDuration, const Duration(milliseconds: 200)); + expect(material.borderOnForeground, true); + expect(material.borderRadius, null); + expect(material.clipBehavior, Clip.none); + expect(material.color, null); + expect(material.elevation, 0.0); + expect(material.shadowColor, const Color(0xff000000)); + expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(2.0))); + expect(material.textStyle.color, const Color(0xdd000000)); + expect(material.textStyle.fontFamily, 'Roboto'); + expect(material.textStyle.fontSize, 14); + expect(material.textStyle.fontWeight, FontWeight.w500); + expect(material.type, MaterialType.transparency); + + // Disabled FlatButton + await tester.pumpWidget( + const Directionality( + textDirection: TextDirection.ltr, + child: FlatButton( + onPressed: null, + child: Text('button'), + ), + ), + ); + material = tester.widget(rawButtonMaterial); + expect(material.animationDuration, const Duration(milliseconds: 200)); + expect(material.borderOnForeground, true); + expect(material.borderRadius, null); + expect(material.clipBehavior, Clip.none); + expect(material.color, null); + expect(material.elevation, 0.0); + expect(material.shadowColor, const Color(0xff000000)); + expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(2.0))); + expect(material.textStyle.color, const Color(0x61000000)); + expect(material.textStyle.fontFamily, 'Roboto'); + expect(material.textStyle.fontSize, 14); + expect(material.textStyle.fontWeight, FontWeight.w500); + expect(material.type, MaterialType.transparency); + }); + + testWidgets('RaisedButton defaults', (WidgetTester tester) async { + final Finder rawButtonMaterial = find.descendant( + of: find.byType(RaisedButton), + matching: find.byType(Material), + ); + + // Enabled RaisedButton + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: RaisedButton( + onPressed: () { }, + child: const Text('button'), + ), + ), + ); + Material material = tester.widget(rawButtonMaterial); + expect(material.animationDuration, const Duration(milliseconds: 200)); + expect(material.borderOnForeground, true); + expect(material.borderRadius, null); + expect(material.clipBehavior, Clip.none); + expect(material.color, const Color(0xffe0e0e0)); + expect(material.elevation, 2.0); + expect(material.shadowColor, const Color(0xff000000)); + expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(2.0))); + expect(material.textStyle.color, const Color(0xdd000000)); + expect(material.textStyle.fontFamily, 'Roboto'); + expect(material.textStyle.fontSize, 14); + expect(material.textStyle.fontWeight, FontWeight.w500); + expect(material.type, MaterialType.button); + + final Offset center = tester.getCenter(find.byType(RaisedButton)); + await tester.startGesture(center); + await tester.pumpAndSettle(); + + // Only elevation changes when enabled and pressed. + material = tester.widget(rawButtonMaterial); + expect(material.animationDuration, const Duration(milliseconds: 200)); + expect(material.borderOnForeground, true); + expect(material.borderRadius, null); + expect(material.clipBehavior, Clip.none); + expect(material.color, const Color(0xffe0e0e0)); + expect(material.elevation, 8.0); + expect(material.shadowColor, const Color(0xff000000)); + expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(2.0))); + expect(material.textStyle.color, const Color(0xdd000000)); + expect(material.textStyle.fontFamily, 'Roboto'); + expect(material.textStyle.fontSize, 14); + expect(material.textStyle.fontWeight, FontWeight.w500); + expect(material.type, MaterialType.button); + + // Disabled RaisedButton + await tester.pumpWidget( + const Directionality( + textDirection: TextDirection.ltr, + child: RaisedButton( + onPressed: null, + child: Text('button'), + ), + ), + ); + material = tester.widget(rawButtonMaterial); + expect(material.animationDuration, const Duration(milliseconds: 200)); + expect(material.borderOnForeground, true); + expect(material.borderRadius, null); + expect(material.clipBehavior, Clip.none); + expect(material.color, const Color(0x61000000)); + expect(material.elevation, 0.0); + expect(material.shadowColor, const Color(0xff000000)); + expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(2.0))); + expect(material.textStyle.color, const Color(0x61000000)); + expect(material.textStyle.fontFamily, 'Roboto'); + expect(material.textStyle.fontSize, 14); + expect(material.textStyle.fontWeight, FontWeight.w500); + expect(material.type, MaterialType.button); + }); + + testWidgets('OutlineButton defaults', (WidgetTester tester) async { + final Finder rawButtonMaterial = find.descendant( + of: find.byType(OutlineButton), + matching: find.byType(Material), + ); + + // Enabled OutlineButton + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: OutlineButton( + onPressed: () { }, + child: const Text('button'), + ), + ), + ); + Material material = tester.widget(rawButtonMaterial); + expect(material.animationDuration, const Duration(milliseconds: 75)); + expect(material.borderOnForeground, true); + expect(material.borderRadius, null); + expect(material.clipBehavior, Clip.none); + expect(material.color, const Color(0x00000000)); + expect(material.elevation, 0.0); + expect(material.shadowColor, const Color(0xff000000)); + expect(material.textStyle.color, const Color(0xdd000000)); + expect(material.textStyle.fontFamily, 'Roboto'); + expect(material.textStyle.fontSize, 14); + expect(material.textStyle.fontWeight, FontWeight.w500); + expect(material.type, MaterialType.button); + + final Offset center = tester.getCenter(find.byType(OutlineButton)); + await tester.startGesture(center); + await tester.pumpAndSettle(); + + // No change vs enabled and not pressed. + material = tester.widget(rawButtonMaterial); + expect(material.animationDuration, const Duration(milliseconds: 75)); + expect(material.borderOnForeground, true); + expect(material.borderRadius, null); + expect(material.clipBehavior, Clip.none); + expect(material.color, const Color(0x00000000)); + expect(material.elevation, 0.0); + expect(material.shadowColor, const Color(0xff000000)); + expect(material.textStyle.color, const Color(0xdd000000)); + expect(material.textStyle.fontFamily, 'Roboto'); + expect(material.textStyle.fontSize, 14); + expect(material.textStyle.fontWeight, FontWeight.w500); + expect(material.type, MaterialType.button); + + // Disabled OutlineButton + await tester.pumpWidget( + const Directionality( + textDirection: TextDirection.ltr, + child: OutlineButton( + onPressed: null, + child: Text('button'), + ), + ), + ); + material = tester.widget(rawButtonMaterial); + expect(material.animationDuration, const Duration(milliseconds: 75)); + expect(material.borderOnForeground, true); + expect(material.borderRadius, null); + expect(material.clipBehavior, Clip.none); + expect(material.color, const Color(0x00000000)); + expect(material.elevation, 0.0); + expect(material.shadowColor, const Color(0xff000000)); + expect(material.textStyle.color, const Color(0x61000000)); + expect(material.textStyle.fontFamily, 'Roboto'); + expect(material.textStyle.fontSize, 14); + expect(material.textStyle.fontWeight, FontWeight.w500); + expect(material.type, MaterialType.button); + }); + testWidgets('Does FlatButton contribute semantics', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( @@ -645,4 +951,27 @@ void main() { ); expect(tester.widget(rawButtonMaterial).shape, const StadiumBorder()); }); + + testWidgets('MaterialButton defaults', (WidgetTester tester) async { + // Regression test for https://github.com/flutter/flutter/issues/30012. + + final Finder rawButtonMaterial = find.descendant( + of: find.byType(MaterialButton), + matching: find.byType(Material), + ); + + await tester.pumpWidget( + const Directionality( + textDirection: TextDirection.ltr, + child: MaterialButton( + disabledColor: Color(0xff00ff00), + onPressed: null, + child: Text('button'), + ), + ), + ); + + final Material material = tester.widget(rawButtonMaterial); + expect(material.color, const Color(0xff00ff00)); + }); } diff --git a/packages/flutter/test/material/dialog_test.dart b/packages/flutter/test/material/dialog_test.dart index c405698a6c..e63d29d818 100644 --- a/packages/flutter/test/material/dialog_test.dart +++ b/packages/flutter/test/material/dialog_test.dart @@ -607,4 +607,42 @@ void main() { expect(find.text('0'), findsNothing); expect(find.text('1'), findsNothing); }); + + // Regression test for https://github.com/flutter/flutter/issues/28505. + testWidgets('showDialog only gets Theme from context on the first call', (WidgetTester tester) async { + Widget buildFrame(Key builderKey) { + return MaterialApp( + home: Center( + child: Builder( + key: builderKey, + builder: (BuildContext outerContext) { + return RaisedButton( + onPressed: () { + showDialog( + context: outerContext, + builder: (BuildContext innerContext) { + return const AlertDialog(title: Text('Title')); + }, + ); + }, + child: const Text('Show Dialog'), + ); + }, + ), + ), + ); + } + + await tester.pumpWidget(buildFrame(UniqueKey())); + + // Open the dialog. + await tester.tap(find.byType(RaisedButton)); + await tester.pumpAndSettle(); + + // Force the Builder to be recreated (new key) which causes outerContext to + // be deactivated. If showDialog()'s implementation were to refer to + // outerContext again, it would crash. + await tester.pumpWidget(buildFrame(UniqueKey())); + await tester.pump(); + }); } diff --git a/packages/flutter/test/material/input_decorator_test.dart b/packages/flutter/test/material/input_decorator_test.dart index 8e8cba8940..6697d22483 100644 --- a/packages/flutter/test/material/input_decorator_test.dart +++ b/packages/flutter/test/material/input_decorator_test.dart @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:async'; import 'dart:io' show Platform; import 'package:flutter/material.dart'; @@ -2255,6 +2256,41 @@ void main() { expect(getBorderRadius(tester), BorderRadius.zero); }); + testWidgets('OutlineInputBorder async lerp', (WidgetTester tester) async { + // Regression test for https://github.com/flutter/flutter/issues/28724 + + final Completer completer = Completer(); + bool waitIsOver = false; + + await tester.pumpWidget( + MaterialApp( + home: StatefulBuilder( + builder: (BuildContext context, StateSetter setState) { + return GestureDetector( + onTap: () async { + setState(() { waitIsOver = true; }); + await completer.future; + setState(() { waitIsOver = false; }); + }, + child: InputDecorator( + decoration: InputDecoration( + labelText: 'Test', + enabledBorder: !waitIsOver ? null : const OutlineInputBorder(borderSide: BorderSide(color: Colors.blue)), + ), + ), + ); + }, + ), + ), + ); + + await tester.tap(find.byType(StatefulBuilder)); + await tester.pumpAndSettle(); + + completer.complete(); + await tester.pumpAndSettle(); + }); + test('InputBorder equality', () { // OutlineInputBorder's equality is defined by the borderRadius, borderSide, & gapPadding const OutlineInputBorder outlineInputBorder = OutlineInputBorder( diff --git a/packages/flutter/test/material/list_tile_test.dart b/packages/flutter/test/material/list_tile_test.dart index 7192fe4634..8a4c93afae 100644 --- a/packages/flutter/test/material/list_tile_test.dart +++ b/packages/flutter/test/material/list_tile_test.dart @@ -785,4 +785,338 @@ void main() { expect(tester.getRect(find.byType(Placeholder).at(2)), Rect.fromLTWH( 16.0, 216.0 + 16.0, 24.0, 12.0)); expect(tester.getRect(find.byType(Placeholder).at(3)), Rect.fromLTWH(800.0 - 24.0 - 16.0, 216.0 + 16.0, 24.0, 24.0)); }); + + testWidgets('ListTile leading icon height does not exceed ListTile height', (WidgetTester tester) async { + // regression test for https://github.com/flutter/flutter/issues/28765 + const SizedBox oversizedWidget = SizedBox(height: 80.0, width: 24.0, child: Placeholder()); + + // Dense One line + await tester.pumpWidget( + MaterialApp( + home: Material( + child: ListView( + children: const [ + ListTile( + leading: oversizedWidget, + title: Text('A'), + dense: true, + ), + ListTile( + leading: oversizedWidget, + title: Text('B'), + dense: true, + ), + ], + ), + ), + ), + ); + + expect(tester.getRect(find.byType(Placeholder).at(0)), Rect.fromLTWH(16.0, 0.0, 24.0, 48.0)); + expect(tester.getRect(find.byType(Placeholder).at(1)), Rect.fromLTWH(16.0, 48.0, 24.0, 48.0)); + + // Non-dense One line + await tester.pumpWidget( + MaterialApp( + home: Material( + child: ListView( + children: const [ + ListTile( + leading: oversizedWidget, + title: Text('A'), + dense: false, + ), + ListTile( + leading: oversizedWidget, + title: Text('B'), + dense: false, + ), + ], + ), + ), + ), + ); + + expect(tester.getRect(find.byType(Placeholder).at(0)), Rect.fromLTWH(16.0, 0.0, 24.0, 56.0)); + expect(tester.getRect(find.byType(Placeholder).at(1)), Rect.fromLTWH(16.0, 56.0, 24.0, 56.0)); + + // Dense Two line + await tester.pumpWidget( + MaterialApp( + home: Material( + child: ListView( + children: const [ + ListTile( + leading: oversizedWidget, + title: Text('A'), + subtitle: Text('A'), + dense: true, + ), + ListTile( + leading: oversizedWidget, + title: Text('B'), + subtitle: Text('B'), + dense: true, + ), + ], + ), + ), + ), + ); + + expect(tester.getRect(find.byType(Placeholder).at(0)), Rect.fromLTWH(16.0, 8.0, 24.0, 48.0)); + expect(tester.getRect(find.byType(Placeholder).at(1)), Rect.fromLTWH(16.0, 64.0 + 8.0, 24.0, 48.0)); + + // Non-dense Two line + await tester.pumpWidget( + MaterialApp( + home: Material( + child: ListView( + children: const [ + ListTile( + leading: oversizedWidget, + title: Text('A'), + subtitle: Text('A'), + dense: false, + ), + ListTile( + leading: oversizedWidget, + title: Text('B'), + subtitle: Text('B'), + dense: false, + ), + ], + ), + ), + ), + ); + + expect(tester.getRect(find.byType(Placeholder).at(0)), Rect.fromLTWH(16.0, 8.0, 24.0, 56.0)); + expect(tester.getRect(find.byType(Placeholder).at(1)), Rect.fromLTWH(16.0, 72.0 + 8.0, 24.0, 56.0)); + + // Dense Three line + await tester.pumpWidget( + MaterialApp( + home: Material( + child: ListView( + children: const [ + ListTile( + leading: oversizedWidget, + title: Text('A'), + subtitle: Text('A'), + isThreeLine: true, + dense: true, + ), + ListTile( + leading: oversizedWidget, + title: Text('B'), + subtitle: Text('B'), + isThreeLine: true, + dense: true, + ), + ], + ), + ), + ), + ); + + expect(tester.getRect(find.byType(Placeholder).at(0)), Rect.fromLTWH(16.0, 16.0, 24.0, 48.0)); + expect(tester.getRect(find.byType(Placeholder).at(1)), Rect.fromLTWH(16.0, 76.0 + 16.0, 24.0, 48.0)); + + // Non-dense Three line + await tester.pumpWidget( + MaterialApp( + home: Material( + child: ListView( + children: const [ + ListTile( + leading: oversizedWidget, + title: Text('A'), + subtitle: Text('A'), + isThreeLine: true, + dense: false, + ), + ListTile( + leading: oversizedWidget, + title: Text('B'), + subtitle: Text('B'), + isThreeLine: true, + dense: false, + ), + ], + ), + ), + ), + ); + + expect(tester.getRect(find.byType(Placeholder).at(0)), Rect.fromLTWH(16.0, 16.0, 24.0, 56.0)); + expect(tester.getRect(find.byType(Placeholder).at(1)), Rect.fromLTWH(16.0, 88.0 + 16.0, 24.0, 56.0)); + }); + + testWidgets('ListTile trailing icon height does not exceed ListTile height', (WidgetTester tester) async { + // regression test for https://github.com/flutter/flutter/issues/28765 + const SizedBox oversizedWidget = SizedBox(height: 80.0, width: 24.0, child: Placeholder()); + + // Dense One line + await tester.pumpWidget( + MaterialApp( + home: Material( + child: ListView( + children: const [ + ListTile( + trailing: oversizedWidget, + title: Text('A'), + dense: true, + ), + ListTile( + trailing: oversizedWidget, + title: Text('B'), + dense: true, + ), + ], + ), + ), + ), + ); + + expect(tester.getRect(find.byType(Placeholder).at(0)), Rect.fromLTWH(800.0 - 16.0 - 24.0, 0, 24.0, 48.0)); + expect(tester.getRect(find.byType(Placeholder).at(1)), Rect.fromLTWH(800.0 - 16.0 - 24.0, 48.0, 24.0, 48.0)); + + // Non-dense One line + await tester.pumpWidget( + MaterialApp( + home: Material( + child: ListView( + children: const [ + ListTile( + trailing: oversizedWidget, + title: Text('A'), + dense: false, + ), + ListTile( + trailing: oversizedWidget, + title: Text('B'), + dense: false, + ), + ], + ), + ), + ), + ); + + expect(tester.getRect(find.byType(Placeholder).at(0)), Rect.fromLTWH(800.0 - 16.0 - 24.0, 0.0, 24.0, 56.0)); + expect(tester.getRect(find.byType(Placeholder).at(1)), Rect.fromLTWH(800.0 - 16.0 - 24.0, 56.0, 24.0, 56.0)); + + // Dense Two line + await tester.pumpWidget( + MaterialApp( + home: Material( + child: ListView( + children: const [ + ListTile( + trailing: oversizedWidget, + title: Text('A'), + subtitle: Text('A'), + dense: true, + ), + ListTile( + trailing: oversizedWidget, + title: Text('B'), + subtitle: Text('B'), + dense: true, + ), + ], + ), + ), + ), + ); + + expect(tester.getRect(find.byType(Placeholder).at(0)), Rect.fromLTWH(800.0 - 16.0 - 24.0, 8.0, 24.0, 48.0)); + expect(tester.getRect(find.byType(Placeholder).at(1)), Rect.fromLTWH(800.0 - 16.0 - 24.0, 64.0 + 8.0, 24.0, 48.0)); + + // Non-dense Two line + await tester.pumpWidget( + MaterialApp( + home: Material( + child: ListView( + children: const [ + ListTile( + trailing: oversizedWidget, + title: Text('A'), + subtitle: Text('A'), + dense: false, + ), + ListTile( + trailing: oversizedWidget, + title: Text('B'), + subtitle: Text('B'), + dense: false, + ), + ], + ), + ), + ), + ); + + expect(tester.getRect(find.byType(Placeholder).at(0)), Rect.fromLTWH(800.0 - 16.0 - 24.0, 8.0, 24.0, 56.0)); + expect(tester.getRect(find.byType(Placeholder).at(1)), Rect.fromLTWH(800.0 - 16.0 - 24.0, 72.0 + 8.0, 24.0, 56.0)); + + // Dense Three line + await tester.pumpWidget( + MaterialApp( + home: Material( + child: ListView( + children: const [ + ListTile( + trailing: oversizedWidget, + title: Text('A'), + subtitle: Text('A'), + isThreeLine: true, + dense: true, + ), + ListTile( + trailing: oversizedWidget, + title: Text('B'), + subtitle: Text('B'), + isThreeLine: true, + dense: true, + ), + ], + ), + ), + ), + ); + + expect(tester.getRect(find.byType(Placeholder).at(0)), Rect.fromLTWH(800.0 - 16.0 - 24.0, 16.0, 24.0, 48.0)); + expect(tester.getRect(find.byType(Placeholder).at(1)), Rect.fromLTWH(800.0 - 16.0 - 24.0, 76.0 + 16.0, 24.0, 48.0)); + + // Non-dense Three line + await tester.pumpWidget( + MaterialApp( + home: Material( + child: ListView( + children: const [ + ListTile( + trailing: oversizedWidget, + title: Text('A'), + subtitle: Text('A'), + isThreeLine: true, + dense: false, + ), + ListTile( + trailing: oversizedWidget, + title: Text('B'), + subtitle: Text('B'), + isThreeLine: true, + dense: false, + ), + ], + ), + ), + ), + ); + + expect(tester.getRect(find.byType(Placeholder).at(0)), Rect.fromLTWH(800.0 - 16.0 - 24.0, 16.0, 24.0, 56.0)); + expect(tester.getRect(find.byType(Placeholder).at(1)), Rect.fromLTWH(800.0 - 16.0 - 24.0, 88.0 + 16.0, 24.0, 56.0)); + }); } diff --git a/packages/flutter/test/material/page_test.dart b/packages/flutter/test/material/page_test.dart index fd0ff4025d..ebdce13f2d 100644 --- a/packages/flutter/test/material/page_test.dart +++ b/packages/flutter/test/material/page_test.dart @@ -597,9 +597,9 @@ void main() { expect(find.text('route'), findsNothing); - // Run the dismiss animation 75%, which exposes the route "push" button, - // and then press the button. MaterialPageTransition duration is 300ms, - // 275 = 300 * 0.75. + // Run the dismiss animation 60%, which exposes the route "push" button, + // and then press the button. A drag dropped animation is 400ms when dropped + // exactly halfway. It follows a curve that is very steep initially. await tester.tap(find.text('push')); await tester.pumpAndSettle(); @@ -607,10 +607,19 @@ void main() { expect(find.text('push'), findsNothing); gesture = await tester.startGesture(const Offset(5, 300)); - await gesture.moveBy(const Offset(400, 0)); // drag halfway + await gesture.moveBy(const Offset(400, 0)); // Drag halfway. await gesture.up(); - await tester.pump(const Duration(milliseconds: 275)); // partially dismiss "route" - expect(find.text('route'), findsOneWidget); + await tester.pump(); // Trigger the dropped snapping animation. + expect( + tester.getTopLeft(find.ancestor(of: find.text('route'), matching: find.byType(Scaffold))), + const Offset(400, 0), + ); + // Let the dismissing snapping animation go 60%. + await tester.pump(const Duration(milliseconds: 240)); + expect( + tester.getTopLeft(find.ancestor(of: find.text('route'), matching: find.byType(Scaffold))).dx, + moreOrLessEquals(798, epsilon: 1), + ); await tester.tap(find.text('push')); await tester.pumpAndSettle(); expect(find.text('route'), findsOneWidget); diff --git a/packages/flutter/test/material/popup_menu_test.dart b/packages/flutter/test/material/popup_menu_test.dart index ed4a16ad20..f57ad57f64 100644 --- a/packages/flutter/test/material/popup_menu_test.dart +++ b/packages/flutter/test/material/popup_menu_test.dart @@ -606,6 +606,41 @@ void main() { expect(selectedValue, '2'); }); + testWidgets('showMenu position required', (WidgetTester tester) async { + // Test for https://github.com/flutter/flutter/issues/22256 + await tester.pumpWidget( + MaterialApp( + home: Material( + child: Center( + child: Builder( + builder: (BuildContext context) { + return RaisedButton( + onPressed: () { + // Ensure showMenu throws an assertion without a position + expect(() { + // ignore: missing_required_param + showMenu( + context: context, + items: >[ + const PopupMenuItem( + value: 1, child: Text('1') + ), + ], + ); + }, throwsAssertionError); + }, + child: const Text('Menu Button'), + ); + }, + ), + ), + ), + ) + ); + + await tester.tap(find.text('Menu Button')); + }); + } class TestApp extends StatefulWidget { diff --git a/packages/flutter/test/material/reorderable_list_test.dart b/packages/flutter/test/material/reorderable_list_test.dart index 56f64f890c..b765d240f0 100644 --- a/packages/flutter/test/material/reorderable_list_test.dart +++ b/packages/flutter/test/material/reorderable_list_test.dart @@ -922,7 +922,7 @@ void main() { await tester.pumpWidget(MaterialApp( home: reorderableListView, )); - expect(tester.getCenter(find.text('A')), greaterThan(tester.getCenter(find.text('B')))); + expect(tester.getCenter(find.text('A')).dy, lessThan(tester.getCenter(find.text('B')).dy)); }); // TODO(djshuckerow): figure out how to write a test for scrolling the list. }); diff --git a/packages/flutter/test/material/tabs_test.dart b/packages/flutter/test/material/tabs_test.dart index 58aab75152..2ecefce037 100644 --- a/packages/flutter/test/material/tabs_test.dart +++ b/packages/flutter/test/material/tabs_test.dart @@ -61,6 +61,7 @@ class AlwaysKeepAliveState extends State @override Widget build(BuildContext context) { + super.build(context); return Text(AlwaysKeepAliveWidget.text); } } diff --git a/packages/flutter/test/material/text_field_test.dart b/packages/flutter/test/material/text_field_test.dart index eef9e727a7..a8811bfe2a 100644 --- a/packages/flutter/test/material/text_field_test.dart +++ b/packages/flutter/test/material/text_field_test.dart @@ -426,6 +426,82 @@ void main() { }, skip: !Platform.isLinux); */ + testWidgets('Overflowing a line with spaces stops the cursor at the end', (WidgetTester tester) async { + final TextEditingController controller = TextEditingController(); + + await tester.pumpWidget( + overlay( + child: TextField( + key: textFieldKey, + controller: controller, + maxLines: null, + ), + ) + ); + expect(controller.selection.baseOffset, -1); + expect(controller.selection.extentOffset, -1); + + const String testValueOneLine = 'enough text to be exactly at the end of the line.'; + await tester.enterText(find.byType(TextField), testValueOneLine); + await skipPastScrollingAnimation(tester); + + RenderBox findInputBox() => tester.renderObject(find.byKey(textFieldKey)); + + RenderBox inputBox = findInputBox(); + final Size oneLineInputSize = inputBox.size; + + await tester.tapAt(textOffsetToPosition(tester, testValueOneLine.length)); + await tester.pump(); + + const String testValueTwoLines = 'enough text to overflow the first line and go to the second'; + await tester.enterText(find.byType(TextField), testValueTwoLines); + await skipPastScrollingAnimation(tester); + + expect(inputBox, findInputBox()); + inputBox = findInputBox(); + expect(inputBox.size.height, greaterThan(oneLineInputSize.height)); + final Size twoLineInputSize = inputBox.size; + + // Enter a string with the same number of characters as testValueTwoLines, + // but where the overflowing part is all spaces. Assert that it only renders + // on one line. + const String testValueSpaces = testValueOneLine + ' '; + expect(testValueSpaces.length, testValueTwoLines.length); + await tester.enterText(find.byType(TextField), testValueSpaces); + await skipPastScrollingAnimation(tester); + + expect(inputBox, findInputBox()); + inputBox = findInputBox(); + expect(inputBox.size.height, oneLineInputSize.height); + + // Swapping the final space for a letter causes it to wrap to 2 lines. + const String testValueSpacesOverflow = testValueOneLine + ' a'; + expect(testValueSpacesOverflow.length, testValueTwoLines.length); + await tester.enterText(find.byType(TextField), testValueSpacesOverflow); + await skipPastScrollingAnimation(tester); + + expect(inputBox, findInputBox()); + inputBox = findInputBox(); + expect(inputBox.size.height, twoLineInputSize.height); + + // Positioning the cursor at the end of a line overflowing with spaces puts + // it inside the input still. + await tester.enterText(find.byType(TextField), testValueSpaces); + await skipPastScrollingAnimation(tester); + await tester.tapAt(textOffsetToPosition(tester, testValueSpaces.length)); + await tester.pump(); + + final double inputWidth = findRenderEditable(tester).size.width; + final Offset cursorOffsetSpaces = findRenderEditable(tester).getLocalRectForCaret( + const TextPosition(offset: testValueSpaces.length), + ).bottomRight; + + // Gap between caret and edge of input, defined in editable.dart. + const int _kCaretGap = 1; + + expect(cursorOffsetSpaces.dx, inputWidth - _kCaretGap); + }); + testWidgets('obscureText control test', (WidgetTester tester) async { await tester.pumpWidget( overlay( @@ -1443,7 +1519,8 @@ void main() { await tester.pumpWidget(builder(maxLines, multipleLineText)); final Text hintTextWidget = tester.widget(find.text(multipleLineText)); expect(hintTextWidget.maxLines, equals(maxLines)); - expect(findHintText(multipleLineText).size, greaterThan(oneLineHintSize)); + expect(findHintText(multipleLineText).size.width, greaterThanOrEqualTo(oneLineHintSize.width)); + expect(findHintText(multipleLineText).size.height, greaterThanOrEqualTo(oneLineHintSize.height)); }); testWidgets('Can drag handles to change selection in multiline', (WidgetTester tester) async { diff --git a/packages/flutter/test/material/theme_test.dart b/packages/flutter/test/material/theme_test.dart index df52aa34ea..c723a11627 100644 --- a/packages/flutter/test/material/theme_test.dart +++ b/packages/flutter/test/material/theme_test.dart @@ -417,28 +417,26 @@ void main() { group('Cupertino theme', () { int buildCount; CupertinoThemeData actualTheme; + IconThemeData actualIconTheme; final Widget singletonThemeSubtree = Builder( builder: (BuildContext context) { buildCount++; actualTheme = CupertinoTheme.of(context); + actualIconTheme = IconTheme.of(context); return const Placeholder(); }, ); Future testTheme(WidgetTester tester, ThemeData theme) async { - await tester.pumpWidget( - Theme( - data: theme, - child: singletonThemeSubtree, - ), - ); + await tester.pumpWidget(Theme(data: theme, child: singletonThemeSubtree)); return actualTheme; } setUp(() { buildCount = 0; actualTheme = null; + actualIconTheme = null; }); testWidgets('Default theme has defaults', (WidgetTester tester) async { @@ -509,6 +507,20 @@ void main() { expect(theme.primaryColor, Colors.orange); }); + testWidgets("CupertinoThemeData does not override material theme's icon theme", + (WidgetTester tester) async { + const Color materialIconColor = Colors.blue; + const Color cupertinoIconColor = Colors.black; + + await testTheme(tester, ThemeData( + iconTheme: const IconThemeData(color: materialIconColor), + cupertinoOverrideTheme: const CupertinoThemeData(primaryColor: cupertinoIconColor) + )); + + expect(buildCount, 1); + expect(actualIconTheme.color, materialIconColor); + }); + testWidgets( 'Changing cupertino theme override triggers rebuilds', (WidgetTester tester) async { diff --git a/packages/flutter/test/material/user_accounts_drawer_header_test.dart b/packages/flutter/test/material/user_accounts_drawer_header_test.dart index 6d997362ed..5a9387c975 100644 --- a/packages/flutter/test/material/user_accounts_drawer_header_test.dart +++ b/packages/flutter/test/material/user_accounts_drawer_header_test.dart @@ -139,6 +139,42 @@ void main() { expect(transformWidget.transform.getRotation()[4], 1.0); }); + // Regression test for https://github.com/flutter/flutter/issues/25801. + testWidgets('UserAccountsDrawerHeader icon does not rotate after setState', (WidgetTester tester) async { + StateSetter testSetState; + await tester.pumpWidget(MaterialApp( + home: Material( + child: StatefulBuilder( + builder: (BuildContext context, StateSetter setState) { + testSetState = setState; + return UserAccountsDrawerHeader( + onDetailsPressed: () { }, + accountName: const Text('name'), + accountEmail: const Text('email'), + ); + }, + ), + ), + )); + + Transform transformWidget = tester.firstWidget(find.byType(Transform)); + + // Icon is right side up. + expect(transformWidget.transform.getRotation()[0], 1.0); + expect(transformWidget.transform.getRotation()[4], 1.0); + + testSetState(() { }); + await tester.pump(const Duration(milliseconds: 10)); + expect(tester.hasRunningAnimations, isFalse); + + await tester.pumpAndSettle(); + transformWidget = tester.firstWidget(find.byType(Transform)); + + // Icon has not rotated. + expect(transformWidget.transform.getRotation()[0], 1.0); + expect(transformWidget.transform.getRotation()[4], 1.0); + }); + testWidgets('UserAccountsDrawerHeader icon rotation test speeeeeedy', (WidgetTester tester) async { await pumpTestWidget(tester); Transform transformWidget = tester.firstWidget(find.byType(Transform)); diff --git a/packages/flutter/test/painting/border_test.dart b/packages/flutter/test/painting/border_test.dart index 6cc94bf688..7e7a42e99b 100644 --- a/packages/flutter/test/painting/border_test.dart +++ b/packages/flutter/test/painting/border_test.dart @@ -13,6 +13,16 @@ void main() { expect(() => Border(bottom: nonconst(null)), throwsAssertionError); }); + test('Border.uniform constructor', () { + expect(() => Border.uniform(null), throwsAssertionError); + const BorderSide side = BorderSide(); + const Border border = Border.uniform(side); + expect(border.left, same(side)); + expect(border.top, same(side)); + expect(border.right, same(side)); + expect(border.bottom, same(side)); + }); + test('Border.merge', () { const BorderSide magenta3 = BorderSide(color: Color(0xFFFF00FF), width: 3.0); const BorderSide magenta6 = BorderSide(color: Color(0xFFFF00FF), width: 6.0); diff --git a/packages/flutter/test/painting/flutter_logo_test.dart b/packages/flutter/test/painting/flutter_logo_test.dart index 9d87e0d0a1..f5f13d2e66 100644 --- a/packages/flutter/test/painting/flutter_logo_test.dart +++ b/packages/flutter/test/painting/flutter_logo_test.dart @@ -7,20 +7,20 @@ import 'package:flutter/painting.dart'; void main() { // Here and below, see: https://github.com/dart-lang/sdk/issues/26980 - final FlutterLogoDecoration start = FlutterLogoDecoration( - lightColor: const Color(0xFF000000), - darkColor: const Color(0xFFFFFFFF), - textColor: const Color(0xFFD4F144), + const FlutterLogoDecoration start = FlutterLogoDecoration( + lightColor: Color(0xFF000000), + darkColor: Color(0xFFFFFFFF), + textColor: Color(0xFFD4F144), style: FlutterLogoStyle.stacked, - margin: const EdgeInsets.all(10.0), + margin: EdgeInsets.all(10.0), ); - final FlutterLogoDecoration end = FlutterLogoDecoration( - lightColor: const Color(0xFFFFFFFF), - darkColor: const Color(0xFF000000), - textColor: const Color(0xFF81D4FA), + const FlutterLogoDecoration end = FlutterLogoDecoration( + lightColor: Color(0xFFFFFFFF), + darkColor: Color(0xFF000000), + textColor: Color(0xFF81D4FA), style: FlutterLogoStyle.stacked, - margin: const EdgeInsets.all(10.0), + margin: EdgeInsets.all(10.0), ); test('FlutterLogoDecoration lerp from null to null is null', () { diff --git a/packages/flutter/test/painting/image_provider_test.dart b/packages/flutter/test/painting/image_provider_test.dart index b49e5e9678..45efc5fd02 100644 --- a/packages/flutter/test/painting/image_provider_test.dart +++ b/packages/flutter/test/painting/image_provider_test.dart @@ -3,11 +3,13 @@ // found in the LICENSE file. import 'dart:async'; +import 'dart:io'; import 'dart:typed_data'; import 'package:flutter/foundation.dart'; import 'package:flutter/painting.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:mockito/mockito.dart'; import '../rendering/rendering_tester.dart'; import 'image_data.dart'; @@ -86,4 +88,77 @@ void main() { }); expect(await caughtError.future, true); }); + + test('ImageProvider.resolve sync errors will be caught', () async { + bool uncaught = false; + final Zone testZone = Zone.current.fork(specification: ZoneSpecification( + handleUncaughtError: (Zone zone, ZoneDelegate zoneDelegate, Zone parent, Object error, StackTrace stackTrace) { + uncaught = true; + } + )); + await testZone.run(() async { + final ImageProvider imageProvider = LoadErrorImageProvider(); + final Completer caughtError = Completer(); + FlutterError.onError = (FlutterErrorDetails details) { + throw Error(); + }; + final ImageStream result = imageProvider.resolve(ImageConfiguration.empty); + result.addListener((ImageInfo info, bool syncCall) { + }, onError: (dynamic error, StackTrace stackTrace) { + caughtError.complete(true); + }); + expect(await caughtError.future, true); + }); + expect(uncaught, false); + }); + + test('ImageProvider.resolve errors in the completer will be caught', () async { + bool uncaught = false; + final Zone testZone = Zone.current.fork(specification: ZoneSpecification( + handleUncaughtError: (Zone zone, ZoneDelegate zoneDelegate, Zone parent, Object error, StackTrace stackTrace) { + uncaught = true; + } + )); + await testZone.run(() async { + final ImageProvider imageProvider = LoadErrorCompleterImageProvider(); + final Completer caughtError = Completer(); + FlutterError.onError = (FlutterErrorDetails details) { + throw Error(); + }; + final ImageStream result = imageProvider.resolve(ImageConfiguration.empty); + result.addListener((ImageInfo info, bool syncCall) { + }, onError: (dynamic error, StackTrace stackTrace) { + caughtError.complete(true); + }); + expect(await caughtError.future, true); + }); + expect(uncaught, false); + }); + + test('ImageProvider.resolve errors in the http client will be caught', () async { + bool uncaught = false; + final HttpClientMock httpClientMock = HttpClientMock(); + when(httpClientMock.getUrl(any)).thenThrow(Error()); + + await HttpOverrides.runZoned(() async { + const ImageProvider imageProvider = NetworkImage('asdasdasdas'); + final Completer caughtError = Completer(); + FlutterError.onError = (FlutterErrorDetails details) { + throw Error(); + }; + final ImageStream result = imageProvider.resolve(ImageConfiguration.empty); + result.addListener((ImageInfo info, bool syncCall) { + }, onError: (dynamic error, StackTrace stackTrace) { + caughtError.complete(true); + }); + expect(await caughtError.future, true); + }, createHttpClient: (SecurityContext context) => httpClientMock, zoneSpecification: ZoneSpecification( + handleUncaughtError: (Zone zone, ZoneDelegate zoneDelegate, Zone parent, Object error, StackTrace stackTrace) { + uncaught = true; + } + )); + expect(uncaught, false); + }); } + +class HttpClientMock extends Mock implements HttpClient {} diff --git a/packages/flutter/test/painting/image_stream_test.dart b/packages/flutter/test/painting/image_stream_test.dart index c6c545fe9a..d6c0341f14 100644 --- a/packages/flutter/test/painting/image_stream_test.dart +++ b/packages/flutter/test/painting/image_stream_test.dart @@ -89,15 +89,39 @@ void main() { expect(tester.takeException(), 'failure message'); }); - testWidgets('First frame decoding starts when codec is ready', (WidgetTester tester) async { + testWidgets('Decoding starts when a listener is added after codec is ready', (WidgetTester tester) async { final Completer completer = Completer(); final MockCodec mockCodec = MockCodec(); mockCodec.frameCount = 1; - MultiFrameImageStreamCompleter( + final ImageStreamCompleter imageStream = MultiFrameImageStreamCompleter( codec: completer.future, scale: 1.0, ); + completer.complete(mockCodec); + await tester.idle(); + expect(mockCodec.numFramesAsked, 0); + + final ImageListener listener = (ImageInfo image, bool synchronousCall) { }; + imageStream.addListener(listener); + await tester.idle(); + expect(mockCodec.numFramesAsked, 1); + }); + + testWidgets('Decoding starts when a codec is ready after a listener is added', (WidgetTester tester) async { + final Completer completer = Completer(); + final MockCodec mockCodec = MockCodec(); + mockCodec.frameCount = 1; + final ImageStreamCompleter imageStream = MultiFrameImageStreamCompleter( + codec: completer.future, + scale: 1.0, + ); + + final ImageListener listener = (ImageInfo image, bool synchronousCall) { }; + imageStream.addListener(listener); + await tester.idle(); + expect(mockCodec.numFramesAsked, 0); + completer.complete(mockCodec); await tester.idle(); expect(mockCodec.numFramesAsked, 1); @@ -108,11 +132,13 @@ void main() { mockCodec.frameCount = 1; final Completer codecCompleter = Completer(); - MultiFrameImageStreamCompleter( + final ImageStreamCompleter imageStream = MultiFrameImageStreamCompleter( codec: codecCompleter.future, scale: 1.0, ); + final ImageListener listener = (ImageInfo image, bool synchronousCall) { }; + imageStream.addListener(listener); codecCompleter.complete(mockCodec); // MultiFrameImageStreamCompleter only sets an error handler for the next // frame future after the codec future has completed. @@ -469,4 +495,76 @@ void main() { expect(tester.takeException(), isNull); expect(capturedException, 'frame completion error'); }); + + testWidgets('remove and add listener ', (WidgetTester tester) async { + final MockCodec mockCodec = MockCodec(); + mockCodec.frameCount = 3; + mockCodec.repetitionCount = 0; + final Completer codecCompleter = Completer(); + + final ImageStreamCompleter imageStream = MultiFrameImageStreamCompleter( + codec: codecCompleter.future, + scale: 1.0, + ); + + final ImageListener listener = (ImageInfo image, bool synchronousCall) { }; + imageStream.addListener(listener); + + codecCompleter.complete(mockCodec); + + await tester.idle(); // let nextFrameFuture complete + + imageStream.removeListener(listener); + imageStream.addListener(listener); + + + final FrameInfo frame1 = FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); + + mockCodec.completeNextFrame(frame1); + await tester.idle(); // let nextFrameFuture complete + await tester.pump(); // first animation frame shows on first app frame. + + await tester.pump(const Duration(milliseconds: 200)); // emit 2nd frame. + }); + + // TODO(amirh): enable this once WidgetTester supports flushTimers. + // https://github.com/flutter/flutter/issues/30344 + // testWidgets('remove and add listener before a delayed frame is scheduled', (WidgetTester tester) async { + // final MockCodec mockCodec = MockCodec(); + // mockCodec.frameCount = 3; + // mockCodec.repetitionCount = 0; + // final Completer codecCompleter = Completer(); + // + // final ImageStreamCompleter imageStream = MultiFrameImageStreamCompleter( + // codec: codecCompleter.future, + // scale: 1.0, + // ); + // + // final ImageListener listener = (ImageInfo image, bool synchronousCall) { }; + // imageStream.addListener(listener); + // + // codecCompleter.complete(mockCodec); + // await tester.idle(); + // + // final FrameInfo frame1 = FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); + // final FrameInfo frame2 = FakeFrameInfo(200, 100, const Duration(milliseconds: 400)); + // final FrameInfo frame3 = FakeFrameInfo(200, 100, const Duration(milliseconds: 0)); + // + // mockCodec.completeNextFrame(frame1); + // await tester.idle(); // let nextFrameFuture complete + // await tester.pump(); // first animation frame shows on first app frame. + // + // mockCodec.completeNextFrame(frame2); + // await tester.pump(const Duration(milliseconds: 100)); // emit 2nd frame. + // + // tester.flushTimers(); + // + // imageStream.removeListener(listener); + // imageStream.addListener(listener); + // + // mockCodec.completeNextFrame(frame3); + // await tester.idle(); // let nextFrameFuture complete + // + // await tester.pump(); + // }); } diff --git a/packages/flutter/test/painting/mocks_for_image_cache.dart b/packages/flutter/test/painting/mocks_for_image_cache.dart index f751449098..dfc7e99465 100644 --- a/packages/flutter/test/painting/mocks_for_image_cache.dart +++ b/packages/flutter/test/painting/mocks_for_image_cache.dart @@ -106,4 +106,30 @@ class ObtainKeyErrorImageProvider extends ImageProvider { + @override + ImageStreamCompleter load(LoadErrorImageProvider key) { + throw Error(); + } + + @override + Future obtainKey(ImageConfiguration configuration) { + return SynchronousFuture(this); + } +} + +class LoadErrorCompleterImageProvider extends ImageProvider { + @override + ImageStreamCompleter load(LoadErrorCompleterImageProvider key) { + final Completer completer = Completer.sync(); + completer.completeError(Error()); + return OneFrameImageStreamCompleter(completer.future); + } + + @override + Future obtainKey(ImageConfiguration configuration) { + return SynchronousFuture(this); + } +} + class TestImageStreamCompleter extends ImageStreamCompleter {} diff --git a/packages/flutter/test/painting/painting_utils.dart b/packages/flutter/test/painting/painting_utils.dart index 861c0a27ec..b423c45545 100644 --- a/packages/flutter/test/painting/painting_utils.dart +++ b/packages/flutter/test/painting/painting_utils.dart @@ -20,6 +20,7 @@ class PaintingBindingSpy extends BindingBase with ServicesBinding, PaintingBindi } @override + // ignore: MUST_CALL_SUPER void initLicenses() { // Do not include any licenses, because we're a test, and the LICENSE file // doesn't get generated for tests. diff --git a/packages/flutter/test/painting/text_painter_test.dart b/packages/flutter/test/painting/text_painter_test.dart index e5f65a90ef..80d0c2228a 100644 --- a/packages/flutter/test/painting/text_painter_test.dart +++ b/packages/flutter/test/painting/text_painter_test.dart @@ -133,7 +133,9 @@ void main() { Offset caretOffset = painter.getOffsetForCaret(const ui.TextPosition(offset: 0), ui.Rect.zero); expect(caretOffset.dx, 21); caretOffset = painter.getOffsetForCaret(const ui.TextPosition(offset: text.length), ui.Rect.zero); - expect(caretOffset.dx, 441); + // The end of the line is 441, but the width is only 420, so the cursor is + // stopped there without overflowing. + expect(caretOffset.dx, painter.width); caretOffset = painter.getOffsetForCaret(const ui.TextPosition(offset: 1), ui.Rect.zero); expect(caretOffset.dx, 35); diff --git a/packages/flutter/test/painting/text_span_test.dart b/packages/flutter/test/painting/text_span_test.dart index 023443b711..072ea5f4cb 100644 --- a/packages/flutter/test/painting/text_span_test.dart +++ b/packages/flutter/test/painting/text_span_test.dart @@ -61,4 +61,27 @@ void main() { ' "c"\n' )); }); + + test('TextSpan toPlainText', () { + const TextSpan textSpan = TextSpan( + text: 'a', + children: [ + TextSpan(text: 'b'), + TextSpan(text: 'c'), + ], + ); + expect(textSpan.toPlainText(), 'abc'); + }); + + test('TextSpan toPlainText with semanticsLabel', () { + const TextSpan textSpan = TextSpan( + text: 'a', + children: [ + TextSpan(text: 'b', semanticsLabel: 'foo'), + TextSpan(text: 'c'), + ], + ); + expect(textSpan.toPlainText(), 'afooc'); + expect(textSpan.toPlainText(includeSemanticsLabels: false), 'abc'); + }); } diff --git a/packages/flutter/test/rendering/editable_test.dart b/packages/flutter/test/rendering/editable_test.dart index 63b6368d92..28f0be549a 100644 --- a/packages/flutter/test/rendering/editable_test.dart +++ b/packages/flutter/test/rendering/editable_test.dart @@ -134,7 +134,7 @@ void main() { expect(editable, paints..rect( color: const Color.fromARGB(0xFF, 0xFF, 0x00, 0x00), - rect: Rect.fromLTWH(40, 2, 1, 6), + rect: Rect.fromLTWH(40, 0, 1, 10), )); // Now change to a rounded caret. @@ -146,7 +146,7 @@ void main() { expect(editable, paints..rrect( color: const Color.fromARGB(0xFF, 0x00, 0x00, 0xFF), rrect: RRect.fromRectAndRadius( - Rect.fromLTWH(40, 2, 4, 6), + Rect.fromLTWH(40, 0, 4, 10), const Radius.circular(3), ), )); @@ -158,7 +158,80 @@ void main() { expect(editable, paints..rrect( color: const Color.fromARGB(0xFF, 0x00, 0x00, 0xFF), rrect: RRect.fromRectAndRadius( - Rect.fromLTWH(80, 2, 4, 16), + Rect.fromLTWH(80, 0, 4, 20), + const Radius.circular(3), + ), + )); + + // Can turn off caret. + showCursor.value = false; + pumpFrame(); + + expect(editable, paintsExactlyCountTimes(#drawRRect, 0)); + }); + + test('Cursor with ideographic script', () { + final TextSelectionDelegate delegate = FakeEditableTextState(); + final ValueNotifier showCursor = ValueNotifier(true); + EditableText.debugDeterministicCursor = true; + + final RenderEditable editable = RenderEditable( + backgroundCursorColor: Colors.grey, + textDirection: TextDirection.ltr, + cursorColor: const Color.fromARGB(0xFF, 0xFF, 0x00, 0x00), + offset: ViewportOffset.zero(), + textSelectionDelegate: delegate, + text: const TextSpan( + text: '中文测试文本是否正确', + style: TextStyle( + height: 1.0, fontSize: 10.0, fontFamily: 'Ahem', + ), + ), + selection: const TextSelection.collapsed( + offset: 4, + affinity: TextAffinity.upstream, + ), + ); + + layout(editable); + + editable.layout(BoxConstraints.loose(const Size(100, 100))); + expect( + editable, + // Draw no cursor by default. + paintsExactlyCountTimes(#drawRect, 0), + ); + + editable.showCursor = showCursor; + pumpFrame(); + + expect(editable, paints..rect( + color: const Color.fromARGB(0xFF, 0xFF, 0x00, 0x00), + rect: Rect.fromLTWH(40, 0, 1, 10), + )); + + // Now change to a rounded caret. + editable.cursorColor = const Color.fromARGB(0xFF, 0x00, 0x00, 0xFF); + editable.cursorWidth = 4; + editable.cursorRadius = const Radius.circular(3); + pumpFrame(); + + expect(editable, paints..rrect( + color: const Color.fromARGB(0xFF, 0x00, 0x00, 0xFF), + rrect: RRect.fromRectAndRadius( + Rect.fromLTWH(40, 0, 4, 10), + const Radius.circular(3), + ), + )); + + editable.textScaleFactor = 2; + pumpFrame(); + + // Now the caret height is much bigger due to the bigger font scale. + expect(editable, paints..rrect( + color: const Color.fromARGB(0xFF, 0x00, 0x00, 0xFF), + rrect: RRect.fromRectAndRadius( + Rect.fromLTWH(80, 0, 4, 20), const Radius.circular(3), ), )); @@ -422,4 +495,25 @@ void main() { expect(updatedSelection.extentOffset, 5); expect(selectionChangedCount, 1); }); + + test('editable hasFocus correctly initialized', () { + // Regression test for https://github.com/flutter/flutter/issues/21640 + final TextSelectionDelegate delegate = FakeEditableTextState(); + final RenderEditable editable = RenderEditable( + text: const TextSpan( + style: TextStyle(height: 1.0, fontSize: 10.0, fontFamily: 'Ahem'), + text: '12345', + ), + textAlign: TextAlign.start, + textDirection: TextDirection.ltr, + locale: const Locale('en', 'US'), + offset: ViewportOffset.zero(), + textSelectionDelegate: delegate, + hasFocus: true, + ); + + expect(editable.hasFocus, true); + editable.hasFocus = false; + expect(editable.hasFocus, false); + }); } diff --git a/packages/flutter/test/rendering/layers_test.dart b/packages/flutter/test/rendering/layers_test.dart index 84f34bb6da..72a94f1755 100644 --- a/packages/flutter/test/rendering/layers_test.dart +++ b/packages/flutter/test/rendering/layers_test.dart @@ -4,6 +4,7 @@ import 'dart:ui'; +import 'package:flutter/foundation.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -112,6 +113,56 @@ void main() { expect(followerLayer.debugSubtreeNeedsAddToScene, true); }); + test('depthFirstIterateChildren', () { + final ContainerLayer a = ContainerLayer(); + final ContainerLayer b = ContainerLayer(); + final ContainerLayer c = ContainerLayer(); + final ContainerLayer d = ContainerLayer(); + final ContainerLayer e = ContainerLayer(); + final ContainerLayer f = ContainerLayer(); + final ContainerLayer g = ContainerLayer(); + + final PictureLayer h = PictureLayer(Rect.zero); + final PictureLayer i = PictureLayer(Rect.zero); + final PictureLayer j = PictureLayer(Rect.zero); + + // The tree is like the following: + // a____ + // / \ + // b___ c + // / \ \ | + // d e f g + // / \ | + // h i j + a.append(b); + a.append(c); + b.append(d); + b.append(e); + b.append(f); + d.append(h); + d.append(i); + c.append(g); + g.append(j); + + expect( + a.depthFirstIterateChildren(), + [b, d, h, i, e, f, c, g, j], + ); + + d.remove(); + // a____ + // / \ + // b___ c + // \ \ | + // e f g + // | + // j + expect( + a.depthFirstIterateChildren(), + [b, e, f, c, g, j], + ); + }); + void checkNeedsAddToScene(Layer layer, void mutateCallback()) { layer.debugMarkClean(); layer.updateSubtreeNeedsAddToScene(); @@ -239,4 +290,170 @@ void main() { layer.shadowColor = const Color(1); }); }); + + group('PhysicalModelLayer checks elevations', () { + /// Adds the layers to a container where A paints before B. + /// + /// Expects there to be `expectedErrorCount` errors. Checking elevations is + /// enabled by default. + void _testConflicts( + PhysicalModelLayer layerA, + PhysicalModelLayer layerB, { + @required int expectedErrorCount, + bool enableCheck = true, + }) { + assert(expectedErrorCount != null); + assert(enableCheck || expectedErrorCount == 0, 'Cannot disable check and expect non-zero error count.'); + final OffsetLayer container = OffsetLayer(); + container.append(layerA); + container.append(layerB); + debugCheckElevationsEnabled = enableCheck; + debugDisableShadows = false; + int errors = 0; + if (enableCheck) { + FlutterError.onError = (FlutterErrorDetails details) { + errors++; + }; + } + container.buildScene(SceneBuilder()); + expect(errors, expectedErrorCount); + debugCheckElevationsEnabled = false; + } + + // Tests: + // + // ───────────── (LayerA, paints first) + // │ ───────────── (LayerB, paints second) + // │ │ + // ─────────────────────────── + test('Overlapping layers at wrong elevation', () { + final PhysicalModelLayer layerA = PhysicalModelLayer( + clipPath: Path()..addRect(Rect.fromLTWH(0, 0, 20, 20)), + elevation: 3.0, + color: const Color(0), + shadowColor: const Color(0), + ); + final PhysicalModelLayer layerB =PhysicalModelLayer( + clipPath: Path()..addRect(Rect.fromLTWH(10, 10, 20, 20)), + elevation: 2.0, + color: const Color(0), + shadowColor: const Color(0), + ); + _testConflicts(layerA, layerB, expectedErrorCount: 1); + }); + + // Tests: + // + // ───────────── (LayerA, paints first) + // │ ───────────── (LayerB, paints second) + // │ │ + // ─────────────────────────── + // + // Causes no error if check is disabled. + test('Overlapping layers at wrong elevation, check disabled', () { + final PhysicalModelLayer layerA = PhysicalModelLayer( + clipPath: Path()..addRect(Rect.fromLTWH(0, 0, 20, 20)), + elevation: 3.0, + color: const Color(0), + shadowColor: const Color(0), + ); + final PhysicalModelLayer layerB =PhysicalModelLayer( + clipPath: Path()..addRect(Rect.fromLTWH(10, 10, 20, 20)), + elevation: 2.0, + color: const Color(0), + shadowColor: const Color(0), + ); + _testConflicts(layerA, layerB, expectedErrorCount: 0, enableCheck: false); + }); + + // Tests: + // + // ────────── (LayerA, paints first) + // │ ─────────── (LayerB, paints second) + // │ │ + // ──────────────────────────── + test('Non-overlapping layers at wrong elevation', () { + final PhysicalModelLayer layerA = PhysicalModelLayer( + clipPath: Path()..addRect(Rect.fromLTWH(0, 0, 20, 20)), + elevation: 3.0, + color: const Color(0), + shadowColor: const Color(0), + ); + final PhysicalModelLayer layerB =PhysicalModelLayer( + clipPath: Path()..addRect(Rect.fromLTWH(20, 20, 20, 20)), + elevation: 2.0, + color: const Color(0), + shadowColor: const Color(0), + ); + _testConflicts(layerA, layerB, expectedErrorCount: 0); + }); + + // Tests: + // + // ─────── (Child of A, paints second) + // │ + // ─────────── (LayerA, paints first) + // │ ──────────── (LayerB, paints third) + // │ │ + // ──────────────────────────── + test('Non-overlapping layers at wrong elevation, child at lower elevation', () { + final PhysicalModelLayer layerA = PhysicalModelLayer( + clipPath: Path()..addRect(Rect.fromLTWH(0, 0, 20, 20)), + elevation: 3.0, + color: const Color(0), + shadowColor: const Color(0), + ); + + layerA.append(PhysicalModelLayer( + clipPath: Path()..addRect(Rect.fromLTWH(2, 2, 10, 10)), + elevation: 1.0, + color: const Color(0), + shadowColor: const Color(0), + )); + + final PhysicalModelLayer layerB =PhysicalModelLayer( + clipPath: Path()..addRect(Rect.fromLTWH(20, 20, 20, 20)), + elevation: 2.0, + color: const Color(0), + shadowColor: const Color(0), + ); + _testConflicts(layerA, layerB, expectedErrorCount: 0); + }); + + // Tests: + // + // ─────────── (Child of A, paints second, overflows) + // │ ──────────── (LayerB, paints third) + // ─────────── │ (LayerA, paints first) + // │ │ + // │ │ + // ──────────────────────────── + // + // Which fails because the overflowing child overlaps something that paints + // after it at a lower elevation. + test('Child overflows parent and overlaps another physical layer', () { + final PhysicalModelLayer layerA = PhysicalModelLayer( + clipPath: Path()..addRect(Rect.fromLTWH(0, 0, 20, 20)), + elevation: 3.0, + color: const Color(0), + shadowColor: const Color(0), + ); + + layerA.append(PhysicalModelLayer( + clipPath: Path()..addRect(Rect.fromLTWH(15, 15, 25, 25)), + elevation: 2.0, + color: const Color(0), + shadowColor: const Color(0), + )); + + final PhysicalModelLayer layerB =PhysicalModelLayer( + clipPath: Path()..addRect(Rect.fromLTWH(20, 20, 20, 20)), + elevation: 4.0, + color: const Color(0), + shadowColor: const Color(0), + ); + + _testConflicts(layerA, layerB, expectedErrorCount: 1); + }); + }); } diff --git a/packages/flutter/test/rendering/slivers_block_test.dart b/packages/flutter/test/rendering/slivers_block_test.dart index 95c69001dd..57e51b907b 100644 --- a/packages/flutter/test/rendering/slivers_block_test.dart +++ b/packages/flutter/test/rendering/slivers_block_test.dart @@ -3,7 +3,9 @@ // found in the LICENSE file. import 'package:flutter/rendering.dart'; +import 'package:flutter/animation.dart'; import 'package:meta/meta.dart'; + import '../flutter_test_alternative.dart'; import 'rendering_tester.dart'; @@ -67,6 +69,49 @@ class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager { void setDidUnderflow(bool value) { } } +class ViewportOffsetSpy extends ViewportOffset { + ViewportOffsetSpy(this._pixels); + + double _pixels; + + @override + double get pixels => _pixels; + + bool corrected = false; + + @override + bool applyViewportDimension(double viewportDimension) => true; + + @override + bool applyContentDimensions(double minScrollExtent, double maxScrollExtent) => true; + + @override + void correctBy(double correction) { + _pixels += correction; + corrected = true; + } + + @override + void jumpTo(double pixels) { + // Do nothing, not required in test. + } + + @override + Future animateTo( + double to, { + @required Duration duration, + @required Curve curve, + }) async { + // Do nothing, not required in test. + } + + @override + ScrollDirection get userScrollDirection => ScrollDirection.idle; + + @override + bool get allowImplicitScrolling => false; +} + void main() { test('RenderSliverList basic test - down', () { RenderObject inner; @@ -254,6 +299,43 @@ void main() { expect(inner.geometry.scrollOffsetCorrection, isNull); }); + test('SliverList - no correction when tiny double precision error', () { + RenderSliverList inner; + RenderBox a; + final TestRenderSliverBoxChildManager childManager = TestRenderSliverBoxChildManager( + children: [ + a = RenderSizedBox(const Size(100.0, 400.0)), + RenderSizedBox(const Size(100.0, 400.0)), + RenderSizedBox(const Size(100.0, 400.0)), + RenderSizedBox(const Size(100.0, 400.0)), + RenderSizedBox(const Size(100.0, 400.0)), + ], + ); + inner = childManager.createRenderObject(); + final RenderViewport root = RenderViewport( + axisDirection: AxisDirection.down, + crossAxisDirection: AxisDirection.right, + offset: ViewportOffset.zero(), + children: [ + inner, + ], + ); + layout(root); + + final SliverMultiBoxAdaptorParentData parentData = a.parentData; + // Simulate double precision error. + parentData.layoutOffset = -0.0000000000001; + + root.offset = ViewportOffset.fixed(900.0); + pumpFrame(); + + final ViewportOffsetSpy spy = ViewportOffsetSpy(0.0); + root.offset = spy; + pumpFrame(); + + expect(spy.corrected, false); + }); + test('SliverMultiBoxAdaptorParentData.toString', () { final SliverMultiBoxAdaptorParentData candidate = SliverMultiBoxAdaptorParentData(); expect(candidate.keepAlive, isFalse); diff --git a/packages/flutter/test/rendering/table_test.dart b/packages/flutter/test/rendering/table_test.dart index e8708da8fb..1f6e8d7735 100644 --- a/packages/flutter/test/rendering/table_test.dart +++ b/packages/flutter/test/rendering/table_test.dart @@ -47,6 +47,19 @@ void main() { expect(table.size, equals(const Size(0.0, 0.0))); }); + test('Table control test: constrained flex columns', () { + final RenderTable table = RenderTable(textDirection: TextDirection.ltr); + final List children = List.generate(6, (_) => RenderPositionedBox()); + + table.setFlatChildren(6, children); + layout(table, constraints: const BoxConstraints.tightFor(width: 100.0)); + + const double expectedWidth = 100.0 / 6; + for (RenderBox child in children) { + expect(child.size.width, moreOrLessEquals(expectedWidth)); + } + }); + test('Table test: combinations', () { RenderTable table; layout(RenderPositionedBox(child: table = RenderTable( diff --git a/packages/flutter/test/services/platform_channel_test.dart b/packages/flutter/test/services/platform_channel_test.dart index 243a254e39..9b1108073e 100644 --- a/packages/flutter/test/services/platform_channel_test.dart +++ b/packages/flutter/test/services/platform_channel_test.dart @@ -69,6 +69,21 @@ void main() { expect(await channel.invokeListMethod('sayHello', 'hello'), ['hello', 'world']); }); + test('can invoke list method and get null result', () async { + BinaryMessages.setMockMessageHandler( + 'ch7', + (ByteData message) async { + final Map methodCall = jsonMessage.decodeMessage(message); + if (methodCall['method'] == 'sayHello') { + return jsonMessage.encodeMessage([null]); + } else { + return jsonMessage.encodeMessage(['unknown', null, null]); + } + }, + ); + expect(await channel.invokeListMethod('sayHello', 'hello'), null); + }); + test('can invoke map method and get result', () async { BinaryMessages.setMockMessageHandler( @@ -86,6 +101,21 @@ void main() { expect(await channel.invokeMapMethod('sayHello', 'hello'), {'hello': 'world'}); }); + test('can invoke map method and get null result', () async { + BinaryMessages.setMockMessageHandler( + 'ch7', + (ByteData message) async { + final Map methodCall = jsonMessage.decodeMessage(message); + if (methodCall['method'] == 'sayHello') { + return jsonMessage.encodeMessage([null]); + } else { + return jsonMessage.encodeMessage(['unknown', null, null]); + } + }, + ); + expect(await channel.invokeMapMethod('sayHello', 'hello'), null); + }); + test('can invoke method and get error', () async { BinaryMessages.setMockMessageHandler( 'ch7', diff --git a/packages/flutter/test/services/raw_keyboard_test.dart b/packages/flutter/test/services/raw_keyboard_test.dart index b5bd89d71e..fec0a66bad 100644 --- a/packages/flutter/test/services/raw_keyboard_test.dart +++ b/packages/flutter/test/services/raw_keyboard_test.dart @@ -92,7 +92,7 @@ void main() { expect( data.isModifierPressed(key, side: modifierTests[modifier].side), isFalse, - reason: '$key should not be pressed with metaState $modifier with metaState $modifier ' + reason: '$key should not be pressed with metaState $modifier ' 'and additional key ${RawKeyEventDataAndroid.modifierFunction}.', ); } @@ -264,7 +264,7 @@ void main() { expect(data.keyLabel, isNull); }); }); - group('RawKeyEventDataMacOs', () { + group('RawKeyEventDataMacOs', () { const Map modifierTests = { RawKeyEventDataMacOs.modifierOption | RawKeyEventDataMacOs.modifierLeftOption: _ModifierCheck(ModifierKey.altModifier, KeyboardSide.left), RawKeyEventDataMacOs.modifierOption | RawKeyEventDataMacOs.modifierRightOption: _ModifierCheck(ModifierKey.altModifier, KeyboardSide.right), @@ -340,7 +340,7 @@ void main() { expect( data.isModifierPressed(key, side: modifierTests[modifier].side), isFalse, - reason: '$key should not be pressed with metaState $modifier with metaState $modifier ' + reason: '$key should not be pressed with metaState $modifier ' 'and additional key ${RawKeyEventDataMacOs.modifierFunction}.', ); } @@ -393,4 +393,129 @@ void main() { expect(data.keyLabel, isNull); }); }); + group('RawKeyEventDataLinux-GFLW', () { + const Map modifierTests = { + GLFWKeyHelper.modifierAlt: _ModifierCheck(ModifierKey.altModifier, KeyboardSide.any), + GLFWKeyHelper.modifierShift: _ModifierCheck(ModifierKey.shiftModifier, KeyboardSide.any), + GLFWKeyHelper.modifierControl: _ModifierCheck(ModifierKey.controlModifier, KeyboardSide.any), + GLFWKeyHelper.modifierMeta: _ModifierCheck(ModifierKey.metaModifier, KeyboardSide.any), + GLFWKeyHelper.modifierNumericPad: _ModifierCheck(ModifierKey.numLockModifier, KeyboardSide.all), + GLFWKeyHelper.modifierCapsLock: _ModifierCheck(ModifierKey.capsLockModifier, KeyboardSide.all), + }; + + test('modifier keys are recognized individually', () { + for (int modifier in modifierTests.keys) { + final RawKeyEvent event = RawKeyEvent.fromMessage({ + 'type': 'keydown', + 'keymap': 'linux', + 'toolkit': 'glfw', + 'keyCode': 0x04, + 'scanCode': 0x01, + 'codePoint': 0x10, + 'modifiers': modifier, + }); + final RawKeyEventDataLinux data = event.data; + for (ModifierKey key in ModifierKey.values) { + if (modifierTests[modifier].key == key) { + expect( + data.isModifierPressed(key, side: modifierTests[modifier].side), + isTrue, + reason: "$key should be pressed with metaState $modifier, but isn't.", + ); + expect(data.getModifierSide(key), equals(modifierTests[modifier].side)); + } else { + expect( + data.isModifierPressed(key, side: modifierTests[modifier].side), + isFalse, + reason: '$key should not be pressed with metaState $modifier.', + ); + } + } + } + }); + test('modifier keys are recognized when combined', () { + for (int modifier in modifierTests.keys) { + if (modifier == GLFWKeyHelper.modifierControl) { + // No need to combine CTRL key with itself. + continue; + } + final RawKeyEvent event = RawKeyEvent.fromMessage({ + 'type': 'keydown', + 'keymap': 'linux', + 'toolkit': 'glfw', + 'keyCode': 0x04, + 'scanCode': 0x64, + 'codePoint': 0x1, + 'modifiers': modifier | GLFWKeyHelper.modifierControl, + }); + final RawKeyEventDataLinux data = event.data; + for (ModifierKey key in ModifierKey.values) { + if (modifierTests[modifier].key == key || key == ModifierKey.controlModifier) { + expect( + data.isModifierPressed(key, side: modifierTests[modifier].side), + isTrue, + reason: '$key should be pressed with metaState $modifier ' + "and additional key ${GLFWKeyHelper.modifierControl}, but isn't.", + ); + if (key != ModifierKey.controlModifier) { + expect(data.getModifierSide(key), equals(modifierTests[modifier].side)); + } else { + expect(data.getModifierSide(key), equals(KeyboardSide.any)); + } + } else { + expect( + data.isModifierPressed(key, side: modifierTests[modifier].side), + isFalse, + reason: '$key should not be pressed with metaState $modifier ' + 'and additional key ${GLFWKeyHelper.modifierControl}.', + ); + } + } + } + }); + test('Printable keyboard keys are correctly translated', () { + final RawKeyEvent keyAEvent = RawKeyEvent.fromMessage(const { + 'type': 'keydown', + 'keymap': 'linux', + 'toolkit': 'glfw', + 'keyCode': 65, + 'scanCode': 0x00000026, + 'codePoint': 97, + 'modifiers': 0x0, + }); + final RawKeyEventDataLinux data = keyAEvent.data; + expect(data.physicalKey, equals(PhysicalKeyboardKey.keyA)); + expect(data.logicalKey, equals(LogicalKeyboardKey.keyA)); + expect(data.keyLabel, equals('a')); + }); + test('Control keyboard keys are correctly translated', () { + final RawKeyEvent escapeKeyEvent = RawKeyEvent.fromMessage(const { + 'type': 'keydown', + 'keymap': 'linux', + 'toolkit': 'glfw', + 'keyCode': 256, + 'scanCode': 0x00000009, + 'codePoint': 0, + 'modifiers': 0x0, + }); + final RawKeyEventDataLinux data = escapeKeyEvent.data; + expect(data.physicalKey, equals(PhysicalKeyboardKey.escape)); + expect(data.logicalKey, equals(LogicalKeyboardKey.escape)); + expect(data.keyLabel, isNull); + }); + test('Modifier keyboard keys are correctly translated', () { + final RawKeyEvent shiftLeftKeyEvent = RawKeyEvent.fromMessage(const { + 'type': 'keydown', + 'keymap': 'linux', + 'toolkit': 'glfw', + 'keyCode': 340, + 'scanCode': 0x00000032, + 'codePoint': 0, + }); + final RawKeyEventDataLinux data = shiftLeftKeyEvent.data; + expect(data.physicalKey, equals(PhysicalKeyboardKey.shiftLeft)); + expect(data.logicalKey, equals(LogicalKeyboardKey.shiftLeft)); + expect(data.keyLabel, isNull); + }); + }); } diff --git a/packages/flutter/test/widgets/basic_test.dart b/packages/flutter/test/widgets/basic_test.dart index a1d6b91f68..41e218c4ad 100644 --- a/packages/flutter/test/widgets/basic_test.dart +++ b/packages/flutter/test/widgets/basic_test.dart @@ -2,7 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:math' as math; import 'package:flutter_test/flutter_test.dart'; +import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter/rendering.dart'; @@ -146,6 +148,64 @@ void main() { }); }); + group('Row', () { + testWidgets('multiple baseline aligned children', (WidgetTester tester) async { + final UniqueKey key1 = UniqueKey(); + final UniqueKey key2 = UniqueKey(); + const double fontSize1 = 54; + const double fontSize2 = 14; + + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: Container( + child: Row( + crossAxisAlignment: CrossAxisAlignment.baseline, + textBaseline: TextBaseline.alphabetic, + children: [ + Text('big text', + key: key1, + style: const TextStyle(fontSize: fontSize1), + ), + Text('one\ntwo\nthree\nfour\nfive\nsix\nseven', + key: key2, + style: const TextStyle(fontSize: fontSize2) + ), + ], + ), + ), + ), + ), + ); + + final RenderBox textBox1 = tester.renderObject(find.byKey(key1)); + final RenderBox textBox2 = tester.renderObject(find.byKey(key2)); + final RenderBox rowBox = tester.renderObject(find.byType(Row)); + + // The two Texts are baseline aligned, so some portion of them extends + // both above and below the baseline. The first has a huge font size, so + // it extends higher above the baseline than usual. The second has many + // lines, but being aligned by the first line's baseline, they hang far + // below the baseline. The size of the parent row is just enough to + // contain both of them. + const double ahemBaselineLocation = 0.8; // https://web-platform-tests.org/writing-tests/ahem.html + const double aboveBaseline1 = fontSize1 * ahemBaselineLocation; + const double belowBaseline1 = fontSize1 * (1 - ahemBaselineLocation); + const double aboveBaseline2 = fontSize2 * ahemBaselineLocation; + const double belowBaseline2 = fontSize2 * (1 - ahemBaselineLocation) + fontSize2 * 6; + final double aboveBaseline = math.max(aboveBaseline1, aboveBaseline2); + final double belowBaseline = math.max(belowBaseline1, belowBaseline2); + expect(rowBox.size.height, greaterThan(textBox1.size.height)); + expect(rowBox.size.height, greaterThan(textBox2.size.height)); + expect(rowBox.size.height, closeTo(aboveBaseline + belowBaseline, .001)); + expect(tester.getTopLeft(find.byKey(key1)).dy, 0); + expect( + tester.getTopLeft(find.byKey(key2)).dy, + closeTo(aboveBaseline1 - aboveBaseline2, .001), + ); + }); + }); + test('UnconstrainedBox toString', () { expect( const UnconstrainedBox(constrainedAxis: Axis.vertical,).toString(), diff --git a/packages/flutter/test/widgets/draggable_scrollable_sheet_test.dart b/packages/flutter/test/widgets/draggable_scrollable_sheet_test.dart new file mode 100644 index 0000000000..c10b2099b0 --- /dev/null +++ b/packages/flutter/test/widgets/draggable_scrollable_sheet_test.dart @@ -0,0 +1,205 @@ +// Copyright 2019 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/foundation.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + Widget _boilerplate(VoidCallback onButtonPressed) { + return Directionality( + textDirection: TextDirection.ltr, + child: Stack( + children: [ + FlatButton( + child: const Text('TapHere'), + onPressed: onButtonPressed, + ), + DraggableScrollableSheet( + maxChildSize: 1.0, + minChildSize: .25, + builder: (BuildContext context, ScrollController scrollController) { + return Container( + color: const Color(0xFFABCDEF), + child: ListView.builder( + controller: scrollController, + itemCount: 100, + itemBuilder: (BuildContext context, int index) => Text('Item $index'), + ), + ); + }, + ), + ], + ), + ); + } + + for (TargetPlatform platform in TargetPlatform.values) { + group('$platform Scroll Physics', () { + debugDefaultTargetPlatformOverride = platform; + + testWidgets('Can be dragged up without covering its container', (WidgetTester tester) async { + int taps = 0; + await tester.pumpWidget(_boilerplate(() => taps++)); + + expect(find.text('TapHere'), findsOneWidget); + await tester.tap(find.text('TapHere')); + expect(taps, 1); + expect(find.text('Item 1'), findsOneWidget); + expect(find.text('Item 21'), findsOneWidget); + expect(find.text('Item 31'), findsNothing); + + await tester.drag(find.text('Item 1'), const Offset(0, -200)); + await tester.pumpAndSettle(); + expect(find.text('TapHere'), findsOneWidget); + await tester.tap(find.text('TapHere')); + expect(taps, 2); + expect(find.text('Item 1'), findsOneWidget); + expect(find.text('Item 21'), findsOneWidget); + expect(find.text('Item 31'), findsOneWidget); + }); + + testWidgets('Can be dragged down when not full height', (WidgetTester tester) async { + await tester.pumpWidget(_boilerplate(null)); + expect(find.text('Item 1'), findsOneWidget); + expect(find.text('Item 21'), findsOneWidget); + expect(find.text('Item 36'), findsNothing); + + await tester.drag(find.text('Item 1'), const Offset(0, 325)); + await tester.pumpAndSettle(); + expect(find.text('Item 1'), findsOneWidget); + expect(find.text('Item 21'), findsNothing); + expect(find.text('Item 36'), findsNothing); + }); + + testWidgets('Can be dragged up and cover its container and scroll in single motion, and then dragged back down', (WidgetTester tester) async { + int taps = 0; + await tester.pumpWidget(_boilerplate(() => taps++)); + + expect(find.text('TapHere'), findsOneWidget); + await tester.tap(find.text('TapHere')); + expect(taps, 1); + expect(find.text('Item 1'), findsOneWidget); + expect(find.text('Item 21'), findsOneWidget); + expect(find.text('Item 36'), findsNothing); + + await tester.drag(find.text('Item 1'), const Offset(0, -325)); + await tester.pumpAndSettle(); + expect(find.text('TapHere'), findsOneWidget); + await tester.tap(find.text('TapHere')); + expect(taps, 1); + expect(find.text('Item 1'), findsOneWidget); + expect(find.text('Item 21'), findsOneWidget); + expect(find.text('Item 36'), findsOneWidget); + + await tester.dragFrom(const Offset(20, 20), const Offset(0, 325)); + await tester.pumpAndSettle(); + await tester.tap(find.text('TapHere')); + expect(taps, 2); + expect(find.text('Item 1'), findsOneWidget); + expect(find.text('Item 18'), findsOneWidget); + expect(find.text('Item 36'), findsNothing); + }); + + testWidgets('Can be flung up gently', (WidgetTester tester) async { + int taps = 0; + await tester.pumpWidget(_boilerplate(() => taps++)); + + expect(find.text('TapHere'), findsOneWidget); + await tester.tap(find.text('TapHere')); + expect(taps, 1); + expect(find.text('Item 1'), findsOneWidget); + expect(find.text('Item 21'), findsOneWidget); + expect(find.text('Item 36'), findsNothing); + expect(find.text('Item 70'), findsNothing); + + await tester.fling(find.text('Item 1'), const Offset(0, -200), 350); + await tester.pumpAndSettle(); + expect(find.text('TapHere'), findsOneWidget); + await tester.tap(find.text('TapHere')); + expect(taps, 2); + expect(find.text('Item 1'), findsOneWidget); + expect(find.text('Item 21'), findsOneWidget); + expect(find.text('Item 36'), findsOneWidget); + expect(find.text('Item 70'), findsNothing); + }); + + testWidgets('Can be flung up', (WidgetTester tester) async { + int taps = 0; + await tester.pumpWidget(_boilerplate(() => taps++)); + + expect(find.text('TapHere'), findsOneWidget); + await tester.tap(find.text('TapHere')); + expect(taps, 1); + expect(find.text('Item 1'), findsOneWidget); + expect(find.text('Item 21'), findsOneWidget); + expect(find.text('Item 70'), findsNothing); + + await tester.fling(find.text('Item 1'), const Offset(0, -200), 2000); + await tester.pumpAndSettle(); + expect(find.text('TapHere'), findsOneWidget); + await tester.tap(find.text('TapHere')); + expect(taps, 1); + expect(find.text('Item 1'), findsNothing); + expect(find.text('Item 21'), findsNothing); + expect(find.text('Item 70'), findsOneWidget); + }); + + testWidgets('Can be flung down when not full height', (WidgetTester tester) async { + await tester.pumpWidget(_boilerplate(null)); + expect(find.text('Item 1'), findsOneWidget); + expect(find.text('Item 21'), findsOneWidget); + expect(find.text('Item 36'), findsNothing); + + await tester.fling(find.text('Item 1'), const Offset(0, 325), 2000); + await tester.pumpAndSettle(); + expect(find.text('Item 1'), findsOneWidget); + expect(find.text('Item 21'), findsNothing); + expect(find.text('Item 36'), findsNothing); + }); + + testWidgets('Can be flung up and then back down', (WidgetTester tester) async { + int taps = 0; + await tester.pumpWidget(_boilerplate(() => taps++)); + + expect(find.text('TapHere'), findsOneWidget); + await tester.tap(find.text('TapHere')); + expect(taps, 1); + expect(find.text('Item 1'), findsOneWidget); + expect(find.text('Item 21'), findsOneWidget); + expect(find.text('Item 70'), findsNothing); + + await tester.fling(find.text('Item 1'), const Offset(0, -200), 2000); + await tester.pumpAndSettle(); + expect(find.text('TapHere'), findsOneWidget); + await tester.tap(find.text('TapHere')); + expect(taps, 1); + expect(find.text('Item 1'), findsNothing); + expect(find.text('Item 21'), findsNothing); + expect(find.text('Item 70'), findsOneWidget); + + await tester.fling(find.text('Item 70'), const Offset(0, 200), 2000); + await tester.pumpAndSettle(); + expect(find.text('TapHere'), findsOneWidget); + await tester.tap(find.text('TapHere')); + expect(taps, 1); + expect(find.text('Item 1'), findsOneWidget); + expect(find.text('Item 21'), findsOneWidget); + expect(find.text('Item 70'), findsNothing); + + await tester.fling(find.text('Item 1'), const Offset(0, 200), 2000); + await tester.pumpAndSettle(); + expect(find.text('TapHere'), findsOneWidget); + await tester.tap(find.text('TapHere')); + expect(taps, 2); + expect(find.text('Item 1'), findsOneWidget); + expect(find.text('Item 21'), findsNothing); + expect(find.text('Item 70'), findsNothing); + }); + + debugDefaultTargetPlatformOverride = null; + }); + } +} diff --git a/packages/flutter/test/widgets/editable_text_cursor_test.dart b/packages/flutter/test/widgets/editable_text_cursor_test.dart index 6e00f92633..88a186dc6d 100644 --- a/packages/flutter/test/widgets/editable_text_cursor_test.dart +++ b/packages/flutter/test/widgets/editable_text_cursor_test.dart @@ -91,7 +91,7 @@ void main() { await expectLater( find.byKey(const ValueKey(1)), - matchesGoldenFile('editable_text_test.0.0.png'), + matchesGoldenFile('editable_text_test.0.1.png'), ); }, skip: !Platform.isLinux); @@ -142,7 +142,7 @@ void main() { await expectLater( find.byKey(const ValueKey(1)), - matchesGoldenFile('editable_text_test.1.0.png'), + matchesGoldenFile('editable_text_test.1.1.png'), ); }, skip: !Platform.isLinux); @@ -476,6 +476,72 @@ void main() { expect(controller.selection.baseOffset, 10); }); + // Regression test for https://github.com/flutter/flutter/pull/30475. + testWidgets('Trying to select with the floating cursor does not crash', (WidgetTester tester) async { + const String text = 'hello world this is fun and cool and awesome!'; + controller.text = text; + final FocusNode focusNode = FocusNode(); + + await tester.pumpWidget( + MediaQuery( + data: const MediaQueryData(devicePixelRatio: 1), + child: Directionality( + textDirection: TextDirection.ltr, + child: FocusScope( + node: focusScopeNode, + autofocus: true, + child: EditableText( + backgroundCursorColor: Colors.grey, + controller: controller, + focusNode: focusNode, + style: textStyle, + cursorColor: cursorColor, + ), + ), + ), + ), + ); + + await tester.tap(find.byType(EditableText)); + final RenderEditable renderEditable = findRenderEditable(tester); + renderEditable.selection = const TextSelection(baseOffset: 29, extentOffset: 29); + + expect(controller.selection.baseOffset, 29); + + final EditableTextState editableTextState = tester.firstState(find.byType(EditableText)); + editableTextState.updateFloatingCursor(RawFloatingCursorPoint(state: FloatingCursorDragState.Start)); + + expect(controller.selection.baseOffset, 29); + + // Sets the origin. + editableTextState.updateFloatingCursor(RawFloatingCursorPoint(state: FloatingCursorDragState.Update, + offset: const Offset(20, 20))); + + expect(controller.selection.baseOffset, 29); + + // Moves the cursor right a few characters. + editableTextState.updateFloatingCursor(RawFloatingCursorPoint(state: FloatingCursorDragState.Update, + offset: const Offset(-250, 20))); + + // But we have not yet set the offset because the user is not done placing the cursor. + expect(controller.selection.baseOffset, 29); + + editableTextState.updateFloatingCursor(RawFloatingCursorPoint(state: FloatingCursorDragState.End)); + // Immediately start a new floating cursor, in the same way as happens when + // the user tries to select text in trackpad mode. + editableTextState.updateFloatingCursor(RawFloatingCursorPoint(state: FloatingCursorDragState.Start)); + await tester.pumpAndSettle(); + + // Set and move the second cursor like a selection. Previously, the second + // Update here caused a crash. + editableTextState.updateFloatingCursor(RawFloatingCursorPoint(state: FloatingCursorDragState.Update, + offset: const Offset(20, 20))); + editableTextState.updateFloatingCursor(RawFloatingCursorPoint(state: FloatingCursorDragState.Update, + offset: const Offset(-250, 20))); + editableTextState.updateFloatingCursor(RawFloatingCursorPoint(state: FloatingCursorDragState.End)); + await tester.pumpAndSettle(); + }); + testWidgets('autofocus sets cursor to the end of text', (WidgetTester tester) async { const String text = 'hello world'; final FocusScopeNode focusScopeNode = FocusScopeNode(); @@ -551,7 +617,7 @@ void main() { expect(editable, paints ..rrect( rrect: RRect.fromRectAndRadius( - Rect.fromLTRB(463.3333435058594, 2.0833332538604736, 465.3333435058594, 14.083333015441895), + Rect.fromLTRB(463.3333435058594, 0.0833332538604736, 465.3333435058594, 16.083333015441895), const Radius.circular(2.0), ), color: const Color(0xff8e8e93), @@ -576,7 +642,7 @@ void main() { expect(find.byType(EditableText), paints ..rrect( rrect: RRect.fromRectAndRadius( - Rect.fromLTRB(191.3333282470703, 2.0833332538604736, 193.3333282470703, 14.083333015441895), + Rect.fromLTRB(191.3333282470703, 0.0833332538604736, 193.3333282470703, 16.083333015441895), const Radius.circular(2.0), ), color: const Color(0xff8e8e93), diff --git a/packages/flutter/test/widgets/error_widget_builder_test.dart b/packages/flutter/test/widgets/error_widget_builder_test.dart index b0372d4a09..eda17850fd 100644 --- a/packages/flutter/test/widgets/error_widget_builder_test.dart +++ b/packages/flutter/test/widgets/error_widget_builder_test.dart @@ -7,6 +7,7 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('ErrorWidget.builder', (WidgetTester tester) async { + final ErrorWidgetBuilder oldBuilder = ErrorWidget.builder; ErrorWidget.builder = (FlutterErrorDetails details) { return const Text('oopsie!', textDirection: TextDirection.ltr); }; @@ -21,5 +22,6 @@ void main() { ); expect(tester.takeException().toString(), 'test'); expect(find.text('oopsie!'), findsOneWidget); + ErrorWidget.builder = oldBuilder; }); } diff --git a/packages/flutter/test/widgets/heroes_test.dart b/packages/flutter/test/widgets/heroes_test.dart index 7aee8c88f9..c6d9f9aebe 100644 --- a/packages/flutter/test/widgets/heroes_test.dart +++ b/packages/flutter/test/widgets/heroes_test.dart @@ -1692,4 +1692,91 @@ void main() { expect(tester.takeException(), isAssertionError); }); + + testWidgets('Heroes fly on pushReplacement', (WidgetTester tester) async { + // Regression test for https://github.com/flutter/flutter/issues/28041. + + const String heroTag = 'foo'; + final GlobalKey navigator = GlobalKey(); + final Key smallContainer = UniqueKey(); + final Key largeContainer = UniqueKey(); + + await tester.pumpWidget( + MaterialApp( + navigatorKey: navigator, + home: Center( + child: Card( + child: Hero( + tag: heroTag, + child: Container( + key: largeContainer, + color: Colors.red, + height: 200.0, + width: 200.0, + ), + ), + ), + ), + ), + ); + + // The initial setup. + expect(find.byKey(largeContainer), isOnstage); + expect(find.byKey(largeContainer), isInCard); + expect(find.byKey(smallContainer, skipOffstage: false), findsNothing); + + navigator.currentState.pushReplacement( + MaterialPageRoute( + builder: (BuildContext context) { + return Center( + child: Card( + child: Hero( + tag: heroTag, + child: Container( + key: smallContainer, + color: Colors.red, + height: 100.0, + width: 100.0, + ), + ), + ), + ); + } + ), + ); + await tester.pump(); + + // The second route exists offstage. + expect(find.byKey(largeContainer), isOnstage); + expect(find.byKey(largeContainer), isInCard); + expect(find.byKey(smallContainer, skipOffstage: false), isOffstage); + expect(find.byKey(smallContainer, skipOffstage: false), isInCard); + + await tester.pump(); + + // The hero started flying. + expect(find.byKey(largeContainer), findsNothing); + expect(find.byKey(smallContainer), isOnstage); + expect(find.byKey(smallContainer), isNotInCard); + + await tester.pump(const Duration(milliseconds: 100)); + + // The hero is in-flight. + expect(find.byKey(largeContainer), findsNothing); + expect(find.byKey(smallContainer), isOnstage); + expect(find.byKey(smallContainer), isNotInCard); + final Size size = tester.getSize(find.byKey(smallContainer)); + expect(size.height, greaterThan(100)); + expect(size.width, greaterThan(100)); + expect(size.height, lessThan(200)); + expect(size.width, lessThan(200)); + + await tester.pumpAndSettle(); + + // The transition has ended. + expect(find.byKey(largeContainer), findsNothing); + expect(find.byKey(smallContainer), isOnstage); + expect(find.byKey(smallContainer), isInCard); + expect(tester.getSize(find.byKey(smallContainer)), const Size(100,100)); + }); } diff --git a/packages/flutter/test/widgets/list_view_test.dart b/packages/flutter/test/widgets/list_view_test.dart index d7d1f26972..432bb35687 100644 --- a/packages/flutter/test/widgets/list_view_test.dart +++ b/packages/flutter/test/widgets/list_view_test.dart @@ -35,8 +35,10 @@ class AliveState extends State with AutomaticKeepAliveClientMixin { bool get wantKeepAlive => widget.alive; @override - Widget build(BuildContext context) => - Text('${widget.index}:$wantKeepAlive'); + Widget build(BuildContext context) { + super.build(context); + return Text('${widget.index}:$wantKeepAlive'); + } } typedef WhetherToKeepAlive = bool Function(int); diff --git a/packages/flutter/test/widgets/listener_test.dart b/packages/flutter/test/widgets/listener_test.dart index 54f54e8a22..a4691e3084 100644 --- a/packages/flutter/test/widgets/listener_test.dart +++ b/packages/flutter/test/widgets/listener_test.dart @@ -129,5 +129,108 @@ void main() { expect(exit.position, equals(const Offset(400.0, 300.0))); expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener.hoverAnnotation), isFalse); }); + testWidgets('Hover transfers between two listeners', (WidgetTester tester) async { + final UniqueKey key1 = UniqueKey(); + final UniqueKey key2 = UniqueKey(); + final List enter1 = []; + final List move1 = []; + final List exit1 = []; + final List enter2 = []; + final List move2 = []; + final List exit2 = []; + void clearLists() { + enter1.clear(); + move1.clear(); + exit1.clear(); + enter2.clear(); + move2.clear(); + exit2.clear(); + } + + await tester.pumpWidget(Container()); + final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); + await gesture.moveTo(const Offset(400.0, 0.0)); + await tester.pump(); + await tester.pumpWidget( + Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Listener( + key: key1, + child: Container( + width: 100.0, + height: 100.0, + ), + onPointerEnter: (PointerEnterEvent details) => enter1.add(details), + onPointerHover: (PointerHoverEvent details) => move1.add(details), + onPointerExit: (PointerExitEvent details) => exit1.add(details), + ), + Listener( + key: key2, + child: Container( + width: 100.0, + height: 100.0, + ), + onPointerEnter: (PointerEnterEvent details) => enter2.add(details), + onPointerHover: (PointerHoverEvent details) => move2.add(details), + onPointerExit: (PointerExitEvent details) => exit2.add(details), + ), + ], + ), + ); + final RenderPointerListener renderListener1 = tester.renderObject(find.byKey(key1)); + final RenderPointerListener renderListener2 = tester.renderObject(find.byKey(key2)); + final Offset center1 = tester.getCenter(find.byKey(key1)); + final Offset center2 = tester.getCenter(find.byKey(key2)); + await gesture.moveTo(center1); + await tester.pump(); + expect(move1, isNotEmpty); + expect(move1.last.position, equals(center1)); + expect(enter1, isNotEmpty); + expect(enter1.last.position, equals(center1)); + expect(exit1, isEmpty); + expect(move2, isEmpty); + expect(enter2, isEmpty); + expect(exit2, isEmpty); + expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener1.hoverAnnotation), isTrue); + expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener2.hoverAnnotation), isTrue); + clearLists(); + await gesture.moveTo(center2); + await tester.pump(); + expect(move1, isEmpty); + expect(enter1, isEmpty); + expect(exit1, isNotEmpty); + expect(exit1.last.position, equals(center2)); + expect(move2, isNotEmpty); + expect(move2.last.position, equals(center2)); + expect(enter2, isNotEmpty); + expect(enter2.last.position, equals(center2)); + expect(exit2, isEmpty); + expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener1.hoverAnnotation), isTrue); + expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener2.hoverAnnotation), isTrue); + clearLists(); + await gesture.moveTo(const Offset(400.0, 450.0)); + await tester.pump(); + expect(move1, isEmpty); + expect(enter1, isEmpty); + expect(exit1, isEmpty); + expect(move2, isEmpty); + expect(enter2, isEmpty); + expect(exit2, isNotEmpty); + expect(exit2.last.position, equals(const Offset(400.0, 450.0))); + expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener1.hoverAnnotation), isTrue); + expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener2.hoverAnnotation), isTrue); + clearLists(); + await tester.pumpWidget(Container()); + expect(move1, isEmpty); + expect(enter1, isEmpty); + expect(exit1, isEmpty); + expect(move2, isEmpty); + expect(enter2, isEmpty); + expect(exit2, isEmpty); + expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener1.hoverAnnotation), isFalse); + expect(tester.binding.mouseTracker.isAnnotationAttached(renderListener2.hoverAnnotation), isFalse); + }); }); } diff --git a/packages/flutter/test/widgets/overlay_test.dart b/packages/flutter/test/widgets/overlay_test.dart index 142d7f4fcd..1ecb6ed60d 100644 --- a/packages/flutter/test/widgets/overlay_test.dart +++ b/packages/flutter/test/widgets/overlay_test.dart @@ -159,4 +159,457 @@ void main() { ), ); }); + + testWidgets('insert top', (WidgetTester tester) async { + final GlobalKey overlayKey = GlobalKey(); + final List buildOrder = []; + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: Overlay( + key: overlayKey, + initialEntries: [ + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add('Base'); + return Container(); + }, + ), + ], + ), + ), + ); + + expect(buildOrder, ['Base']); + + buildOrder.clear(); + final OverlayState overlay = overlayKey.currentState; + overlay.insert( + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add('New'); + return Container(); + } + ), + ); + await tester.pump(); + + expect(buildOrder, ['Base', 'New']); + }); + + testWidgets('insert below', (WidgetTester tester) async { + final GlobalKey overlayKey = GlobalKey(); + OverlayEntry base; + final List buildOrder = []; + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: Overlay( + key: overlayKey, + initialEntries: [ + base = OverlayEntry( + builder: (BuildContext context) { + buildOrder.add('Base'); + return Container(); + }, + ), + ], + ), + ), + ); + + expect(buildOrder, ['Base']); + + buildOrder.clear(); + final OverlayState overlay = overlayKey.currentState; + overlay.insert( + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add('New'); + return Container(); + } + ), + below: base, + ); + await tester.pump(); + + expect(buildOrder, ['New', 'Base']); + }); + + testWidgets('insert above', (WidgetTester tester) async { + final GlobalKey overlayKey = GlobalKey(); + OverlayEntry base; + final List buildOrder = []; + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: Overlay( + key: overlayKey, + initialEntries: [ + base = OverlayEntry( + builder: (BuildContext context) { + buildOrder.add('Base'); + return Container(); + }, + ), + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add('Top'); + return Container(); + }, + ), + ], + ), + ), + ); + + expect(buildOrder, ['Base', 'Top']); + + buildOrder.clear(); + final OverlayState overlay = overlayKey.currentState; + overlay.insert( + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add('New'); + return Container(); + } + ), + above: base, + ); + await tester.pump(); + + expect(buildOrder, ['Base', 'New', 'Top']); + }); + + testWidgets('insertAll top', (WidgetTester tester) async { + final GlobalKey overlayKey = GlobalKey(); + final List buildOrder = []; + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: Overlay( + key: overlayKey, + initialEntries: [ + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add('Base'); + return Container(); + }, + ), + ], + ), + ), + ); + + expect(buildOrder, ['Base']); + + final List entries = [ + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add('New1'); + return Container(); + }, + ), + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add('New2'); + return Container(); + }, + ), + ]; + + buildOrder.clear(); + final OverlayState overlay = overlayKey.currentState; + overlay.insertAll(entries); + await tester.pump(); + + expect(buildOrder, ['Base', 'New1', 'New2']); + }); + + testWidgets('insertAll below', (WidgetTester tester) async { + final GlobalKey overlayKey = GlobalKey(); + OverlayEntry base; + final List buildOrder = []; + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: Overlay( + key: overlayKey, + initialEntries: [ + base = OverlayEntry( + builder: (BuildContext context) { + buildOrder.add('Base'); + return Container(); + }, + ), + ], + ), + ), + ); + + expect(buildOrder, ['Base']); + + final List entries = [ + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add('New1'); + return Container(); + }, + ), + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add('New2'); + return Container(); + }, + ), + ]; + + buildOrder.clear(); + final OverlayState overlay = overlayKey.currentState; + overlay.insertAll(entries, below: base); + await tester.pump(); + + expect(buildOrder, ['New1', 'New2','Base']); + }); + + testWidgets('insertAll above', (WidgetTester tester) async { + final GlobalKey overlayKey = GlobalKey(); + final List buildOrder = []; + OverlayEntry base; + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: Overlay( + key: overlayKey, + initialEntries: [ + base = OverlayEntry( + builder: (BuildContext context) { + buildOrder.add('Base'); + return Container(); + }, + ), + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add('Top'); + return Container(); + }, + ), + ], + ), + ), + ); + + expect(buildOrder, ['Base', 'Top']); + + final List entries = [ + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add('New1'); + return Container(); + }, + ), + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add('New2'); + return Container(); + }, + ), + ]; + + buildOrder.clear(); + final OverlayState overlay = overlayKey.currentState; + overlay.insertAll(entries, above: base); + await tester.pump(); + + expect(buildOrder, ['Base', 'New1', 'New2', 'Top']); + }); + + testWidgets('rearrange', (WidgetTester tester) async { + final GlobalKey overlayKey = GlobalKey(); + final List buildOrder = []; + final List initialEntries = [ + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add(0); + return Container(); + }, + ), + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add(1); + return Container(); + }, + ), + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add(2); + return Container(); + }, + ), + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add(3); + return Container(); + }, + ), + ]; + + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: Overlay( + key: overlayKey, + initialEntries: initialEntries, + ), + ), + ); + + expect(buildOrder, [0, 1, 2, 3]); + + final List rearranged = [ + initialEntries[3], + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add(4); + return Container(); + }, + ), + initialEntries[2], + // 1 intentionally missing, will end up on top + initialEntries[0], + ]; + + buildOrder.clear(); + final OverlayState overlay = overlayKey.currentState; + overlay.rearrange(rearranged); + await tester.pump(); + + expect(buildOrder, [3, 4, 2, 0, 1]); + }); + + testWidgets('rearrange above', (WidgetTester tester) async { + final GlobalKey overlayKey = GlobalKey(); + final List buildOrder = []; + final List initialEntries = [ + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add(0); + return Container(); + }, + ), + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add(1); + return Container(); + }, + ), + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add(2); + return Container(); + }, + ), + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add(3); + return Container(); + }, + ), + ]; + + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: Overlay( + key: overlayKey, + initialEntries: initialEntries, + ), + ), + ); + + expect(buildOrder, [0, 1, 2, 3]); + + final List rearranged = [ + initialEntries[3], + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add(4); + return Container(); + }, + ), + initialEntries[2], + // 1 intentionally missing + initialEntries[0], + ]; + + buildOrder.clear(); + final OverlayState overlay = overlayKey.currentState; + overlay.rearrange(rearranged, above: initialEntries[2]); + await tester.pump(); + + expect(buildOrder, [3, 4, 2, 1, 0]); + }); + + testWidgets('rearrange below', (WidgetTester tester) async { + final GlobalKey overlayKey = GlobalKey(); + final List buildOrder = []; + final List initialEntries = [ + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add(0); + return Container(); + }, + ), + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add(1); + return Container(); + }, + ), + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add(2); + return Container(); + }, + ), + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add(3); + return Container(); + }, + ), + ]; + + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: Overlay( + key: overlayKey, + initialEntries: initialEntries, + ), + ), + ); + + expect(buildOrder, [0, 1, 2, 3]); + + final List rearranged = [ + initialEntries[3], + OverlayEntry( + builder: (BuildContext context) { + buildOrder.add(4); + return Container(); + }, + ), + initialEntries[2], + // 1 intentionally missing + initialEntries[0], + ]; + + buildOrder.clear(); + final OverlayState overlay = overlayKey.currentState; + overlay.rearrange(rearranged, below: initialEntries[2]); + await tester.pump(); + + expect(buildOrder, [3, 4, 1, 2, 0]); + }); } diff --git a/packages/flutter/test/widgets/physical_model_test.dart b/packages/flutter/test/widgets/physical_model_test.dart index 75fce540a4..2465d2e4e9 100644 --- a/packages/flutter/test/widgets/physical_model_test.dart +++ b/packages/flutter/test/widgets/physical_model_test.dart @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:io' show Platform; +import 'dart:math' as math show pi; + import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; @@ -61,6 +64,424 @@ void main() { ); expect(tester.takeException(), startsWith('A RenderFlex overflowed by ')); - expect(find.byKey(key), matchesGoldenFile('physical_model_overflow.png')); + await expectLater( + find.byKey(key), + matchesGoldenFile('physical_model_overflow.png'), + skip: !Platform.isLinux, + ); + }); + + group('PhysicalModelLayer checks elevation', () { + Future _testStackChildren( + WidgetTester tester, + List children, { + @required int expectedErrorCount, + bool enableCheck = true, + }) async { + assert(expectedErrorCount != null); + if (enableCheck) { + debugCheckElevationsEnabled = true; + } else { + assert(expectedErrorCount == 0, 'Cannot expect errors if check is disabled.'); + } + debugDisableShadows = false; + int count = 0; + final Function oldOnError = FlutterError.onError; + FlutterError.onError = (FlutterErrorDetails details) { + count++; + }; + await tester.pumpWidget(Directionality( + textDirection: TextDirection.ltr, + child: Stack( + children: children, + ), + ), + ); + FlutterError.onError = oldOnError; + expect(count, expectedErrorCount); + if (enableCheck) { + debugCheckElevationsEnabled = false; + } + debugDisableShadows = true; + } + + // Tests: + // + // ─────────── (red rect, paints second, child) + // │ + // ─────────── (green rect, paints first) + // │ + // ──────────────────────────── + testWidgets('entirely overlapping, direct child', (WidgetTester tester) async { + final List children = [ + Container( + width: 300, + height: 300, + child: const Material( + elevation: 1.0, + color: Colors.green, + child: Material( + elevation: 2.0, + color: Colors.red, + ) + ), + ), + ]; + + await _testStackChildren(tester, children, expectedErrorCount: 0); + expect(find.byType(Material), findsNWidgets(2)); + }); + + + // Tests: + // + // ─────────────── (green rect, paints second) + // ─────────── │ (blue rect, paints first) + // │ │ + // │ │ + // ──────────────────────────── + testWidgets('entirely overlapping, correct painting order', (WidgetTester tester) async { + final List children = [ + Container( + width: 300, + height: 300, + child: const Material( + elevation: 1.0, + color: Colors.green, + ), + ), + Container( + width: 300, + height: 300, + child: const Material( + elevation: 2.0, + color: Colors.blue, + ), + ), + ]; + + await _testStackChildren(tester, children, expectedErrorCount: 0); + expect(find.byType(Material), findsNWidgets(2)); + }); + + + // Tests: + // + // ─────────────── (green rect, paints first) + // │ ─────────── (blue rect, paints second) + // │ │ + // │ │ + // ──────────────────────────── + testWidgets('entirely overlapping, wrong painting order', (WidgetTester tester) async { + final List children = [ + Container( + width: 300, + height: 300, + child: const Material( + elevation: 2.0, + color: Colors.green, + ), + ), + Container( + width: 300, + height: 300, + child: const Material( + elevation: 1.0, + color: Colors.blue, + ), + ), + ]; + + await _testStackChildren(tester, children, expectedErrorCount: 1); + expect(find.byType(Material), findsNWidgets(2)); + }); + + + // Tests: + // + // ─────────────── (brown rect, paints first) + // │ ─────────── (red circle, paints second) + // │ │ + // │ │ + // ──────────────────────────── + testWidgets('not non-rect not overlapping, wrong painting order', (WidgetTester tester) async { + // These would be overlapping if we only took the rectangular bounds of the circle. + final List children = [ + Positioned.fromRect( + rect: Rect.fromLTWH(150, 150, 150, 150), + child: Container( + width: 300, + height: 300, + child: const Material( + elevation: 3.0, + color: Colors.brown, + ), + ), + ), + Positioned.fromRect( + rect: Rect.fromLTWH(20, 20, 140, 150), + child: Container( + width: 300, + height: 300, + child: const Material( + elevation: 2.0, + color: Colors.red, + shape: CircleBorder() + ), + ), + ), + ]; + + await _testStackChildren(tester, children, expectedErrorCount: 0); + expect(find.byType(Material), findsNWidgets(2)); + }); + + // Tests: + // + // ─────────────── (brown rect, paints first) + // │ ─────────── (red circle, paints second) + // │ │ + // │ │ + // ──────────────────────────── + testWidgets('not non-rect entirely overlapping, wrong painting order', (WidgetTester tester) async { + final List children = [ + Positioned.fromRect( + rect: Rect.fromLTWH(20, 20, 140, 150), + child: Container( + width: 300, + height: 300, + child: const Material( + elevation: 3.0, + color: Colors.brown, + ), + ), + ), + Positioned.fromRect( + rect: Rect.fromLTWH(50, 50, 100, 100), + child: Container( + width: 300, + height: 300, + child: const Material( + elevation: 2.0, + color: Colors.red, + shape: CircleBorder() + ), + ), + ), + ]; + + await _testStackChildren(tester, children, expectedErrorCount: 1); + expect(find.byType(Material), findsNWidgets(2)); + }); + + // Tests: + // + // ─────────────── (brown rect, paints first) + // │ ──────────── (red circle, paints second) + // │ │ + // │ │ + // ──────────────────────────── + testWidgets('non-rect partially overlapping, wrong painting order', (WidgetTester tester) async { + final List children = [ + Positioned.fromRect( + rect: Rect.fromLTWH(150, 150, 150, 150), + child: Container( + width: 300, + height: 300, + child: const Material( + elevation: 3.0, + color: Colors.brown, + ), + ), + ), + Positioned.fromRect( + rect: Rect.fromLTWH(30, 20, 150, 150), + child: Container( + width: 300, + height: 300, + child: const Material( + elevation: 2.0, + color: Colors.red, + shape: CircleBorder() + ), + ), + ), + ]; + + await _testStackChildren(tester, children, expectedErrorCount: 1); + expect(find.byType(Material), findsNWidgets(2)); + }); + + // Tests: + // + // ─────────────── (green rect, paints second, overlaps red rect) + // │ + // │ + // ────────────────────────── (brown and red rects, overlapping but same elevation, paint first and third) + // │ │ + // ──────────────────────────── + // + // Fails because the green rect overlaps the + testWidgets('child partially overlapping, wrong painting order', (WidgetTester tester) async { + final List children = [ + Positioned.fromRect( + rect: Rect.fromLTWH(150, 150, 150, 150), + child: Container( + width: 300, + height: 300, + child: const Material( + elevation: 1.0, + color: Colors.brown, + child: Padding( + padding: EdgeInsets.all(30.0), + child: Material( + elevation: 2.0, + color: Colors.green, + ), + ), + ), + ), + ), + Positioned.fromRect( + rect: Rect.fromLTWH(30, 20, 180, 180), + child: Container( + width: 300, + height: 300, + child: const Material( + elevation: 1.0, + color: Colors.red, + ), + ), + ), + ]; + + await _testStackChildren(tester, children, expectedErrorCount: 1); + expect(find.byType(Material), findsNWidgets(3)); + }); + + // Tests: + // + // ─────────────── (brown rect, paints first) + // │ ──────────── (red circle, paints second) + // │ │ + // │ │ + // ──────────────────────────── + testWidgets('non-rect partially overlapping, wrong painting order, check disabled', (WidgetTester tester) async { + final List children = [ + Positioned.fromRect( + rect: Rect.fromLTWH(150, 150, 150, 150), + child: Container( + width: 300, + height: 300, + child: const Material( + elevation: 3.0, + color: Colors.brown, + ), + ), + ), + Positioned.fromRect( + rect: Rect.fromLTWH(30, 20, 150, 150), + child: Container( + width: 300, + height: 300, + child: const Material( + elevation: 2.0, + color: Colors.red, + shape: CircleBorder() + ), + ), + ), + ]; + + await _testStackChildren( + tester, + children, + expectedErrorCount: 0, + enableCheck: false, + ); + expect(find.byType(Material), findsNWidgets(2)); + }); + + // Tests: + // + // ──────────── (brown rect, paints first, rotated but doesn't overlap) + // │ ──────────── (red circle, paints second) + // │ │ + // │ │ + // ──────────────────────────── + testWidgets('with a RenderTransform, non-overlapping', (WidgetTester tester) async { + + final List children = [ + Positioned.fromRect( + rect: Rect.fromLTWH(140, 100, 140, 150), + child: Container( + width: 300, + height: 300, + child: Transform.rotate( + angle: math.pi / 180 * 15, + child: const Material( + elevation: 3.0, + color: Colors.brown, + ), + ), + ), + ), + Positioned.fromRect( + rect: Rect.fromLTWH(50, 50, 100, 100), + child: Container( + width: 300, + height: 300, + child: const Material( + elevation: 2.0, + color: Colors.red, + shape: CircleBorder()), + ), + ), + ]; + + await _testStackChildren(tester, children, expectedErrorCount: 0); + expect(find.byType(Material), findsNWidgets(2)); + }); + + // Tests: + // + // ────────────── (brown rect, paints first, rotated so it overlaps) + // │ ──────────── (red circle, paints second) + // │ │ + // │ │ + // ──────────────────────────── + // This would be fine without the rotation. + testWidgets('with a RenderTransform, overlapping', (WidgetTester tester) async { + final List children = [ + Positioned.fromRect( + rect: Rect.fromLTWH(140, 100, 140, 150), + child: Container( + width: 300, + height: 300, + child: Transform.rotate( + angle: math.pi / 180 * 8, + child: const Material( + elevation: 3.0, + color: Colors.brown, + ), + ), + ), + ), + Positioned.fromRect( + rect: Rect.fromLTWH(50, 50, 100, 100), + child: Container( + width: 300, + height: 300, + child: const Material( + elevation: 2.0, + color: Colors.red, + shape: CircleBorder()), + ), + ), + ]; + + await _testStackChildren(tester, children, expectedErrorCount: 1); + expect(find.byType(Material), findsNWidgets(2)); + }); }); } diff --git a/packages/flutter/test/widgets/platform_view_test.dart b/packages/flutter/test/widgets/platform_view_test.dart index 7c6fce6748..912bfa659a 100644 --- a/packages/flutter/test/widgets/platform_view_test.dart +++ b/packages/flutter/test/widgets/platform_view_test.dart @@ -1474,5 +1474,43 @@ void main() { expect(factoryInvocationCount, 1); }); + + testWidgets('UiKitView has correct semantics', (WidgetTester tester) async { + final SemanticsHandle handle = tester.ensureSemantics(); + final int currentViewId = platformViewsRegistry.getNextPlatformViewId(); + expect(currentViewId, greaterThanOrEqualTo(0)); + final FakeIosPlatformViewsController viewsController = FakeIosPlatformViewsController(); + viewsController.registerViewType('webview'); + + await tester.pumpWidget( + Semantics( + container: true, + child: const Align( + alignment: Alignment.bottomRight, + child: SizedBox( + width: 200.0, + height: 100.0, + child: UiKitView( + viewType: 'webview', + layoutDirection: TextDirection.ltr, + ), + ), + ), + ), + ); + // First frame is before the platform view was created so the render object + // is not yet in the tree. + await tester.pump(); + + final SemanticsNode semantics = tester.getSemantics(find.byType(UiKitView)); + + expect(semantics.platformViewId, currentViewId + 1); + expect(semantics.rect, Rect.fromLTWH(0, 0, 200, 100)); + // A 200x100 rect positioned at bottom right of a 800x600 box. + expect(semantics.transform, Matrix4.translationValues(600, 500, 0)); + expect(semantics.childrenCount, 0); + + handle.dispose(); + }); }); } diff --git a/packages/flutter/test/widgets/semantics_keep_alive_offstage_test.dart b/packages/flutter/test/widgets/semantics_keep_alive_offstage_test.dart index 1dfbebf848..5dc55d40f8 100644 --- a/packages/flutter/test/widgets/semantics_keep_alive_offstage_test.dart +++ b/packages/flutter/test/widgets/semantics_keep_alive_offstage_test.dart @@ -127,6 +127,7 @@ class ProblemWidget extends StatefulWidget { class ProblemWidgetState extends State with AutomaticKeepAliveClientMixin { @override Widget build(BuildContext context) { + super.build(context); Widget child = Semantics( container: true, child: Text(widget.text), diff --git a/packages/flutter/test/widgets/slivers_test.dart b/packages/flutter/test/widgets/slivers_test.dart index c25ee665b1..91b8041209 100644 --- a/packages/flutter/test/widgets/slivers_test.dart +++ b/packages/flutter/test/widgets/slivers_test.dart @@ -195,4 +195,19 @@ void main() { expect(find.text('B'), findsNothing); expect(find.text('BOTTOM'), findsOneWidget); }); + + testWidgets('Can override ErrorWidget.build', (WidgetTester tester) async { + const Text errorText = Text('error'); + final ErrorWidgetBuilder oldBuilder = ErrorWidget.builder; + ErrorWidget.builder = (FlutterErrorDetails details) => errorText; + final SliverChildBuilderDelegate builderThrowsDelegate = SliverChildBuilderDelegate( + (_, __) => throw 'builder', + addAutomaticKeepAlives: false, + addRepaintBoundaries: false, + addSemanticIndexes: false, + ); + expect(builderThrowsDelegate.build(null, 0), errorText); + expect(tester.takeException(), 'builder'); + ErrorWidget.builder = oldBuilder; + }); } diff --git a/packages/flutter/test/widgets/text_test.dart b/packages/flutter/test/widgets/text_test.dart index 36b02fb65e..d91fb94f13 100644 --- a/packages/flutter/test/widgets/text_test.dart +++ b/packages/flutter/test/widgets/text_test.dart @@ -184,6 +184,51 @@ void main() { semantics.dispose(); }); + testWidgets('recognizers split semantic nodes with text span labels', (WidgetTester tester) async { + final SemanticsTester semantics = SemanticsTester(tester); + const TextStyle textStyle = TextStyle(fontFamily: 'Ahem'); + await tester.pumpWidget( + Text.rich( + TextSpan( + children: [ + const TextSpan(text: 'hello '), + TextSpan(text: 'world', recognizer: TapGestureRecognizer()..onTap = () { }), + const TextSpan(text: ' this is a '), + const TextSpan(text: 'cat-astrophe', semanticsLabel: 'regrettable event'), + ], + style: textStyle, + ), + textDirection: TextDirection.ltr, + ), + ); + final TestSemantics expectedSemantics = TestSemantics.root( + children: [ + TestSemantics.rootChild( + children: [ + TestSemantics( + label: 'hello ', + textDirection: TextDirection.ltr, + ), + TestSemantics( + label: 'world', + textDirection: TextDirection.ltr, + actions: [ + SemanticsAction.tap, + ], + ), + TestSemantics( + label: ' regrettable event', + textDirection: TextDirection.ltr, + ), + ], + ), + ], + ); + expect(semantics, hasSemantics(expectedSemantics, ignoreTransform: true, ignoreId: true, ignoreRect: true)); + semantics.dispose(); + }); + + testWidgets('recognizers split semantic node - bidi', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); const TextStyle textStyle = TextStyle(fontFamily: 'Ahem'); diff --git a/packages/flutter_driver/lib/src/driver/driver.dart b/packages/flutter_driver/lib/src/driver/driver.dart index 7a45a7b69d..da07854749 100644 --- a/packages/flutter_driver/lib/src/driver/driver.dart +++ b/packages/flutter_driver/lib/src/driver/driver.dart @@ -150,6 +150,22 @@ class FlutterDriver { static int _nextDriverId = 0; + // The additional blank line in the beginning is for _log.warning. + static const String _kDebugWarning = ''' + +┏╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┓ +┇ ⚠ THIS BENCHMARK IS BEING RUN IN DEBUG MODE ⚠ ┇ +┡╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍┦ +│ │ +│ Numbers obtained from a benchmark while asserts are │ +│ enabled will not accurately reflect the performance │ +│ that will be experienced by end users using release ╎ +│ builds. Benchmarks should be run using this command ┆ +│ line: flutter drive --profile test_perf.dart ┊ +│ ┊ +└─────────────────────────────────────────────────╌┄┈ 🐢 +'''; + /// Connects to a Flutter application. /// /// Resumes the application if it is currently paused (e.g. at a breakpoint). @@ -708,7 +724,9 @@ class FlutterDriver { /// [getFlagList]: https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md#getflaglist Future>> getVmFlags() async { final Map result = await _peer.sendRequest('getFlagList'); - return result['flags']; + return result != null + ? result['flags'].cast>() + : const >[]; } /// Starts recording performance traces. @@ -764,6 +782,16 @@ class FlutterDriver { } } + Future _isPrecompiledMode() async { + final List> flags = await getVmFlags(); + for(Map flag in flags) { + if (flag['name'] == 'precompiled_mode') { + return flag['valueAsString'] == 'true'; + } + } + return false; + } + /// Runs [action] and outputs a performance trace for it. /// /// Waits for the `Future` returned by [action] to complete prior to stopping @@ -778,6 +806,9 @@ class FlutterDriver { /// If [retainPriorEvents] is true, retains events recorded prior to calling /// [action]. Otherwise, prior events are cleared before calling [action]. By /// default, prior events are cleared. + /// + /// If this is run in debug mode, a warning message will be printed to suggest + /// running the benchmark in profile mode instead. Future traceAction( Future action(), { List streams = _defaultStreams, @@ -788,6 +819,10 @@ class FlutterDriver { } await startTracing(streams: streams); await action(); + + if (!(await _isPrecompiledMode())) { + _log.warning(_kDebugWarning); + } return stopTracingAndDownloadTimeline(); } diff --git a/packages/flutter_driver/pubspec.yaml b/packages/flutter_driver/pubspec.yaml index 6f4b003e50..58a214b6c8 100644 --- a/packages/flutter_driver/pubspec.yaml +++ b/packages/flutter_driver/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_driver description: Integration and performance test API for Flutter applications -homepage: http://flutter.io +homepage: http://flutter.dev author: Flutter Authors environment: @@ -9,11 +9,11 @@ environment: dependencies: file: 5.0.7 - json_rpc_2: 2.0.9 + json_rpc_2: 2.0.10 meta: 1.1.6 path: 1.6.2 - web_socket_channel: 1.0.9 - vm_service_client: 0.2.6 + web_socket_channel: 1.0.12 + vm_service_client: 0.2.6+1 flutter: sdk: flutter flutter_test: @@ -21,29 +21,29 @@ dependencies: fuchsia_remote_debug_protocol: sdk: flutter - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - intl: 0.15.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl: 0.15.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" platform: 2.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" process: 3.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vector_math: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" dev_dependencies: mockito: 4.0.0 - quiver: 2.0.1 + quiver: 2.0.2 -# PUBSPEC CHECKSUM: 2371 +# PUBSPEC CHECKSUM: 42b5 diff --git a/packages/flutter_goldens/pubspec.yaml b/packages/flutter_goldens/pubspec.yaml index 576135cbf1..4a682090b8 100644 --- a/packages/flutter_goldens/pubspec.yaml +++ b/packages/flutter_goldens/pubspec.yaml @@ -15,24 +15,24 @@ dependencies: flutter_goldens_client: path: ../flutter_goldens_client - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - intl: 0.15.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl: 0.15.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - quiver: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + quiver: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vector_math: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" dev_dependencies: mockito: 4.0.0 -# PUBSPEC CHECKSUM: 7fce +# PUBSPEC CHECKSUM: b564 diff --git a/packages/flutter_goldens_client/pubspec.yaml b/packages/flutter_goldens_client/pubspec.yaml index f1e01fc220..aa18160d95 100644 --- a/packages/flutter_goldens_client/pubspec.yaml +++ b/packages/flutter_goldens_client/pubspec.yaml @@ -10,7 +10,7 @@ dependencies: platform: 2.2.0 process: 3.0.9 - intl: 0.15.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl: 0.15.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -18,4 +18,4 @@ dartdoc: # Exclude this package from the hosted API docs. nodoc: true -# PUBSPEC CHECKSUM: 3e32 +# PUBSPEC CHECKSUM: a533 diff --git a/packages/flutter_localizations/lib/flutter_localizations.dart b/packages/flutter_localizations/lib/flutter_localizations.dart index 83d910929c..354a9254f6 100644 --- a/packages/flutter_localizations/lib/flutter_localizations.dart +++ b/packages/flutter_localizations/lib/flutter_localizations.dart @@ -5,6 +5,6 @@ /// Localizations for the Flutter library library flutter_localizations; -export 'src/l10n/localizations.dart'; +export 'src/l10n/generated_material_localizations.dart'; export 'src/material_localizations.dart'; export 'src/widgets_localizations.dart'; diff --git a/packages/flutter_localizations/lib/src/cupertino_localizations.dart b/packages/flutter_localizations/lib/src/cupertino_localizations.dart new file mode 100644 index 0000000000..557a9344d9 --- /dev/null +++ b/packages/flutter_localizations/lib/src/cupertino_localizations.dart @@ -0,0 +1,439 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +import 'package:flutter/cupertino.dart'; +import 'package:flutter/foundation.dart'; +import 'package:intl/intl.dart' as intl; +import 'package:intl/date_symbols.dart' as intl; + +import 'utils/date_localizations.dart' as util; +import 'widgets_localizations.dart'; + +/// Implementation of localized strings for Cupertino widgets using the `intl` +/// package for date and time formatting. +/// +/// Further localization of strings beyond date time formatting are provided +/// by language specific subclasses of [GlobalCupertinoLocalizations] +/// +/// See also: +/// +/// * [DefaultCupertinoLocalizations], which provides US English localizations +/// for Cupertino widgets. +abstract class GlobalCupertinoLocalizations implements CupertinoLocalizations { + /// Initializes an object that defines the Cupertino widgets' localized + /// strings for the given `localeName`. + /// + /// The remaining '*Format' arguments uses the intl package to provide + /// [DateFormat] configurations for the `localeName`. + const GlobalCupertinoLocalizations({ + @required String localeName, + @required intl.DateFormat fullYearFormat, + @required intl.DateFormat dayFormat, + @required intl.DateFormat mediumDateFormat, + @required intl.DateFormat singleDigitHourFormat, + @required intl.DateFormat singleDigitMinuteFormat, + @required intl.DateFormat doubleDigitMinuteFormat, + @required intl.DateFormat singleDigitSecondFormat, + @required intl.NumberFormat decimalFormat, + }) : assert(localeName != null), + _localeName = localeName, + assert(fullYearFormat != null), + _fullYearFormat = fullYearFormat, + assert(dayFormat != null), + _dayFormat = dayFormat, + assert(mediumDateFormat != null), + _mediumDateFormat = mediumDateFormat, + assert(singleDigitHourFormat != null), + _singleDigitHourFormat = singleDigitHourFormat, + assert(singleDigitMinuteFormat != null), + _singleDigitMinuteFormat = singleDigitMinuteFormat, + assert(doubleDigitMinuteFormat != null), + _doubleDigitMinuteFormat = doubleDigitMinuteFormat, + assert(singleDigitSecondFormat != null), + _singleDigitSecondFormat = singleDigitSecondFormat, + assert(decimalFormat != null), + _decimalFormat =decimalFormat; + + final String _localeName; + final intl.DateFormat _fullYearFormat; + final intl.DateFormat _dayFormat; + final intl.DateFormat _mediumDateFormat; + final intl.DateFormat _singleDigitHourFormat; + final intl.DateFormat _singleDigitMinuteFormat; + final intl.DateFormat _doubleDigitMinuteFormat; + final intl.DateFormat _singleDigitSecondFormat; + final intl.NumberFormat _decimalFormat; + + @override + String datePickerYear(int yearIndex) { + return _fullYearFormat.format(DateTime.utc(yearIndex)); + } + + @override + String datePickerMonth(int monthIndex) { + // It doesn't actually have anything to do with _fullYearFormat. It's just + // taking advantage of the fact that _fullYearFormat loaded the needed + // locale's symbols. + return _fullYearFormat.dateSymbols.MONTHS[monthIndex - 1]; + } + + @override + String datePickerDayOfMonth(int dayIndex) { + // Year and month doesn't matter since we just want to day formatted. + return _dayFormat.format(DateTime.utc(0, 0, dayIndex)); + } + + @override + String datePickerMediumDate(DateTime date) { + return _mediumDateFormat.format(date); + } + + @override + String datePickerHour(int hour) { + return _singleDigitHourFormat.format(DateTime.utc(0, 0, 0, hour)); + } + + @override + String datePickerMinute(int minute) { + return _doubleDigitMinuteFormat.format(DateTime.utc(0, 0, 0, 0, minute)); + } + + /// Subclasses should provide the optional zero pluralization of [datePickerHourSemanticsLabel] based on the ARB file. + @protected String get datePickerHourSemanticsLabelZero => null; + /// Subclasses should provide the optional one pluralization of [datePickerHourSemanticsLabel] based on the ARB file. + @protected String get datePickerHourSemanticsLabelOne => null; + /// Subclasses should provide the optional two pluralization of [datePickerHourSemanticsLabel] based on the ARB file. + @protected String get datePickerHourSemanticsLabelTwo => null; + /// Subclasses should provide the optional few pluralization of [datePickerHourSemanticsLabel] based on the ARB file. + @protected String get datePickerHourSemanticsLabelFew => null; + /// Subclasses should provide the optional many pluralization of [datePickerHourSemanticsLabel] based on the ARB file. + @protected String get datePickerHourSemanticsLabelMany => null; + /// Subclasses should provide the required other pluralization of [datePickerHourSemanticsLabel] based on the ARB file. + @protected String get datePickerHourSemanticsLabelOther; + + @override + String datePickerHourSemanticsLabel(int hour) { + return intl.Intl.pluralLogic( + hour, + zero: datePickerHourSemanticsLabelZero, + one: datePickerHourSemanticsLabelOne, + two: datePickerHourSemanticsLabelTwo, + few: datePickerHourSemanticsLabelFew, + many: datePickerHourSemanticsLabelMany, + other: datePickerHourSemanticsLabelOther, + locale: _localeName, + ).replaceFirst(r'$hour', _decimalFormat.format(hour)); + } + + /// Subclasses should provide the optional zero pluralization of [datePickerMinuteSemanticsLabel] based on the ARB file. + @protected String get datePickerMinuteSemanticsLabelZero => null; + /// Subclasses should provide the optional one pluralization of [datePickerMinuteSemanticsLabel] based on the ARB file. + @protected String get datePickerMinuteSemanticsLabelOne => null; + /// Subclasses should provide the optional two pluralization of [datePickerMinuteSemanticsLabel] based on the ARB file. + @protected String get datePickerMinuteSemanticsLabelTwo => null; + /// Subclasses should provide the optional few pluralization of [datePickerMinuteSemanticsLabel] based on the ARB file. + @protected String get datePickerMinuteSemanticsLabelFew => null; + /// Subclasses should provide the optional many pluralization of [datePickerMinuteSemanticsLabel] based on the ARB file. + @protected String get datePickerMinuteSemanticsLabelMany => null; + /// Subclasses should provide the required other pluralization of [datePickerMinuteSemanticsLabel] based on the ARB file. + @protected String get datePickerMinuteSemanticsLabelOther; + + @override + String datePickerMinuteSemanticsLabel(int minute) { + return intl.Intl.pluralLogic( + minute, + zero: datePickerMinuteSemanticsLabelZero, + one: datePickerMinuteSemanticsLabelOne, + two: datePickerMinuteSemanticsLabelTwo, + few: datePickerMinuteSemanticsLabelFew, + many: datePickerMinuteSemanticsLabelMany, + other: datePickerMinuteSemanticsLabelOther, + locale: _localeName, + ).replaceFirst(r'$minute', _decimalFormat.format(minute)); + } + + /// A string describing the [DatePickerDateOrder] enum value. + /// + /// Subclasses should provide this string value based on the ARB file for + /// the locale. + /// + /// See also: + /// + /// * [datePickerDateOrder], which provides the [DatePickerDateOrder] + /// enum value for [CupertinoLocalizations] based on this string value + @protected + String get datePickerDateOrderString; + + @override + DatePickerDateOrder get datePickerDateOrder { + switch (datePickerDateOrderString) { + case 'dmy': + return DatePickerDateOrder.dmy; + case 'mdy': + return DatePickerDateOrder.mdy; + case 'ymd': + return DatePickerDateOrder.ymd; + case 'ydm': + return DatePickerDateOrder.ydm; + default: + assert( + false, + 'Failed to load DatePickerDateOrder $datePickerDateOrderString for ' + 'locale $_localeName.\nNon conforming string for $_localeName\'s ' + '.arb file', + ); + return null; + } + } + + /// A string describing the [DatePickerDateTimeOrder] enum value. + /// + /// Subclasses should provide this string value based on the ARB file for + /// the locale. + /// + /// See also: + /// + /// * [datePickerDateTimeOrder], which provides the [DatePickerDateTimeOrder] + /// enum value for [CupertinoLocalizations] based on this string value. + @protected + String get datePickerDateTimeOrderString; + + @override + DatePickerDateTimeOrder get datePickerDateTimeOrder { + switch (datePickerDateTimeOrderString) { + case 'date_time_dayPeriod': + return DatePickerDateTimeOrder.date_time_dayPeriod; + case 'date_dayPeriod_time': + return DatePickerDateTimeOrder.date_dayPeriod_time; + case 'time_dayPeriod_date': + return DatePickerDateTimeOrder.time_dayPeriod_date; + case 'dayPeriod_time_date': + return DatePickerDateTimeOrder.dayPeriod_time_date; + default: + assert( + false, + 'Failed to load DatePickerDateTimeOrder $datePickerDateTimeOrderString ' + 'for locale $_localeName.\nNon conforming string for $_localeName\'s ' + '.arb file', + ); + return null; + } + } + + @override + String timerPickerHour(int hour) { + return _singleDigitHourFormat.format(DateTime.utc(0, 0, 0, hour)); + } + + @override + String timerPickerMinute(int minute) { + return _singleDigitMinuteFormat.format(DateTime.utc(0, 0, 0, 0, minute)); + } + + @override + String timerPickerSecond(int second) { + return _singleDigitSecondFormat.format(DateTime.utc(0, 0, 0, 0, 0, second)); + } + + /// Subclasses should provide the optional zero pluralization of [timerPickerHourLabel] based on the ARB file. + @protected String get timerPickerHourLabelZero => null; + /// Subclasses should provide the optional one pluralization of [timerPickerHourLabel] based on the ARB file. + @protected String get timerPickerHourLabelOne => null; + /// Subclasses should provide the optional two pluralization of [timerPickerHourLabel] based on the ARB file. + @protected String get timerPickerHourLabelTwo => null; + /// Subclasses should provide the optional few pluralization of [timerPickerHourLabel] based on the ARB file. + @protected String get timerPickerHourLabelFew => null; + /// Subclasses should provide the optional many pluralization of [timerPickerHourLabel] based on the ARB file. + @protected String get timerPickerHourLabelMany => null; + /// Subclasses should provide the required other pluralization of [timerPickerHourLabel] based on the ARB file. + @protected String get timerPickerHourLabelOther; + + @override + String timerPickerHourLabel(int hour) { + return intl.Intl.pluralLogic( + hour, + zero: timerPickerHourLabelZero, + one: timerPickerHourLabelOne, + two: timerPickerHourLabelTwo, + few: timerPickerHourLabelFew, + many: timerPickerHourLabelMany, + other: timerPickerHourLabelOther, + locale: _localeName, + ).replaceFirst(r'$hour', _decimalFormat.format(hour)); + } + + /// Subclasses should provide the optional zero pluralization of [timerPickerMinuteLabel] based on the ARB file. + @protected String get timerPickerMinuteLabelZero => null; + /// Subclasses should provide the optional one pluralization of [timerPickerMinuteLabel] based on the ARB file. + @protected String get timerPickerMinuteLabelOne => null; + /// Subclasses should provide the optional two pluralization of [timerPickerMinuteLabel] based on the ARB file. + @protected String get timerPickerMinuteLabelTwo => null; + /// Subclasses should provide the optional few pluralization of [timerPickerMinuteLabel] based on the ARB file. + @protected String get timerPickerMinuteLabelFew => null; + /// Subclasses should provide the optional many pluralization of [timerPickerMinuteLabel] based on the ARB file. + @protected String get timerPickerMinuteLabelMany => null; + /// Subclasses should provide the required other pluralization of [timerPickerMinuteLabel] based on the ARB file. + @protected String get timerPickerMinuteLabelOther; + + @override + String timerPickerMinuteLabel(int minute) { + return intl.Intl.pluralLogic( + minute, + zero: timerPickerMinuteLabelZero, + one: timerPickerMinuteLabelOne, + two: timerPickerMinuteLabelTwo, + few: timerPickerMinuteLabelFew, + many: timerPickerMinuteLabelMany, + other: timerPickerMinuteLabelOther, + locale: _localeName, + ).replaceFirst(r'$minute', _decimalFormat.format(minute)); + } + + /// Subclasses should provide the optional zero pluralization of [timerPickerSecondLabel] based on the ARB file. + @protected String get timerPickerSecondLabelZero => null; + /// Subclasses should provide the optional one pluralization of [timerPickerSecondLabel] based on the ARB file. + @protected String get timerPickerSecondLabelOne => null; + /// Subclasses should provide the optional two pluralization of [timerPickerSecondLabel] based on the ARB file. + @protected String get timerPickerSecondLabelTwo => null; + /// Subclasses should provide the optional few pluralization of [timerPickerSecondLabel] based on the ARB file. + @protected String get timerPickerSecondLabelFew => null; + /// Subclasses should provide the optional many pluralization of [timerPickerSecondLabel] based on the ARB file. + @protected String get timerPickerSecondLabelMany => null; + /// Subclasses should provide the required other pluralization of [timerPickerSecondLabel] based on the ARB file. + @protected String get timerPickerSecondLabelOther; + + @override + String timerPickerSecondLabel(int second) { + return intl.Intl.pluralLogic( + second, + zero: timerPickerSecondLabelZero, + one: timerPickerSecondLabelOne, + two: timerPickerSecondLabelTwo, + few: timerPickerSecondLabelFew, + many: timerPickerSecondLabelMany, + other: timerPickerSecondLabelOther, + locale: _localeName, + ).replaceFirst(r'$second', _decimalFormat.format(second)); + } + + /// A [LocalizationsDelegate] that uses [GlobalCupertinoLocalizations.load] + /// to create an instance of this class. + /// + /// Most internationalized apps will use [GlobalCupertinoLocalizations.delegates] + /// as the value of [CupertinoApp.localizationsDelegates] to include + /// the localizations for both the cupertino and widget libraries. + static const LocalizationsDelegate delegate = _GlobalCupertinoLocalizationsDelegate(); + + /// A value for [CupertinoApp.localizationsDelegates] that's typically used by + /// internationalized apps. + /// + /// ## Sample code + /// + /// To include the localizations provided by this class and by + /// [GlobalWidgetsLocalizations] in a [CupertinoApp], + /// use [GlobalCupertinoLocalizations.delegates] as the value of + /// [CupertinoApp.localizationsDelegates], and specify the locales your + /// app supports with [CupertinoApp.supportedLocales]: + /// + /// ```dart + /// new CupertinoApp( + /// localizationsDelegates: GlobalCupertinoLocalizations.delegates, + /// supportedLocales: [ + /// const Locale('en', 'US'), // English + /// const Locale('he', 'IL'), // Hebrew + /// ], + /// // ... + /// ) + /// ``` + static const List> delegates = >[ + GlobalCupertinoLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + ]; +} + +class _GlobalCupertinoLocalizationsDelegate extends LocalizationsDelegate { + const _GlobalCupertinoLocalizationsDelegate(); + + @override + bool isSupported(Locale locale) => false; // TODO(xster): implement. + + static final Map> _loadedTranslations = >{}; + + @override + Future load(Locale locale) { + assert(isSupported(locale)); // TODO(xster): implement. + return _loadedTranslations.putIfAbsent(locale, () { + util.loadDateIntlDataIfNotLoaded(); + + final String localeName = intl.Intl.canonicalizedLocale(locale.toString()); + assert( + locale.toString() == localeName, + 'Flutter does not support the non-standard locale form $locale (which ' + 'might be $localeName', + ); + + intl.DateFormat fullYearFormat; + intl.DateFormat dayFormat; + intl.DateFormat mediumDateFormat; + // We don't want any additional decoration here. The am/pm is handled in + // the date picker. We just want an hour number localized. + intl.DateFormat singleDigitHourFormat; + intl.DateFormat singleDigitMinuteFormat; + intl.DateFormat doubleDigitMinuteFormat; + intl.DateFormat singleDigitSecondFormat; + intl.NumberFormat decimalFormat; + + void loadFormats(String locale) { + fullYearFormat = intl.DateFormat.y(locale); + dayFormat = intl.DateFormat.d(locale); + mediumDateFormat = intl.DateFormat.MMMEd(locale); + // TODO(xster): fix when https://github.com/dart-lang/intl/issues/207 is resolved. + singleDigitHourFormat = intl.DateFormat('HH', locale); + singleDigitMinuteFormat = intl.DateFormat.m(locale); + doubleDigitMinuteFormat = intl.DateFormat('mm', locale); + singleDigitSecondFormat = intl.DateFormat.s(locale); + decimalFormat = intl.NumberFormat(locale); + } + + if (intl.DateFormat.localeExists(localeName)) { + loadFormats(localeName); + } else if (intl.DateFormat.localeExists(locale.languageCode)) { + loadFormats(locale.languageCode); + } else { + loadFormats(null); + } + + return SynchronousFuture(_getCupertinoTranslation( + localeName, + fullYearFormat, + dayFormat, + mediumDateFormat, + singleDigitHourFormat, + singleDigitMinuteFormat, + doubleDigitMinuteFormat, + singleDigitSecondFormat, + decimalFormat, + )); + }); + } + + @override + bool shouldReload(_GlobalCupertinoLocalizationsDelegate old) => false; +} + +CupertinoLocalizations _getCupertinoTranslation( + String localeName, + intl.DateFormat fullYearFormat, + intl.DateFormat dayFormat, + intl.DateFormat mediumDateFormat, + intl.DateFormat singleDigitHourFormat, + intl.DateFormat singleDigitMinuteFormat, + intl.DateFormat doubleDigitMinuteFormat, + intl.DateFormat singleDigitSecondFormat, + intl.NumberFormat decimalFormat, +) { + return null; // TODO(xster): implement in generated subclass. +} diff --git a/packages/flutter_localizations/lib/src/l10n/README.md b/packages/flutter_localizations/lib/src/l10n/README.md index bcd4cdbab5..0892171160 100644 --- a/packages/flutter_localizations/lib/src/l10n/README.md +++ b/packages/flutter_localizations/lib/src/l10n/README.md @@ -7,7 +7,7 @@ linked with the rest of flutter_localizations package. If you're looking for information about internationalizing Flutter apps in general, see the -[Internationalizing Flutter Apps](https://flutter.io/tutorials/internationalization/) tutorial. +[Internationalizing Flutter Apps](https://flutter.dev/tutorials/internationalization/) tutorial. ### Translations for one locale: .arb files @@ -148,13 +148,13 @@ section in the Material spec. The Material theme uses the ### Generated file localizations.dart: all of the localizations as a Map If you look at the comment at the top of `localizations.dart` you'll -see that it was manually generated using a `dev/tools` app called +see that it was manually generated using a `dev/tools/localization` app called `gen_localizations`. You can see what that script would generate by running this command: ```dart -dart dev/tools/gen_localizations.dart packages/flutter_localizations/lib/src/l10n material +dart dev/tools/localization/gen_localizations.dart packages/flutter_localizations/lib/src/l10n material ``` The gen_localizations app just combines the contents of all of the @@ -172,7 +172,7 @@ To in-place update the `localizations.dart` file using the default values, you can just run: ```dart -dart dev/tools/gen_localizations.dart --overwrite +dart dev/tools/localization/gen_localizations.dart --overwrite ``` @@ -189,7 +189,7 @@ If you have feedback about the translations please ### See Also -The [Internationalizing Flutter Apps](https://flutter.io/tutorials/internationalization/) +The [Internationalizing Flutter Apps](https://flutter.dev/tutorials/internationalization/) tutorial describes how to use the internationalization APIs in an ordinary Flutter app. diff --git a/packages/flutter_localizations/lib/src/l10n/cupertino_en.arb b/packages/flutter_localizations/lib/src/l10n/cupertino_en.arb index 81d9663d5c..7d3cc73d7c 100644 --- a/packages/flutter_localizations/lib/src/l10n/cupertino_en.arb +++ b/packages/flutter_localizations/lib/src/l10n/cupertino_en.arb @@ -1,12 +1,13 @@ { + "datePickerHourSemanticsLabelOne": "$hour o'clock", "datePickerHourSemanticsLabelOther": "$hour o'clock", "@datePickerHourSemanticsLabel": { "description": "Accessibility announcement for the selected hour on a time picker such as '5 o'clock' or '5点'", "plural": "hour" }, - "datePickerMinuteSemanticsOne": "1 minute", - "datePickerMinuteSemanticsOther": "$minute minutes", + "datePickerMinuteSemanticsLabelOne": "1 minute", + "datePickerMinuteSemanticsLabelOther": "$minute minutes", "@datePickerMinuteSemanticsLabel": { "description": "Accessibility announcement for the selected minute on a time picker such as '15 minutes' or '15分'", "plural": "minute" @@ -14,22 +15,22 @@ "datePickerDateOrder": "mdy", "@datePickerDateOrder": { - "description": "The standard order for the locale to arrange day, month and year in a date. Options are dmy, mdy, ymd and ydm." + "description": "Choose a standard order for the locale to arrange day, month and year in a date. Do not transliterate the abbreviations themselves. The only options are dmy, mdy, ymd and ydm. For instance, in French, use dmy (for day month year) but do not translate into jma (for jour mois année). " }, "datePickerDateTimeOrder": "date_time_dayPeriod", "@datePickerDateTimeOrder": { - "description": "The standard order for the locale to date, time and am/pm in a datetime. Options are date_time_dayPeriod, date_dayPeriod_time, time_dayPeriod_date and dayPeriod_time_date where 'dayPeriod' is am/pm." + "description": "Choose a standard order for the locale to arrange date, time and am/pm in a datetime. Do not transliterate the choices themselves. The only options are date_time_dayPeriod, date_dayPeriod_time, time_dayPeriod_date and dayPeriod_time_date where 'dayPeriod' is am/pm. You can ignore the position of dayPeriod if the locale uses 24h time only. For instance, in French, use date_time_dayPeriod, but do not translate into date_heure_périodeDuJour or some such." }, "anteMeridiemAbbreviation": "AM", "@anteMeridiemAbbreviation": { - "description": "The abbreviation for ante meridiem (before noon) shown in the time picker." + "description": "The abbreviation for ante meridiem (before noon) shown in the time picker when it's not using the 24h format. Reference the text iOS uses such as in the iOS clock app." }, "postMeridiemAbbreviation": "PM", "@postMeridiemAbbreviation": { - "description": "The abbreviation for post meridiem (after noon) shown in the time picker." + "description": "The abbreviation for post meridiem (after noon) shown in the time picker when it's not using the 24h format. Reference the text iOS uses such as in the iOS clock app." }, "alertDialogLabel": "Alert", @@ -40,39 +41,41 @@ "timerPickerHourLabelOne": "hour", "timerPickerHourLabelOther": "hours", "@timerPickerHourLabel": { - "description": "The label adjacent to an hour integer number in a countdown timer.", + "description": "The label adjacent to an hour integer number in a countdown timer. The reference abbreviation is what iOS does in the stock clock app's countdown timer.", "plural": "hour" }, + "timerPickerMinuteLabelOne": "min", "timerPickerMinuteLabelOther": "min", "@timerPickerMinuteLabel": { - "description": "The label adjacent to a minute integer number in a countdown timer.", + "description": "The label adjacent to a minute integer number in a countdown timer. The reference abbreviation is what iOS does in the stock clock app's countdown timer.", "plural": "minute" }, + "timerPickerSecondLabelOne": "sec", "timerPickerSecondLabelOther": "sec", "@timerPickerSecondLabel": { - "description": "The label adjacent to a second integer number in a countdown timer.", + "description": "The label adjacent to a second integer number in a countdown timer. The reference abbreviation is what iOS does in the stock clock app's countdown timer.", "plural": "second" }, "cutButtonLabel": "Cut", "@cutButtonLabel": { - "description": "The label for cut buttons and menu items." + "description": "The label for cut buttons and menu items. The reference abbreviation is what iOS shows on text selection toolbars." }, "copyButtonLabel": "Copy", "@copyButtonLabel": { - "description": "The label for copy buttons and menu items." + "description": "The label for copy buttons and menu items. The reference abbreviation is what iOS shows on text selection toolbars." }, "pasteButtonLabel": "Paste", "@pasteButtonLabel": { - "description": "The label for paste buttons and menu items." + "description": "The label for paste buttons and menu items. The reference abbreviation is what iOS shows on text selection toolbars." }, "selectAllButtonLabel": "Select All", "@selectAllButtonLabel": { - "description": "The label for select-all buttons and menu items." + "description": "The label for select-all buttons and menu items. The reference abbreviation is what iOS shows on text selection toolbars." } } diff --git a/packages/flutter_localizations/lib/src/l10n/cupertino_fr.arb b/packages/flutter_localizations/lib/src/l10n/cupertino_fr.arb new file mode 100644 index 0000000000..995c723df0 --- /dev/null +++ b/packages/flutter_localizations/lib/src/l10n/cupertino_fr.arb @@ -0,0 +1,20 @@ +{ + "datePickerHourSemanticsLabelOne": "une heure", + "datePickerHourSemanticsLabelOther": "$hour heures", + "datePickerMinuteSemanticsLabelOne": "une minute", + "datePickerMinuteSemanticsLabelOther": "$minute minutes", + "datePickerDateOrder": "dmy", + "datePickerDateTimeOrder": "date_time_dayPeriod", + "anteMeridiemAbbreviation": "AM", + "postMeridiemAbbreviation": "PM", + "alertDialogLabel": "Alerte", + "timerPickerHourLabelOne": "heure", + "timerPickerHourLabelOther": "heures", + "timerPickerMinuteLabelOne": "minute", + "timerPickerMinuteLabelOther": "minutes", + "timerPickerSecondLabelOther": "s", + "cutButtonLabel": "Couper", + "copyButtonLabel": "Copier", + "pasteButtonLabel": "Coller", + "selectAllButtonLabel": "Tout sélect." +} diff --git a/packages/flutter_localizations/lib/src/l10n/date_localizations.dart b/packages/flutter_localizations/lib/src/l10n/generated_date_localizations.dart similarity index 99% rename from packages/flutter_localizations/lib/src/l10n/date_localizations.dart rename to packages/flutter_localizations/lib/src/l10n/generated_date_localizations.dart index c2a0f5f7ac..3f11af3c69 100644 --- a/packages/flutter_localizations/lib/src/l10n/date_localizations.dart +++ b/packages/flutter_localizations/lib/src/l10n/generated_date_localizations.dart @@ -4,7 +4,7 @@ // This file has been automatically generated. Please do not edit it manually. // To regenerate run (omit --overwrite to print to console instead of the file): -// dart --enable-asserts dev/tools/gen_date_localizations.dart --overwrite +// dart --enable-asserts dev/tools/localization/gen_date_localizations.dart --overwrite /// The subset of date symbols supported by the intl package which are also /// supported by flutter_localizations. diff --git a/packages/flutter_localizations/lib/src/l10n/localizations.dart b/packages/flutter_localizations/lib/src/l10n/generated_material_localizations.dart similarity index 99% rename from packages/flutter_localizations/lib/src/l10n/localizations.dart rename to packages/flutter_localizations/lib/src/l10n/generated_material_localizations.dart index 95e4aed84a..254d82390d 100644 --- a/packages/flutter_localizations/lib/src/l10n/localizations.dart +++ b/packages/flutter_localizations/lib/src/l10n/generated_material_localizations.dart @@ -4,7 +4,7 @@ // This file has been automatically generated. Please do not edit it manually. // To regenerate the file, use: -// dart dev/tools/gen_localizations.dart --overwrite +// dart dev/tools/localization/gen_localizations.dart --overwrite import 'dart:collection'; @@ -17,9 +17,9 @@ import '../material_localizations.dart'; // The classes defined here encode all of the translations found in the // `flutter_localizations/lib/src/l10n/*.arb` files. // -// These classes are constructed by the [getTranslation] method at the bottom of -// this file, and used by the [_MaterialLocalizationsDelegate.load] method defined -// in `flutter_localizations/lib/src/material_localizations.dart`. +// These classes are constructed by the [getMaterialTranslation] method at the +// bottom of this file, and used by the [_MaterialLocalizationsDelegate.load] +// method defined in `flutter_localizations/lib/src/material_localizations.dart`. /// The translations for Arabic (`ar`). class MaterialLocalizationAr extends GlobalMaterialLocalizations { @@ -13144,7 +13144,7 @@ class MaterialLocalizationZhHantTw extends MaterialLocalizationZhHant { /// /// See also: /// -/// * [getTranslation], whose documentation describes these values. +/// * [getMaterialTranslation], whose documentation describes these values. final Set kSupportedLanguages = HashSet.from(const [ 'ar', // Arabic 'bg', // Bulgarian @@ -13202,7 +13202,7 @@ final Set kSupportedLanguages = HashSet.from(const [ /// Creates a [GlobalMaterialLocalizations] instance for the given `locale`. /// -/// All of the function's arguments except `locale` will be passed to the [new +/// All of the function's arguments except `locale` will be passed to the [ /// GlobalMaterialLocalizations] constructor. (The `localeName` argument of that /// constructor is specified by the actual subclass constructor by this /// function.) @@ -13266,7 +13266,7 @@ final Set kSupportedLanguages = HashSet.from(const [ /// /// Generally speaking, this method is only intended to be used by /// [GlobalMaterialLocalizations.delegate]. -GlobalMaterialLocalizations getTranslation( +GlobalMaterialLocalizations getMaterialTranslation( Locale locale, intl.DateFormat fullYearFormat, intl.DateFormat mediumDateFormat, @@ -13486,6 +13486,6 @@ GlobalMaterialLocalizations getTranslation( return MaterialLocalizationZh(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); } } - assert(false, 'getTranslation() called for unsupported locale "$locale"'); + assert(false, 'getMaterialTranslation() called for unsupported locale "$locale"'); return null; } diff --git a/packages/flutter_localizations/lib/src/material_localizations.dart b/packages/flutter_localizations/lib/src/material_localizations.dart index 93181f245b..a0b72d2eb1 100644 --- a/packages/flutter_localizations/lib/src/material_localizations.dart +++ b/packages/flutter_localizations/lib/src/material_localizations.dart @@ -8,10 +8,9 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart' as intl; import 'package:intl/date_symbols.dart' as intl; -import 'package:intl/date_symbol_data_custom.dart' as date_symbol_data_custom; -import 'l10n/date_localizations.dart' as date_localizations; -import 'l10n/localizations.dart'; +import 'l10n/generated_material_localizations.dart'; +import 'utils/date_localizations.dart' as util; import 'widgets_localizations.dart'; /// Implementation of localized strings for the material widgets using the @@ -63,7 +62,7 @@ import 'widgets_localizations.dart'; /// See also: /// /// * The Flutter Internationalization Tutorial, -/// . +/// . /// * [DefaultMaterialLocalizations], which only provides US English translations. abstract class GlobalMaterialLocalizations implements MaterialLocalizations { /// Initializes an object that defines the material widgets' localized strings @@ -559,57 +558,20 @@ class _MaterialLocalizationsDelegate extends LocalizationsDelegate kSupportedLanguages.contains(locale.languageCode); - /// Tracks if date i18n data has been loaded. - static bool _dateIntlDataInitialized = false; - - /// Loads i18n data for dates if it hasn't be loaded yet. - /// - /// Only the first invocation of this function has the effect of loading the - /// data. Subsequent invocations have no effect. - static void _loadDateIntlDataIfNotLoaded() { - if (!_dateIntlDataInitialized) { - // TODO(garyq): Add support for scriptCodes. Do not strip scriptCode from string. - - // Keep track of initialzed locales, or will fail on attempted double init. - // This can only happen if a locale with a stripped scriptCode has already - // been initialzed. This should be removed when scriptCode stripping is removed. - final Set initializedLocales = {}; - date_localizations.dateSymbols.forEach((String locale, dynamic data) { - // Strip scriptCode from the locale, as we do not distinguish between scripts - // for dates. - final List codes = locale.split('_'); - String countryCode; - if (codes.length == 2) { - countryCode = codes[1].length < 4 ? codes[1] : null; - } else if (codes.length == 3) { - countryCode = codes[1].length < codes[2].length ? codes[1] : codes[2]; - } - locale = codes[0] + (countryCode != null ? '_' + countryCode : ''); - if (initializedLocales.contains(locale)) - return; - initializedLocales.add(locale); - // Perform initialization. - assert(date_localizations.datePatterns.containsKey(locale)); - final intl.DateSymbols symbols = intl.DateSymbols.deserializeFromMap(data); - date_symbol_data_custom.initializeDateFormattingCustom( - locale: locale, - symbols: symbols, - patterns: date_localizations.datePatterns[locale], - ); - }); - _dateIntlDataInitialized = true; - } - } - static final Map> _loadedTranslations = >{}; @override Future load(Locale locale) { assert(isSupported(locale)); return _loadedTranslations.putIfAbsent(locale, () { - _loadDateIntlDataIfNotLoaded(); + util.loadDateIntlDataIfNotLoaded(); final String localeName = intl.Intl.canonicalizedLocale(locale.toString()); + assert( + locale.toString() == localeName, + 'Flutter does not support the non-standard locale form $locale (which ' + 'might be $localeName', + ); intl.DateFormat fullYearFormat; intl.DateFormat mediumDateFormat; @@ -645,9 +607,7 @@ class _MaterialLocalizationsDelegate extends LocalizationsDelegate(getTranslation( + return SynchronousFuture(getMaterialTranslation( locale, fullYearFormat, mediumDateFormat, diff --git a/packages/flutter_localizations/lib/src/utils/date_localizations.dart b/packages/flutter_localizations/lib/src/utils/date_localizations.dart new file mode 100644 index 0000000000..704322c102 --- /dev/null +++ b/packages/flutter_localizations/lib/src/utils/date_localizations.dart @@ -0,0 +1,49 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:intl/date_symbols.dart' as intl; +import 'package:intl/date_symbol_data_custom.dart' as date_symbol_data_custom; +import '../l10n/generated_date_localizations.dart' as date_localizations; + +/// Tracks if date i18n data has been loaded. +bool _dateIntlDataInitialized = false; + +/// Loads i18n data for dates if it hasn't be loaded yet. +/// +/// Only the first invocation of this function has the effect of loading the +/// data. Subsequent invocations have no effect. +void loadDateIntlDataIfNotLoaded() { + if (!_dateIntlDataInitialized) { + // TODO(garyq): Add support for scriptCodes. Do not strip scriptCode from string. + + // Keep track of initialzed locales, or will fail on attempted double init. + // This can only happen if a locale with a stripped scriptCode has already + // been initialzed. This should be removed when scriptCode stripping is removed. + final Set initializedLocales = {}; + date_localizations.dateSymbols.forEach((String locale, dynamic data) { + // Strip scriptCode from the locale, as we do not distinguish between scripts + // for dates. + final List codes = locale.split('_'); + String countryCode; + if (codes.length == 2) { + countryCode = codes[1].length < 4 ? codes[1] : null; + } else if (codes.length == 3) { + countryCode = codes[1].length < codes[2].length ? codes[1] : codes[2]; + } + locale = codes[0] + (countryCode != null ? '_' + countryCode : ''); + if (initializedLocales.contains(locale)) + return; + initializedLocales.add(locale); + // Perform initialization. + assert(date_localizations.datePatterns.containsKey(locale)); + final intl.DateSymbols symbols = intl.DateSymbols.deserializeFromMap(data); + date_symbol_data_custom.initializeDateFormattingCustom( + locale: locale, + symbols: symbols, + patterns: date_localizations.datePatterns[locale], + ); + }); + _dateIntlDataInitialized = true; + } +} \ No newline at end of file diff --git a/packages/flutter_localizations/pubspec.yaml b/packages/flutter_localizations/pubspec.yaml index 13f28d9bad..b151269fa0 100644 --- a/packages/flutter_localizations/pubspec.yaml +++ b/packages/flutter_localizations/pubspec.yaml @@ -9,7 +9,7 @@ dependencies: flutter: sdk: flutter - intl: 0.15.7 + intl: 0.15.8 collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -22,17 +22,17 @@ dev_dependencies: sdk: flutter mockito: 4.0.0 - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - quiver: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + quiver: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" -# PUBSPEC CHECKSUM: b343 +# PUBSPEC CHECKSUM: 0cd8 diff --git a/packages/flutter_test/lib/src/accessibility.dart b/packages/flutter_test/lib/src/accessibility.dart index 2d382c9693..5fac46a184 100644 --- a/packages/flutter_test/lib/src/accessibility.dart +++ b/packages/flutter_test/lib/src/accessibility.dart @@ -200,7 +200,7 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline { final ByteData byteData = await tester.binding.runAsync(() async { // Needs to be the same pixel ratio otherwise our dimensions won't match the // last transform layer. - image = await layer.toImage(renderView.paintBounds, pixelRatio: 1.0); + image = await layer.toImage(renderView.paintBounds, pixelRatio: 1 / 3); return image.toByteData(); }); @@ -214,10 +214,12 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline { children.add(child); return true; }); - for (SemanticsNode child in children) + for (SemanticsNode child in children) { result += await evaluateNode(child); - if (_shouldSkipNode(data)) + } + if (_shouldSkipNode(data)) { return result; + } // We need to look up the inherited text properties to determine the // contrast ratio based on text size/weight. @@ -225,14 +227,22 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline { bool isBold; final String text = (data.label?.isEmpty == true) ? data.value : data.label; final List elements = find.text(text).hitTestable().evaluate().toList(); + Rect paintBounds; if (elements.length == 1) { final Element element = elements.single; + final RenderBox renderObject = element.renderObject; + element.renderObject.paintBounds; + paintBounds = Rect.fromPoints( + renderObject.localToGlobal(element.renderObject.paintBounds.topLeft - const Offset(4.0, 4.0)), + renderObject.localToGlobal(element.renderObject.paintBounds.bottomRight + const Offset(4.0, 4.0)), + ); final Widget widget = element.widget; final DefaultTextStyle defaultTextStyle = DefaultTextStyle.of(element); if (widget is Text) { TextStyle effectiveTextStyle = widget.style; - if (widget.style == null || widget.style.inherit) + if (widget.style == null || widget.style.inherit) { effectiveTextStyle = defaultTextStyle.style.merge(widget.style); + } fontSize = effectiveTextStyle.fontSize; isBold = effectiveTextStyle.fontWeight == FontWeight.bold; } else if (widget is EditableText) { @@ -249,21 +259,14 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline { return result; } - // Transform local coordinate to screen coordinates. - Rect paintBounds = node.rect; - SemanticsNode current = node; - while (current != null && current.parent != null) { - if (current.transform != null) - paintBounds = MatrixUtils.transformRect(current.transform, paintBounds); - paintBounds = paintBounds.shift(current.parent?.rect?.topLeft ?? Offset.zero); - current = current.parent; - } - if (_isNodeOffScreen(paintBounds)) + if (_isNodeOffScreen(paintBounds)) { return result; + } final List subset = _subsetToRect(byteData, paintBounds, image.width, image.height); // Node was too far off screen. - if (subset.isEmpty) + if (subset.isEmpty) { return result; + } final _ContrastReport report = _ContrastReport(subset); final double contrastRatio = report.contrastRatio(); const double delta = -0.01; @@ -342,8 +345,9 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline { class _ContrastReport { factory _ContrastReport(List colors) { final Map colorHistogram = {}; - for (int color in colors) + for (int color in colors) { colorHistogram[color] = (colorHistogram[color] ?? 0) + 1; + } if (colorHistogram.length == 1) { final Color hslColor = Color(colorHistogram.keys.first); return _ContrastReport._(hslColor, hslColor); diff --git a/packages/flutter_test/lib/src/binding.dart b/packages/flutter_test/lib/src/binding.dart index 6c1ab7a5e3..115877b810 100644 --- a/packages/flutter_test/lib/src/binding.dart +++ b/packages/flutter_test/lib/src/binding.dart @@ -168,6 +168,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase } @override + // ignore: MUST_CALL_SUPER void initLicenses() { // Do not include any licenses, because we're a test, and the LICENSE file // doesn't get generated for tests. @@ -583,6 +584,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase final bool autoUpdateGoldensBeforeTest = autoUpdateGoldenFiles; final TestExceptionReporter reportTestExceptionBeforeTest = reportTestException; + final ErrorWidgetBuilder errorWidgetBuilderBeforeTest = ErrorWidget.builder; // run the test await testBody(); @@ -597,6 +599,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase invariantTester(); _verifyAutoUpdateGoldensUnset(autoUpdateGoldensBeforeTest); _verifyReportTestExceptionUnset(reportTestExceptionBeforeTest); + _verifyErrorWidgetBuilderUnset(errorWidgetBuilderBeforeTest); _verifyInvariants(); } @@ -666,6 +669,21 @@ abstract class TestWidgetsFlutterBinding extends BindingBase }()); } + void _verifyErrorWidgetBuilderUnset(ErrorWidgetBuilder valueBeforeTest) { + assert(() { + if (ErrorWidget.builder != valueBeforeTest) { + FlutterError.reportError(FlutterErrorDetails( + exception: FlutterError( + 'The value of ErrorWidget.builder was changed by the test.', + ), + stack: StackTrace.current, + library: 'Flutter test framework', + )); + } + return true; + }()); + } + /// Called by the [testWidgets] function after a test is executed. void postTest() { assert(inTest); diff --git a/packages/flutter_test/lib/src/matchers.dart b/packages/flutter_test/lib/src/matchers.dart index 6a480e6448..816cdeced4 100644 --- a/packages/flutter_test/lib/src/matchers.dart +++ b/packages/flutter_test/lib/src/matchers.dart @@ -1813,7 +1813,7 @@ class _MatchesSemanticsData extends Matcher { final List providedCustomActions = data.customSemanticsActionIds.map((int id) { return CustomSemanticsAction.getAction(id); }).toList(); - final List expectedCustomActions = List.from(customActions ?? const []); + final List expectedCustomActions = customActions?.toList() ?? []; if (hintOverrides?.onTapHint != null) expectedCustomActions.add(CustomSemanticsAction.overridingAction(hint: hintOverrides.onTapHint, action: SemanticsAction.tap)); if (hintOverrides?.onLongPressHint != null) diff --git a/packages/flutter_test/pubspec.yaml b/packages/flutter_test/pubspec.yaml index 2f17920dfd..40f42e1b8d 100644 --- a/packages/flutter_test/pubspec.yaml +++ b/packages/flutter_test/pubspec.yaml @@ -13,13 +13,13 @@ dependencies: # We depend on very specific internal implementation details of the # 'test' package, which change between versions, so when upgrading # this, make sure the tests are still running correctly. - test_api: 0.2.2 + test_api: 0.2.4 # Used by golden file comparator path: 1.6.2 # We use FakeAsync and other testing utilities. - quiver: 2.0.1 + quiver: 2.0.2 # We import stack_trace because the test packages uses it and we # need to be able to unmangle the stack traces that it passed to @@ -29,15 +29,15 @@ dependencies: # Used by globalToLocal et al. vector_math: 2.0.8 - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -45,6 +45,6 @@ dependencies: dev_dependencies: file: 5.0.7 - intl: 0.15.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl: 0.15.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" -# PUBSPEC CHECKSUM: bdf3 +# PUBSPEC CHECKSUM: 3289 diff --git a/packages/flutter_test/test/accessibility_test.dart b/packages/flutter_test/test/accessibility_test.dart index 284c17c70f..960013b00e 100644 --- a/packages/flutter_test/test/accessibility_test.dart +++ b/packages/flutter_test/test/accessibility_test.dart @@ -92,13 +92,17 @@ void main() { await tester.pumpWidget(MaterialApp( home: Scaffold( body: Center( - child: TextField( - controller: TextEditingController(text: 'this is a test'), + child: SizedBox( + width: 100, + child: TextField( + controller: TextEditingController(text: 'this is a test'), + ), ), ), ), ), ); + await tester.idle(); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); @@ -121,9 +125,9 @@ void main() { expect(result.reason, 'SemanticsNode#21(Rect.fromLTRB(300.0, 200.0, 500.0, 400.0), label: "this is a test",' ' textDirection: ltr):\nExpected contrast ratio of at least ' - '4.5 but found 0.88 for a font size of 14.0. ' - 'The computed foreground color was: Color(0xffffeb3b), ' - 'The computed background color was: Color(0xffffff00)\n' + '4.5 but found 1.17 for a font size of 14.0. The ' + 'computed foreground color was: Color(0xfffafafa), The computed background color was:' + ' Color(0xffffeb3b)\n' 'See also: https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html'); handle.dispose(); }); @@ -418,6 +422,24 @@ void main() { }); }); + testWidgets('regression test for material widget', (WidgetTester tester) async { + final SemanticsHandle handle = tester.ensureSemantics(); + await tester.pumpWidget( + MaterialApp( + theme: ThemeData.light(), + home: Scaffold( + backgroundColor: Colors.white, + body: RaisedButton( + color: const Color(0xFFFBBC04), + elevation: 0, + onPressed: () {}, + child: const Text('Button', style: TextStyle(color: Colors.black)), + ), + ), + )); + await expectLater(tester, meetsGuideline(textContrastGuideline)); + handle.dispose(); + }); } Widget _boilerplate(Widget child) { diff --git a/packages/flutter_tools/BUILD.gn b/packages/flutter_tools/BUILD.gn index 2df1803a31..48b481deef 100644 --- a/packages/flutter_tools/BUILD.gn +++ b/packages/flutter_tools/BUILD.gn @@ -253,4 +253,8 @@ dart_tool("fuchsia_attach") { deps = [ ":flutter_tools", ] + + non_dart_deps = [ + "//third_party/flutter/frontend_server:frontend_server_tool_snapshot($host_toolchain)", + ] } diff --git a/packages/flutter_tools/bin/fuchsia_tester.dart b/packages/flutter_tools/bin/fuchsia_tester.dart index dd3756e662..789aa5ca75 100644 --- a/packages/flutter_tools/bin/fuchsia_tester.dart +++ b/packages/flutter_tools/bin/fuchsia_tester.dart @@ -18,6 +18,7 @@ import 'package:flutter_tools/src/dart/package_map.dart'; import 'package:flutter_tools/src/artifacts.dart'; import 'package:flutter_tools/src/disabled_usage.dart'; import 'package:flutter_tools/src/globals.dart'; +import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/test/coverage_collector.dart'; import 'package:flutter_tools/src/test/runner.dart'; import 'package:flutter_tools/src/usage.dart'; @@ -99,8 +100,7 @@ Future run(List args) async { fs.link(artifacts.getArtifactPath(Artifact.flutterTester)); testerDestLink.parent.createSync(recursive: true); testerDestLink.createSync(fs.path.absolute(shellPath)); - final Link icudtlLink = testerDestLink.parent.childLink('icudtl.dat'); - icudtlLink.createSync(fs.path.absolute(argResults[_kOptionIcudtl])); + final Directory sdkRootDest = fs.directory(artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath)); sdkRootDest.createSync(recursive: true); @@ -116,7 +116,10 @@ Future run(List args) async { Directory testDirectory; CoverageCollector collector; if (argResults['coverage']) { - collector = CoverageCollector(); + collector = CoverageCollector( + flutterProject: await FlutterProject.current(), + coverageDirectory: coverageDirectory, + ); if (!argResults.options.contains(_kOptionTestDirectory)) { throwToolExit('Use of --coverage requires setting --test-directory'); } @@ -141,6 +144,8 @@ Future run(List args) async { enableObservatory: collector != null, precompiledDillFiles: tests, concurrency: math.max(1, platform.numberOfProcessors - 2), + icudtlPath: fs.path.absolute(argResults[_kOptionIcudtl]), + coverageDirectory: coverageDirectory, ); if (collector != null) { diff --git a/packages/flutter_tools/bin/xcode_backend.sh b/packages/flutter_tools/bin/xcode_backend.sh index 1bf2310435..f8f3a2fb89 100755 --- a/packages/flutter_tools/bin/xcode_backend.sh +++ b/packages/flutter_tools/bin/xcode_backend.sh @@ -46,6 +46,19 @@ BuildApp() { target_path="${FLUTTER_TARGET}" fi + local derived_dir="${SOURCE_ROOT}/Flutter" + if [[ -e "${project_path}/.ios" ]]; then + derived_dir="${project_path}/.ios/Flutter" + fi + + # Default value of assets_path is flutter_assets + local assets_path="flutter_assets" + # The value of assets_path can set by add FLTAssetsPath to AppFrameworkInfo.plist + FLTAssetsPath=$(/usr/libexec/PlistBuddy -c "Print :FLTAssetsPath" "${derived_dir}/AppFrameworkInfo.plist" 2>/dev/null) + if [[ -n "$FLTAssetsPath" ]]; then + assets_path="${FLTAssetsPath}" + fi + # Use FLUTTER_BUILD_MODE if it's set, otherwise use the Xcode build configuration name # This means that if someone wants to use an Xcode build config other than Debug/Profile/Release, # they _must_ set FLUTTER_BUILD_MODE so we know what type of artifact to build. @@ -87,10 +100,6 @@ BuildApp() { AssertExists "${framework_path}" AssertExists "${project_path}" - local derived_dir="${SOURCE_ROOT}/Flutter" - if [[ -e "${project_path}/.ios" ]]; then - derived_dir="${project_path}/.ios/Flutter" - fi RunCommand mkdir -p -- "$derived_dir" AssertExists "$derived_dir" @@ -248,7 +257,7 @@ BuildApp() { --target="${target_path}" \ --${build_mode} \ --depfile="${build_dir}/snapshot_blob.bin.d" \ - --asset-dir="${derived_dir}/App.framework/flutter_assets" \ + --asset-dir="${derived_dir}/App.framework/${assets_path}" \ ${precompilation_flag} \ ${flutter_engine_flag} \ ${local_engine_flag} \ diff --git a/packages/flutter_tools/lib/src/android/android_device.dart b/packages/flutter_tools/lib/src/android/android_device.dart index c0d1efd754..335a149b47 100644 --- a/packages/flutter_tools/lib/src/android/android_device.dart +++ b/packages/flutter_tools/lib/src/android/android_device.dart @@ -277,7 +277,7 @@ class AndroidDevice extends Device { if (!await _checkForSupportedAdbVersion() || !await _checkForSupportedAndroidVersion()) return false; - final Status status = logger.startProgress('Installing ${fs.path.relative(apk.file.path)}...', timeout: kSlowOperation); + final Status status = logger.startProgress('Installing ${fs.path.relative(apk.file.path)}...', timeout: timeoutConfiguration.slowOperation); final RunResult installResult = await runAsync(adbCommandForDevice(['install', '-t', '-r', apk.file.path])); status.stop(); // Some versions of adb exit with exit code 0 even on failure :( diff --git a/packages/flutter_tools/lib/src/android/gradle.dart b/packages/flutter_tools/lib/src/android/gradle.dart index e08a3c4267..6e76379f77 100644 --- a/packages/flutter_tools/lib/src/android/gradle.dart +++ b/packages/flutter_tools/lib/src/android/gradle.dart @@ -115,7 +115,7 @@ Future _gradleProject() async { /// Runs `gradlew dependencies`, ensuring that dependencies are resolved and /// potentially downloaded. Future checkGradleDependencies() async { - final Status progress = logger.startProgress('Ensuring gradle dependencies are up to date...', timeout: kSlowOperation); + final Status progress = logger.startProgress('Ensuring gradle dependencies are up to date...', timeout: timeoutConfiguration.slowOperation); final FlutterProject flutterProject = await FlutterProject.current(); final String gradle = await _ensureGradle(flutterProject); await runCheckedAsync( @@ -133,7 +133,7 @@ Future _readGradleProject() async { final FlutterProject flutterProject = await FlutterProject.current(); final String gradle = await _ensureGradle(flutterProject); updateLocalProperties(project: flutterProject); - final Status status = logger.startProgress('Resolving dependencies...', timeout: kSlowOperation); + final Status status = logger.startProgress('Resolving dependencies...', timeout: timeoutConfiguration.slowOperation); GradleProject project; try { final RunResult propertiesRunResult = await runCheckedAsync( @@ -211,7 +211,7 @@ Future _ensureGradle(FlutterProject project) async { // of validating the Gradle executable. This may take several seconds. Future _initializeGradle(FlutterProject project) async { final Directory android = project.android.hostAppGradleRoot; - final Status status = logger.startProgress('Initializing gradle...', timeout: kSlowOperation); + final Status status = logger.startProgress('Initializing gradle...', timeout: timeoutConfiguration.slowOperation); String gradle = _locateGradlewExecutable(android); if (gradle == null) { injectGradleWrapper(android); @@ -351,7 +351,7 @@ Future _buildGradleProjectV1(FlutterProject project, String gradle) async // Run 'gradlew build'. final Status status = logger.startProgress( 'Running \'gradlew build\'...', - timeout: kSlowOperation, + timeout: timeoutConfiguration.slowOperation, multilineOutput: true, ); final int exitCode = await runCommandAndStreamOutput( @@ -403,7 +403,7 @@ Future _buildGradleProjectV2( } final Status status = logger.startProgress( 'Running Gradle task \'$assembleTask\'...', - timeout: kSlowOperation, + timeout: timeoutConfiguration.slowOperation, multilineOutput: true, ); final String gradlePath = fs.file(gradle).absolute.path; diff --git a/packages/flutter_tools/lib/src/artifacts.dart b/packages/flutter_tools/lib/src/artifacts.dart index 2c614d6331..7ff4f34a44 100644 --- a/packages/flutter_tools/lib/src/artifacts.dart +++ b/packages/flutter_tools/lib/src/artifacts.dart @@ -105,7 +105,7 @@ abstract class Artifacts { } // Returns the requested [artifact] for the [platform] and [mode] combination. - String getArtifactPath(Artifact artifact, [ TargetPlatform platform, BuildMode mode ]); + String getArtifactPath(Artifact artifact, { TargetPlatform platform, BuildMode mode }); // Returns which set of engine artifacts is currently used for the [platform] // and [mode] combination. @@ -116,7 +116,7 @@ abstract class Artifacts { class CachedArtifacts extends Artifacts { @override - String getArtifactPath(Artifact artifact, [ TargetPlatform platform, BuildMode mode ]) { + String getArtifactPath(Artifact artifact, { TargetPlatform platform, BuildMode mode }) { platform ??= _currentHostPlatform; switch (platform) { case TargetPlatform.android_arm: @@ -173,9 +173,10 @@ class CachedArtifacts extends Artifacts { } } - String _getFlutterPatchedSdkPath() { + String _getFlutterPatchedSdkPath(BuildMode mode) { final String engineArtifactsPath = cache.getArtifactDirectory('engine').path; - return fs.path.join(engineArtifactsPath, 'common', 'flutter_patched_sdk'); + return fs.path.join(engineArtifactsPath, 'common', + mode == BuildMode.release ? 'flutter_patched_sdk_product' : 'flutter_patched_sdk'); } String _getFlutterWebSdkPath() { @@ -200,11 +201,11 @@ class CachedArtifacts extends Artifacts { case Artifact.engineDartBinary: return fs.path.join(dartSdkPath, 'bin', _artifactToFileName(artifact)); case Artifact.platformKernelDill: - return fs.path.join(_getFlutterPatchedSdkPath(), _artifactToFileName(artifact)); + return fs.path.join(_getFlutterPatchedSdkPath(mode), _artifactToFileName(artifact)); case Artifact.platformLibrariesJson: - return fs.path.join(_getFlutterPatchedSdkPath(), 'lib', _artifactToFileName(artifact)); + return fs.path.join(_getFlutterPatchedSdkPath(mode), 'lib', _artifactToFileName(artifact)); case Artifact.flutterPatchedSdkPath: - return _getFlutterPatchedSdkPath(); + return _getFlutterPatchedSdkPath(mode); case Artifact.flutterWebSdk: return _getFlutterWebSdkPath(); case Artifact.dart2jsSnapshot: @@ -262,7 +263,7 @@ class LocalEngineArtifacts extends Artifacts { String _hostEngineOutPath; @override - String getArtifactPath(Artifact artifact, [ TargetPlatform platform, BuildMode mode ]) { + String getArtifactPath(Artifact artifact, { TargetPlatform platform, BuildMode mode }) { switch (artifact) { case Artifact.snapshotDart: return fs.path.join(_engineSrcPath, 'flutter', 'lib', 'snapshot', _artifactToFileName(artifact)); @@ -274,13 +275,17 @@ class LocalEngineArtifacts extends Artifacts { case Artifact.vmSnapshotData: return fs.path.join(engineOutPath, 'gen', 'flutter', 'lib', 'snapshot', _artifactToFileName(artifact)); case Artifact.platformKernelDill: - return fs.path.join(_getFlutterPatchedSdkPath(), _artifactToFileName(artifact)); + return fs.path.join(_getFlutterPatchedSdkPath(mode), _artifactToFileName(artifact)); case Artifact.platformLibrariesJson: - return fs.path.join(_getFlutterPatchedSdkPath(), 'lib', _artifactToFileName(artifact)); + return fs.path.join(_getFlutterPatchedSdkPath(mode), 'lib', _artifactToFileName(artifact)); case Artifact.flutterFramework: return fs.path.join(engineOutPath, _artifactToFileName(artifact)); case Artifact.flutterPatchedSdkPath: - return _getFlutterPatchedSdkPath(); + // When using local engine always use [BuildMode.debug] regardless of + // what was specified in [mode] argument because local engine will + // have only one flutter_patched_sdk in standard location, that + // is happen to be what debug(non-release) mode is using. + return _getFlutterPatchedSdkPath(BuildMode.debug); case Artifact.flutterWebSdk: return _getFlutterWebSdkPath(); case Artifact.frontendServerSnapshotForEngineDartSdk: @@ -303,8 +308,9 @@ class LocalEngineArtifacts extends Artifacts { return fs.path.basename(engineOutPath); } - String _getFlutterPatchedSdkPath() { - return fs.path.join(engineOutPath, 'flutter_patched_sdk'); + String _getFlutterPatchedSdkPath(BuildMode buildMode) { + return fs.path.join(engineOutPath, + buildMode == BuildMode.release ? 'flutter_patched_sdk_product' : 'flutter_patched_sdk'); } String _getFlutterWebSdkPath() { @@ -356,7 +362,7 @@ class OverrideArtifacts implements Artifacts { final File flutterPatchedSdk; @override - String getArtifactPath(Artifact artifact, [ TargetPlatform platform, BuildMode mode ]) { + String getArtifactPath(Artifact artifact, { TargetPlatform platform, BuildMode mode }) { if (artifact == Artifact.frontendServerSnapshotForEngineDartSdk && frontendServer != null) { return frontendServer.path; } @@ -369,7 +375,7 @@ class OverrideArtifacts implements Artifacts { if (artifact == Artifact.flutterPatchedSdkPath && flutterPatchedSdk != null) { return flutterPatchedSdk.path; } - return parent.getArtifactPath(artifact, platform, mode); + return parent.getArtifactPath(artifact, platform: platform, mode: mode); } @override diff --git a/packages/flutter_tools/lib/src/asset.dart b/packages/flutter_tools/lib/src/asset.dart index e845551842..e1e16e41af 100644 --- a/packages/flutter_tools/lib/src/asset.dart +++ b/packages/flutter_tools/lib/src/asset.dart @@ -63,6 +63,10 @@ class _ManifestAssetBundle implements AssetBundle { @override final Map entries = {}; + // If an asset corresponds to a wildcard directory, then it may have been + // updated without changes to the manifest. + final Map _wildcardDirectories = {}; + DateTime _lastBuildTimestamp; static const String defaultManifestPath = 'pubspec.yaml'; @@ -83,6 +87,16 @@ class _ManifestAssetBundle implements AssetBundle { if (stat.type == FileSystemEntityType.notFound) return true; + for (Directory directory in _wildcardDirectories.values) { + final DateTime dateTime = directory.statSync().modified; + if (dateTime == null) { + continue; + } + if (dateTime.isAfter(_lastBuildTimestamp)) { + return true; + } + } + return stat.modified.isAfter(_lastBuildTimestamp); } @@ -119,6 +133,7 @@ class _ManifestAssetBundle implements AssetBundle { final String assetBasePath = fs.path.dirname(fs.path.absolute(manifestPath)); final PackageMap packageMap = PackageMap(packagesPath); + final List wildcardDirectories = []; // The _assetVariants map contains an entry for each asset listed // in the pubspec.yaml file's assets and font and sections. The @@ -127,12 +142,14 @@ class _ManifestAssetBundle implements AssetBundle { final Map<_Asset, List<_Asset>> assetVariants = _parseAssets( packageMap, flutterManifest, + wildcardDirectories, assetBasePath, excludeDirs: [assetDirPath, getBuildDirectory()], ); - if (assetVariants == null) + if (assetVariants == null) { return 1; + } final List> fonts = _parseFonts( flutterManifest, @@ -156,6 +173,7 @@ class _ManifestAssetBundle implements AssetBundle { final Map<_Asset, List<_Asset>> packageAssets = _parseAssets( packageMap, packageFlutterManifest, + wildcardDirectories, packageBasePath, packageName: packageName, ); @@ -206,6 +224,11 @@ class _ManifestAssetBundle implements AssetBundle { entries[asset.entryUri.path] ??= DevFSFileContent(asset.assetFile); } + // Update wildcard directories we we can detect changes in them. + for (Uri uri in wildcardDirectories) { + _wildcardDirectories[uri] ??= fs.directory(uri); + } + entries[_assetManifestJson] = _createAssetManifest(assetVariants); entries[_fontManifestJson] = DevFSStringContent(json.encode(fonts)); @@ -524,6 +547,7 @@ class _AssetDirectoryCache { Map<_Asset, List<_Asset>> _parseAssets( PackageMap packageMap, FlutterManifest flutterManifest, + List wildcardDirectories, String assetBase, { List excludeDirs = const [], String packageName, @@ -533,6 +557,7 @@ Map<_Asset, List<_Asset>> _parseAssets( final _AssetDirectoryCache cache = _AssetDirectoryCache(excludeDirs); for (Uri assetUri in flutterManifest.assets) { if (assetUri.toString().endsWith('/')) { + wildcardDirectories.add(assetUri); _parseAssetsFromFolder(packageMap, flutterManifest, assetBase, cache, result, assetUri, excludeDirs: excludeDirs, packageName: packageName); diff --git a/packages/flutter_tools/lib/src/base/build.dart b/packages/flutter_tools/lib/src/base/build.dart index d7c406d5df..578c82ee92 100644 --- a/packages/flutter_tools/lib/src/base/build.dart +++ b/packages/flutter_tools/lib/src/base/build.dart @@ -43,7 +43,7 @@ class GenSnapshot { static String getSnapshotterPath(SnapshotType snapshotType) { return artifacts.getArtifactPath( - Artifact.genSnapshot, snapshotType.platform, snapshotType.mode); + Artifact.genSnapshot, platform: snapshotType.platform, mode: snapshotType.mode); } Future run({ @@ -70,6 +70,13 @@ class GenSnapshot { } class AOTSnapshotter { + AOTSnapshotter({this.reportTimings = false}); + + /// If true then AOTSnapshotter would report timings for individual building + /// steps (Dart front-end parsing and snapshot generation) in a stable + /// machine readable form. See [AOTSnapshotter._timedStep]. + final bool reportTimings; + /// Builds an architecture-specific ahead-of-time compiled snapshot of the specified script. Future build({ @required TargetPlatform platform, @@ -85,7 +92,6 @@ class AOTSnapshotter { if (fs.file('pubspec.yaml').existsSync()) { flutterProject = await FlutterProject.current(); } - final FlutterEngine engine = FlutterEngine(cache); if (!_isValidAotPlatform(platform, buildMode)) { printError('${getNameForTargetPlatform(platform)} does not support AOT compilation.'); return 1; @@ -187,7 +193,7 @@ class AOTSnapshotter { 'entryPoint': mainPath, 'sharedLib': buildSharedLibrary.toString(), 'extraGenSnapshotOptions': extraGenSnapshotOptions.join(' '), - 'engineHash': engine.version, + 'engineHash': Cache.instance.engineRevision, 'buildersUsed': '${flutterProject != null ? flutterProject.hasBuilders : false}', }, depfilePaths: [], @@ -198,11 +204,11 @@ class AOTSnapshotter { } final SnapshotType snapshotType = SnapshotType(platform, buildMode); - final int genSnapshotExitCode = await genSnapshot.run( + final int genSnapshotExitCode = await _timedStep('gen_snapshot', () => genSnapshot.run( snapshotType: snapshotType, additionalArgs: genSnapshotArgs, iosArch: iosArch, - ); + )); if (genSnapshotExitCode != 0) { printError('Dart snapshot generator failed with exit code $genSnapshotExitCode'); return genSnapshotExitCode; @@ -310,8 +316,8 @@ class AOTSnapshotter { final String depfilePath = fs.path.join(outputPath, 'kernel_compile.d'); final KernelCompiler kernelCompiler = await kernelCompilerFactory.create(flutterProject); - final CompilerOutput compilerOutput = await kernelCompiler.compile( - sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), + final CompilerOutput compilerOutput = await _timedStep('frontend', () => kernelCompiler.compile( + sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath, mode: buildMode), mainPath: mainPath, packagesPath: packagesPath, outputFilePath: getKernelPathForTransformerOptions( @@ -324,7 +330,7 @@ class AOTSnapshotter { aot: true, trackWidgetCreation: trackWidgetCreation, targetProductVm: buildMode == BuildMode.release, - ); + )); // Write path to frontend_server, since things need to be re-generated when that changes. final String frontendPath = artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk); @@ -346,6 +352,20 @@ class AOTSnapshotter { String _getPackagePath(PackageMap packageMap, String package) { return fs.path.dirname(fs.path.fromUri(packageMap.map[package])); } + + /// This method is used to measure duration of an action and emit it into + /// verbose output from flutter_tool for other tools (e.g. benchmark runner) + /// to find. + /// Important: external performance tracking tools expect format of this + /// output to be stable. + Future _timedStep(String marker, FutureOr Function() action) async { + final Stopwatch sw = Stopwatch()..start(); + final T value = await action(); + if (reportTimings) { + printStatus('$marker(RunTime): ${sw.elapsedMilliseconds} ms.'); + } + return value; + } } class JITSnapshotter { @@ -371,8 +391,8 @@ class JITSnapshotter { final Directory outputDir = fs.directory(outputPath); outputDir.createSync(recursive: true); - final String engineVmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData, null, buildMode); - final String engineIsolateSnapshotData = artifacts.getArtifactPath(Artifact.isolateSnapshotData, null, buildMode); + final String engineVmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData, mode: buildMode); + final String engineIsolateSnapshotData = artifacts.getArtifactPath(Artifact.isolateSnapshotData, mode: buildMode); final String isolateSnapshotData = fs.path.join(outputDir.path, 'isolate_snapshot_data'); final String isolateSnapshotInstructions = fs.path.join(outputDir.path, 'isolate_snapshot_instr'); diff --git a/packages/flutter_tools/lib/src/base/io.dart b/packages/flutter_tools/lib/src/base/io.dart index 862f43b943..1c9761ef16 100644 --- a/packages/flutter_tools/lib/src/base/io.dart +++ b/packages/flutter_tools/lib/src/base/io.dart @@ -37,6 +37,7 @@ import 'process.dart'; export 'dart:io' show BytesBuilder, + CompressionOptions, // Directory NO! Use `file_system.dart` exitCode, // File NO! Use `file_system.dart` diff --git a/packages/flutter_tools/lib/src/base/logger.dart b/packages/flutter_tools/lib/src/base/logger.dart index 97110d1e23..b1402d2b4e 100644 --- a/packages/flutter_tools/lib/src/base/logger.dart +++ b/packages/flutter_tools/lib/src/base/logger.dart @@ -13,8 +13,29 @@ import 'terminal.dart'; import 'utils.dart'; const int kDefaultStatusPadding = 59; -const Duration kFastOperation = Duration(seconds: 2); -const Duration kSlowOperation = Duration(minutes: 2); +const Duration _kFastOperation = Duration(seconds: 2); +const Duration _kSlowOperation = Duration(minutes: 2); + +/// The [TimeoutConfiguration] instance. +/// +/// If not provided via injection, a default instance is provided. +TimeoutConfiguration get timeoutConfiguration => context[TimeoutConfiguration] ?? const TimeoutConfiguration(); + +class TimeoutConfiguration { + const TimeoutConfiguration(); + + /// The expected time that various "slow" operations take, such as running + /// the analyzer. + /// + /// Defaults to 2 minutes. + Duration get slowOperation => _kSlowOperation; + + /// The expected time that various "fast" operations take, such as a hot + /// reload. + /// + /// Defaults to 2 seconds. + Duration get fastOperation => _kFastOperation; +} typedef VoidCallback = void Function(); @@ -375,7 +396,7 @@ class VerboseLogger extends Logger { timeout: timeout, onFinish: () { String time; - if (timeout == null || timeout > kFastOperation) { + if (timeout == null || timeout > timeoutConfiguration.fastOperation) { time = getElapsedAsSeconds(timer.elapsed); } else { time = getElapsedAsMilliseconds(timer.elapsed); @@ -473,7 +494,7 @@ abstract class Status { @protected String get elapsedTime { - if (timeout == null || timeout > kFastOperation) + if (timeout == null || timeout > timeoutConfiguration.fastOperation) return getElapsedAsSeconds(_stopwatch.elapsed); return getElapsedAsMilliseconds(_stopwatch.elapsed); } @@ -599,6 +620,8 @@ class AnsiSpinner extends Status { final String _backspaceChar = '\b'; final String _clearChar = ' '; + bool timedOut = false; + int ticks = 0; Timer timer; @@ -639,15 +662,19 @@ class AnsiSpinner extends Status { assert(timer.isActive); stdout.write(_backspace); ticks += 1; - stdout.write('${_clearChar * spinnerIndent}$_currentAnimationFrame'); if (seemsSlow) { + if (!timedOut) { + timedOut = true; + stdout.write('$_clear\n'); + } if (slowWarningCallback != null) { - _slowWarning = ' ' + slowWarningCallback(); + _slowWarning = slowWarningCallback(); } else { - _slowWarning = ' ' + _defaultSlowWarning; + _slowWarning = _defaultSlowWarning; } stdout.write(_slowWarning); } + stdout.write('${_clearChar * spinnerIndent}$_currentAnimationFrame'); } @override diff --git a/packages/flutter_tools/lib/src/base/user_messages.dart b/packages/flutter_tools/lib/src/base/user_messages.dart index 17824382fb..104d364b24 100644 --- a/packages/flutter_tools/lib/src/base/user_messages.dart +++ b/packages/flutter_tools/lib/src/base/user_messages.dart @@ -23,7 +23,7 @@ class UserMessages { String get flutterBinariesLinuxRepairCommands => 'On Debian/Ubuntu/Mint: sudo apt-get install lib32stdc++6\n' 'On Fedora: dnf install libstdc++.i686\n' - 'On Arch: pacman -S lib32-libstdc++5 (you need to enable multilib: https://wiki.archlinux.org/index.php/Official_repositories#multilib)'; + 'On Arch: pacman -S lib32-gcc-libs'; // Messages used in NoIdeValidator String get noIdeStatusInfo => 'No supported IDEs installed'; @@ -33,7 +33,7 @@ class UserMessages { String intellijStatusInfo(String version) => 'version $version'; String get intellijPluginInfo => 'For information about installing plugins, see\n' - 'https://flutter.io/intellij-setup/#installing-the-plugins'; + 'https://flutter.dev/intellij-setup/#installing-the-plugins'; String intellijMinimumVersion(String minVersion) => 'This install is older than the minimum recommended version of $minVersion.'; String intellijLocation(String installPath) => 'IntelliJ at $installPath'; @@ -65,7 +65,7 @@ class UserMessages { 'Unable to locate Android SDK.\n' 'Install Android Studio from: https://developer.android.com/studio/index.html\n' 'On first launch it will assist you in installing the Android SDK components.\n' - '(or visit https://flutter.io/setup/#android-setup for detailed instructions).\n' + '(or visit https://flutter.dev/setup/#android-setup for detailed instructions).\n' 'If the Android SDK has been installed to a custom location, set $envKey to that location.\n' 'You may also want to add it to your PATH environment variable.\n'; String androidSdkLocation(String directory) => 'Android SDK at $directory'; @@ -73,7 +73,7 @@ class UserMessages { 'Platform $platform, build-tools $tools'; String get androidSdkInstallHelp => 'Try re-installing or updating your Android SDK,\n' - 'visit https://flutter.io/setup/#android-setup for detailed instructions.'; + 'visit https://flutter.dev/setup/#android-setup for detailed instructions.'; String get androidMissingNdk => 'Android NDK location not configured (optional; useful for native profiling support)'; String androidNdkLocation(String directory) => 'Android NDK at $directory'; // Also occurs in AndroidLicenseValidator @@ -92,7 +92,7 @@ class UserMessages { 'Android license status unknown.\n' 'Try re-installing or updating your Android SDK Manager.\n' 'See https://developer.android.com/studio/#downloads or visit ' - 'https://flutter.io/setup/#android-setup for detailed instructions.'; + 'https://flutter.dev/setup/#android-setup for detailed instructions.'; String androidSdkManagerOutdated(String managerPath) => 'A newer version of the Android SDK is required. To update, run:\n' '$managerPath --update\n'; @@ -101,12 +101,12 @@ class UserMessages { String androidMissingSdkManager(String sdkManagerPath) => 'Android sdkmanager tool not found ($sdkManagerPath).\n' 'Try re-installing or updating your Android SDK,\n' - 'visit https://flutter.io/setup/#android-setup for detailed instructions.'; + 'visit https://flutter.dev/setup/#android-setup for detailed instructions.'; String androidSdkBuildToolsOutdated(String managerPath, int sdkMinVersion, String buildToolsMinVersion) => 'Flutter requires Android SDK $sdkMinVersion and the Android BuildTools $buildToolsMinVersion\n' 'To update using sdkmanager, run:\n' ' "$managerPath" "platforms;android-$sdkMinVersion" "build-tools;$buildToolsMinVersion"\n' - 'or visit https://flutter.io/setup/#android-setup for detailed instructions.'; + 'or visit https://flutter.dev/setup/#android-setup for detailed instructions.'; // Messages used in AndroidStudioValidator String androidStudioVersion(String version) => 'version $version'; @@ -124,7 +124,7 @@ class UserMessages { 'but Android Studio not found at this location.'; String get androidStudioInstallation => 'Android Studio not found; download from https://developer.android.com/studio/index.html\n' - '(or visit https://flutter.io/setup/#android-setup for detailed instructions).'; + '(or visit https://flutter.dev/setup/#android-setup for detailed instructions).'; // Messages used in IOSValidator String iOSXcodeLocation(String location) => 'Xcode at $location'; diff --git a/packages/flutter_tools/lib/src/build_runner/build_runner.dart b/packages/flutter_tools/lib/src/build_runner/build_runner.dart index c4dddce613..27a9922d35 100644 --- a/packages/flutter_tools/lib/src/build_runner/build_runner.dart +++ b/packages/flutter_tools/lib/src/build_runner/build_runner.dart @@ -21,7 +21,6 @@ import '../base/logger.dart'; import '../base/platform.dart'; import '../base/process_manager.dart'; import '../codegen.dart'; -import '../dart/package_map.dart'; import '../dart/pub.dart'; import '../globals.dart'; import '../project.dart'; @@ -128,7 +127,6 @@ class BuildRunner extends CodeGenerator { List extraFrontEndOptions = const [], }) async { await generateBuildScript(flutterProject); - _generatePackages(flutterProject); final String engineDartBinaryPath = artifacts.getArtifactPath(Artifact.engineDartBinary); final File buildSnapshot = flutterProject .dartTool @@ -160,18 +158,6 @@ class BuildRunner extends CodeGenerator { })); return _BuildRunnerCodegenDaemon(buildDaemonClient); } - - // Create generated packages file which adds a multi-root scheme to the user's - // project directory. Currently we only replace the root package with a multiroot - // scheme. To support codegen on arbitrary packages we would need to do - // this for each dependency. - void _generatePackages(FlutterProject flutterProject) { - final String oldPackagesContents = fs.file(PackageMap.globalPackagesPath).readAsStringSync(); - final String appName = flutterProject.manifest.appName; - final String newPackagesContents = oldPackagesContents.replaceFirst('$appName:lib/', '$appName:$kMultiRootScheme:/'); - final String generatedPackagesPath = fs.path.setExtension(PackageMap.globalPackagesPath, '.generated'); - fs.file(generatedPackagesPath).writeAsStringSync(newPackagesContents); - } } class _BuildRunnerCodegenDaemon implements CodegenDaemon { diff --git a/packages/flutter_tools/lib/src/bundle.dart b/packages/flutter_tools/lib/src/bundle.dart index 8cff1b20a2..7e2fe447e5 100644 --- a/packages/flutter_tools/lib/src/bundle.dart +++ b/packages/flutter_tools/lib/src/bundle.dart @@ -103,7 +103,7 @@ Future build({ ensureDirectoryExists(applicationKernelFilePath); final KernelCompiler kernelCompiler = await kernelCompilerFactory.create(flutterProject); final CompilerOutput compilerOutput = await kernelCompiler.compile( - sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), + sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath, mode: buildMode), incrementalCompilerByteStorePath: compilationTraceFilePath != null ? null : fs.path.absolute(getIncrementalCompilerByteStoreDirectory()), mainPath: fs.file(mainPath).absolute.path, @@ -202,15 +202,15 @@ Future assemble({ final Map assetEntries = Map.from(assetBundle.entries); if (kernelContent != null) { if (compilationTraceFilePath != null) { - final String vmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData, null, buildMode); + final String vmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData, mode: buildMode); final String isolateSnapshotData = fs.path.join(getBuildDirectory(), _kIsolateSnapshotData); final String isolateSnapshotInstr = fs.path.join(getBuildDirectory(), _kIsolateSnapshotInstr); assetEntries[_kVMSnapshotData] = DevFSFileContent(fs.file(vmSnapshotData)); assetEntries[_kIsolateSnapshotData] = DevFSFileContent(fs.file(isolateSnapshotData)); assetEntries[_kIsolateSnapshotInstr] = DevFSFileContent(fs.file(isolateSnapshotInstr)); } else { - final String vmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData, null, buildMode); - final String isolateSnapshotData = artifacts.getArtifactPath(Artifact.isolateSnapshotData, null, buildMode); + final String vmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData, mode: buildMode); + final String isolateSnapshotData = artifacts.getArtifactPath(Artifact.isolateSnapshotData, mode: buildMode); assetEntries[_kKernelKey] = kernelContent; assetEntries[_kVMSnapshotData] = DevFSFileContent(fs.file(vmSnapshotData)); assetEntries[_kIsolateSnapshotData] = DevFSFileContent(fs.file(isolateSnapshotData)); diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart index 618b55c95d..dcfe070c45 100644 --- a/packages/flutter_tools/lib/src/cache.dart +++ b/packages/flutter_tools/lib/src/cache.dart @@ -15,6 +15,30 @@ import 'base/os.dart'; import 'base/platform.dart'; import 'globals.dart'; +/// A tag for a set of development artifacts that need to be cached. +enum DevelopmentArtifact { + /// Artifacts required for Android development. + android, + + /// Artifacts required for iOS development. + iOS, + + /// Artifacts required for web development, + web, + + /// Artifacts required for desktop macOS. + macOS, + + /// Artifacts required for desktop Windows. + windows, + + /// Artifacts required for desktop linux. + linux, + + /// Artifacts required by all developments. + universal, +} + /// A wrapper around the `bin/cache/` directory. class Cache { /// [rootOverride] is configurable for testing. @@ -22,9 +46,14 @@ class Cache { Cache({ Directory rootOverride, List artifacts }) : _rootOverride = rootOverride { if (artifacts == null) { _artifacts.add(MaterialFonts(this)); - _artifacts.add(FlutterEngine(this)); + _artifacts.add(AndroidEngineArtifacts(this)); + _artifacts.add(IOSEngineArtifacts(this)); _artifacts.add(GradleWrapper(this)); _artifacts.add(FlutterWebSdk(this)); + _artifacts.add(FlutterSdk(this)); + _artifacts.add(WindowsEngineArtifacts(this)); + _artifacts.add(MacOSEngineArtifacts(this)); + _artifacts.add(LinuxEngineArtifacts(this)); } else { _artifacts.addAll(artifacts); } @@ -217,35 +246,61 @@ class Cache { return cachedFile.path; } - Future updateAll() async { - if (!_lockEnabled) + /// Update the cache to contain all `requiredArtifacts`. + Future updateAll(Set requiredArtifacts) async { + if (!_lockEnabled) { return; + } try { for (CachedArtifact artifact in _artifacts) { - if (!artifact.isUpToDate()) - await artifact.update(); + if (!artifact.isUpToDate()) { + await artifact.update(requiredArtifacts); + } } } on SocketException catch (e) { if (_hostsBlockedInChina.contains(e.address?.host)) { printError( 'Failed to retrieve Flutter tool dependencies: ${e.message}.\n' 'If you\'re in China, please see this page: ' - 'https://flutter.io/community/china', + 'https://flutter.dev/community/china', emphasis: true, ); } rethrow; } } + + Future areRemoteArtifactsAvailable({ + String engineVersion, + bool includeAllPlatforms = true, + }) async { + final bool includeAllPlatformsState = cache.includeAllPlatforms; + bool allAvailible = true; + cache.includeAllPlatforms = includeAllPlatforms; + for (CachedArtifact cachedArtifact in _artifacts) { + if (cachedArtifact is EngineCachedArtifact) { + allAvailible &= await cachedArtifact.checkForArtifacts(engineVersion); + } + } + cache.includeAllPlatforms = includeAllPlatformsState; + return allAvailible; + } } /// An artifact managed by the cache. abstract class CachedArtifact { - CachedArtifact(this.name, this.cache); + CachedArtifact(this.name, this.cache, this.developmentArtifacts); final String name; final Cache cache; + // The name of the stamp file. Defaults to the same as the + // artifact name. + String get stampName => name; + + /// All development artifacts this cache provides. + final Set developmentArtifacts; + Directory get location => cache.getArtifactDirectory(name); String get version => cache.getVersionFor(name); @@ -256,19 +311,27 @@ abstract class CachedArtifact { final List _downloadedFiles = []; bool isUpToDate() { - if (!location.existsSync()) + if (!location.existsSync()) { return false; - if (version != cache.getStampFor(name)) + } + if (version != cache.getStampFor(stampName)) { return false; + } return isUpToDateInner(); } - Future update() async { - if (location.existsSync()) - location.deleteSync(recursive: true); - location.createSync(recursive: true); + Future update(Set requiredArtifacts) async { + // If the set of required artifacts does not include any from this cache, + // then we can claim we are up to date to skip downloading. + if (!requiredArtifacts.any(developmentArtifacts.contains)) { + printTrace('Artifact $this is not required, skipping update.'); + return; + } + if (!location.existsSync()) { + location.createSync(recursive: true); + } await updateInner(); - cache.setStampFor(name, version); + cache.setStampFor(stampName, version); _removeDownloadedFiles(); } @@ -306,7 +369,7 @@ abstract class CachedArtifact { Future _downloadArchive(String message, Uri url, Directory location, bool verifier(File f), void extractor(File f, Directory d)) { return _withDownloadFile('${flattenNameSubdirs(url)}', (File tempFile) async { if (!verifier(tempFile)) { - final Status status = logger.startProgress(message, timeout: kSlowOperation); + final Status status = logger.startProgress(message, timeout: timeoutConfiguration.slowOperation); try { await _downloadFile(url, tempFile); status.stop(); @@ -355,7 +418,11 @@ void _maybeWarnAboutStorageOverride(String overrideUrl) { /// A cached artifact containing fonts used for Material Design. class MaterialFonts extends CachedArtifact { - MaterialFonts(Cache cache) : super('material_fonts', cache); + MaterialFonts(Cache cache) : super( + 'material_fonts', + cache, + const { DevelopmentArtifact.universal }, + ); @override Future updateInner() { @@ -369,7 +436,11 @@ class MaterialFonts extends CachedArtifact { /// /// This SDK references code within the regular Dart sdk to reduce download size. class FlutterWebSdk extends CachedArtifact { - FlutterWebSdk(Cache cache) : super('flutter_web_sdk', cache); + FlutterWebSdk(Cache cache) : super( + 'flutter_web_sdk', + cache, + const { DevelopmentArtifact.web }, + ); @override Directory get location => cache.getWebSdkDirectory(); @@ -405,133 +476,47 @@ class FlutterWebSdk extends CachedArtifact { } } -/// A cached artifact containing the Flutter engine binaries. -class FlutterEngine extends CachedArtifact { - FlutterEngine(Cache cache) : super('engine', cache); +abstract class EngineCachedArtifact extends CachedArtifact { + EngineCachedArtifact( + this.stampName, + Cache cache, + Set requiredArtifacts, + ) : super('engine', cache, requiredArtifacts); - List _getPackageDirs() => const ['sky_engine']; + @override + final String stampName; - // Return a list of (cache directory path, download URL path) tuples. - List> _getBinaryDirs() { - final List> binaryDirs = >[]; + /// Return a list of (directory path, download URL path) tuples. + List> getBinaryDirs(); - binaryDirs.add(['common', 'flutter_patched_sdk.zip']); + /// A list of cache directory paths to which the LICENSE file should be copied. + List getLicenseDirs(); - if (cache.includeAllPlatforms) - binaryDirs - ..addAll(_osxBinaryDirs) - ..addAll(_linuxBinaryDirs) - ..addAll(_windowsBinaryDirs) - ..addAll(_androidBinaryDirs) - ..addAll(_iosBinaryDirs) - ..addAll(_dartSdks); - else if (platform.isLinux) - binaryDirs - ..addAll(_linuxBinaryDirs) - ..addAll(_androidBinaryDirs); - else if (platform.isMacOS) - binaryDirs - ..addAll(_osxBinaryDirs) - ..addAll(_androidBinaryDirs) - ..addAll(_iosBinaryDirs); - else if (platform.isWindows) - binaryDirs - ..addAll(_windowsBinaryDirs) - ..addAll(_androidBinaryDirs); - - return binaryDirs; - } - - List> get _osxBinaryDirs => >[ - ['darwin-x64', 'darwin-x64/artifacts.zip'], - ['android-arm-profile/darwin-x64', 'android-arm-profile/darwin-x64.zip'], - ['android-arm-release/darwin-x64', 'android-arm-release/darwin-x64.zip'], - ['android-arm64-profile/darwin-x64', 'android-arm64-profile/darwin-x64.zip'], - ['android-arm64-release/darwin-x64', 'android-arm64-release/darwin-x64.zip'], - ['android-arm-dynamic-profile/darwin-x64', 'android-arm-dynamic-profile/darwin-x64.zip'], - ['android-arm-dynamic-release/darwin-x64', 'android-arm-dynamic-release/darwin-x64.zip'], - ['android-arm64-dynamic-profile/darwin-x64', 'android-arm64-dynamic-profile/darwin-x64.zip'], - ['android-arm64-dynamic-release/darwin-x64', 'android-arm64-dynamic-release/darwin-x64.zip'], - ]; - - List> get _linuxBinaryDirs => >[ - ['linux-x64', 'linux-x64/artifacts.zip'], - ['android-arm-profile/linux-x64', 'android-arm-profile/linux-x64.zip'], - ['android-arm-release/linux-x64', 'android-arm-release/linux-x64.zip'], - ['android-arm64-profile/linux-x64', 'android-arm64-profile/linux-x64.zip'], - ['android-arm64-release/linux-x64', 'android-arm64-release/linux-x64.zip'], - ['android-arm-dynamic-profile/linux-x64', 'android-arm-dynamic-profile/linux-x64.zip'], - ['android-arm-dynamic-release/linux-x64', 'android-arm-dynamic-release/linux-x64.zip'], - ['android-arm64-dynamic-profile/linux-x64', 'android-arm64-dynamic-profile/linux-x64.zip'], - ['android-arm64-dynamic-release/linux-x64', 'android-arm64-dynamic-release/linux-x64.zip'], - ]; - - List> get _windowsBinaryDirs => >[ - ['windows-x64', 'windows-x64/artifacts.zip'], - ['android-arm-profile/windows-x64', 'android-arm-profile/windows-x64.zip'], - ['android-arm-release/windows-x64', 'android-arm-release/windows-x64.zip'], - ['android-arm64-profile/windows-x64', 'android-arm64-profile/windows-x64.zip'], - ['android-arm64-release/windows-x64', 'android-arm64-release/windows-x64.zip'], - ['android-arm-dynamic-profile/windows-x64', 'android-arm-dynamic-profile/windows-x64.zip'], - ['android-arm-dynamic-release/windows-x64', 'android-arm-dynamic-release/windows-x64.zip'], - ['android-arm64-dynamic-profile/windows-x64', 'android-arm64-dynamic-profile/windows-x64.zip'], - ['android-arm64-dynamic-release/windows-x64', 'android-arm64-dynamic-release/windows-x64.zip'], - ]; - - List> get _androidBinaryDirs => >[ - ['android-x86', 'android-x86/artifacts.zip'], - ['android-x64', 'android-x64/artifacts.zip'], - ['android-arm', 'android-arm/artifacts.zip'], - ['android-arm-profile', 'android-arm-profile/artifacts.zip'], - ['android-arm-release', 'android-arm-release/artifacts.zip'], - ['android-arm64', 'android-arm64/artifacts.zip'], - ['android-arm64-profile', 'android-arm64-profile/artifacts.zip'], - ['android-arm64-release', 'android-arm64-release/artifacts.zip'], - ['android-arm-dynamic-profile', 'android-arm-dynamic-profile/artifacts.zip'], - ['android-arm-dynamic-release', 'android-arm-dynamic-release/artifacts.zip'], - ['android-arm64-dynamic-profile', 'android-arm64-dynamic-profile/artifacts.zip'], - ['android-arm64-dynamic-release', 'android-arm64-dynamic-release/artifacts.zip'], - ]; - - List> get _iosBinaryDirs => >[ - ['ios', 'ios/artifacts.zip'], - ['ios-profile', 'ios-profile/artifacts.zip'], - ['ios-release', 'ios-release/artifacts.zip'], - ]; - - List> get _dartSdks => > [ - ['darwin-x64', 'dart-sdk-darwin-x64.zip'], - ['linux-x64', 'dart-sdk-linux-x64.zip'], - ['windows-x64', 'dart-sdk-windows-x64.zip'], - ]; - - // A list of cache directory paths to which the LICENSE file should be copied. - List _getLicenseDirs() { - if (cache.includeAllPlatforms || platform.isMacOS) { - return const ['ios', 'ios-profile', 'ios-release']; - } - return const []; - } + /// A list of the dart package directories to download. + List getPackageDirs(); @override bool isUpToDateInner() { final Directory pkgDir = cache.getCacheDir('pkg'); - for (String pkgName in _getPackageDirs()) { + for (String pkgName in getPackageDirs()) { final String pkgPath = fs.path.join(pkgDir.path, pkgName); - if (!fs.directory(pkgPath).existsSync()) + if (!fs.directory(pkgPath).existsSync()) { return false; + } } - for (List toolsDir in _getBinaryDirs()) { + for (List toolsDir in getBinaryDirs()) { final Directory dir = fs.directory(fs.path.join(location.path, toolsDir[0])); - if (!dir.existsSync()) + if (!dir.existsSync()) { return false; + } } - for (String licenseDir in _getLicenseDirs()) { + for (String licenseDir in getLicenseDirs()) { final File file = fs.file(fs.path.join(location.path, licenseDir, 'LICENSE')); - if (!file.existsSync()) + if (!file.existsSync()) { return false; + } } return true; } @@ -541,15 +526,11 @@ class FlutterEngine extends CachedArtifact { final String url = '$_storageBaseUrl/flutter_infra/flutter/$version/'; final Directory pkgDir = cache.getCacheDir('pkg'); - for (String pkgName in _getPackageDirs()) { - final String pkgPath = fs.path.join(pkgDir.path, pkgName); - final Directory dir = fs.directory(pkgPath); - if (dir.existsSync()) - dir.deleteSync(recursive: true); + for (String pkgName in getPackageDirs()) { await _downloadZipArchive('Downloading package $pkgName...', Uri.parse(url + pkgName + '.zip'), pkgDir); } - for (List toolsDir in _getBinaryDirs()) { + for (List toolsDir in getBinaryDirs()) { final String cacheDir = toolsDir[0]; final String urlPath = toolsDir[1]; final Directory dir = fs.directory(fs.path.join(location.path, cacheDir)); @@ -557,57 +538,47 @@ class FlutterEngine extends CachedArtifact { _makeFilesExecutable(dir); - final File frameworkZip = fs.file(fs.path.join(dir.path, 'Flutter.framework.zip')); - if (frameworkZip.existsSync()) { - final Directory framework = fs.directory(fs.path.join(dir.path, 'Flutter.framework')); - framework.createSync(); - os.unzip(frameworkZip, framework); + const List frameworkNames = ['Flutter', 'FlutterMacOS']; + for (String frameworkName in frameworkNames) { + final File frameworkZip = fs.file(fs.path.join(dir.path, '$frameworkName.framework.zip')); + if (frameworkZip.existsSync()) { + final Directory framework = fs.directory(fs.path.join(dir.path, '$frameworkName.framework')); + framework.createSync(); + os.unzip(frameworkZip, framework); + } } } final File licenseSource = fs.file(fs.path.join(Cache.flutterRoot, 'LICENSE')); - for (String licenseDir in _getLicenseDirs()) { + for (String licenseDir in getLicenseDirs()) { final String licenseDestinationPath = fs.path.join(location.path, licenseDir, 'LICENSE'); await licenseSource.copy(licenseDestinationPath); } } - Future areRemoteArtifactsAvailable({ - String engineVersion, - bool includeAllPlatforms = true, - }) async { - final bool includeAllPlatformsState = cache.includeAllPlatforms; - cache.includeAllPlatforms = includeAllPlatforms; + Future checkForArtifacts(String engineVersion) async { + engineVersion ??= version; + final String url = '$_storageBaseUrl/flutter_infra/flutter/$engineVersion/'; - Future checkForArtifacts(String engineVersion) async { - engineVersion ??= version; - final String url = '$_storageBaseUrl/flutter_infra/flutter/$engineVersion/'; - - bool exists = false; - for (String pkgName in _getPackageDirs()) { - exists = await _doesRemoteExist('Checking package $pkgName is available...', - Uri.parse(url + pkgName + '.zip')); - if (!exists) { - return false; - } + bool exists = false; + for (String pkgName in getPackageDirs()) { + exists = await _doesRemoteExist('Checking package $pkgName is available...', + Uri.parse(url + pkgName + '.zip')); + if (!exists) { + return false; } - - for (List toolsDir in _getBinaryDirs()) { - final String cacheDir = toolsDir[0]; - final String urlPath = toolsDir[1]; - exists = await _doesRemoteExist('Checking $cacheDir tools are available...', - Uri.parse(url + urlPath)); - if (!exists) { - return false; - } - } - - return true; } - final bool result = await checkForArtifacts(engineVersion); - cache.includeAllPlatforms = includeAllPlatformsState; - return result; + for (List toolsDir in getBinaryDirs()) { + final String cacheDir = toolsDir[0]; + final String urlPath = toolsDir[1]; + exists = await _doesRemoteExist('Checking $cacheDir tools are available...', + Uri.parse(url + urlPath)); + if (!exists) { + return false; + } + } + return true; } @@ -622,9 +593,196 @@ class FlutterEngine extends CachedArtifact { } } + +/// A cached artifact containing the dart:ui source code. +class FlutterSdk extends EngineCachedArtifact { + FlutterSdk(Cache cache) : super( + 'flutter_sdk', + cache, + const { DevelopmentArtifact.universal }, + ); + + @override + List getPackageDirs() => const ['sky_engine']; + + @override + List> getBinaryDirs() { + final List> binaryDirs = >[ + ['common', 'flutter_patched_sdk.zip'], + ['common', 'flutter_patched_sdk_product.zip'], + ]; + if (cache.includeAllPlatforms) { + binaryDirs.addAll(>[ + ['windows-x64', 'windows-x64/artifacts.zip'], + ['linux-x64', 'linux-x64/artifacts.zip'], + ['darwin-x64', 'darwin-x64/artifacts.zip'], + ]); + } else if (platform.isWindows) { + binaryDirs.addAll(>[ + ['windows-x64', 'windows-x64/artifacts.zip'], + ]); + } else if (platform.isMacOS) { + binaryDirs.addAll(>[ + ['darwin-x64', 'darwin-x64/artifacts.zip'], + ]); + } else if (platform.isLinux) { + binaryDirs.addAll(>[ + ['linux-x64', 'linux-x64/artifacts.zip'], + ]); + } + return binaryDirs; + } + + @override + List getLicenseDirs() => const []; +} + +class MacOSEngineArtifacts extends EngineCachedArtifact { + MacOSEngineArtifacts(Cache cache) : super( + 'macos-sdk', + cache, + const { DevelopmentArtifact.macOS }, + ); + + @override + List getPackageDirs() => const []; + + @override + List> getBinaryDirs() { + if (platform.isMacOS) { + return _macOSDesktopBinaryDirs; + } + return const >[]; + } + + @override + List getLicenseDirs() => const []; +} + +class WindowsEngineArtifacts extends EngineCachedArtifact { + WindowsEngineArtifacts(Cache cache) : super( + 'windows-sdk', + cache, + const { DevelopmentArtifact.windows }, + ); + + @override + List getPackageDirs() => const []; + + @override + List> getBinaryDirs() { + if (platform.isWindows) { + return _windowsDesktopBinaryDirs; + } + return const >[]; + } + + @override + List getLicenseDirs() => const []; +} + +class LinuxEngineArtifacts extends EngineCachedArtifact { + LinuxEngineArtifacts(Cache cache) : super( + 'linux-sdk', + cache, + const { DevelopmentArtifact.linux }, + ); + + @override + List getPackageDirs() => const []; + + @override + List> getBinaryDirs() { + if (platform.isLinux) { + return _linuxDesktopBinaryDirs; + } + return const >[]; + } + + @override + List getLicenseDirs() => const []; +} + +class AndroidEngineArtifacts extends EngineCachedArtifact { + AndroidEngineArtifacts(Cache cache) : super( + 'android-sdk', + cache, + const { DevelopmentArtifact.android }, + ); + + @override + List getPackageDirs() => const []; + + @override + List> getBinaryDirs() { + final List> binaryDirs = >[]; + if (cache.includeAllPlatforms) { + binaryDirs + ..addAll(_osxBinaryDirs) + ..addAll(_linuxBinaryDirs) + ..addAll(_windowsBinaryDirs) + ..addAll(_androidBinaryDirs) + ..addAll(_dartSdks); + } else if (platform.isWindows) { + binaryDirs + ..addAll(_windowsBinaryDirs) + ..addAll(_androidBinaryDirs); + } else if (platform.isMacOS) { + binaryDirs + ..addAll(_osxBinaryDirs) + ..addAll(_androidBinaryDirs); + } else if (platform.isLinux) { + binaryDirs + ..addAll(_linuxBinaryDirs) + ..addAll(_androidBinaryDirs); + } + return binaryDirs; + } + + @override + List getLicenseDirs() { return []; } +} + +class IOSEngineArtifacts extends EngineCachedArtifact { + IOSEngineArtifacts(Cache cache) : super( + 'ios-sdk', + cache, + { DevelopmentArtifact.iOS }, + ); + + @override + List> getBinaryDirs() { + final List> binaryDirs = >[]; + if (platform.isMacOS || cache.includeAllPlatforms) { + binaryDirs.addAll(_iosBinaryDirs); + } + return binaryDirs; + } + + @override + List getLicenseDirs() { + if (cache.includeAllPlatforms || platform.isMacOS) { + return const ['ios', 'ios-profile', 'ios-release']; + } + return const []; + } + + @override + List getPackageDirs() { + return []; + } +} + /// A cached artifact containing Gradle Wrapper scripts and binaries. +/// +/// While this is only required for Android, we need to always download it due +/// the ensurePlatformSpecificTooling logic. class GradleWrapper extends CachedArtifact { - GradleWrapper(Cache cache) : super('gradle_wrapper', cache); + GradleWrapper(Cache cache) : super( + 'gradle_wrapper', + cache, + const { DevelopmentArtifact.universal }, + ); List get _gradleScripts => ['gradlew', 'gradlew.bat']; @@ -644,8 +802,9 @@ class GradleWrapper extends CachedArtifact { @override bool isUpToDateInner() { final Directory wrapperDir = cache.getCacheDir(fs.path.join('artifacts', 'gradle_wrapper')); - if (!fs.directory(wrapperDir).existsSync()) + if (!fs.directory(wrapperDir).existsSync()) { return false; + } for (String scriptName in _gradleScripts) { final File scriptFile = fs.file(fs.path.join(wrapperDir.path, scriptName)); if (!scriptFile.existsSync()) @@ -698,7 +857,7 @@ Future _downloadFile(Uri url, File location) async { } Future _doesRemoteExist(String message, Uri url) async { - final Status status = logger.startProgress(message, timeout: kSlowOperation); + final Status status = logger.startProgress(message, timeout: timeoutConfiguration.slowOperation); final bool exists = await doesRemoteFileExist(url); status.stop(); return exists; @@ -706,6 +865,81 @@ Future _doesRemoteExist(String message, Uri url) async { /// Create the given [directory] and parents, as necessary. void _ensureExists(Directory directory) { - if (!directory.existsSync()) + if (!directory.existsSync()) { directory.createSync(recursive: true); + } } + +const List> _windowsDesktopBinaryDirs = >[ + ['windows-x64', 'windows-x64/windows-x64-flutter.zip'], + ['windows-x64', 'windows-x64/flutter-cpp-client-wrapper.zip'], +]; + +const List> _linuxDesktopBinaryDirs = >[ + ['linux-x64', 'linux-x64/linux-x64-flutter.zip'], + ['linux-x64', 'linux-x64/flutter-cpp-client-wrapper.zip'], +]; + +const List> _macOSDesktopBinaryDirs = >[ + ['darwin-x64', 'darwin-x64/FlutterMacOS.framework.zip'], +]; + +const List> _osxBinaryDirs = >[ + ['android-arm-profile/darwin-x64', 'android-arm-profile/darwin-x64.zip'], + ['android-arm-release/darwin-x64', 'android-arm-release/darwin-x64.zip'], + ['android-arm64-profile/darwin-x64', 'android-arm64-profile/darwin-x64.zip'], + ['android-arm64-release/darwin-x64', 'android-arm64-release/darwin-x64.zip'], + ['android-arm-dynamic-profile/darwin-x64', 'android-arm-dynamic-profile/darwin-x64.zip'], + ['android-arm-dynamic-release/darwin-x64', 'android-arm-dynamic-release/darwin-x64.zip'], + ['android-arm64-dynamic-profile/darwin-x64', 'android-arm64-dynamic-profile/darwin-x64.zip'], + ['android-arm64-dynamic-release/darwin-x64', 'android-arm64-dynamic-release/darwin-x64.zip'], +]; + +const List> _linuxBinaryDirs = >[ + ['android-arm-profile/linux-x64', 'android-arm-profile/linux-x64.zip'], + ['android-arm-release/linux-x64', 'android-arm-release/linux-x64.zip'], + ['android-arm64-profile/linux-x64', 'android-arm64-profile/linux-x64.zip'], + ['android-arm64-release/linux-x64', 'android-arm64-release/linux-x64.zip'], + ['android-arm-dynamic-profile/linux-x64', 'android-arm-dynamic-profile/linux-x64.zip'], + ['android-arm-dynamic-release/linux-x64', 'android-arm-dynamic-release/linux-x64.zip'], + ['android-arm64-dynamic-profile/linux-x64', 'android-arm64-dynamic-profile/linux-x64.zip'], + ['android-arm64-dynamic-release/linux-x64', 'android-arm64-dynamic-release/linux-x64.zip'], +]; + +const List> _windowsBinaryDirs = >[ + ['android-arm-profile/windows-x64', 'android-arm-profile/windows-x64.zip'], + ['android-arm-release/windows-x64', 'android-arm-release/windows-x64.zip'], + ['android-arm64-profile/windows-x64', 'android-arm64-profile/windows-x64.zip'], + ['android-arm64-release/windows-x64', 'android-arm64-release/windows-x64.zip'], + ['android-arm-dynamic-profile/windows-x64', 'android-arm-dynamic-profile/windows-x64.zip'], + ['android-arm-dynamic-release/windows-x64', 'android-arm-dynamic-release/windows-x64.zip'], + ['android-arm64-dynamic-profile/windows-x64', 'android-arm64-dynamic-profile/windows-x64.zip'], + ['android-arm64-dynamic-release/windows-x64', 'android-arm64-dynamic-release/windows-x64.zip'], +]; + +const List> _androidBinaryDirs = >[ + ['android-x86', 'android-x86/artifacts.zip'], + ['android-x64', 'android-x64/artifacts.zip'], + ['android-arm', 'android-arm/artifacts.zip'], + ['android-arm-profile', 'android-arm-profile/artifacts.zip'], + ['android-arm-release', 'android-arm-release/artifacts.zip'], + ['android-arm64', 'android-arm64/artifacts.zip'], + ['android-arm64-profile', 'android-arm64-profile/artifacts.zip'], + ['android-arm64-release', 'android-arm64-release/artifacts.zip'], + ['android-arm-dynamic-profile', 'android-arm-dynamic-profile/artifacts.zip'], + ['android-arm-dynamic-release', 'android-arm-dynamic-release/artifacts.zip'], + ['android-arm64-dynamic-profile', 'android-arm64-dynamic-profile/artifacts.zip'], + ['android-arm64-dynamic-release', 'android-arm64-dynamic-release/artifacts.zip'], +]; + +const List> _iosBinaryDirs = >[ + ['ios', 'ios/artifacts.zip'], + ['ios-profile', 'ios-profile/artifacts.zip'], + ['ios-release', 'ios-release/artifacts.zip'], +]; + +const List> _dartSdks = > [ + ['darwin-x64', 'dart-sdk-darwin-x64.zip'], + ['linux-x64', 'dart-sdk-linux-x64.zip'], + ['windows-x64', 'dart-sdk-windows-x64.zip'], +]; diff --git a/packages/flutter_tools/lib/src/codegen.dart b/packages/flutter_tools/lib/src/codegen.dart index 808fdbca4a..c2503a04d9 100644 --- a/packages/flutter_tools/lib/src/codegen.dart +++ b/packages/flutter_tools/lib/src/codegen.dart @@ -41,6 +41,18 @@ abstract class CodeGenerator { // Generates a synthetic package under .dart_tool/flutter_tool which is in turn // used to generate a build script. Future generateBuildScript(FlutterProject flutterProject); + + /// Create generated packages file which adds a multi-root scheme to the user's + /// project directory. Currently we only replace the root package with a multiroot + /// scheme. To support codegen on arbitrary packages we would need to do + /// this for each dependency. + void updatePackages(FlutterProject flutterProject) { + final String oldPackagesContents = fs.file(PackageMap.globalPackagesPath).readAsStringSync(); + final String appName = flutterProject.manifest.appName; + final String newPackagesContents = oldPackagesContents.replaceFirst('$appName:lib/', '$appName:$kMultiRootScheme:/'); + final String generatedPackagesPath = fs.path.setExtension(PackageMap.globalPackagesPath, '.generated'); + fs.file(generatedPackagesPath).writeAsStringSync(newPackagesContents); + } } class UnsupportedCodeGenerator extends CodeGenerator { @@ -104,6 +116,7 @@ class CodeGeneratingKernelCompiler implements KernelCompiler { 'build* pipeline'); } final FlutterProject flutterProject = await FlutterProject.current(); + codeGenerator.updatePackages(flutterProject); final CodegenDaemon codegenDaemon = await codeGenerator.daemon(flutterProject); codegenDaemon.startBuild(); await for (CodegenStatus codegenStatus in codegenDaemon.buildResults) { @@ -141,7 +154,7 @@ class CodeGeneratingKernelCompiler implements KernelCompiler { /// An implementation of a [ResidentCompiler] which runs a [BuildRunner] before /// talking to the CFE. class CodeGeneratingResidentCompiler implements ResidentCompiler { - CodeGeneratingResidentCompiler._(this._residentCompiler, this._codegenDaemon); + CodeGeneratingResidentCompiler._(this._residentCompiler, this._codegenDaemon, this._flutterProject); /// Creates a new [ResidentCompiler] and configures a [BuildDaemonClient] to /// run builds. @@ -158,6 +171,7 @@ class CodeGeneratingResidentCompiler implements ResidentCompiler { String initializeFromDill, bool runCold = false, }) async { + codeGenerator.updatePackages(flutterProject); final ResidentCompiler residentCompiler = ResidentCompiler( artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), trackWidgetCreation: trackWidgetCreation, @@ -182,11 +196,12 @@ class CodeGeneratingResidentCompiler implements ResidentCompiler { if (status == CodegenStatus.Failed) { printError('Code generation failed, build may have compile errors.'); } - return CodeGeneratingResidentCompiler._(residentCompiler, codegenDaemon); + return CodeGeneratingResidentCompiler._(residentCompiler, codegenDaemon, flutterProject); } final ResidentCompiler _residentCompiler; final CodegenDaemon _codegenDaemon; + final FlutterProject _flutterProject; @override void accept() { @@ -206,7 +221,13 @@ class CodeGeneratingResidentCompiler implements ResidentCompiler { }); } if (_codegenDaemon.lastStatus == CodegenStatus.Failed) { - printError('Codegeneration failed, halting build.'); + printError('Code generation failed, build may have compile errors.'); + } + // Update the generated packages file if the original packages file has changes. + if (fs.statSync(PackageMap.globalPackagesPath).modified.millisecondsSinceEpoch > + fs.statSync(PackageMap.globalGeneratedPackagesPath).modified.millisecondsSinceEpoch) { + codeGenerator.updatePackages(_flutterProject); + invalidatedFiles.add(fs.file(PackageMap.globalGeneratedPackagesPath).uri); } return _residentCompiler.recompile( mainPath, diff --git a/packages/flutter_tools/lib/src/commands/analyze.dart b/packages/flutter_tools/lib/src/commands/analyze.dart index 5cbc68ba56..3d8ca6b366 100644 --- a/packages/flutter_tools/lib/src/commands/analyze.dart +++ b/packages/flutter_tools/lib/src/commands/analyze.dart @@ -64,6 +64,11 @@ class AnalyzeCommand extends FlutterCommand { @override String get description => "Analyze the project's Dart code."; + @override + Future> get requiredArtifacts async => const { + DevelopmentArtifact.universal, + }; + @override bool get shouldRunPub { // If they're not analyzing the current project. diff --git a/packages/flutter_tools/lib/src/commands/analyze_continuously.dart b/packages/flutter_tools/lib/src/commands/analyze_continuously.dart index d470d9e2a5..a82cdd741c 100644 --- a/packages/flutter_tools/lib/src/commands/analyze_continuously.dart +++ b/packages/flutter_tools/lib/src/commands/analyze_continuously.dart @@ -77,7 +77,7 @@ class AnalyzeContinuously extends AnalyzeBase { analysisStatus?.cancel(); if (!firstAnalysis) printStatus('\n'); - analysisStatus = logger.startProgress('Analyzing $analysisTarget...', timeout: kSlowOperation); + analysisStatus = logger.startProgress('Analyzing $analysisTarget...', timeout: timeoutConfiguration.slowOperation); analyzedPaths.clear(); analysisTimer = Stopwatch()..start(); } else { diff --git a/packages/flutter_tools/lib/src/commands/analyze_once.dart b/packages/flutter_tools/lib/src/commands/analyze_once.dart index ca21e8326c..9f164f0c46 100644 --- a/packages/flutter_tools/lib/src/commands/analyze_once.dart +++ b/packages/flutter_tools/lib/src/commands/analyze_once.dart @@ -107,7 +107,7 @@ class AnalyzeOnce extends AnalyzeBase { ? '${directories.length} ${directories.length == 1 ? 'directory' : 'directories'}' : fs.path.basename(directories.first); final Status progress = argResults['preamble'] - ? logger.startProgress('Analyzing $message...', timeout: kSlowOperation) + ? logger.startProgress('Analyzing $message...', timeout: timeoutConfiguration.slowOperation) : null; await analysisCompleter.future; diff --git a/packages/flutter_tools/lib/src/commands/attach.dart b/packages/flutter_tools/lib/src/commands/attach.dart index 0031a4c599..43f15a1491 100644 --- a/packages/flutter_tools/lib/src/commands/attach.dart +++ b/packages/flutter_tools/lib/src/commands/attach.dart @@ -216,6 +216,7 @@ class AttachCommand extends FlutterCommand { viewFilter: argResults['isolate-filter'], target: argResults['target'], targetModel: TargetModel(argResults['target-model']), + buildMode: getBuildMode(), ); flutterDevice.observatoryUris = [ observatoryUri ]; final List flutterDevices = [flutterDevice]; diff --git a/packages/flutter_tools/lib/src/commands/build_aot.dart b/packages/flutter_tools/lib/src/commands/build_aot.dart index d9243be5ff..ea32069960 100644 --- a/packages/flutter_tools/lib/src/commands/build_aot.dart +++ b/packages/flutter_tools/lib/src/commands/build_aot.dart @@ -16,7 +16,7 @@ import '../resident_runner.dart'; import '../runner/flutter_command.dart'; import 'build.dart'; -class BuildAotCommand extends BuildSubCommand { +class BuildAotCommand extends BuildSubCommand with TargetPlatformBasedDevelopmentArtifacts { BuildAotCommand() { usesTargetOption(); addBuildModeFlags(); @@ -33,6 +33,11 @@ class BuildAotCommand extends BuildSubCommand { defaultsTo: false, help: 'Compile to a *.so file (requires NDK when building for Android).', ) + ..addFlag('report-timings', + negatable: false, + defaultsTo: false, + help: 'Report timing information about build steps in machine readable form,', + ) ..addMultiOption('ios-arch', splitCommas: true, defaultsTo: defaultIOSArchs.map(getNameForIOSArch), @@ -69,13 +74,14 @@ class BuildAotCommand extends BuildSubCommand { final String typeName = artifacts.getEngineType(platform, buildMode); status = logger.startProgress( 'Building AOT snapshot in ${getFriendlyModeName(getBuildMode())} mode ($typeName)...', - timeout: kSlowOperation, + timeout: timeoutConfiguration.slowOperation, ); } final String outputPath = argResults['output-dir'] ?? getAotBuildDirectory(); + final bool reportTimings = argResults['report-timings']; try { String mainPath = findMainDartFile(targetFile); - final AOTSnapshotter snapshotter = AOTSnapshotter(); + final AOTSnapshotter snapshotter = AOTSnapshotter(reportTimings: reportTimings); // Compile to kernel. mainPath = await snapshotter.compileKernel( diff --git a/packages/flutter_tools/lib/src/commands/build_apk.dart b/packages/flutter_tools/lib/src/commands/build_apk.dart index 2660932b2d..8a2ac3cb34 100644 --- a/packages/flutter_tools/lib/src/commands/build_apk.dart +++ b/packages/flutter_tools/lib/src/commands/build_apk.dart @@ -6,7 +6,7 @@ import 'dart:async'; import '../android/apk.dart'; import '../project.dart'; -import '../runner/flutter_command.dart' show FlutterCommandResult; +import '../runner/flutter_command.dart' show DevelopmentArtifact, FlutterCommandResult; import 'build.dart'; class BuildApkCommand extends BuildSubCommand { @@ -34,6 +34,12 @@ class BuildApkCommand extends BuildSubCommand { @override final String name = 'apk'; + @override + Future> get requiredArtifacts async => const { + DevelopmentArtifact.universal, + DevelopmentArtifact.android, + }; + @override final String description = 'Build an Android APK file from your app.\n\n' 'This command can build debug and release versions of your application. \'debug\' builds support ' diff --git a/packages/flutter_tools/lib/src/commands/build_ios.dart b/packages/flutter_tools/lib/src/commands/build_ios.dart index b90e332975..f82dab9085 100644 --- a/packages/flutter_tools/lib/src/commands/build_ios.dart +++ b/packages/flutter_tools/lib/src/commands/build_ios.dart @@ -10,7 +10,7 @@ import '../base/utils.dart'; import '../build_info.dart'; import '../globals.dart'; import '../ios/mac.dart'; -import '../runner/flutter_command.dart' show FlutterCommandResult; +import '../runner/flutter_command.dart' show DevelopmentArtifact, FlutterCommandResult; import 'build.dart'; class BuildIOSCommand extends BuildSubCommand { @@ -48,6 +48,12 @@ class BuildIOSCommand extends BuildSubCommand { @override final String description = 'Build an iOS application bundle (Mac OS X host only).'; + @override + Future> get requiredArtifacts async => const { + DevelopmentArtifact.universal, + DevelopmentArtifact.iOS, + }; + @override Future runCommand() async { final bool forSimulator = argResults['simulator']; diff --git a/packages/flutter_tools/lib/src/commands/build_web.dart b/packages/flutter_tools/lib/src/commands/build_web.dart index af43d1fd4a..8a1fd9ecff 100644 --- a/packages/flutter_tools/lib/src/commands/build_web.dart +++ b/packages/flutter_tools/lib/src/commands/build_web.dart @@ -8,7 +8,7 @@ import '../base/common.dart'; import '../base/logger.dart'; import '../build_info.dart'; import '../globals.dart'; -import '../runner/flutter_command.dart' show FlutterCommandResult; +import '../runner/flutter_command.dart' show DevelopmentArtifact, FlutterCommandResult; import '../web/compile.dart'; import 'build.dart'; @@ -19,12 +19,21 @@ class BuildWebCommand extends BuildSubCommand { defaultBuildMode = BuildMode.release; } + @override + Future> get requiredArtifacts async => const { + DevelopmentArtifact.universal, + DevelopmentArtifact.web, + }; + @override final String name = 'web'; @override bool get hidden => true; + @override + bool get isExperimental => true; + @override final String description = '(EXPERIMENTAL) build a web application bundle.'; diff --git a/packages/flutter_tools/lib/src/commands/channel.dart b/packages/flutter_tools/lib/src/commands/channel.dart index 1b0bd0fdbe..d9672f62c1 100644 --- a/packages/flutter_tools/lib/src/commands/channel.dart +++ b/packages/flutter_tools/lib/src/commands/channel.dart @@ -31,6 +31,9 @@ class ChannelCommand extends FlutterCommand { @override String get invocation => '${runner.executableName} $name []'; + @override + Future> get requiredArtifacts async => const {}; + @override Future runCommand() async { switch (argResults.rest.length) { diff --git a/packages/flutter_tools/lib/src/commands/clean.dart b/packages/flutter_tools/lib/src/commands/clean.dart index c427e39e00..65682e8f4d 100644 --- a/packages/flutter_tools/lib/src/commands/clean.dart +++ b/packages/flutter_tools/lib/src/commands/clean.dart @@ -22,6 +22,9 @@ class CleanCommand extends FlutterCommand { @override final String description = 'Delete the build/ and .dart_tool/ directories.'; + @override + Future> get requiredArtifacts async => const {}; + @override Future runCommand() async { final FlutterProject flutterProject = await FlutterProject.current(); diff --git a/packages/flutter_tools/lib/src/commands/config.dart b/packages/flutter_tools/lib/src/commands/config.dart index dd25ec70e2..89d0142283 100644 --- a/packages/flutter_tools/lib/src/commands/config.dart +++ b/packages/flutter_tools/lib/src/commands/config.dart @@ -44,6 +44,9 @@ class ConfigCommand extends FlutterCommand { @override bool get shouldUpdateCache => false; + @override + Future> get requiredArtifacts async => const {}; + @override String get usageFooter { // List all config settings. diff --git a/packages/flutter_tools/lib/src/commands/create.dart b/packages/flutter_tools/lib/src/commands/create.dart index c11fecc01a..5118df7b69 100644 --- a/packages/flutter_tools/lib/src/commands/create.dart +++ b/packages/flutter_tools/lib/src/commands/create.dart @@ -245,7 +245,7 @@ class CreateCommand extends FlutterCommand { throwToolExit('Neither the --flutter-root command line flag nor the FLUTTER_ROOT environment ' 'variable was specified. Unable to find package:flutter.', exitCode: 2); - await Cache.instance.updateAll(); + await Cache.instance.updateAll({ DevelopmentArtifact.universal }); final String flutterRoot = fs.path.absolute(Cache.flutterRoot); @@ -407,7 +407,7 @@ Your $application code is in $relativeAppMain. Your plugin code is in $relativePluginMain. Host platform code is in the "android" and "ios" directories under $relativePluginPath. -To edit platform code in an IDE see https://flutter.io/developing-packages/#edit-plugin-package. +To edit platform code in an IDE see https://flutter.dev/developing-packages/#edit-plugin-package. '''); } } else { diff --git a/packages/flutter_tools/lib/src/commands/daemon.dart b/packages/flutter_tools/lib/src/commands/daemon.dart index a4e1524ad3..08e52075a1 100644 --- a/packages/flutter_tools/lib/src/commands/daemon.dart +++ b/packages/flutter_tools/lib/src/commands/daemon.dart @@ -351,6 +351,7 @@ class AppDomain extends Domain { dillOutputPath: dillOutputPath, viewFilter: isolateFilter, target: target, + buildMode: options.buildInfo.mode, ); ResidentRunner runner; diff --git a/packages/flutter_tools/lib/src/commands/devices.dart b/packages/flutter_tools/lib/src/commands/devices.dart index 78effffd19..904b055c77 100644 --- a/packages/flutter_tools/lib/src/commands/devices.dart +++ b/packages/flutter_tools/lib/src/commands/devices.dart @@ -34,7 +34,7 @@ class DevicesCommand extends FlutterCommand { 'No devices detected.\n\n' "Run 'flutter emulators' to list and start any available device emulators.\n\n" 'Or, if you expected your device to be detected, please run "flutter doctor" to diagnose ' - 'potential issues, or visit https://flutter.io/setup/ for troubleshooting tips.'); + 'potential issues, or visit https://flutter.dev/setup/ for troubleshooting tips.'); final List diagnostics = await deviceManager.getDeviceDiagnostics(); if (diagnostics.isNotEmpty) { printStatus(''); diff --git a/packages/flutter_tools/lib/src/commands/drive.dart b/packages/flutter_tools/lib/src/commands/drive.dart index 11df0d56b9..22232abd97 100644 --- a/packages/flutter_tools/lib/src/commands/drive.dart +++ b/packages/flutter_tools/lib/src/commands/drive.dart @@ -64,6 +64,10 @@ class DriveCommand extends RunCommandBase { 'extension, so e.g. if the target is "lib/main.dart", the driver will be ' '"test_driver/main_test.dart".', valueHelp: 'path', + ) + ..addFlag('build', + defaultsTo: true, + help: 'Build the app before running.', ); } @@ -78,6 +82,7 @@ class DriveCommand extends RunCommandBase { Device _device; Device get device => _device; + bool get shouldBuild => argResults['build']; /// Subscription to log messages printed on the device or simulator. // ignore: cancel_subscriptions @@ -234,12 +239,15 @@ Future _startApp(DriveCommand command) async { printTrace('Stopping previously running application, if any.'); await appStopper(command); - printTrace('Installing application package.'); final ApplicationPackage package = await command.applicationPackages .getPackageForPlatform(await command.device.targetPlatform); - if (await command.device.isAppInstalled(package)) - await command.device.uninstallApp(package); - await command.device.installApp(package); + + if (command.shouldBuild) { + printTrace('Installing application package.'); + if (await command.device.isAppInstalled(package)) + await command.device.uninstallApp(package); + await command.device.installApp(package); + } final Map platformArgs = {}; if (command.traceStartup) @@ -264,6 +272,7 @@ Future _startApp(DriveCommand command) async { observatoryPort: command.observatoryPort, ), platformArgs: platformArgs, + prebuiltApplication: !command.shouldBuild, usesTerminalUi: false, ); diff --git a/packages/flutter_tools/lib/src/commands/emulators.dart b/packages/flutter_tools/lib/src/commands/emulators.dart index 471a26de8a..53492a2978 100644 --- a/packages/flutter_tools/lib/src/commands/emulators.dart +++ b/packages/flutter_tools/lib/src/commands/emulators.dart @@ -135,7 +135,7 @@ class EmulatorsCommand extends FlutterCommand { if (showRunInstruction || showCreateInstruction) { printStatus(''); } - // TODO(dantup): Update this link to flutter.io if/when we have a better page. + // TODO(dantup): Update this link to flutter.dev if/when we have a better page. // That page can then link out to these places if required. printStatus('You can find more information on managing emulators at the links below:\n' ' https://developer.android.com/studio/run/managing-avds\n' diff --git a/packages/flutter_tools/lib/src/commands/format.dart b/packages/flutter_tools/lib/src/commands/format.dart index 9d5d56e1a3..1b0c407891 100644 --- a/packages/flutter_tools/lib/src/commands/format.dart +++ b/packages/flutter_tools/lib/src/commands/format.dart @@ -39,6 +39,11 @@ class FormatCommand extends FlutterCommand { @override final String description = 'Format one or more dart files.'; + @override + Future> get requiredArtifacts async => const { + DevelopmentArtifact.universal, + }; + @override String get invocation => '${runner.executableName} $name '; diff --git a/packages/flutter_tools/lib/src/commands/generate.dart b/packages/flutter_tools/lib/src/commands/generate.dart index d1026acac4..2694e2d13c 100644 --- a/packages/flutter_tools/lib/src/commands/generate.dart +++ b/packages/flutter_tools/lib/src/commands/generate.dart @@ -21,6 +21,11 @@ class GenerateCommand extends FlutterCommand { @override bool get hidden => true; + @override + Future> get requiredArtifacts async => const { + DevelopmentArtifact.universal, + }; + @override Future runCommand() async { Cache.releaseLockEarly(); diff --git a/packages/flutter_tools/lib/src/commands/ide_config.dart b/packages/flutter_tools/lib/src/commands/ide_config.dart index 2e14108c02..ad1034094b 100644 --- a/packages/flutter_tools/lib/src/commands/ide_config.dart +++ b/packages/flutter_tools/lib/src/commands/ide_config.dart @@ -42,6 +42,9 @@ class IdeConfigCommand extends FlutterCommand { @override final String name = 'ide-config'; + @override + Future> get requiredArtifacts async => const {}; + @override final String description = 'Configure the IDE for use in the Flutter tree.\n\n' 'If run on a Flutter tree that is already configured for the IDE, this ' @@ -223,7 +226,7 @@ class IdeConfigCommand extends FlutterCommand { throwToolExit('Currently, the only supported IDE is IntelliJ\n$usage', exitCode: 2); } - await Cache.instance.updateAll(); + await Cache.instance.updateAll({ DevelopmentArtifact.universal }); if (argResults['update-templates']) { _handleTemplateUpdate(); diff --git a/packages/flutter_tools/lib/src/commands/inject_plugins.dart b/packages/flutter_tools/lib/src/commands/inject_plugins.dart index 4acc452bae..d13c19b6b6 100644 --- a/packages/flutter_tools/lib/src/commands/inject_plugins.dart +++ b/packages/flutter_tools/lib/src/commands/inject_plugins.dart @@ -23,6 +23,9 @@ class InjectPluginsCommand extends FlutterCommand { @override final bool hidden; + @override + Future> get requiredArtifacts async => const {}; + @override Future runCommand() async { final FlutterProject project = await FlutterProject.current(); diff --git a/packages/flutter_tools/lib/src/commands/install.dart b/packages/flutter_tools/lib/src/commands/install.dart index ab439062cb..5e0d43c882 100644 --- a/packages/flutter_tools/lib/src/commands/install.dart +++ b/packages/flutter_tools/lib/src/commands/install.dart @@ -11,7 +11,7 @@ import '../device.dart'; import '../globals.dart'; import '../runner/flutter_command.dart'; -class InstallCommand extends FlutterCommand { +class InstallCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts { InstallCommand() { requiresPubspecYaml(); } diff --git a/packages/flutter_tools/lib/src/commands/logs.dart b/packages/flutter_tools/lib/src/commands/logs.dart index 3e0ec00215..c97c62ce35 100644 --- a/packages/flutter_tools/lib/src/commands/logs.dart +++ b/packages/flutter_tools/lib/src/commands/logs.dart @@ -26,6 +26,9 @@ class LogsCommand extends FlutterCommand { @override final String description = 'Show log output for running Flutter apps.'; + @override + Future> get requiredArtifacts async => const {}; + Device device; @override diff --git a/packages/flutter_tools/lib/src/commands/packages.dart b/packages/flutter_tools/lib/src/commands/packages.dart index befbe878ae..2740a29fc8 100644 --- a/packages/flutter_tools/lib/src/commands/packages.dart +++ b/packages/flutter_tools/lib/src/commands/packages.dart @@ -15,6 +15,14 @@ class PackagesCommand extends FlutterCommand { addSubcommand(PackagesGetCommand('get', false)); addSubcommand(PackagesGetCommand('upgrade', true)); addSubcommand(PackagesTestCommand()); + addSubcommand(PackagesForwardCommand('downgrade', 'Downgrade packages in a Flutter project', requiresPubspec: true)); + addSubcommand(PackagesForwardCommand('publish', 'Publish the current package to pub.dartlang.org', requiresPubspec: true)); + addSubcommand(PackagesForwardCommand('deps', 'Print package dependencies', requiresPubspec: true)); + addSubcommand(PackagesForwardCommand('run', 'Run an executable from a package', requiresPubspec: true)); + addSubcommand(PackagesForwardCommand('cache', 'Work with the Pub system cache')); + addSubcommand(PackagesForwardCommand('version', 'Print Pub version')); + addSubcommand(PackagesForwardCommand('uploader', 'Manage uploaders for a package on pub.dartlang.org')); + addSubcommand(PackagesForwardCommand('global', 'Work with Pub global packages')); addSubcommand(PackagesPassthroughCommand()); } @@ -27,6 +35,11 @@ class PackagesCommand extends FlutterCommand { @override final String description = 'Commands for managing Flutter packages.'; + @override + Future> get requiredArtifacts async => const { + DevelopmentArtifact.universal, + }; + @override Future runCommand() async => null; } @@ -124,6 +137,37 @@ class PackagesTestCommand extends FlutterCommand { } } +class PackagesForwardCommand extends FlutterCommand { + PackagesForwardCommand(this._commandName, this._description, {bool requiresPubspec = false}) { + if (requiresPubspec) { + requiresPubspecYaml(); + } + } + final String _commandName; + final String _description; + + @override + String get name => _commandName; + + @override + String get description { + return '$_description.\n' + 'This runs the "pub" tool in a Flutter context.'; + } + + @override + String get invocation { + return '${runner.executableName} packages $_commandName []'; + } + + @override + Future runCommand() async { + await pub([_commandName]..addAll(argResults.rest), context: PubContext.pubForward, retry: false); + return null; + } + +} + class PackagesPassthroughCommand extends FlutterCommand { PackagesPassthroughCommand() { requiresPubspecYaml(); diff --git a/packages/flutter_tools/lib/src/commands/precache.dart b/packages/flutter_tools/lib/src/commands/precache.dart index b1fc4dcc77..9c39c00db3 100644 --- a/packages/flutter_tools/lib/src/commands/precache.dart +++ b/packages/flutter_tools/lib/src/commands/precache.dart @@ -4,13 +4,27 @@ import 'dart:async'; +import '../cache.dart'; import '../globals.dart'; import '../runner/flutter_command.dart'; +import '../version.dart'; class PrecacheCommand extends FlutterCommand { PrecacheCommand() { argParser.addFlag('all-platforms', abbr: 'a', negatable: false, help: 'Precache artifacts for all platforms.'); + argParser.addFlag('android', negatable: true, defaultsTo: true, + help: 'Precache artifacts for Android development'); + argParser.addFlag('ios', negatable: true, defaultsTo: true, + help: 'Precache artifacts for iOS developemnt'); + argParser.addFlag('web', negatable: true, defaultsTo: false, + help: 'Precache artifacts for web development'); + argParser.addFlag('linux', negatable: true, defaultsTo: false, + help: 'Precache artifacts for linux desktop development'); + argParser.addFlag('windows', negatable: true, defaultsTo: false, + help: 'Precache artifacts for windows desktop development'); + argParser.addFlag('macos', negatable: true, defaultsTo: false, + help: 'Precache artifacts for macOS desktop development'); } @override @@ -24,14 +38,36 @@ class PrecacheCommand extends FlutterCommand { @override Future runCommand() async { - if (argResults['all-platforms']) + if (argResults['all-platforms']) { cache.includeAllPlatforms = true; + } + final Set requiredArtifacts = { DevelopmentArtifact.universal }; + if (argResults['android']) { + requiredArtifacts.add(DevelopmentArtifact.android); + } + if (argResults['ios']) { + requiredArtifacts.add(DevelopmentArtifact.iOS); + } + if (!FlutterVersion.instance.isStable) { + if (argResults['web']) { + requiredArtifacts.add(DevelopmentArtifact.web); + } + if (argResults['linux']) { + requiredArtifacts.add(DevelopmentArtifact.linux); + } + if (argResults['windows']) { + requiredArtifacts.add(DevelopmentArtifact.windows); + } + if (argResults['macos']) { + requiredArtifacts.add(DevelopmentArtifact.macOS); + } + } - if (cache.isUpToDate()) + if (cache.isUpToDate()) { printStatus('Already up-to-date.'); - else - await cache.updateAll(); - + } else { + await cache.updateAll(requiredArtifacts); + } return null; } } diff --git a/packages/flutter_tools/lib/src/commands/run.dart b/packages/flutter_tools/lib/src/commands/run.dart index e72ae1aa05..926154c0f2 100644 --- a/packages/flutter_tools/lib/src/commands/run.dart +++ b/packages/flutter_tools/lib/src/commands/run.dart @@ -20,7 +20,7 @@ import '../runner/flutter_command.dart'; import '../tracing.dart'; import 'daemon.dart'; -abstract class RunCommandBase extends FlutterCommand { +abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopmentArtifacts { // Used by run and drive commands. RunCommandBase({ bool verboseHelp = false }) { addBuildModeFlags(defaultToRelease: false, verboseHelp: verboseHelp); @@ -64,6 +64,7 @@ abstract class RunCommandBase extends FlutterCommand { } bool get traceStartup => argResults['trace-startup']; + String get route => argResults['route']; } @@ -215,7 +216,7 @@ class RunCommand extends RunCommandBase { printStatus("Run 'flutter emulators' to list and start any available device emulators."); printStatus(''); printStatus('If you expected your device to be detected, please run "flutter doctor" to diagnose'); - printStatus('potential issues, or visit https://flutter.io/setup/ for troubleshooting tips.'); + printStatus('potential issues, or visit https://flutter.dev/setup/ for troubleshooting tips.'); } } @@ -368,6 +369,7 @@ class RunCommand extends RunCommandBase { viewFilter: argResults['isolate-filter'], experimentalFlags: expFlags, target: argResults['target'], + buildMode: getBuildMode(), ); flutterDevices.add(flutterDevice); } diff --git a/packages/flutter_tools/lib/src/commands/test.dart b/packages/flutter_tools/lib/src/commands/test.dart index 93a6d2abed..c6160133e8 100644 --- a/packages/flutter_tools/lib/src/commands/test.dart +++ b/packages/flutter_tools/lib/src/commands/test.dart @@ -11,6 +11,7 @@ import '../base/platform.dart'; import '../cache.dart'; import '../codegen.dart'; import '../dart/pub.dart'; +import '../globals.dart'; import '../project.dart'; import '../runner/flutter_command.dart'; import '../test/coverage_collector.dart'; @@ -85,6 +86,11 @@ class TestCommand extends FastFlutterCommand { valueHelp: 'jobs'); } + @override + Future> get requiredArtifacts async => { + DevelopmentArtifact.universal, + }; + @override String get name => 'test'; @@ -93,6 +99,7 @@ class TestCommand extends FastFlutterCommand { @override Future runCommand() async { + await cache.updateAll(await requiredArtifacts); if (!fs.isFileSync('pubspec.yaml')) { throwToolExit( 'Error: No pubspec.yaml file found in the current working directory.\n' @@ -142,7 +149,9 @@ class TestCommand extends FastFlutterCommand { CoverageCollector collector; if (argResults['coverage'] || argResults['merge-coverage']) { - collector = CoverageCollector(); + collector = CoverageCollector( + flutterProject: await FlutterProject.current(), + ); } final bool machine = argResults['machine']; diff --git a/packages/flutter_tools/lib/src/commands/update_packages.dart b/packages/flutter_tools/lib/src/commands/update_packages.dart index fd4f51a760..d18123ed13 100644 --- a/packages/flutter_tools/lib/src/commands/update_packages.dart +++ b/packages/flutter_tools/lib/src/commands/update_packages.dart @@ -84,10 +84,15 @@ class UpdatePackagesCommand extends FlutterCommand { @override final bool hidden; + @override + Future> get requiredArtifacts async => { + DevelopmentArtifact.universal, + }; + Future _downloadCoverageData() async { final Status status = logger.startProgress( 'Downloading lcov data for package:flutter...', - timeout: kSlowOperation, + timeout: timeoutConfiguration.slowOperation, ); final String urlBase = platform.environment['FLUTTER_STORAGE_BASE_URL'] ?? 'https://storage.googleapis.com'; final List data = await fetchUrl(Uri.parse('$urlBase/flutter_infra/flutter/coverage/lcov.info')); diff --git a/packages/flutter_tools/lib/src/commands/upgrade.dart b/packages/flutter_tools/lib/src/commands/upgrade.dart index f39e33b7f3..896164d17e 100644 --- a/packages/flutter_tools/lib/src/commands/upgrade.dart +++ b/packages/flutter_tools/lib/src/commands/upgrade.dart @@ -36,6 +36,11 @@ class UpgradeCommand extends FlutterCommand { @override bool get shouldUpdateCache => false; + @override + Future> get requiredArtifacts async => { + DevelopmentArtifact.universal, + }; + @override Future runCommand() async { final UpgradeCommandRunner upgradeCommandRunner = UpgradeCommandRunner(); @@ -67,6 +72,17 @@ class UpgradeCommandRunner { ); } } + // If there are uncomitted changes we might be on the right commit but + // we should still warn. + if (!force && await hasUncomittedChanges()) { + throwToolExit( + 'Your flutter checkout has local changes that would be erased by ' + 'upgrading. If you want to keep these changes, it is recommended that ' + 'you stash them via "git stash" or else commit the changes to a local ' + 'branch. If it is okay to remove local changes, then re-run this ' + 'command with --force.' + ); + } await resetChanges(gitTagVersion); await upgradeChannel(flutterVersion); await attemptFastForward(); @@ -76,6 +92,18 @@ class UpgradeCommandRunner { return null; } + Future hasUncomittedChanges() async { + try { + final RunResult result = await runCheckedAsync([ + 'git', 'status', '-s' + ], workingDirectory: Cache.flutterRoot); + return result.stdout.trim().isNotEmpty; + } catch (e) { + throwToolExit('git status failed: $e'); + } + return false; + } + /// Check if there is an upstream repository configured. /// /// Exits tool if there is no upstream. diff --git a/packages/flutter_tools/lib/src/commands/version.dart b/packages/flutter_tools/lib/src/commands/version.dart index 33884d26b8..f3c8d32ab7 100644 --- a/packages/flutter_tools/lib/src/commands/version.dart +++ b/packages/flutter_tools/lib/src/commands/version.dart @@ -35,7 +35,7 @@ class VersionCommand extends FlutterCommand { Future> getTags() async { final RunResult runResult = await runCheckedAsync( - ['git', 'tag', '-l', 'v*'], + ['git', 'tag', '-l', 'v*', '--sort=-creatordate'], workingDirectory: Cache.flutterRoot, ); return runResult.toString().split('\n'); diff --git a/packages/flutter_tools/lib/src/compile.dart b/packages/flutter_tools/lib/src/compile.dart index 4ba74eb666..f2c15f9278 100644 --- a/packages/flutter_tools/lib/src/compile.dart +++ b/packages/flutter_tools/lib/src/compile.dart @@ -232,7 +232,6 @@ class KernelCompiler { if (fs.file('pubspec.yaml').existsSync()) { flutterProject = await FlutterProject.current(); } - final FlutterEngine engine = FlutterEngine(cache); // TODO(cbracken): eliminate pathFilter. // Currently the compiler emits buildbot paths for the core libs in the @@ -246,7 +245,7 @@ class KernelCompiler { 'entryPoint': mainPath, 'trackWidgetCreation': trackWidgetCreation.toString(), 'linkPlatformKernelIn': linkPlatformKernelIn.toString(), - 'engineHash': engine.version, + 'engineHash': Cache.instance.engineRevision, 'buildersUsed': '${flutterProject != null ? flutterProject.hasBuilders : false}', }, depfilePaths: [depFilePath], diff --git a/packages/flutter_tools/lib/src/context_runner.dart b/packages/flutter_tools/lib/src/context_runner.dart index c85afd0cc9..2e253a9be1 100644 --- a/packages/flutter_tools/lib/src/context_runner.dart +++ b/packages/flutter_tools/lib/src/context_runner.dart @@ -91,6 +91,7 @@ Future runInContext( SimControl: () => SimControl(), SystemClock: () => const SystemClock(), Stdio: () => const Stdio(), + TimeoutConfiguration: () => const TimeoutConfiguration(), Usage: () => Usage(), UserMessages: () => UserMessages(), WindowsWorkflow: () => const WindowsWorkflow(), diff --git a/packages/flutter_tools/lib/src/dart/pub.dart b/packages/flutter_tools/lib/src/dart/pub.dart index 3ca0c05343..5c53c2c007 100644 --- a/packages/flutter_tools/lib/src/dart/pub.dart +++ b/packages/flutter_tools/lib/src/dart/pub.dart @@ -41,6 +41,7 @@ class PubContext { static final PubContext interactive = PubContext._(['interactive']); static final PubContext pubGet = PubContext._(['get']); static final PubContext pubUpgrade = PubContext._(['upgrade']); + static final PubContext pubForward = PubContext._(['forward']); static final PubContext runTest = PubContext._(['run_test']); static final PubContext flutterTests = PubContext._(['flutter_tests']); @@ -93,7 +94,7 @@ Future pubGet({ final String command = upgrade ? 'upgrade' : 'get'; final Status status = logger.startProgress( 'Running "flutter packages $command" in ${fs.path.basename(directory)}...', - timeout: kSlowOperation, + timeout: timeoutConfiguration.slowOperation, ); final List args = ['--verbosity=warning']; if (FlutterCommand.current != null && FlutterCommand.current.globalResults['verbose']) diff --git a/packages/flutter_tools/lib/src/desktop.dart b/packages/flutter_tools/lib/src/desktop.dart index 153e2fbe06..e1af6698e7 100644 --- a/packages/flutter_tools/lib/src/desktop.dart +++ b/packages/flutter_tools/lib/src/desktop.dart @@ -3,11 +3,12 @@ // found in the LICENSE file. import 'base/platform.dart'; +import 'version.dart'; // Only launch or display desktop embedding devices if // `FLUTTER_DESKTOP_EMBEDDING` environment variable is set to true. bool get flutterDesktopEnabled { _flutterDesktopEnabled ??= platform.environment['FLUTTER_DESKTOP_EMBEDDING']?.toLowerCase() == 'true'; - return _flutterDesktopEnabled; + return _flutterDesktopEnabled && !FlutterVersion.instance.isStable; } bool _flutterDesktopEnabled; diff --git a/packages/flutter_tools/lib/src/doctor.dart b/packages/flutter_tools/lib/src/doctor.dart index 962bba65c0..b2d49c5f9b 100644 --- a/packages/flutter_tools/lib/src/doctor.dart +++ b/packages/flutter_tools/lib/src/doctor.dart @@ -170,9 +170,7 @@ class Doctor { } Future checkRemoteArtifacts(String engineRevision) async { - final Cache cache = Cache(); - final FlutterEngine engine = FlutterEngine(cache); - return await engine.areRemoteArtifactsAvailable(engineVersion: engineRevision); + return Cache.instance.areRemoteArtifactsAvailable(engineVersion: engineRevision); } /// Print information about the state of installed tooling. @@ -189,7 +187,7 @@ class Doctor { for (ValidatorTask validatorTask in startValidatorTasks()) { final DoctorValidator validator = validatorTask.validator; final Status status = Status.withSpinner( - timeout: kFastOperation, + timeout: timeoutConfiguration.fastOperation, slowWarningCallback: () => validator.slowWarning, ); ValidationResult result; diff --git a/packages/flutter_tools/lib/src/ios/cocoapods.dart b/packages/flutter_tools/lib/src/ios/cocoapods.dart index 24d0430cd0..03c89da5f9 100644 --- a/packages/flutter_tools/lib/src/ios/cocoapods.dart +++ b/packages/flutter_tools/lib/src/ios/cocoapods.dart @@ -23,7 +23,7 @@ import 'xcodeproj.dart'; const String noCocoaPodsConsequence = ''' CocoaPods is used to retrieve the iOS platform side's plugin code that responds to your plugin usage on the Dart side. Without resolving iOS dependencies with CocoaPods, plugins will not work on iOS. - For more info, see https://flutter.io/platform-plugins'''; + For more info, see https://flutter.dev/platform-plugins'''; const String unknownCocoaPodsConsequence = ''' Flutter is unable to determine the installed CocoaPods's version. @@ -254,7 +254,7 @@ class CocoaPods { } Future _runPodInstall(IosProject iosProject, String engineDirectory) async { - final Status status = logger.startProgress('Running pod install...', timeout: kSlowOperation); + final Status status = logger.startProgress('Running pod install...', timeout: timeoutConfiguration.slowOperation); final ProcessResult result = await processManager.run( ['pod', 'install', '--verbose'], workingDirectory: iosProject.hostAppRoot.path, diff --git a/packages/flutter_tools/lib/src/ios/code_signing.dart b/packages/flutter_tools/lib/src/ios/code_signing.dart index 9111b5fcfe..90cca8044e 100644 --- a/packages/flutter_tools/lib/src/ios/code_signing.dart +++ b/packages/flutter_tools/lib/src/ios/code_signing.dart @@ -46,7 +46,7 @@ It's also possible that a previously installed app with the same Bundle\u0020 Identifier was signed with a different certificate. For more information, please visit: - https://flutter.io/setup/#deploy-to-ios-devices + https://flutter.dev/setup/#deploy-to-ios-devices Or run on an iOS simulator without code signing ════════════════════════════════════════════════════════════════════════════════'''; @@ -60,7 +60,7 @@ Provisioning Profile. Please ensure that a Development Team is selected by: $fixWithDevelopmentTeamInstruction For more information, please visit: - https://flutter.io/setup/#deploy-to-ios-devices + https://flutter.dev/setup/#deploy-to-ios-devices Or run on an iOS simulator without code signing ════════════════════════════════════════════════════════════════════════════════'''; diff --git a/packages/flutter_tools/lib/src/ios/devices.dart b/packages/flutter_tools/lib/src/ios/devices.dart index efa4962e72..9cc4272a5c 100644 --- a/packages/flutter_tools/lib/src/ios/devices.dart +++ b/packages/flutter_tools/lib/src/ios/devices.dart @@ -309,7 +309,7 @@ class IOSDevice extends Device { int installationResult = -1; Uri localObservatoryUri; - final Status installStatus = logger.startProgress('Installing and launching...', timeout: kSlowOperation); + final Status installStatus = logger.startProgress('Installing and launching...', timeout: timeoutConfiguration.slowOperation); if (!debuggingOptions.debuggingEnabled) { // If debugging is not enabled, just launch the application and continue. diff --git a/packages/flutter_tools/lib/src/ios/ios_workflow.dart b/packages/flutter_tools/lib/src/ios/ios_workflow.dart index 675df0814c..224c227db9 100644 --- a/packages/flutter_tools/lib/src/ios/ios_workflow.dart +++ b/packages/flutter_tools/lib/src/ios/ios_workflow.dart @@ -52,6 +52,9 @@ class IOSValidator extends DoctorValidator { String get iosDeployMinimumVersion => '1.9.4'; + // ios-deploy <= v1.9.3 declares itself as v2.0.0 + List get iosDeployBadVersions => ['2.0.0']; + Future get iosDeployVersionText async => (await runAsync(['ios-deploy', '--version'])).processResult.stdout.replaceAll('\n', ''); bool get hasHomebrew => os.which('brew') != null; @@ -63,7 +66,8 @@ class IOSValidator extends DoctorValidator { return false; try { final Version version = Version.parse(await iosDeployVersionText); - return version >= Version.parse(iosDeployMinimumVersion); + return version >= Version.parse(iosDeployMinimumVersion) + && !iosDeployBadVersions.map((String v) => Version.parse(v)).contains(version); } on FormatException catch (_) { return false; } diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart index 19410efc64..19ec184387 100644 --- a/packages/flutter_tools/lib/src/ios/mac.dart +++ b/packages/flutter_tools/lib/src/ios/mac.dart @@ -480,7 +480,7 @@ Future buildXcodeProject({ initialBuildStatus = null; buildSubStatus = logger.startProgress( line, - timeout: kSlowOperation, + timeout: timeoutConfiguration.slowOperation, progressIndicatorPadding: kDefaultStatusPadding - 7, ); } @@ -495,7 +495,7 @@ Future buildXcodeProject({ } final Stopwatch buildStopwatch = Stopwatch()..start(); - initialBuildStatus = logger.startProgress('Running Xcode build...', timeout: kFastOperation); + initialBuildStatus = logger.startProgress('Running Xcode build...', timeout: timeoutConfiguration.fastOperation); final RunResult buildResult = await runAsync( buildCommands, workingDirectory: app.project.hostAppRoot.path, diff --git a/packages/flutter_tools/lib/src/ios/xcodeproj.dart b/packages/flutter_tools/lib/src/ios/xcodeproj.dart index 3261776add..c929186bf3 100644 --- a/packages/flutter_tools/lib/src/ios/xcodeproj.dart +++ b/packages/flutter_tools/lib/src/ios/xcodeproj.dart @@ -23,7 +23,8 @@ final RegExp _settingExpr = RegExp(r'(\w+)\s*=\s*(.*)$'); final RegExp _varExpr = RegExp(r'\$\(([^)]*)\)'); String flutterFrameworkDir(BuildMode mode) { - return fs.path.normalize(fs.path.dirname(artifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, mode))); + return fs.path.normalize(fs.path.dirname(artifacts.getArtifactPath( + Artifact.flutterFramework, platform: TargetPlatform.ios, mode: mode))); } /// Writes or rewrites Xcode property files with the specified information. diff --git a/packages/flutter_tools/lib/src/plugins.dart b/packages/flutter_tools/lib/src/plugins.dart index 5f67181484..306183c8a0 100644 --- a/packages/flutter_tools/lib/src/plugins.dart +++ b/packages/flutter_tools/lib/src/plugins.dart @@ -221,7 +221,7 @@ Pod::Spec.new do |s| s.description = <<-DESC Depends on all your plugins, and provides a function to register them. DESC - s.homepage = 'https://flutter.io' + s.homepage = 'https://flutter.dev' s.license = { :type => 'BSD' } s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' } s.ios.deployment_target = '8.0' diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart index f38cc5bb3a..47b7964efe 100644 --- a/packages/flutter_tools/lib/src/resident_runner.dart +++ b/packages/flutter_tools/lib/src/resident_runner.dart @@ -38,9 +38,10 @@ class FlutterDevice { TargetModel targetModel = TargetModel.flutter, List experimentalFlags, ResidentCompiler generator, + @required BuildMode buildMode, }) : assert(trackWidgetCreation != null), generator = generator ?? ResidentCompiler( - artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), + artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath, mode: buildMode), trackWidgetCreation: trackWidgetCreation, fileSystemRoots: fileSystemRoots, fileSystemScheme: fileSystemScheme, @@ -60,6 +61,7 @@ class FlutterDevice { TargetModel targetModel = TargetModel.flutter, List experimentalFlags, ResidentCompiler generator, + @required BuildMode buildMode, }) async { ResidentCompiler generator; final FlutterProject flutterProject = await FlutterProject.current(); @@ -69,7 +71,7 @@ class FlutterDevice { ); } else { generator = ResidentCompiler( - artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), + artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath, mode: buildMode), trackWidgetCreation: trackWidgetCreation, fileSystemRoots: fileSystemRoots, fileSystemScheme: fileSystemScheme, @@ -87,6 +89,7 @@ class FlutterDevice { experimentalFlags: experimentalFlags, targetModel: targetModel, generator: generator, + buildMode: buildMode, ); } @@ -272,6 +275,11 @@ class FlutterDevice { await view.uiIsolate.flutterToggleDebugPaintSizeEnabled(); } + Future toggleDebugCheckElevationsEnabled() async { + for (FlutterView view in views) + await view.uiIsolate.flutterToggleDebugCheckElevationsEnabled(); + } + Future debugTogglePerformanceOverlayOverride() async { for (FlutterView view in views) await view.uiIsolate.flutterTogglePerformanceOverlayOverride(); @@ -282,6 +290,12 @@ class FlutterDevice { await view.uiIsolate.flutterToggleWidgetInspector(); } + Future toggleProfileWidgetBuilds() async { + for (FlutterView view in views) { + await view.uiIsolate.flutterToggleProfileWidgetBuilds(); + } + } + Future togglePlatform({ String from }) async { String to; switch (from) { @@ -447,7 +461,7 @@ class FlutterDevice { }) async { final Status devFSStatus = logger.startProgress( 'Syncing files to device ${device.name}...', - timeout: kFastOperation, + timeout: timeoutConfiguration.fastOperation, ); UpdateFSReport report; try { @@ -620,6 +634,12 @@ abstract class ResidentRunner { await device.toggleDebugPaintSizeEnabled(); } + Future _debugToggleDebugCheckElevationsEnabled() async { + await refreshViews(); + for (FlutterDevice device in flutterDevices) + await device.toggleDebugCheckElevationsEnabled(); + } + Future _debugTogglePerformanceOverlayOverride() async { await refreshViews(); for (FlutterDevice device in flutterDevices) @@ -632,8 +652,15 @@ abstract class ResidentRunner { await device.toggleWidgetInspector(); } + Future _debugToggleProfileWidgetBuilds() async { + await refreshViews(); + for (FlutterDevice device in flutterDevices) { + await device.toggleProfileWidgetBuilds(); + } + } + Future _screenshot(FlutterDevice device) async { - final Status status = logger.startProgress('Taking screenshot for ${device.device.name}...', timeout: kFastOperation); + final Status status = logger.startProgress('Taking screenshot for ${device.device.name}...', timeout: timeoutConfiguration.fastOperation); final File outputFile = getUniqueFile(fs.currentDirectory, 'flutter', 'png'); try { if (supportsServiceProtocol && isRunningDebug) { @@ -859,6 +886,10 @@ abstract class ResidentRunner { await _screenshot(device); } return true; + } else if (character == 'a') { + if (supportsServiceProtocol) { + await _debugToggleProfileWidgetBuilds(); + } } else if (lower == 'o') { if (supportsServiceProtocol && isRunningDebug) { await _debugTogglePlatform(); @@ -871,6 +902,9 @@ abstract class ResidentRunner { } else if (lower == 'd') { await detach(); return true; + } else if (lower == 'z') { + await _debugToggleDebugCheckElevationsEnabled(); + return true; } return false; @@ -962,10 +996,12 @@ abstract class ResidentRunner { printStatus('To toggle the widget inspector (WidgetsApp.showWidgetInspectorOverride), press "i".'); printStatus('To toggle the display of construction lines (debugPaintSizeEnabled), press "p".'); printStatus('To simulate different operating systems, (defaultTargetPlatform), press "o".'); + printStatus('To toggle the elevation checker, press "z".'); } else { printStatus('To dump the accessibility tree (debugDumpSemantics), press "S" (for traversal order) or "U" (for inverse hit test order).'); } printStatus('To display the performance overlay (WidgetsApp.showPerformanceOverlay), press "P".'); + printStatus('To enable timeline events for all widget build methods, (debugProfileWidgetBuilds), press "a"'); } if (flutterDevices.any((FlutterDevice d) => d.device.supportsScreenshot)) { printStatus('To save a screenshot to flutter.png, press "s".'); diff --git a/packages/flutter_tools/lib/src/run_hot.dart b/packages/flutter_tools/lib/src/run_hot.dart index 1bfe83296e..ee8706cbc1 100644 --- a/packages/flutter_tools/lib/src/run_hot.dart +++ b/packages/flutter_tools/lib/src/run_hot.dart @@ -538,7 +538,7 @@ class HotRunner extends ResidentRunner { } final Status status = logger.startProgress( 'Performing hot restart...', - timeout: kFastOperation, + timeout: timeoutConfiguration.fastOperation, progressId: 'hot.restart', ); try { @@ -557,7 +557,7 @@ class HotRunner extends ResidentRunner { final String progressPrefix = reloadOnTopOfSnapshot ? 'Initializing' : 'Performing'; Status status = logger.startProgress( '$progressPrefix hot reload...', - timeout: kFastOperation, + timeout: timeoutConfiguration.fastOperation, progressId: 'hot.reload', ); OperationResult result; @@ -570,7 +570,7 @@ class HotRunner extends ResidentRunner { status?.cancel(); status = logger.startProgress( message, - timeout: kSlowOperation, + timeout: timeoutConfiguration.slowOperation, progressId: 'hot.reload', ); showTime = false; diff --git a/packages/flutter_tools/lib/src/runner/flutter_command.dart b/packages/flutter_tools/lib/src/runner/flutter_command.dart index 4c80af5a9f..19c77117ff 100644 --- a/packages/flutter_tools/lib/src/runner/flutter_command.dart +++ b/packages/flutter_tools/lib/src/runner/flutter_command.dart @@ -19,6 +19,7 @@ import '../base/user_messages.dart'; import '../base/utils.dart'; import '../build_info.dart'; import '../bundle.dart' as bundle; +import '../cache.dart'; import '../dart/package_map.dart'; import '../dart/pub.dart'; import '../device.dart'; @@ -26,8 +27,11 @@ import '../doctor.dart'; import '../globals.dart'; import '../project.dart'; import '../usage.dart'; +import '../version.dart'; import 'flutter_command_runner.dart'; +export '../cache.dart' show DevelopmentArtifact; + enum ExitStatus { success, warning, @@ -461,6 +465,11 @@ abstract class FlutterCommand extends Command { } } + /// Whether this feature should not be usable on stable branches. + /// + /// Defaults to false, meaning it is usable. + bool get isExperimental => false; + /// Additional usage values to be sent with the usage ping. Future> get usageValues async => const {}; @@ -530,8 +539,9 @@ abstract class FlutterCommand extends Command { // Populate the cache. We call this before pub get below so that the sky_engine // package is available in the flutter cache for pub to find. - if (shouldUpdateCache) - await cache.updateAll(); + if (shouldUpdateCache) { + await cache.updateAll(await requiredArtifacts); + } if (shouldRunPub) { await pubGet(context: PubContext.getVerifyContext(name)); @@ -549,6 +559,16 @@ abstract class FlutterCommand extends Command { return await runCommand(); } + /// The set of development artifacts required for this command. + /// + /// Defaults to [DevelopmentArtifact.universal], + /// [DevelopmentArtifact.android], and [DevelopmentArtifact.iOS]. + Future> get requiredArtifacts async => const { + DevelopmentArtifact.universal, + DevelopmentArtifact.iOS, + DevelopmentArtifact.android, + }; + /// Subclasses must implement this to execute the command. /// Optionally provide a [FlutterCommandResult] to send more details about the /// execution for analytics. @@ -621,6 +641,12 @@ abstract class FlutterCommand extends Command { @protected @mustCallSuper Future validateCommand() async { + // If we're on a stable branch, then don't allow the usage of + // "experimental" features. + if (isExperimental && FlutterVersion.instance.isStable) { + throwToolExit('Experimental feature $name is not supported on stable branches'); + } + if (_requiresPubspecYaml && !PackageMap.isUsingCustomPackagesPath) { // Don't expect a pubspec.yaml file if the user passed in an explicit .packages file path. if (!fs.isFileSync('pubspec.yaml')) { @@ -663,6 +689,90 @@ abstract class FlutterCommand extends Command { ApplicationPackageStore applicationPackages; } +/// A mixin which applies an implementation of [requiredArtifacts] that only +/// downloads artifacts corresponding to an attached device. +mixin DeviceBasedDevelopmentArtifacts on FlutterCommand { + @override + Future> get requiredArtifacts async { + // If there are no attached devices, use the default configuration. + // Otherwise, only add development artifacts which correspond to a + // connected device. + final List devices = await deviceManager.getDevices().toList(); + if (devices.isEmpty) { + return super.requiredArtifacts; + } + final Set artifacts = { + DevelopmentArtifact.universal, + }; + for (Device device in devices) { + final TargetPlatform targetPlatform = await device.targetPlatform; + switch (targetPlatform) { + case TargetPlatform.android_arm: + case TargetPlatform.android_arm64: + case TargetPlatform.android_x64: + case TargetPlatform.android_x86: + artifacts.add(DevelopmentArtifact.android); + break; + case TargetPlatform.web: + artifacts.add(DevelopmentArtifact.web); + break; + case TargetPlatform.ios: + artifacts.add(DevelopmentArtifact.iOS); + break; + case TargetPlatform.darwin_x64: + case TargetPlatform.fuchsia: + case TargetPlatform.tester: + case TargetPlatform.windows_x64: + case TargetPlatform.linux_x64: + // No artifacts currently supported. + break; + } + } + return artifacts; + } +} + +/// A mixin which applies an implementation of [requiredArtifacts] that only +/// downloads artifacts corresponding to a target device. +mixin TargetPlatformBasedDevelopmentArtifacts on FlutterCommand { + @override + Future> get requiredArtifacts async { + // If there is no specified target device, fallback to the default + // confiugration. + final String rawTargetPlatform = argResults['target-platform']; + final TargetPlatform targetPlatform = getTargetPlatformForName(rawTargetPlatform); + if (targetPlatform == null) { + return super.requiredArtifacts; + } + + final Set artifacts = { + DevelopmentArtifact.universal, + }; + switch (targetPlatform) { + case TargetPlatform.android_arm: + case TargetPlatform.android_arm64: + case TargetPlatform.android_x64: + case TargetPlatform.android_x86: + artifacts.add(DevelopmentArtifact.android); + break; + case TargetPlatform.web: + artifacts.add(DevelopmentArtifact.web); + break; + case TargetPlatform.ios: + artifacts.add(DevelopmentArtifact.iOS); + break; + case TargetPlatform.darwin_x64: + case TargetPlatform.fuchsia: + case TargetPlatform.tester: + case TargetPlatform.windows_x64: + case TargetPlatform.linux_x64: + // No artifacts currently supported. + break; + } + return artifacts; + } +} + /// A command which runs less analytics and checks to speed up startup time. abstract class FastFlutterCommand extends FlutterCommand { @override diff --git a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart index 9d375f2c85..3ca8b2ad03 100644 --- a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart +++ b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart @@ -506,7 +506,10 @@ class FlutterCommandRunner extends CommandRunner { final List projectPaths = fs.directory(rootPath) .listSync(followLinks: false) .expand((FileSystemEntity entity) { - return entity is Directory ? _gatherProjectPaths(entity.path) : []; + if (entity is Directory && !fs.path.split(entity.path).contains('.dart_tool')) { + return _gatherProjectPaths(entity.path); + } + return []; }) .toList(); diff --git a/packages/flutter_tools/lib/src/test/coverage_collector.dart b/packages/flutter_tools/lib/src/test/coverage_collector.dart index ff8ca0c625..5bbe7ed56e 100644 --- a/packages/flutter_tools/lib/src/test/coverage_collector.dart +++ b/packages/flutter_tools/lib/src/test/coverage_collector.dart @@ -14,12 +14,18 @@ import '../base/platform.dart'; import '../base/process_manager.dart'; import '../dart/package_map.dart'; import '../globals.dart'; +import '../project.dart'; +import '../vmservice.dart'; import 'watcher.dart'; /// A class that's used to collect coverage data during tests. class CoverageCollector extends TestWatcher { + CoverageCollector({this.flutterProject, this.coverageDirectory}); + Map _globalHitmap; + final Directory coverageDirectory; + final FlutterProject flutterProject; @override Future handleFinishedTest(ProcessEvent event) async { @@ -43,7 +49,6 @@ class CoverageCollector extends TestWatcher { Future collectCoverage(Process process, Uri observatoryUri) async { assert(process != null); assert(observatoryUri != null); - final int pid = process.pid; printTrace('pid $pid: collecting coverage data from $observatoryUri...'); @@ -52,7 +57,17 @@ class CoverageCollector extends TestWatcher { .then((int code) { throw Exception('Failed to collect coverage, process terminated prematurely with exit code $code.'); }); - final Future collectionComplete = coverage.collect(observatoryUri, false, false) + final Future collectionComplete = collect(observatoryUri, (String libraryName) { + // If we have a specified coverage directory or could not find the package name, then + // accept all libraries. + if (coverageDirectory != null) { + return true; + } + if (flutterProject == null) { + return true; + } + return libraryName.contains(flutterProject.manifest.appName); + }) .then((Map result) { if (result == null) throw Exception('Failed to collect coverage.'); @@ -92,7 +107,7 @@ class CoverageCollector extends TestWatcher { } Future collectCoverageData(String coveragePath, { bool mergeCoverageData = false, Directory coverageDirectory }) async { - final Status status = logger.startProgress('Collecting coverage information...', timeout: kFastOperation); + final Status status = logger.startProgress('Collecting coverage information...', timeout: timeoutConfiguration.fastOperation); final String coverageData = await finalizeCoverage( coverageDirectory: coverageDirectory, ); @@ -141,3 +156,144 @@ class CoverageCollector extends TestWatcher { return true; } } + +Future> collect(Uri serviceUri, bool Function(String) libraryPredicate) async { + final VMService vmService = await VMService.connect(serviceUri, compression: CompressionOptions.compressionOff); + await vmService.getVM(); + return _getAllCoverage(vmService, libraryPredicate); +} + + +Future> _getAllCoverage(VMService service, bool Function(String) libraryPredicate) async { + await service.getVM(); + final List> coverage = >[]; + for (Isolate isolateRef in service.vm.isolates) { + await isolateRef.load(); + final Map scriptList = await isolateRef.invokeRpcRaw('getScripts', params: {'isolateId': isolateRef.id}); + final List> futures = >[]; + + final Map> scripts = >{}; + final Map> sourceReports = >{}; + // For each ScriptRef loaded into the VM, load the corresponding Script and + // SourceReport object. + for (Map script in scriptList['scripts']) { + if (!libraryPredicate(script['uri'])) { + continue; + } + final String scriptId = script['id']; + futures.add( + isolateRef.invokeRpcRaw('getSourceReport', params: { + 'forceCompile': true, + 'scriptId': scriptId, + 'isolateId': isolateRef.id, + 'reports': ['Coverage'], + }) + .then((Map report) { + sourceReports[scriptId] = report; + }) + ); + futures.add( + isolateRef.invokeRpcRaw('getObject', params: { + 'isolateId': isolateRef.id, + 'objectId': scriptId, + }) + .then((Map script) { + scripts[scriptId] = script; + }) + ); + } + await Future.wait(futures); + _buildCoverageMap(scripts, sourceReports, coverage); + } + return {'type': 'CodeCoverage', 'coverage': coverage}; +} + +// Build a hitmap of Uri -> Line -> Hit Count for each script object. +void _buildCoverageMap( + Map> scripts, + Map> sourceReports, + List> coverage, +) { + final Map> hitMaps = >{}; + for (String scriptId in scripts.keys) { + final Map sourceReport = sourceReports[scriptId]; + for (Map range in sourceReport['ranges']) { + final Map coverage = range['coverage']; + // Coverage reports may sometimes be null for a Script. + if (coverage == null) { + continue; + } + final Map scriptRef = sourceReport['scripts'][range['scriptIndex']]; + final String uri = scriptRef['uri']; + + hitMaps[uri] ??= {}; + final Map hitMap = hitMaps[uri]; + final List hits = coverage['hits']; + final List misses = coverage['misses']; + final List tokenPositions = scripts[scriptRef['id']]['tokenPosTable']; + // The token positions can be null if the script has no coverable lines. + if (tokenPositions == null) { + continue; + } + if (hits != null) { + for (int hit in hits) { + final int line = _lineAndColumn(hit, tokenPositions)[0]; + final int current = hitMap[line] ?? 0; + hitMap[line] = current + 1; + } + } + if (misses != null) { + for (int miss in misses) { + final int line = _lineAndColumn(miss, tokenPositions)[0]; + hitMap[line] ??= 0; + } + } + } + } + hitMaps.forEach((String uri, Map hitMap) { + coverage.add(_toScriptCoverageJson(uri, hitMap)); + }); +} + +// Binary search the token position table for the line and column which +// corresponds to each token position. +// The format of this table is described in https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md#script +List _lineAndColumn(int position, List tokenPositions) { + int min = 0; + int max = tokenPositions.length; + while (min < max) { + final int mid = min + ((max - min) >> 1); + final List row = tokenPositions[mid]; + if (row[1] > position) { + max = mid; + } else { + for (int i = 1; i < row.length; i += 2) { + if (row[i] == position) { + return [row.first, row[i + 1]]; + } + } + min = mid + 1; + } + } + throw StateError('Unreachable'); +} + +// Returns a JSON hit map backward-compatible with pre-1.16.0 SDKs. +Map _toScriptCoverageJson(String scriptUri, Map hitMap) { + final Map json = {}; + final List hits = []; + hitMap.forEach((int line, int hitCount) { + hits.add(line); + hits.add(hitCount); + }); + json['source'] = scriptUri; + json['script'] = { + 'type': '@Script', + 'fixedId': true, + 'id': 'libraries/1/scripts/${Uri.encodeComponent(scriptUri)}', + 'uri': scriptUri, + '_kind': 'library', + }; + json['hits'] = hits; + return json; +} diff --git a/packages/flutter_tools/lib/src/test/flutter_platform.dart b/packages/flutter_tools/lib/src/test/flutter_platform.dart index 876b3af7b1..91caadecbf 100644 --- a/packages/flutter_tools/lib/src/test/flutter_platform.dart +++ b/packages/flutter_tools/lib/src/test/flutter_platform.dart @@ -92,6 +92,7 @@ void installHook({ InternetAddressType serverType = InternetAddressType.IPv4, Uri projectRootDirectory, FlutterProject flutterProject, + String icudtlPath, }) { assert(enableObservatory || (!startPaused && observatoryPort == null)); hack.registerPlatformPlugin( @@ -111,6 +112,7 @@ void installHook({ updateGoldens: updateGoldens, projectRootDirectory: projectRootDirectory, flutterProject: flutterProject, + icudtlPath: icudtlPath, ), ); } @@ -390,6 +392,7 @@ class _FlutterPlatform extends PlatformPlugin { this.updateGoldens, this.projectRootDirectory, this.flutterProject, + this.icudtlPath, }) : assert(shellPath != null); final String shellPath; @@ -406,6 +409,7 @@ class _FlutterPlatform extends PlatformPlugin { final bool updateGoldens; final Uri projectRootDirectory; final FlutterProject flutterProject; + final String icudtlPath; Directory fontsDirectory; _Compiler compiler; @@ -952,6 +956,10 @@ class _FlutterPlatform extends PlatformPlugin { command.add('--ipv6'); } + if (icudtlPath != null) { + command.add('--icu-data-file-path=$icudtlPath'); + } + command.addAll([ '--enable-checked-mode', '--verify-entry-points', diff --git a/packages/flutter_tools/lib/src/test/runner.dart b/packages/flutter_tools/lib/src/test/runner.dart index dfcb81af68..14ed2d438f 100644 --- a/packages/flutter_tools/lib/src/test/runner.dart +++ b/packages/flutter_tools/lib/src/test/runner.dart @@ -36,6 +36,8 @@ Future runTests( TestWatcher watcher, @required int concurrency, FlutterProject flutterProject, + String icudtlPath, + Directory coverageDirectory, }) async { // Compute the command-line arguments for package:test. final List testArgs = []; @@ -83,6 +85,7 @@ Future runTests( updateGoldens: updateGoldens, projectRootDirectory: fs.currentDirectory.uri, flutterProject: flutterProject, + icudtlPath: icudtlPath, ); // Make the global packages path absolute. diff --git a/packages/flutter_tools/lib/src/tracing.dart b/packages/flutter_tools/lib/src/tracing.dart index a4559f8152..0a666d8008 100644 --- a/packages/flutter_tools/lib/src/tracing.dart +++ b/packages/flutter_tools/lib/src/tracing.dart @@ -40,7 +40,7 @@ class Tracing { if (awaitFirstFrame) { final Status status = logger.startProgress( 'Waiting for application to render first frame...', - timeout: kFastOperation, + timeout: timeoutConfiguration.fastOperation, ); try { final Completer whenFirstFrameRendered = Completer(); diff --git a/packages/flutter_tools/lib/src/usage.dart b/packages/flutter_tools/lib/src/usage.dart index 3cd6c63304..a570d733d5 100644 --- a/packages/flutter_tools/lib/src/usage.dart +++ b/packages/flutter_tools/lib/src/usage.dart @@ -148,7 +148,7 @@ class Usage { printStatus(''); printStatus(''' ╔════════════════════════════════════════════════════════════════════════════╗ - ║ Welcome to Flutter! - https://flutter.io ║ + ║ Welcome to Flutter! - https://flutter.dev ║ ║ ║ ║ The Flutter tool anonymously reports feature usage statistics and crash ║ ║ reports to Google in order to help Google contribute improvements to ║ diff --git a/packages/flutter_tools/lib/src/version.dart b/packages/flutter_tools/lib/src/version.dart index 3df1df0e84..d571f37be5 100644 --- a/packages/flutter_tools/lib/src/version.dart +++ b/packages/flutter_tools/lib/src/version.dart @@ -32,6 +32,11 @@ class FlutterVersion { return _repositoryUrl; } + /// Whether we are currently on the stable branch. + bool get isStable { + return getBranchName() == 'stable'; + } + static const Set officialChannels = { 'master', 'dev', diff --git a/packages/flutter_tools/lib/src/vmservice.dart b/packages/flutter_tools/lib/src/vmservice.dart index 7adcd72f4e..05a642c8a1 100644 --- a/packages/flutter_tools/lib/src/vmservice.dart +++ b/packages/flutter_tools/lib/src/vmservice.dart @@ -24,10 +24,10 @@ import 'vmservice_record_replay.dart'; /// Override `WebSocketConnector` in [context] to use a different constructor /// for [WebSocket]s (used by tests). -typedef WebSocketConnector = Future Function(String url); +typedef WebSocketConnector = Future Function(String url, {io.CompressionOptions compression}); /// A function that opens a two-way communication channel to the specified [uri]. -typedef _OpenChannel = Future> Function(Uri uri); +typedef _OpenChannel = Future> Function(Uri uri, {io.CompressionOptions compression}); _OpenChannel _openChannel = _defaultOpenChannel; @@ -62,7 +62,7 @@ typedef CompileExpression = Future Function( const String _kRecordingType = 'vmservice'; -Future> _defaultOpenChannel(Uri uri) async { +Future> _defaultOpenChannel(Uri uri, {io.CompressionOptions compression = io.CompressionOptions.compressionDefault}) async { Duration delay = const Duration(milliseconds: 100); int attempts = 0; io.WebSocket socket; @@ -86,7 +86,7 @@ Future> _defaultOpenChannel(Uri uri) async { while (socket == null) { attempts += 1; try { - socket = await constructor(uri.toString()); + socket = await constructor(uri.toString(), compression: compression); } on io.WebSocketException catch (e) { await handleError(e); } on io.SocketException catch (e) { @@ -220,7 +220,7 @@ class VMService { /// `"vmservice"` subdirectory. static void enableRecordingConnection(String location) { final Directory dir = getRecordingSink(location, _kRecordingType); - _openChannel = (Uri uri) async { + _openChannel = (Uri uri, {io.CompressionOptions compression}) async { final StreamChannel delegate = await _defaultOpenChannel(uri); return RecordingVMServiceChannel(delegate, dir); }; @@ -233,7 +233,7 @@ class VMService { /// passed to [enableRecordingConnection]), or a [ToolExit] will be thrown. static void enableReplayConnection(String location) { final Directory dir = getReplaySource(location, _kRecordingType); - _openChannel = (Uri uri) async => ReplayVMServiceChannel(dir); + _openChannel = (Uri uri, {io.CompressionOptions compression}) async => ReplayVMServiceChannel(dir); } /// Connect to a Dart VM Service at [httpUri]. @@ -249,9 +249,10 @@ class VMService { ReloadSources reloadSources, Restart restart, CompileExpression compileExpression, + io.CompressionOptions compression = io.CompressionOptions.compressionDefault, }) async { final Uri wsUri = httpUri.replace(scheme: 'ws', path: fs.path.join(httpUri.path, 'ws')); - final StreamChannel channel = await _openChannel(wsUri); + final StreamChannel channel = await _openChannel(wsUri, compression: compression); final rpc.Peer peer = rpc.Peer.withoutJson(jsonDocument.bind(channel)); final VMService service = VMService(peer, httpUri, wsUri, reloadSources, restart, compileExpression); // This call is to ensure we are able to establish a connection instead of @@ -1283,10 +1284,14 @@ class Isolate extends ServiceObjectOwner { Future> flutterToggleDebugPaintSizeEnabled() => _flutterToggle('debugPaint'); + Future> flutterToggleDebugCheckElevationsEnabled() => _flutterToggle('debugCheckElevationsEnabled'); + Future> flutterTogglePerformanceOverlayOverride() => _flutterToggle('showPerformanceOverlay'); Future> flutterToggleWidgetInspector() => _flutterToggle('inspector.show'); + Future> flutterToggleProfileWidgetBuilds() => _flutterToggle('profileWidgetBuilds'); + Future> flutterDebugAllowBanner(bool show) { return invokeFlutterExtensionRpcRaw( 'ext.flutter.debugAllowBanner', diff --git a/packages/flutter_tools/lib/src/web/web_device.dart b/packages/flutter_tools/lib/src/web/web_device.dart index 4b34393e93..fd78729986 100644 --- a/packages/flutter_tools/lib/src/web/web_device.dart +++ b/packages/flutter_tools/lib/src/web/web_device.dart @@ -13,6 +13,7 @@ import '../build_info.dart'; import '../device.dart'; import '../globals.dart'; import '../project.dart'; +import '../version.dart'; import '../web/compile.dart'; ChromeLauncher get chromeLauncher => context[ChromeLauncher]; @@ -21,7 +22,7 @@ ChromeLauncher get chromeLauncher => context[ChromeLauncher]; /// environment variable is set to true. bool get flutterWebEnabled { _flutterWebEnabled = platform.environment['FLUTTER_WEB']?.toLowerCase() == 'true'; - return _flutterWebEnabled; + return _flutterWebEnabled && !FlutterVersion.instance.isStable; } bool _flutterWebEnabled; diff --git a/packages/flutter_tools/pubspec.yaml b/packages/flutter_tools/pubspec.yaml index a1d023d28a..48a0ff779c 100644 --- a/packages/flutter_tools/pubspec.yaml +++ b/packages/flutter_tools/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_tools description: Tools for building Flutter applications -homepage: https://flutter.io +homepage: https://flutter.dev author: Flutter Authors environment: @@ -17,9 +17,9 @@ dependencies: crypto: 2.0.6 file: 5.0.7 http: 0.12.0+1 - intl: 0.15.7 - json_rpc_2: 2.0.9 - linter: 0.1.82 + intl: 0.15.8 + json_rpc_2: 2.0.10 + linter: 0.1.83 meta: 1.1.6 multicast_dns: 0.1.0+1 mustache: 1.1.1 @@ -27,12 +27,12 @@ dependencies: platform: 2.2.0 plugin: 0.2.0+3 process: 3.0.9 - quiver: 2.0.1 + quiver: 2.0.2 stack_trace: 1.9.3 - stream_channel: 1.6.8 + stream_channel: 2.0.0 usage: 3.4.1 - vm_service_client: 0.2.6 - web_socket_channel: 1.0.9 + vm_service_client: 0.2.6+1 + web_socket_channel: 1.0.12 xml: 3.4.1 yaml: 2.1.15 flutter_goldens_client: @@ -41,39 +41,37 @@ dependencies: # We depend on very specific internal implementation details of the # 'test' package, which change between versions, so when upgrading # this, make sure the tests are still running correctly. - test_api: 0.2.2 - test_core: 0.2.1+1 + test_api: 0.2.4 + test_core: 0.2.3 # Code generation dependencies - build_runner_core: 2.0.3 - dart_style: 1.2.3 + build_runner_core: 3.0.1 + dart_style: 1.2.4 code_builder: 3.2.0 - build: 1.1.1 + build: 1.1.2 build_modules: 1.0.9 - build_daemon: 0.4.2 + build_daemon: 0.5.0 - analyzer: 0.35.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + analyzer: 0.35.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" bazel_worker: 0.1.20 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" build_config: 0.3.1+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" build_resolvers: 1.0.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" built_collection: 4.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - built_value: 6.3.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + built_value: 6.3.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" fixnum: 0.10.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - front_end: 0.1.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + front_end: 0.1.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.1.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" graphs: 0.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - html: 0.13.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 0.3.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" json_annotation: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - kernel: 0.3.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + kernel: 0.3.14 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" package_resolver: 1.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -83,17 +81,16 @@ dependencies: pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pubspec_parse: 0.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" scratch_space: 0.0.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - shelf_web_socket: 0.2.2+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf: 0.7.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + shelf_web_socket: 0.2.2+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_map_stack_trace: 1.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_maps: 0.10.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_transform: 0.0.15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_transform: 0.0.17 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" timing: 0.1.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - utf: 0.9.0+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 0.9.7+10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" dev_dependencies: @@ -101,11 +98,13 @@ dev_dependencies: mockito: 4.0.0 file_testing: 2.1.0 vm_service_lib: 3.14.2 - test: 1.5.3 - build_runner: 1.2.8 + test: 1.6.1 + build_runner: 1.3.1 build_vm_compilers: 0.1.1+5 build_test: 0.10.6 + csslib: 0.14.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + html: 0.13.4+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 2.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.1+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 0.9.6+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" @@ -113,9 +112,10 @@ dev_dependencies: node_preamble: 1.4.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + utf: 0.9.0+5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" dartdoc: # Exclude this package from the hosted API docs. nodoc: true -# PUBSPEC CHECKSUM: fa2f +# PUBSPEC CHECKSUM: fc76 diff --git a/packages/flutter_tools/templates/app/README.md.tmpl b/packages/flutter_tools/templates/app/README.md.tmpl index af7c7459ae..19d2325555 100644 --- a/packages/flutter_tools/templates/app/README.md.tmpl +++ b/packages/flutter_tools/templates/app/README.md.tmpl @@ -8,9 +8,9 @@ This project is a starting point for a Flutter application. A few resources to get you started if this is your first Flutter project: -- [Lab: Write your first Flutter app](https://flutter.io/docs/get-started/codelab) -- [Cookbook: Useful Flutter samples](https://flutter.io/docs/cookbook) +- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) For help getting started with Flutter, view our -[online documentation](https://flutter.io/docs), which offers tutorials, +[online documentation](https://flutter.dev/docs), which offers tutorials, samples, guidance on mobile development, and a full API reference. diff --git a/packages/flutter_tools/templates/app/lib/main.dart.tmpl b/packages/flutter_tools/templates/app/lib/main.dart.tmpl index 6b05dca91c..64e65858cb 100644 --- a/packages/flutter_tools/templates/app/lib/main.dart.tmpl +++ b/packages/flutter_tools/templates/app/lib/main.dart.tmpl @@ -15,7 +15,7 @@ void main() => runApp(MyApp()); {{#withDriverTest}} void main() { // Enable integration testing with the Flutter Driver extension. - // See https://flutter.io/testing/ for more info. + // See https://flutter.dev/testing/ for more info. enableFlutterDriverExtension(); runApp(MyApp()); } diff --git a/packages/flutter_tools/templates/app/pubspec.yaml.tmpl b/packages/flutter_tools/templates/app/pubspec.yaml.tmpl index 526e1756b0..6d803b0ab7 100644 --- a/packages/flutter_tools/templates/app/pubspec.yaml.tmpl +++ b/packages/flutter_tools/templates/app/pubspec.yaml.tmpl @@ -35,7 +35,7 @@ dev_dependencies: {{#withDriverTest}} flutter_driver: sdk: flutter - test: 1.5.2 + test: 1.6.1 {{/withDriverTest}} {{#withPluginHook}} @@ -60,10 +60,10 @@ flutter: # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.io/assets-and-images/#resolution-aware. + # https://flutter.dev/assets-and-images/#resolution-aware. # For details regarding adding assets from package dependencies, see - # https://flutter.io/assets-and-images/#from-packages + # https://flutter.dev/assets-and-images/#from-packages # To add custom fonts to your application, add a fonts section here, # in this "flutter" section. Each entry in this list should have a @@ -83,4 +83,4 @@ flutter: # weight: 700 # # For details regarding fonts from package dependencies, - # see https://flutter.io/custom-fonts/#from-packages + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/packages/flutter_tools/templates/module/common/README.md.tmpl b/packages/flutter_tools/templates/module/common/README.md.tmpl index f140e12b54..bf1e2d2dc3 100644 --- a/packages/flutter_tools/templates/module/common/README.md.tmpl +++ b/packages/flutter_tools/templates/module/common/README.md.tmpl @@ -5,4 +5,4 @@ ## Getting Started For help getting started with Flutter, view our online -[documentation](https://flutter.io/). +[documentation](https://flutter.dev/). diff --git a/packages/flutter_tools/templates/module/common/lib/main.dart.tmpl b/packages/flutter_tools/templates/module/common/lib/main.dart.tmpl index e169489df4..19fe128352 100644 --- a/packages/flutter_tools/templates/module/common/lib/main.dart.tmpl +++ b/packages/flutter_tools/templates/module/common/lib/main.dart.tmpl @@ -15,7 +15,7 @@ void main() => runApp(MyApp()); {{#withDriverTest}} void main() { // Enable integration testing with the Flutter Driver extension. - // See https://flutter.io/testing/ for more info. + // See https://flutter.dev/testing/ for more info. enableFlutterDriverExtension(); runApp(MyApp()); } diff --git a/packages/flutter_tools/templates/module/common/pubspec.yaml.tmpl b/packages/flutter_tools/templates/module/common/pubspec.yaml.tmpl index 185a8700d3..fc61b10d9b 100644 --- a/packages/flutter_tools/templates/module/common/pubspec.yaml.tmpl +++ b/packages/flutter_tools/templates/module/common/pubspec.yaml.tmpl @@ -52,10 +52,10 @@ flutter: # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.io/assets-and-images/#resolution-aware. + # https://flutter.dev/assets-and-images/#resolution-aware. # For details regarding adding assets from package dependencies, see - # https://flutter.io/assets-and-images/#from-packages + # https://flutter.dev/assets-and-images/#from-packages # To add Flutter specific custom fonts to your application, add a fonts # section here, in this "flutter" section. Each entry in this list should @@ -75,7 +75,7 @@ flutter: # weight: 700 # # For details regarding fonts from package dependencies, - # see https://flutter.io/custom-fonts/#from-packages + # see https://flutter.dev/custom-fonts/#from-packages # This section identifies your Flutter project as a module meant for diff --git a/packages/flutter_tools/templates/package/.gitignore.tmpl b/packages/flutter_tools/templates/package/.gitignore.tmpl index 446ed0d1c2..9d7edcf8be 100644 --- a/packages/flutter_tools/templates/package/.gitignore.tmpl +++ b/packages/flutter_tools/templates/package/.gitignore.tmpl @@ -1,10 +1,70 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp .DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# Visual Studio Code related +.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ .dart_tool/ - +.flutter-plugins .packages +.pub-cache/ .pub/ - build/ -ios/.generated/ -ios/Flutter/Generated.xcconfig -ios/Runner/GeneratedPluginRegistrant.* + +# Android related +**/android/**/gradle-wrapper.jar +**/android/.gradle +**/android/captures/ +**/android/gradlew +**/android/gradlew.bat +**/android/local.properties +**/android/**/GeneratedPluginRegistrant.java + +# iOS/XCode related +**/ios/**/*.mode1v3 +**/ios/**/*.mode2v3 +**/ios/**/*.moved-aside +**/ios/**/*.pbxuser +**/ios/**/*.perspectivev3 +**/ios/**/*sync/ +**/ios/**/.sconsign.dblite +**/ios/**/.tags* +**/ios/**/.vagrant/ +**/ios/**/DerivedData/ +**/ios/**/Icon? +**/ios/**/Pods/ +**/ios/**/.symlinks/ +**/ios/**/profile +**/ios/**/xcuserdata +**/ios/.generated/ +**/ios/Flutter/App.framework +**/ios/Flutter/Flutter.framework +**/ios/Flutter/Generated.xcconfig +**/ios/Flutter/app.flx +**/ios/Flutter/app.zip +**/ios/Flutter/flutter_assets/ +**/ios/ServiceDefinitions.json +**/ios/Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!**/ios/**/default.mode1v3 +!**/ios/**/default.mode2v3 +!**/ios/**/default.pbxuser +!**/ios/**/default.perspectivev3 +!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages diff --git a/packages/flutter_tools/templates/package/README.md.tmpl b/packages/flutter_tools/templates/package/README.md.tmpl index 800b83a5ec..e607b50654 100644 --- a/packages/flutter_tools/templates/package/README.md.tmpl +++ b/packages/flutter_tools/templates/package/README.md.tmpl @@ -5,10 +5,10 @@ ## Getting Started This project is a starting point for a Dart -[package](https://flutter.io/developing-packages/), +[package](https://flutter.dev/developing-packages/), a library module containing code that can be shared easily across multiple Flutter or Dart projects. For help getting started with Flutter, view our -[online documentation](https://flutter.io/docs), which offers tutorials, +[online documentation](https://flutter.dev/docs), which offers tutorials, samples, guidance on mobile development, and a full API reference. diff --git a/packages/flutter_tools/templates/package/pubspec.yaml.tmpl b/packages/flutter_tools/templates/package/pubspec.yaml.tmpl index 108d360037..8b0c81bb3b 100644 --- a/packages/flutter_tools/templates/package/pubspec.yaml.tmpl +++ b/packages/flutter_tools/templates/package/pubspec.yaml.tmpl @@ -31,10 +31,10 @@ flutter: # - images/a_dot_ham.jpeg # # For details regarding assets in packages, see - # https://flutter.io/assets-and-images/#from-packages + # https://flutter.dev/assets-and-images/#from-packages # # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.io/assets-and-images/#resolution-aware. + # https://flutter.dev/assets-and-images/#resolution-aware. # To add custom fonts to your package, add a fonts section here, # in this "flutter" section. Each entry in this list should have a @@ -54,4 +54,4 @@ flutter: # weight: 700 # # For details regarding fonts in packages, see - # https://flutter.io/custom-fonts/#from-packages + # https://flutter.dev/custom-fonts/#from-packages diff --git a/packages/flutter_tools/templates/plugin/README.md.tmpl b/packages/flutter_tools/templates/plugin/README.md.tmpl index f08ca4a198..d9c79a1525 100644 --- a/packages/flutter_tools/templates/plugin/README.md.tmpl +++ b/packages/flutter_tools/templates/plugin/README.md.tmpl @@ -5,10 +5,10 @@ ## Getting Started This project is a starting point for a Flutter -[plug-in package](https://flutter.io/developing-packages/), +[plug-in package](https://flutter.dev/developing-packages/), a specialized package that includes platform-specific implementation code for Android and/or iOS. For help getting started with Flutter, view our -[online documentation](https://flutter.io/docs), which offers tutorials, +[online documentation](https://flutter.dev/docs), which offers tutorials, samples, guidance on mobile development, and a full API reference. diff --git a/packages/flutter_tools/templates/plugin/pubspec.yaml.tmpl b/packages/flutter_tools/templates/plugin/pubspec.yaml.tmpl index 2476e4f27d..94c170064c 100644 --- a/packages/flutter_tools/templates/plugin/pubspec.yaml.tmpl +++ b/packages/flutter_tools/templates/plugin/pubspec.yaml.tmpl @@ -34,10 +34,10 @@ flutter: # - images/a_dot_ham.jpeg # # For details regarding assets in packages, see - # https://flutter.io/assets-and-images/#from-packages + # https://flutter.dev/assets-and-images/#from-packages # # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.io/assets-and-images/#resolution-aware. + # https://flutter.dev/assets-and-images/#resolution-aware. # To add custom fonts to your plugin package, add a fonts section here, # in this "flutter" section. Each entry in this list should have a @@ -57,4 +57,4 @@ flutter: # weight: 700 # # For details regarding fonts in packages, see - # https://flutter.io/custom-fonts/#from-packages + # https://flutter.dev/custom-fonts/#from-packages diff --git a/packages/flutter_tools/test/android/gradle_test.dart b/packages/flutter_tools/test/android/gradle_test.dart index c25d2adc24..d9cbefe2cf 100644 --- a/packages/flutter_tools/test/android/gradle_test.dart +++ b/packages/flutter_tools/test/android/gradle_test.dart @@ -252,7 +252,8 @@ someOtherTask String expectedBuildName, String expectedBuildNumber, }) async { - when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.android_arm, any)).thenReturn('engine'); + when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, + platform: TargetPlatform.android_arm, mode: anyNamed('mode'))).thenReturn('engine'); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'android_arm')); final File manifestFile = fs.file('path/to/project/pubspec.yaml'); diff --git a/packages/flutter_tools/test/artifacts_test.dart b/packages/flutter_tools/test/artifacts_test.dart index 00b17e45b4..fcc6c8f1d8 100644 --- a/packages/flutter_tools/test/artifacts_test.dart +++ b/packages/flutter_tools/test/artifacts_test.dart @@ -28,7 +28,7 @@ void main() { testUsingContext('getArtifactPath', () { expect( - artifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, BuildMode.release), + artifacts.getArtifactPath(Artifact.flutterFramework, platform: TargetPlatform.ios, mode: BuildMode.release), fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'ios-release', 'Flutter.framework'), ); expect( @@ -78,7 +78,7 @@ void main() { testUsingContext('getArtifactPath', () { expect( - artifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, BuildMode.release), + artifacts.getArtifactPath(Artifact.flutterFramework, platform: TargetPlatform.ios, mode: BuildMode.release), fs.path.join(tempDir.path, 'out', 'android_debug_unopt', 'Flutter.framework'), ); expect( diff --git a/packages/flutter_tools/test/asset_bundle_test.dart b/packages/flutter_tools/test/asset_bundle_test.dart index 7a0bb002b3..6d99cde99a 100644 --- a/packages/flutter_tools/test/asset_bundle_test.dart +++ b/packages/flutter_tools/test/asset_bundle_test.dart @@ -56,6 +56,89 @@ void main() { }, overrides: { FileSystem: () => testFileSystem, }); + + testUsingContext('wildcard directories are updated when filesystem changes', () async { + fs.file('.packages').createSync(); + fs.file(fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true); + fs.file('pubspec.yaml') + ..createSync() + ..writeAsStringSync(r''' +name: example +flutter: + assets: + - assets/foo/ +'''); + final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); + await bundle.build(manifestPath: 'pubspec.yaml'); + // Expected assets: + // - asset manifest + // - font manifest + // - license file + // - assets/foo/bar.txt + expect(bundle.entries.length, 4); + expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false); + + // Adding a file should update the stat of the directory, but instead + // we need to fully recreate it. + fs.directory(fs.path.join('assets', 'foo')).deleteSync(recursive: true); + fs.file(fs.path.join('assets', 'foo', 'fizz.txt')).createSync(recursive: true); + fs.file(fs.path.join('assets', 'foo', 'bar.txt')).createSync(); + + expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), true); + await bundle.build(manifestPath: 'pubspec.yaml'); + // Expected assets: + // - asset manifest + // - font manifest + // - license file + // - assets/foo/bar.txt + // - assets/foo/fizz.txt + expect(bundle.entries.length, 5); + }, overrides: { + FileSystem: () => testFileSystem, + }); + + testUsingContext('handle removal of wildcard directories', () async { + fs.file('.packages').createSync(); + fs.file(fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true); + fs.file('pubspec.yaml') + ..createSync() + ..writeAsStringSync(r''' +name: example +flutter: + assets: + - assets/foo/ +'''); + final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); + await bundle.build(manifestPath: 'pubspec.yaml'); + // Expected assets: + // - asset manifest + // - font manifest + // - license file + // - assets/foo/bar.txt + expect(bundle.entries.length, 4); + expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false); + + // Delete the wildcard directory and update pubspec file. + fs.directory(fs.path.join('assets', 'foo')).deleteSync(recursive: true); + fs.file('pubspec.yaml') + ..createSync() + ..writeAsStringSync(r''' +name: example'''); + + // Even though the previous file was removed, it is left in the + // asset manifest and not updated. This is due to the devfs not + // supporting file deletion. + expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), true); + await bundle.build(manifestPath: 'pubspec.yaml'); + // Expected assets: + // - asset manifest + // - font manifest + // - license file + // - assets/foo/bar.txt + expect(bundle.entries.length, 4); + }, overrides: { + FileSystem: () => testFileSystem, + }); }); } diff --git a/packages/flutter_tools/test/base/build_test.dart b/packages/flutter_tools/test/base/build_test.dart index 9adce02dea..facb0fd3b3 100644 --- a/packages/flutter_tools/test/base/build_test.dart +++ b/packages/flutter_tools/test/base/build_test.dart @@ -13,6 +13,7 @@ import 'package:flutter_tools/src/base/build.dart'; import 'package:flutter_tools/src/base/context.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; +import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/process.dart'; import 'package:flutter_tools/src/ios/mac.dart'; import 'package:flutter_tools/src/version.dart'; @@ -87,9 +88,11 @@ void main() { _FakeGenSnapshot genSnapshot; MemoryFileSystem fs; AOTSnapshotter snapshotter; + AOTSnapshotter snapshotterWithTimings; MockAndroidSdk mockAndroidSdk; MockArtifacts mockArtifacts; MockXcode mockXcode; + BufferLogger bufferLogger; setUp(() async { fs = MemoryFileSystem(); @@ -105,11 +108,14 @@ void main() { genSnapshot = _FakeGenSnapshot(); snapshotter = AOTSnapshotter(); + snapshotterWithTimings = AOTSnapshotter(reportTimings: true); mockAndroidSdk = MockAndroidSdk(); mockArtifacts = MockArtifacts(); mockXcode = MockXcode(); + bufferLogger = BufferLogger(); for (BuildMode mode in BuildMode.values) { - when(mockArtifacts.getArtifactPath(Artifact.snapshotDart, any, mode)).thenReturn(kSnapshotDart); + when(mockArtifacts.getArtifactPath(Artifact.snapshotDart, + platform: anyNamed('platform'), mode: mode)).thenReturn(kSnapshotDart); } }); @@ -119,6 +125,7 @@ void main() { FileSystem: () => fs, GenSnapshot: () => genSnapshot, Xcode: () => mockXcode, + Logger: () => bufferLogger, }; testUsingContext('iOS debug AOT snapshot is invalid', () async { @@ -491,6 +498,36 @@ void main() { ]); }, overrides: contextOverrides); + testUsingContext('reports timing', () async { + fs.file('main.dill').writeAsStringSync('binary magic'); + + final String outputPath = fs.path.join('build', 'foo'); + fs.directory(outputPath).createSync(recursive: true); + + genSnapshot.outputs = { + fs.path.join(outputPath, 'vm_snapshot_data'): '', + fs.path.join(outputPath, 'isolate_snapshot_data'): '', + fs.path.join(outputPath, 'vm_snapshot_instr'): '', + fs.path.join(outputPath, 'isolate_snapshot_instr'): '', + }; + + final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), ['command name', 'arguments...']); + when(xcode.cc(any)).thenAnswer((_) => Future.value(successResult)); + when(xcode.clang(any)).thenAnswer((_) => Future.value(successResult)); + + final int genSnapshotExitCode = await snapshotterWithTimings.build( + platform: TargetPlatform.android_arm, + buildMode: BuildMode.release, + mainPath: 'main.dill', + packagesPath: '.packages', + outputPath: outputPath, + buildSharedLibrary: false, + ); + + expect(genSnapshotExitCode, 0); + expect(genSnapshot.callCount, 1); + expect(bufferLogger.statusText, matches(RegExp(r'gen_snapshot\(RunTime\): \d+ ms.'))); + }, overrides: contextOverrides); }); group('Snapshotter - JIT', () { @@ -516,9 +553,11 @@ void main() { mockArtifacts = MockArtifacts(); for (BuildMode mode in BuildMode.values) { - when(mockArtifacts.getArtifactPath(Artifact.vmSnapshotData, null, mode)) + when(mockArtifacts.getArtifactPath(Artifact.vmSnapshotData, + platform: anyNamed('platform'), mode: mode)) .thenReturn(kEngineVmSnapshotData); - when(mockArtifacts.getArtifactPath(Artifact.isolateSnapshotData, null, mode)) + when(mockArtifacts.getArtifactPath(Artifact.isolateSnapshotData, + platform: anyNamed('platform'), mode: mode)) .thenReturn(kEngineIsolateSnapshotData); } }); diff --git a/packages/flutter_tools/test/base/logger_test.dart b/packages/flutter_tools/test/base/logger_test.dart index 99c532f27d..e650ce5b12 100644 --- a/packages/flutter_tools/test/base/logger_test.dart +++ b/packages/flutter_tools/test/base/logger_test.dart @@ -148,7 +148,8 @@ void main() { await tenMillisecondsLater; doWhileAsync(time, () => ansiSpinner.ticks < 30); // three seconds expect(ansiSpinner.seemsSlow, isTrue); - expect(outputStdout().join('\n'), contains('This is taking an unexpectedly long time.')); + // Check the 2nd line to verify there's a newline before the warning + expect(outputStdout()[1], contains('This is taking an unexpectedly long time.')); ansiSpinner.stop(); expect(outputStdout().join('\n'), isNot(contains('(!)'))); done = true; @@ -166,7 +167,7 @@ void main() { final Status status = logger.startProgress( 'Hello', progressId: null, - timeout: kSlowOperation, + timeout: timeoutConfiguration.slowOperation, progressIndicatorPadding: 20, // this minus the "Hello" equals the 15 below. ); expect(outputStderr().length, equals(1)); @@ -357,7 +358,7 @@ void main() { called = 0; summaryStatus = SummaryStatus( message: 'Hello world', - timeout: kSlowOperation, + timeout: timeoutConfiguration.slowOperation, padding: 20, onFinish: () => called++, ); @@ -593,7 +594,7 @@ void main() { final Status status = logger.startProgress( 'Hello', progressId: null, - timeout: kSlowOperation, + timeout: timeoutConfiguration.slowOperation, progressIndicatorPadding: 20, // this minus the "Hello" equals the 15 below. ); expect(outputStderr().length, equals(1)); @@ -661,8 +662,8 @@ void main() { testUsingContext('sequential startProgress calls with StdoutLogger', () async { final Logger logger = context[Logger]; - logger.startProgress('AAA', timeout: kFastOperation)..stop(); - logger.startProgress('BBB', timeout: kFastOperation)..stop(); + logger.startProgress('AAA', timeout: timeoutConfiguration.fastOperation)..stop(); + logger.startProgress('BBB', timeout: timeoutConfiguration.fastOperation)..stop(); final List output = outputStdout(); expect(output.length, equals(3)); // There's 61 spaces at the start: 59 (padding default) - 3 (length of AAA) + 5 (margin). @@ -679,8 +680,8 @@ void main() { testUsingContext('sequential startProgress calls with VerboseLogger and StdoutLogger', () async { final Logger logger = context[Logger]; - logger.startProgress('AAA', timeout: kFastOperation)..stop(); - logger.startProgress('BBB', timeout: kFastOperation)..stop(); + logger.startProgress('AAA', timeout: timeoutConfiguration.fastOperation)..stop(); + logger.startProgress('BBB', timeout: timeoutConfiguration.fastOperation)..stop(); expect(outputStdout(), [ matches(r'^\[ (?: {0,2}\+[0-9]{1,3} ms| )\] AAA$'), matches(r'^\[ (?: {0,2}\+[0-9]{1,3} ms| )\] AAA \(completed.*\)$'), @@ -696,8 +697,8 @@ void main() { testUsingContext('sequential startProgress calls with BufferLogger', () async { final BufferLogger logger = context[Logger]; - logger.startProgress('AAA', timeout: kFastOperation)..stop(); - logger.startProgress('BBB', timeout: kFastOperation)..stop(); + logger.startProgress('AAA', timeout: timeoutConfiguration.fastOperation)..stop(); + logger.startProgress('BBB', timeout: timeoutConfiguration.fastOperation)..stop(); expect(logger.statusText, 'AAA\nBBB\n'); }, overrides: { Logger: () => BufferLogger(), diff --git a/packages/flutter_tools/test/cache_test.dart b/packages/flutter_tools/test/cache_test.dart index 1e7916f361..a95964a551 100644 --- a/packages/flutter_tools/test/cache_test.dart +++ b/packages/flutter_tools/test/cache_test.dart @@ -103,9 +103,9 @@ void main() { when(artifact1.isUpToDate()).thenReturn(true); when(artifact2.isUpToDate()).thenReturn(false); final Cache cache = Cache(artifacts: [artifact1, artifact2]); - await cache.updateAll(); - verifyNever(artifact1.update()); - verify(artifact2.update()); + await cache.updateAll({}); + verifyNever(artifact1.update({})); + verify(artifact2.update({})); }); testUsingContext('failed storage.googleapis.com download shows China warning', () async { final CachedArtifact artifact1 = MockCachedArtifact(); @@ -114,30 +114,30 @@ void main() { when(artifact2.isUpToDate()).thenReturn(false); final MockInternetAddress address = MockInternetAddress(); when(address.host).thenReturn('storage.googleapis.com'); - when(artifact1.update()).thenThrow(SocketException( + when(artifact1.update({})).thenThrow(SocketException( 'Connection reset by peer', address: address, )); final Cache cache = Cache(artifacts: [artifact1, artifact2]); try { - await cache.updateAll(); + await cache.updateAll({}); fail('Mock thrown exception expected'); } catch (e) { - verify(artifact1.update()); + verify(artifact1.update({})); // Don't continue when retrieval fails. - verifyNever(artifact2.update()); + verifyNever(artifact2.update({})); expect( testLogger.errorText, - contains('https://flutter.io/community/china'), + contains('https://flutter.dev/community/china'), ); } }); }); testUsingContext('flattenNameSubdirs', () { - expect(flattenNameSubdirs(Uri.parse('http://flutter.io/foo/bar')), 'flutter.io/foo/bar'); + expect(flattenNameSubdirs(Uri.parse('http://flutter.dev/foo/bar')), 'flutter.dev/foo/bar'); expect(flattenNameSubdirs(Uri.parse('http://docs.flutter.io/foo/bar')), 'docs.flutter.io/foo/bar'); - expect(flattenNameSubdirs(Uri.parse('https://www.flutter.io')), 'www.flutter.io'); + expect(flattenNameSubdirs(Uri.parse('https://www.flutter.dev')), 'www.flutter.dev'); }, overrides: { FileSystem: () => MockFileSystem(), }); diff --git a/packages/flutter_tools/test/commands/drive_test.dart b/packages/flutter_tools/test/commands/drive_test.dart index 81a435c059..d7bf21b893 100644 --- a/packages/flutter_tools/test/commands/drive_test.dart +++ b/packages/flutter_tools/test/commands/drive_test.dart @@ -291,6 +291,130 @@ void main() { Platform: macOsPlatform, }); }); + + group('build arguments', () { + String testApp, testFile; + + setUp(() { + restoreAppStarter(); + }); + + Future appStarterSetup() async { + withMockDevice(); + + final MockDeviceLogReader mockDeviceLogReader = MockDeviceLogReader(); + when(mockDevice.getLogReader()).thenReturn(mockDeviceLogReader); + final MockLaunchResult mockLaunchResult = MockLaunchResult(); + when(mockLaunchResult.started).thenReturn(true); + when(mockDevice.startApp( + null, + mainPath: anyNamed('mainPath'), + route: anyNamed('route'), + debuggingOptions: anyNamed('debuggingOptions'), + platformArgs: anyNamed('platformArgs'), + prebuiltApplication: anyNamed('prebuiltApplication'), + usesTerminalUi: false, + )).thenAnswer((_) => Future.value(mockLaunchResult)); + when(mockDevice.isAppInstalled(any)).thenAnswer((_) => Future.value(false)); + + testApp = fs.path.join(tempDir.path, 'test', 'e2e.dart'); + testFile = fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart'); + + testRunner = (List testArgs, String observatoryUri) async { + throwToolExit(null, exitCode: 123); + }; + appStopper = expectAsync1( + (DriveCommand command) async { + return true; + }, + count: 2, + ); + + final MemoryFileSystem memFs = fs; + await memFs.file(testApp).writeAsString('main() {}'); + await memFs.file(testFile).writeAsString('main() {}'); + } + + testUsingContext('does not use pre-built app if no build arg provided', () async { + await appStarterSetup(); + + final List args = [ + 'drive', + '--target=$testApp', + ]; + try { + await createTestCommandRunner(command).run(args); + } on ToolExit catch (e) { + expect(e.exitCode, 123); + expect(e.message, null); + } + verify(mockDevice.startApp( + null, + mainPath: anyNamed('mainPath'), + route: anyNamed('route'), + debuggingOptions: anyNamed('debuggingOptions'), + platformArgs: anyNamed('platformArgs'), + prebuiltApplication: false, + usesTerminalUi: false, + )); + }, overrides: { + FileSystem: () => fs, + }); + + testUsingContext('does not use pre-built app if --build arg provided', () async { + await appStarterSetup(); + + final List args = [ + 'drive', + '--build', + '--target=$testApp', + ]; + try { + await createTestCommandRunner(command).run(args); + } on ToolExit catch (e) { + expect(e.exitCode, 123); + expect(e.message, null); + } + verify(mockDevice.startApp( + null, + mainPath: anyNamed('mainPath'), + route: anyNamed('route'), + debuggingOptions: anyNamed('debuggingOptions'), + platformArgs: anyNamed('platformArgs'), + prebuiltApplication: false, + usesTerminalUi: false, + )); + }, overrides: { + FileSystem: () => fs, + }); + + testUsingContext('uses prebuilt app if --no-build arg provided', () async { + await appStarterSetup(); + + final List args = [ + 'drive', + '--no-build', + '--target=$testApp', + ]; + try { + await createTestCommandRunner(command).run(args); + } on ToolExit catch (e) { + expect(e.exitCode, 123); + expect(e.message, null); + } + verify(mockDevice.startApp( + null, + mainPath: anyNamed('mainPath'), + route: anyNamed('route'), + debuggingOptions: anyNamed('debuggingOptions'), + platformArgs: anyNamed('platformArgs'), + prebuiltApplication: true, + usesTerminalUi: false, + )); + }, overrides: { + FileSystem: () => fs, + }); + }); }); } @@ -301,3 +425,5 @@ class MockDevice extends Mock implements Device { } class MockAndroidDevice extends Mock implements AndroidDevice { } + +class MockLaunchResult extends Mock implements LaunchResult { } diff --git a/packages/flutter_tools/test/commands/packages_test.dart b/packages/flutter_tools/test/commands/packages_test.dart index 2d37e95c03..94dfbae6b7 100644 --- a/packages/flutter_tools/test/commands/packages_test.dart +++ b/packages/flutter_tools/test/commands/packages_test.dart @@ -308,7 +308,7 @@ void main() { Stdio: () => mockStdio, }); - testUsingContext('publish', () async { + testUsingContext('pub publish', () async { final PromptingProcess process = PromptingProcess(); mockProcessManager.processFactory = (List commands) => process; final Future runPackages = createTestCommandRunner(PackagesCommand()).run(['packages', 'pub', 'publish']); @@ -331,5 +331,84 @@ void main() { ProcessManager: () => mockProcessManager, Stdio: () => mockStdio, }); + + testUsingContext('publish', () async { + await createTestCommandRunner(PackagesCommand()).run(['packages', 'publish']); + final List commands = mockProcessManager.commands; + expect(commands, hasLength(3)); + expect(commands[0], matches(r'dart-sdk[\\/]bin[\\/]pub')); + expect(commands[1], '--trace'); + expect(commands[2], 'publish'); + }, overrides: { + ProcessManager: () => mockProcessManager, + Stdio: () => mockStdio, + BotDetector: () => const AlwaysTrueBotDetector(), + }); + + testUsingContext('deps', () async { + await createTestCommandRunner(PackagesCommand()).run(['packages', 'deps']); + final List commands = mockProcessManager.commands; + expect(commands, hasLength(3)); + expect(commands[0], matches(r'dart-sdk[\\/]bin[\\/]pub')); + expect(commands[1], '--trace'); + expect(commands[2], 'deps'); + }, overrides: { + ProcessManager: () => mockProcessManager, + Stdio: () => mockStdio, + BotDetector: () => const AlwaysTrueBotDetector(), + }); + + testUsingContext('cache', () async { + await createTestCommandRunner(PackagesCommand()).run(['packages', 'cache']); + final List commands = mockProcessManager.commands; + expect(commands, hasLength(3)); + expect(commands[0], matches(r'dart-sdk[\\/]bin[\\/]pub')); + expect(commands[1], '--trace'); + expect(commands[2], 'cache'); + }, overrides: { + ProcessManager: () => mockProcessManager, + Stdio: () => mockStdio, + BotDetector: () => const AlwaysTrueBotDetector(), + }); + + testUsingContext('version', () async { + await createTestCommandRunner(PackagesCommand()).run(['packages', 'version']); + final List commands = mockProcessManager.commands; + expect(commands, hasLength(3)); + expect(commands[0], matches(r'dart-sdk[\\/]bin[\\/]pub')); + expect(commands[1], '--trace'); + expect(commands[2], 'version'); + }, overrides: { + ProcessManager: () => mockProcessManager, + Stdio: () => mockStdio, + BotDetector: () => const AlwaysTrueBotDetector(), + }); + + testUsingContext('uploader', () async { + await createTestCommandRunner(PackagesCommand()).run(['packages', 'uploader']); + final List commands = mockProcessManager.commands; + expect(commands, hasLength(3)); + expect(commands[0], matches(r'dart-sdk[\\/]bin[\\/]pub')); + expect(commands[1], '--trace'); + expect(commands[2], 'uploader'); + }, overrides: { + ProcessManager: () => mockProcessManager, + Stdio: () => mockStdio, + BotDetector: () => const AlwaysTrueBotDetector(), + }); + + testUsingContext('global', () async { + await createTestCommandRunner(PackagesCommand()).run(['packages', 'global', 'list']); + final List commands = mockProcessManager.commands; + expect(commands, hasLength(4)); + expect(commands[0], matches(r'dart-sdk[\\/]bin[\\/]pub')); + expect(commands[1], '--trace'); + expect(commands[2], 'global'); + expect(commands[3], 'list'); + }, overrides: { + ProcessManager: () => mockProcessManager, + Stdio: () => mockStdio, + BotDetector: () => const AlwaysTrueBotDetector(), + }); }); } diff --git a/packages/flutter_tools/test/commands/precache_test.dart b/packages/flutter_tools/test/commands/precache_test.dart new file mode 100644 index 0000000000..090df1b6c6 --- /dev/null +++ b/packages/flutter_tools/test/commands/precache_test.dart @@ -0,0 +1,69 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_tools/src/cache.dart'; +import 'package:flutter_tools/src/commands/precache.dart'; +import 'package:flutter_tools/src/runner/flutter_command.dart'; +import 'package:flutter_tools/src/version.dart'; +import 'package:mockito/mockito.dart'; + +import '../src/common.dart'; +import '../src/context.dart'; +import '../src/mocks.dart'; + +void main() { + group('precache', () { + final MockCache cache = MockCache(); + Set artifacts; + + when(cache.isUpToDate()).thenReturn(false); + when(cache.updateAll(any)).thenAnswer((Invocation invocation) { + artifacts = invocation.positionalArguments.first; + return Future.value(null); + }); + + testUsingContext('Adds artifact flags to requested artifacts', () async { + final PrecacheCommand command = PrecacheCommand(); + applyMocksToCommand(command); + await createTestCommandRunner(command).run( + const ['precache', '--ios', '--android', '--web', '--macos', '--linux', '--windows'] + ); + expect(artifacts, unorderedEquals({ + DevelopmentArtifact.universal, + DevelopmentArtifact.iOS, + DevelopmentArtifact.android, + DevelopmentArtifact.web, + DevelopmentArtifact.macOS, + DevelopmentArtifact.linux, + DevelopmentArtifact.windows, + })); + }, overrides: { + Cache: () => cache, + }); + + final MockFlutterVersion flutterVersion = MockFlutterVersion(); + when(flutterVersion.isStable).thenReturn(true); + + testUsingContext('Adds artifact flags to requested artifacts on stable', () async { + // Release lock between test cases. + Cache.releaseLockEarly(); + final PrecacheCommand command = PrecacheCommand(); + applyMocksToCommand(command); + await createTestCommandRunner(command).run( + const ['precache', '--ios', '--android', '--web', '--macos', '--linux', '--windows'] + ); + expect(artifacts, unorderedEquals({ + DevelopmentArtifact.universal, + DevelopmentArtifact.iOS, + DevelopmentArtifact.android, + })); + }, overrides: { + Cache: () => cache, + FlutterVersion: () => flutterVersion, + }); + }); +} + +class MockFlutterVersion extends Mock implements FlutterVersion {} +class MockCache extends Mock implements Cache {} diff --git a/packages/flutter_tools/test/commands/run_test.dart b/packages/flutter_tools/test/commands/run_test.dart index 16c4efe65a..497b572ce6 100644 --- a/packages/flutter_tools/test/commands/run_test.dart +++ b/packages/flutter_tools/test/commands/run_test.dart @@ -3,13 +3,19 @@ // found in the LICENSE file. import 'package:flutter_tools/src/base/common.dart'; +import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/commands/run.dart'; +import 'package:flutter_tools/src/device.dart'; +import 'package:flutter_tools/src/runner/flutter_command.dart'; +import 'package:mockito/mockito.dart'; import '../src/common.dart'; import '../src/context.dart'; import '../src/mocks.dart'; void main() { + final MockDeviceManager mockDeviceManager = MockDeviceManager(); + group('run', () { testUsingContext('fails when target not found', () async { final RunCommand command = RunCommand(); @@ -21,5 +27,65 @@ void main() { expect(e.exitCode ?? 1, 1); } }); + + testUsingContext('should only request artifacts corresponding to connected devices', () async { + when(mockDeviceManager.getDevices()).thenAnswer((Invocation invocation) { + return Stream.fromIterable([ + MockDevice(TargetPlatform.android_arm), + ]); + }); + + expect(await RunCommand().requiredArtifacts, unorderedEquals({ + DevelopmentArtifact.universal, + DevelopmentArtifact.android, + })); + + when(mockDeviceManager.getDevices()).thenAnswer((Invocation invocation) { + return Stream.fromIterable([ + MockDevice(TargetPlatform.ios), + ]); + }); + + expect(await RunCommand().requiredArtifacts, unorderedEquals({ + DevelopmentArtifact.universal, + DevelopmentArtifact.iOS, + })); + + when(mockDeviceManager.getDevices()).thenAnswer((Invocation invocation) { + return Stream.fromIterable([ + MockDevice(TargetPlatform.ios), + MockDevice(TargetPlatform.android_arm), + ]); + }); + + expect(await RunCommand().requiredArtifacts, unorderedEquals({ + DevelopmentArtifact.universal, + DevelopmentArtifact.iOS, + DevelopmentArtifact.android, + })); + + when(mockDeviceManager.getDevices()).thenAnswer((Invocation invocation) { + return Stream.fromIterable([ + MockDevice(TargetPlatform.web), + ]); + }); + + expect(await RunCommand().requiredArtifacts, unorderedEquals({ + DevelopmentArtifact.universal, + DevelopmentArtifact.web, + })); + }, overrides: { + DeviceManager: () => mockDeviceManager, + }); }); } + +class MockDeviceManager extends Mock implements DeviceManager {} +class MockDevice extends Mock implements Device { + MockDevice(this._targetPlatform); + + final TargetPlatform _targetPlatform; + + @override + Future get targetPlatform async => _targetPlatform; +} \ No newline at end of file diff --git a/packages/flutter_tools/test/commands/upgrade_test.dart b/packages/flutter_tools/test/commands/upgrade_test.dart index 2ee2b76d53..00e38a7f19 100644 --- a/packages/flutter_tools/test/commands/upgrade_test.dart +++ b/packages/flutter_tools/test/commands/upgrade_test.dart @@ -29,6 +29,7 @@ void main() { fakeCommandRunner = FakeUpgradeCommandRunner(); realCommandRunner = UpgradeCommandRunner(); processManager = MockProcessManager(); + fakeCommandRunner.willHaveUncomittedChanges = false; }); test('throws on unknown tag, official branch, noforce', () async { @@ -49,6 +50,26 @@ void main() { expect(await result, null); }); + test('throws tool exit with uncommited changes', () async { + fakeCommandRunner.willHaveUncomittedChanges = true; + final Future result = fakeCommandRunner.runCommand( + false, + gitTagVersion, + flutterVersion, + ); + expect(result, throwsA(isA())); + }); + + test('does not throw tool exit with uncommited changes and force', () async { + fakeCommandRunner.willHaveUncomittedChanges = true; + final Future result = fakeCommandRunner.runCommand( + true, + gitTagVersion, + flutterVersion, + ); + expect(await result, null); + }); + test('Doesn\'t throw on known tag, dev branch, no force', () async { final Future result = fakeCommandRunner.runCommand( false, @@ -127,9 +148,14 @@ void main() { } class FakeUpgradeCommandRunner extends UpgradeCommandRunner { + bool willHaveUncomittedChanges = false; + @override Future verifyUpstreamConfigured() async {} + @override + Future hasUncomittedChanges() async => willHaveUncomittedChanges; + @override Future resetChanges(GitTagVersion gitTagVersion) async {} diff --git a/packages/flutter_tools/test/hot_test.dart b/packages/flutter_tools/test/hot_test.dart index 37ac83fdee..4868321fbc 100644 --- a/packages/flutter_tools/test/hot_test.dart +++ b/packages/flutter_tools/test/hot_test.dart @@ -5,6 +5,7 @@ import 'dart:async'; import 'package:flutter_tools/src/artifacts.dart'; +import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/devfs.dart'; import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/resident_runner.dart'; @@ -130,7 +131,7 @@ void main() { when(mockDevice.supportsHotRestart).thenReturn(false); // Trigger hot restart. final List devices = [ - FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false)..devFS = mockDevFs, + FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug)..devFS = mockDevFs, ]; final OperationResult result = await HotRunner(devices).restart(fullRestart: true); // Expect hot restart failed. @@ -151,8 +152,8 @@ void main() { when(mockHotDevice.supportsHotRestart).thenReturn(true); // Trigger hot restart. final List devices = [ - FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false)..devFS = mockDevFs, - FlutterDevice(mockHotDevice, generator: residentCompiler, trackWidgetCreation: false)..devFS = mockDevFs, + FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug)..devFS = mockDevFs, + FlutterDevice(mockHotDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug)..devFS = mockDevFs, ]; final OperationResult result = await HotRunner(devices).restart(fullRestart: true); // Expect hot restart failed. @@ -173,8 +174,8 @@ void main() { when(mockHotDevice.supportsHotRestart).thenReturn(true); // Trigger a restart. final List devices = [ - FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false)..devFS = mockDevFs, - FlutterDevice(mockHotDevice, generator: residentCompiler, trackWidgetCreation: false)..devFS = mockDevFs, + FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug)..devFS = mockDevFs, + FlutterDevice(mockHotDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug)..devFS = mockDevFs, ]; final OperationResult result = await HotRunner(devices).restart(fullRestart: true); // Expect hot restart was successful. @@ -190,7 +191,7 @@ void main() { when(mockDevice.supportsHotReload).thenReturn(true); when(mockDevice.supportsHotRestart).thenReturn(true); final List devices = [ - FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false), + FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug), ]; final OperationResult result = await HotRunner(devices).restart(fullRestart: true); expect(result.isOk, false); @@ -207,7 +208,7 @@ void main() { when(mockDevice.supportsHotRestart).thenReturn(true); // Trigger hot restart. final List devices = [ - FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false)..devFS = mockDevFs, + FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug)..devFS = mockDevFs, ]; final OperationResult result = await HotRunner(devices).restart(fullRestart: true); // Expect hot restart successful. @@ -233,7 +234,7 @@ void main() { when(mockDevice.supportsHotRestart).thenReturn(true); when(mockDevice.supportsStopApp).thenReturn(false); final List devices = [ - FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false), + FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug), ]; await HotRunner(devices).cleanupAfterSignal(); expect(shutdownTestingConfig.shutdownHookCalled, true); @@ -248,7 +249,7 @@ void main() { when(mockDevice.supportsHotRestart).thenReturn(true); when(mockDevice.supportsStopApp).thenReturn(false); final List devices = [ - FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false), + FlutterDevice(mockDevice, generator: residentCompiler, trackWidgetCreation: false, buildMode: BuildMode.debug), ]; await HotRunner(devices).preStop(); expect(shutdownTestingConfig.shutdownHookCalled, true); diff --git a/packages/flutter_tools/test/ios/ios_workflow_test.dart b/packages/flutter_tools/test/ios/ios_workflow_test.dart index 46926562a2..eafaa192eb 100644 --- a/packages/flutter_tools/test/ios/ios_workflow_test.dart +++ b/packages/flutter_tools/test/ios/ios_workflow_test.dart @@ -230,6 +230,22 @@ Show information about a connected device. CocoaPods: () => cocoaPods, }); + testUsingContext('Emits partial status when ios-deploy version is a known bad version', () async { + when(xcode.isInstalled).thenReturn(true); + when(xcode.versionText) + .thenReturn('Xcode 8.2.1\nBuild version 8C1002\n'); + when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(true); + when(xcode.eulaSigned).thenReturn(true); + when(xcode.isSimctlInstalled).thenReturn(true); + final IOSWorkflowTestTarget workflow = IOSWorkflowTestTarget(iosDeployVersionText: '2.0.0'); + final ValidationResult result = await workflow.validate(); + expect(result.type, ValidationType.partial); + }, overrides: { + IMobileDevice: () => iMobileDevice, + Xcode: () => xcode, + CocoaPods: () => cocoaPods, + }); + testUsingContext('Emits partial status when simctl is not installed', () async { when(xcode.isInstalled).thenReturn(true); when(xcode.versionText) diff --git a/packages/flutter_tools/test/ios/xcodeproj_test.dart b/packages/flutter_tools/test/ios/xcodeproj_test.dart index ed4fa5e07e..86e33f473c 100644 --- a/packages/flutter_tools/test/ios/xcodeproj_test.dart +++ b/packages/flutter_tools/test/ios/xcodeproj_test.dart @@ -282,7 +282,8 @@ Information about project "Runner": } testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async { - when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, any)).thenReturn('engine'); + when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, + platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine'); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm')); const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, targetPlatform: TargetPlatform.ios); @@ -300,7 +301,8 @@ Information about project "Runner": }); testUsingOsxContext('sets TRACK_WIDGET_CREATION=true when trackWidgetCreation is true', () async { - when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, any)).thenReturn('engine'); + when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, + platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine'); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm')); const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, trackWidgetCreation: true, targetPlatform: TargetPlatform.ios); final FlutterProject project = await FlutterProject.fromPath('path/to/project'); @@ -317,7 +319,8 @@ Information about project "Runner": }); testUsingOsxContext('does not set TRACK_WIDGET_CREATION when trackWidgetCreation is false', () async { - when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, any)).thenReturn('engine'); + when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, + platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine'); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm')); const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, targetPlatform: TargetPlatform.ios); final FlutterProject project = await FlutterProject.fromPath('path/to/project'); @@ -334,7 +337,8 @@ Information about project "Runner": }); testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async { - when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, any)).thenReturn('engine'); + when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, + platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine'); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile')); const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, targetPlatform: TargetPlatform.ios); @@ -366,7 +370,8 @@ Information about project "Runner": String expectedBuildName, String expectedBuildNumber, }) async { - when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, any)).thenReturn('engine'); + when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, + platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine'); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios')); final File manifestFile = fs.file('path/to/project/pubspec.yaml'); diff --git a/packages/flutter_tools/test/resident_runner_test.dart b/packages/flutter_tools/test/resident_runner_test.dart index 2a20530991..a4c96b39d7 100644 --- a/packages/flutter_tools/test/resident_runner_test.dart +++ b/packages/flutter_tools/test/resident_runner_test.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'dart:async'; +import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/resident_runner.dart'; import 'package:mockito/mockito.dart'; @@ -53,7 +54,7 @@ void main() { // TODO(jacobr): make these tests run with `trackWidgetCreation: true` as // well as the default flags. return TestRunner( - [FlutterDevice(MockDevice(), trackWidgetCreation: false)], + [FlutterDevice(MockDevice(), trackWidgetCreation: false, buildMode: BuildMode.debug)], ); } diff --git a/packages/flutter_tools/test/runner/flutter_command_test.dart b/packages/flutter_tools/test/runner/flutter_command_test.dart index f98371a095..e91b95b22d 100644 --- a/packages/flutter_tools/test/runner/flutter_command_test.dart +++ b/packages/flutter_tools/test/runner/flutter_command_test.dart @@ -7,6 +7,7 @@ import 'package:flutter_tools/src/base/time.dart'; import 'package:flutter_tools/src/usage.dart'; import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/runner/flutter_command.dart'; +import 'package:flutter_tools/src/version.dart'; import 'package:mockito/mockito.dart'; import '../src/common.dart'; @@ -42,7 +43,7 @@ void main() { testUsingContext('honors shouldUpdateCache true', () async { final DummyFlutterCommand flutterCommand = DummyFlutterCommand(shouldUpdateCache: true); await flutterCommand.run(); - verify(cache.updateAll()).called(1); + verify(cache.updateAll(any)).called(1); }, overrides: { Cache: () => cache, @@ -155,4 +156,43 @@ void main() { }); }); + + group('Experimental commands', () { + final MockVersion stableVersion = MockVersion(); + final MockVersion betaVersion = MockVersion(); + final FakeCommand fakeCommand = FakeCommand(); + when(stableVersion.isStable).thenReturn(true); + when(betaVersion.isStable).thenReturn(false); + + testUsingContext('Can be disabled on stable branch', () async { + expect(() => fakeCommand.run(), throwsA(isA())); + }, overrides: { + FlutterVersion: () => stableVersion, + }); + + testUsingContext('Works normally on regular branches', () async { + expect(fakeCommand.run(), completes); + }, overrides: { + FlutterVersion: () => betaVersion, + }); + }); } + + +class FakeCommand extends FlutterCommand { + @override + String get description => null; + + @override + String get name => 'fake'; + + @override + bool get isExperimental => true; + + @override + Future runCommand() async { + return null; + } +} + +class MockVersion extends Mock implements FlutterVersion {} diff --git a/packages/flutter_tools/test/runner/utils.dart b/packages/flutter_tools/test/runner/utils.dart index b7b1ec1292..e69e50d37f 100644 --- a/packages/flutter_tools/test/runner/utils.dart +++ b/packages/flutter_tools/test/runner/utils.dart @@ -14,7 +14,7 @@ typedef CommandFunction = Future Function(); class DummyFlutterCommand extends FlutterCommand { DummyFlutterCommand({ - this.shouldUpdateCache = false, + this.shouldUpdateCache = false, this.noUsagePath = false, this.commandFunction, }); diff --git a/packages/flutter_tools/test/src/context.dart b/packages/flutter_tools/test/src/context.dart index 9326144e40..72036760fc 100644 --- a/packages/flutter_tools/test/src/context.dart +++ b/packages/flutter_tools/test/src/context.dart @@ -86,6 +86,7 @@ void testUsingContext( Usage: () => MockUsage(), XcodeProjectInterpreter: () => MockXcodeProjectInterpreter(), FileSystem: () => LocalFileSystemBlockingSetCurrentDirectory(), + TimeoutConfiguration: () => const TimeoutConfiguration(), }, body: () { final String flutterRoot = getFlutterRoot(); @@ -303,7 +304,10 @@ class MockXcodeProjectInterpreter implements XcodeProjectInterpreter { } } -class MockFlutterVersion extends Mock implements FlutterVersion {} +class MockFlutterVersion extends Mock implements FlutterVersion { + @override + bool get isStable => false; +} class MockClock extends Mock implements SystemClock {} diff --git a/packages/flutter_tools/test/vmservice_test.dart b/packages/flutter_tools/test/vmservice_test.dart index 15c64c4132..5049489522 100644 --- a/packages/flutter_tools/test/vmservice_test.dart +++ b/packages/flutter_tools/test/vmservice_test.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'dart:async'; +import 'dart:io'; import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/logger.dart'; @@ -178,7 +179,7 @@ void main() { }, overrides: { Logger: () => StdoutLogger(), Stdio: () => mockStdio, - WebSocketConnector: () => (String url) async => throw const SocketException('test'), + WebSocketConnector: () => (String url, {CompressionOptions compression}) async => throw const SocketException('test'), }); testUsingContext('refreshViews', () { diff --git a/packages/fuchsia_remote_debug_protocol/examples/drive_todo_list_scroll.dart b/packages/fuchsia_remote_debug_protocol/examples/drive_todo_list_scroll.dart index bfe954b20a..8510bb4208 100644 --- a/packages/fuchsia_remote_debug_protocol/examples/drive_todo_list_scroll.dart +++ b/packages/fuchsia_remote_debug_protocol/examples/drive_todo_list_scroll.dart @@ -16,7 +16,7 @@ import 'package:fuchsia_remote_debug_protocol/logging.dart'; /// /// Make sure to set up your application (you can change the name from /// 'todo_list') follows the setup for testing with the flutter driver: -/// https://flutter.io/testing/#adding-the-flutter_driver-dependency +/// https://flutter.dev/testing/#adding-the-flutter_driver-dependency /// /// Example usage: /// diff --git a/packages/fuchsia_remote_debug_protocol/lib/src/dart/dart_vm.dart b/packages/fuchsia_remote_debug_protocol/lib/src/dart/dart_vm.dart index 5075e06e7a..f15bd0c1f4 100644 --- a/packages/fuchsia_remote_debug_protocol/lib/src/dart/dart_vm.dart +++ b/packages/fuchsia_remote_debug_protocol/lib/src/dart/dart_vm.dart @@ -128,24 +128,18 @@ class DartVm { /// Returns a [List] of [IsolateRef] objects whose name matches `pattern`. /// /// This is not limited to Isolates running Flutter, but to any Isolate on the - /// VM. - /// - /// `includeNonFlutterIsolates` makes sure to add non-flutter Dart isolates, - /// and defaults to `false`. + /// VM. Therefore, the [pattern] argument should be written to exclude + /// matching unintended isolates. Future> getMainIsolatesByPattern( Pattern pattern, { Duration timeout = _kRpcTimeout, - bool includeNonFlutterIsolates = false, }) async { final Map jsonVmRef = await invokeRpc('getVM', timeout: timeout); final List result = []; for (Map jsonIsolate in jsonVmRef['isolates']) { final String name = jsonIsolate['name']; - // `:main()` is included at the end of a flutter isolate, whereas the - // name of a dart Isolate is concluded as if the name were a function. - if (name.contains(pattern) && - (includeNonFlutterIsolates || name.contains(RegExp(r':main\(\)')))) { + if (pattern.matchAsPrefix(name) != null) { _log.fine('Found Isolate matching "$pattern": "$name"'); result.add(IsolateRef._fromJson(jsonIsolate, this)); } diff --git a/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart b/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart index 8af956194a..66cba359e8 100644 --- a/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart +++ b/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart @@ -289,14 +289,10 @@ class FuchsiaRemoteConnection { /// If there are no live Dart VM's or the Isolate cannot be found, waits until /// either `timeout` is reached, or a Dart VM starts up with a name that /// matches `pattern`. - /// - /// `includeNonFlutterIsolates` can be set to true to include all isolates - /// found instead of just Flutter Isolates. Future> getMainIsolatesByPattern( Pattern pattern, { Duration timeout = _kIsolateFindTimeout, Duration vmConnectionTimeout = _kDartVmConnectionTimeout, - bool includeNonFlutterIsolates = false, }) async { // If for some reason there are no Dart VM's that are alive, wait for one to // start with the Isolate in question. @@ -315,10 +311,7 @@ class FuchsiaRemoteConnection { if (vmService == null) { continue; } - isolates.add(vmService.getMainIsolatesByPattern( - pattern, - includeNonFlutterIsolates: includeNonFlutterIsolates, - )); + isolates.add(vmService.getMainIsolatesByPattern(pattern)); } final List result = await Future.wait>(isolates) diff --git a/packages/fuchsia_remote_debug_protocol/pubspec.yaml b/packages/fuchsia_remote_debug_protocol/pubspec.yaml index 16df3a5a0f..b4df1e384f 100644 --- a/packages/fuchsia_remote_debug_protocol/pubspec.yaml +++ b/packages/fuchsia_remote_debug_protocol/pubspec.yaml @@ -1,6 +1,6 @@ name: fuchsia_remote_debug_protocol description: Provides an API to test/debug Flutter applications on remote Fuchsia devices and emulators. -homepage: http://flutter.io +homepage: http://flutter.dev author: Flutter Authors environment: @@ -8,40 +8,40 @@ environment: sdk: ">=2.2.0 <3.0.0" dependencies: - json_rpc_2: 2.0.9 + json_rpc_2: 2.0.10 process: 3.0.9 - web_socket_channel: 1.0.9 + web_socket_channel: 1.0.12 flutter_test: sdk: flutter flutter_driver: sdk: flutter - async: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + async: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.14.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" file: 5.0.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - intl: 0.15.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - matcher: 0.12.3+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + intl: 0.15.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" platform: 2.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - quiver: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + quiver: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.5.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - stream_channel: 1.6.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + stream_channel: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - test_api: 0.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + test_api: 0.2.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vector_math: 2.0.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" - vm_service_client: 0.2.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" + vm_service_client: 0.2.6+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" dev_dependencies: mockito: 4.0.0 -# PUBSPEC CHECKSUM: 2371 +# PUBSPEC CHECKSUM: 42b5 diff --git a/packages/fuchsia_remote_debug_protocol/test/src/dart/dart_vm_test.dart b/packages/fuchsia_remote_debug_protocol/test/src/dart/dart_vm_test.dart index 979698854a..d18d9773be 100644 --- a/packages/fuchsia_remote_debug_protocol/test/src/dart/dart_vm_test.dart +++ b/packages/fuchsia_remote_debug_protocol/test/src/dart/dart_vm_test.dart @@ -241,7 +241,7 @@ void main() { 'type': '@Isolate', 'fixedId': 'true', 'id': 'isolates/3', - 'name': 'file://flutterBinary2:main()', + 'name': 'flutterBinary.cmx', 'number': '3', }, { @@ -268,13 +268,9 @@ void main() { await DartVm.connect(Uri.parse('http://whatever.com/ws')); expect(vm, isNot(null)); final List matchingFlutterIsolates = - await vm.getMainIsolatesByPattern('flutterBinary'); + await vm.getMainIsolatesByPattern('flutterBinary.cmx'); expect(matchingFlutterIsolates.length, 1); - final List allFlutterIsolates = - await vm.getMainIsolatesByPattern(''); - expect(allFlutterIsolates.length, 2); - final List allIsolates = await vm.getMainIsolatesByPattern('', - includeNonFlutterIsolates: true); + final List allIsolates = await vm.getMainIsolatesByPattern(''); expect(allIsolates.length, 4); });