Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- novelforge-project/agent-workspace/flutter/dev/a11y_assessments/README.mdAdded+3
- novelforge-project/agent-workspace/flutter/dev/a11y_assessments/analysis_options.yamlAdded+1
- novelforge-project/agent-workspace/flutter/dev/a11y_assessments/pubspec.lockAdded+188
- novelforge-project/agent-workspace/flutter/dev/a11y_assessments/pubspec.yamlAdded+41
- novelforge-project/agent-workspace/flutter/dev/automated_tests/README.mdAdded+2
- novelforge-project/agent-workspace/flutter/dev/automated_tests/pubspec.lockAdded+504
- novelforge-project/agent-workspace/flutter/dev/automated_tests/pubspec.yamlAdded+78
- novelforge-project/agent-workspace/flutter/dev/bots/README.mdAdded+188
- novelforge-project/agent-workspace/flutter/dev/bots/accept_android_sdk_licenses.shAdded+23
- novelforge-project/agent-workspace/flutter/dev/bots/allowlist.dartAdded+54
- novelforge-project/agent-workspace/flutter/dev/bots/analysis_options.yamlAdded+5
- novelforge-project/agent-workspace/flutter/dev/bots/analyze.dartAdded+2189
- novelforge-project/agent-workspace/flutter/dev/bots/analyze_snippet_code.dartAdded+1199
- novelforge-project/agent-workspace/flutter/dev/bots/bots.imlAdded+14
- novelforge-project/agent-workspace/flutter/dev/bots/browser.dartAdded+109
- novelforge-project/agent-workspace/flutter/dev/bots/check_code_samples.dartAdded+494
- novelforge-project/agent-workspace/flutter/dev/bots/codelabs_build_test.shAdded+44
- novelforge-project/agent-workspace/flutter/dev/bots/docs.shAdded+154
- novelforge-project/agent-workspace/flutter/dev/bots/post_process_docs.dartAdded+157
- novelforge-project/agent-workspace/flutter/dev/bots/prepare_package.dartAdded+164
- novelforge-project/agent-workspace/flutter/dev/bots/pubspec.lockAdded+524
- novelforge-project/agent-workspace/flutter/dev/bots/pubspec.yamlAdded+78
- novelforge-project/agent-workspace/flutter/dev/bots/run_command.dartAdded+224
- novelforge-project/agent-workspace/flutter/dev/bots/service_worker_test.dartAdded+838
- novelforge-project/agent-workspace/flutter/dev/bots/serviceaccount.encAdded
- novelforge-project/agent-workspace/flutter/dev/bots/test.dartAdded
- novelforge-project/agent-workspace/flutter/dev/bots/tool_subsharding.dartAdded+102
- novelforge-project/agent-workspace/flutter/dev/bots/unpublish_package.dartAdded+504
- novelforge-project/agent-workspace/flutter/dev/bots/utils.dartAdded+255
- novelforge-project/agent-workspace/flutter/dev/conductor/README.mdAdded+118
- novelforge-project/agent-workspace/flutter/dev/customer_testing/ci.batAdded+27
- novelforge-project/agent-workspace/flutter/dev/customer_testing/ci.shAdded+37
- novelforge-project/agent-workspace/flutter/dev/customer_testing/pubspec.lockAdded+373
- novelforge-project/agent-workspace/flutter/dev/customer_testing/pubspec.yamlAdded+59
- novelforge-project/agent-workspace/flutter/dev/customer_testing/run_tests.dartAdded+137
- novelforge-project/agent-workspace/flutter/dev/devicelab/README.mdAdded+259
- novelforge-project/agent-workspace/flutter/dev/devicelab/analysis_options.yamlAdded+5
- novelforge-project/agent-workspace/flutter/dev/devicelab/devicelab.imlAdded+14
- novelforge-project/agent-workspace/flutter/dev/devicelab/pubspec.lockAdded+501
- novelforge-project/agent-workspace/flutter/dev/devicelab/pubspec.yamlAdded+76
- novelforge-project/agent-workspace/flutter/dev/docs/README.mdAdded+96
- novelforge-project/agent-workspace/flutter/dev/docs/analysis_options.yamlAdded+3
- novelforge-project/agent-workspace/flutter/dev/docs/analytics-footer.htmlAdded+4
- novelforge-project/agent-workspace/flutter/dev/docs/analytics-header.htmlAdded+7
- novelforge-project/agent-workspace/flutter/dev/docs/dartdoc_options.yamlAdded+5
- novelforge-project/agent-workspace/flutter/dev/docs/dashing.jsonAdded+71
- novelforge-project/agent-workspace/flutter/dev/docs/favicon.icoAdded
- novelforge-project/agent-workspace/flutter/dev/docs/firebase.jsonAdded+22
- novelforge-project/agent-workspace/flutter/dev/docs/firebase_rules.jsonAdded+6
- novelforge-project/agent-workspace/flutter/dev/docs/opensearch.htmlAdded+1
123# a11y_assessments
An application to conduct accessibility assessments.1include: ../../analysis_options.yaml123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188# Generated by pub# See https://dart.dev/tools/pub/glossary#lockfilepackages: async: dependency: "direct dev" description: name: async sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted version: "2.11.0" boolean_selector: dependency: "direct dev" description: name: boolean_selector sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" url: "https://pub.dev" source: hosted version: "2.1.1" characters: dependency: "direct main" description: name: characters sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" url: "https://pub.dev" source: hosted version: "1.3.0" clock: dependency: "direct dev" description: name: clock sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf url: "https://pub.dev" source: hosted version: "1.1.1" collection: dependency: "direct main" description: name: collection sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted version: "1.18.0" fake_async: dependency: "direct dev" description: name: fake_async sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" url: "https://pub.dev" source: hosted version: "1.3.1" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" leak_tracker: dependency: "direct dev" description: name: leak_tracker sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" url: "https://pub.dev" source: hosted version: "10.0.0" leak_tracker_flutter_testing: dependency: "direct dev" description: name: leak_tracker_flutter_testing sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 url: "https://pub.dev" source: hosted version: "2.0.1" leak_tracker_testing: dependency: "direct dev" description: name: leak_tracker_testing sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 url: "https://pub.dev" source: hosted version: "2.0.1" matcher: dependency: "direct dev" description: name: matcher sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted version: "0.12.16+1" material_color_utilities: dependency: "direct main" description: name: material_color_utilities sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted version: "0.8.0" meta: dependency: "direct main" description: name: meta sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 url: "https://pub.dev" source: hosted version: "1.11.0" path: dependency: "direct dev" description: name: path sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted version: "1.9.0" sky_engine: dependency: transitive description: flutter source: sdk version: "0.0.99" source_span: dependency: "direct dev" description: name: source_span sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" url: "https://pub.dev" source: hosted version: "1.10.0" stack_trace: dependency: "direct dev" description: name: stack_trace sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted version: "1.11.1" stream_channel: dependency: "direct dev" description: name: stream_channel sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted version: "2.1.2" string_scanner: dependency: "direct dev" description: name: string_scanner sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" url: "https://pub.dev" source: hosted version: "1.2.0" term_glyph: dependency: "direct dev" description: name: term_glyph sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 url: "https://pub.dev" source: hosted version: "1.2.1" test_api: dependency: "direct dev" description: name: test_api sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" url: "https://pub.dev" source: hosted version: "0.6.1" vector_math: dependency: "direct main" description: name: vector_math sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" url: "https://pub.dev" source: hosted version: "2.1.4" vm_service: dependency: "direct dev" description: name: vm_service sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 url: "https://pub.dev" source: hosted version: "13.0.0"sdks: dart: ">=3.2.0-22.0.dev <4.0.0"1234567891011121314151617181920212223242526272829303132333435363738394041name: a11y_assessmentsdescription: A new Flutter project
environment: sdk: '>=3.2.0-22.0.dev <4.0.0'
dependencies: flutter: sdk: flutter
characters: 1.3.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.18.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" material_color_utilities: 0.8.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.11.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vector_math: 2.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
dev_dependencies: flutter_test: sdk: flutter
async: 2.11.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" clock: 1.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" fake_async: 1.3.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" leak_tracker: 10.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" leak_tracker_flutter_testing: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" leak_tracker_testing: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" matcher: 0.12.16+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.9.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.10.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.11.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stream_channel: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" test_api: 0.6.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vm_service: 13.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
flutter: uses-material-design: true
# PUBSPEC CHECKSUM: 802312This is a fake package for use by automated testing.For example, the `flutter_tools` package uses this to test `flutter test`.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504# Generated by pub# See https://dart.dev/tools/pub/glossary#lockfilepackages: _fe_analyzer_shared: dependency: "direct main" description: name: _fe_analyzer_shared sha256: "36a321c3d2cbe01cbcb3540a87b8843846e0206df3e691fa7b23e19e78de6d49" url: "https://pub.dev" source: hosted version: "65.0.0" analyzer: dependency: "direct main" description: name: analyzer sha256: dfe03b90ec022450e22513b5e5ca1f01c0c01de9c3fba2f7fd233cb57a6b9a07 url: "https://pub.dev" source: hosted version: "6.3.0" args: dependency: "direct main" description: name: args sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 url: "https://pub.dev" source: hosted version: "2.4.2" async: dependency: "direct main" description: name: async sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted version: "2.11.0" boolean_selector: dependency: "direct main" description: name: boolean_selector sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" url: "https://pub.dev" source: hosted version: "2.1.1" characters: dependency: "direct main" description: name: characters sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" url: "https://pub.dev" source: hosted version: "1.3.0" clock: dependency: "direct main" description: name: clock sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf url: "https://pub.dev" source: hosted version: "1.1.1" collection: dependency: "direct main" description: name: collection sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted version: "1.18.0" convert: dependency: "direct main" description: name: convert sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" url: "https://pub.dev" source: hosted version: "3.1.1" coverage: dependency: "direct main" description: name: coverage sha256: "8acabb8306b57a409bf4c83522065672ee13179297a6bb0cb9ead73948df7c76" url: "https://pub.dev" source: hosted version: "1.7.2" crypto: dependency: "direct main" description: name: crypto sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab url: "https://pub.dev" source: hosted version: "3.0.3" fake_async: dependency: "direct main" description: name: fake_async sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" url: "https://pub.dev" source: hosted version: "1.3.1" file: dependency: "direct main" description: name: file sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" url: "https://pub.dev" source: hosted version: "7.0.0" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" flutter_driver: dependency: transitive description: flutter source: sdk version: "0.0.0" flutter_goldens: dependency: "direct main" description: flutter source: sdk version: "0.0.0" flutter_test: dependency: "direct main" description: flutter source: sdk version: "0.0.0" frontend_server_client: dependency: "direct main" description: name: frontend_server_client sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612" url: "https://pub.dev" source: hosted version: "3.2.0" fuchsia_remote_debug_protocol: dependency: transitive description: flutter source: sdk version: "0.0.0" glob: dependency: "direct main" description: name: glob sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" url: "https://pub.dev" source: hosted version: "2.1.2" http_multi_server: dependency: "direct main" description: name: http_multi_server sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" url: "https://pub.dev" source: hosted version: "3.2.1" http_parser: dependency: "direct main" description: name: http_parser sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" url: "https://pub.dev" source: hosted version: "4.0.2" integration_test: dependency: "direct main" description: flutter source: sdk version: "0.0.0" io: dependency: "direct main" description: name: io sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" url: "https://pub.dev" source: hosted version: "1.0.4" js: dependency: "direct main" description: name: js sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 url: "https://pub.dev" source: hosted version: "0.6.7" leak_tracker: dependency: "direct main" description: name: leak_tracker sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" url: "https://pub.dev" source: hosted version: "10.0.0" leak_tracker_flutter_testing: dependency: "direct main" description: name: leak_tracker_flutter_testing sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 url: "https://pub.dev" source: hosted version: "2.0.1" leak_tracker_testing: dependency: "direct main" description: name: leak_tracker_testing sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 url: "https://pub.dev" source: hosted version: "2.0.1" logging: dependency: "direct main" description: name: logging sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" url: "https://pub.dev" source: hosted version: "1.2.0" matcher: dependency: "direct main" description: name: matcher sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted version: "0.12.16+1" material_color_utilities: dependency: "direct main" description: name: material_color_utilities sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted version: "0.8.0" meta: dependency: "direct main" description: name: meta sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 url: "https://pub.dev" source: hosted version: "1.11.0" mime: dependency: "direct main" description: name: mime sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e url: "https://pub.dev" source: hosted version: "1.0.4" node_preamble: dependency: "direct main" description: name: node_preamble sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" url: "https://pub.dev" source: hosted version: "2.0.2" package_config: dependency: "direct main" description: name: package_config sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" url: "https://pub.dev" source: hosted version: "2.1.0" path: dependency: "direct main" description: name: path sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted version: "1.9.0" platform: dependency: "direct main" description: name: platform sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec" url: "https://pub.dev" source: hosted version: "3.1.4" pool: dependency: "direct main" description: name: pool sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" url: "https://pub.dev" source: hosted version: "1.5.1" process: dependency: "direct main" description: name: process sha256: "21e54fd2faf1b5bdd5102afd25012184a6793927648ea81eea80552ac9405b32" url: "https://pub.dev" source: hosted version: "5.0.2" pub_semver: dependency: "direct main" description: name: pub_semver sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" url: "https://pub.dev" source: hosted version: "2.1.4" shelf: dependency: "direct main" description: name: shelf sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 url: "https://pub.dev" source: hosted version: "1.4.1" shelf_packages_handler: dependency: "direct main" description: name: shelf_packages_handler sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" url: "https://pub.dev" source: hosted version: "3.0.2" shelf_static: dependency: "direct main" description: name: shelf_static sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e url: "https://pub.dev" source: hosted version: "1.1.2" shelf_web_socket: dependency: "direct main" description: name: shelf_web_socket sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" url: "https://pub.dev" source: hosted version: "1.0.4" sky_engine: dependency: transitive description: flutter source: sdk version: "0.0.99" source_map_stack_trace: dependency: "direct main" description: name: source_map_stack_trace sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae" url: "https://pub.dev" source: hosted version: "2.1.1" source_maps: dependency: "direct main" description: name: source_maps sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703" url: "https://pub.dev" source: hosted version: "0.10.12" source_span: dependency: "direct main" description: name: source_span sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" url: "https://pub.dev" source: hosted version: "1.10.0" stack_trace: dependency: "direct main" description: name: stack_trace sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted version: "1.11.1" stream_channel: dependency: "direct main" description: name: stream_channel sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted version: "2.1.2" string_scanner: dependency: "direct main" description: name: string_scanner sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" url: "https://pub.dev" source: hosted version: "1.2.0" sync_http: dependency: transitive description: name: sync_http sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961" url: "https://pub.dev" source: hosted version: "0.3.1" term_glyph: dependency: "direct main" description: name: term_glyph sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 url: "https://pub.dev" source: hosted version: "1.2.1" test: dependency: "direct main" description: name: test sha256: a1f7595805820fcc05e5c52e3a231aedd0b72972cb333e8c738a8b1239448b6f url: "https://pub.dev" source: hosted version: "1.24.9" test_api: dependency: "direct main" description: name: test_api sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" url: "https://pub.dev" source: hosted version: "0.6.1" test_core: dependency: "direct main" description: name: test_core sha256: a757b14fc47507060a162cc2530d9a4a2f92f5100a952c7443b5cad5ef5b106a url: "https://pub.dev" source: hosted version: "0.5.9" typed_data: dependency: "direct main" description: name: typed_data sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c url: "https://pub.dev" source: hosted version: "1.3.2" vector_math: dependency: "direct main" description: name: vector_math sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" url: "https://pub.dev" source: hosted version: "2.1.4" vm_service: dependency: "direct main" description: name: vm_service sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 url: "https://pub.dev" source: hosted version: "13.0.0" watcher: dependency: "direct main" description: name: watcher sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" url: "https://pub.dev" source: hosted version: "1.1.0" web: dependency: "direct main" description: name: web sha256: edc8a9573dd8c5a83a183dae1af2b6fd4131377404706ca4e5420474784906fa url: "https://pub.dev" source: hosted version: "0.4.0" web_socket_channel: dependency: "direct main" description: name: web_socket_channel sha256: "045ec2137c27bf1a32e6ffa0e734d532a6677bf9016a0d1a406c54e499ff945b" url: "https://pub.dev" source: hosted version: "2.4.1" webdriver: dependency: transitive description: name: webdriver sha256: "003d7da9519e1e5f329422b36c4dcdf18d7d2978d1ba099ea4e45ba490ed845e" url: "https://pub.dev" source: hosted version: "3.0.3" webkit_inspection_protocol: dependency: "direct main" description: name: webkit_inspection_protocol sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572" url: "https://pub.dev" source: hosted version: "1.2.1" yaml: dependency: "direct main" description: name: yaml sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" url: "https://pub.dev" source: hosted version: "3.1.2"sdks: dart: ">=3.2.0 <4.0.0"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778name: flutter_automated_tests
environment: sdk: '>=3.2.0-0 <4.0.0'
dependencies: flutter: sdk: flutter flutter_test: sdk: flutter flutter_goldens: sdk: flutter integration_test: sdk: flutter platform: 3.1.4 test: 1.24.9
_fe_analyzer_shared: 65.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" analyzer: 6.3.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" args: 2.4.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" async: 2.11.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" characters: 1.3.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" clock: 1.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.18.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 3.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" coverage: 1.7.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 3.0.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" fake_async: 1.3.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" file: 7.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" frontend_server_client: 3.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 3.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 4.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" leak_tracker: 10.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" leak_tracker_flutter_testing: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" leak_tracker_testing: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" logging: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" matcher: 0.12.16+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" material_color_utilities: 0.8.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.11.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" node_preamble: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" package_config: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.9.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" process: 5.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 2.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf: 1.4.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 3.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_static: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_web_socket: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_map_stack_trace: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_maps: 0.10.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.10.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.11.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stream_channel: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" test_api: 0.6.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" test_core: 0.5.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.3.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vector_math: 2.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vm_service: 13.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" web: 0.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" web_socket_channel: 2.4.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" webkit_inspection_protocol: 1.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 3.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
flutter: uses-material-design: true assets: - icon/test.png
# PUBSPEC CHECKSUM: 9de1123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188# Flutter's Build Infrastructure
This directory exists to support building Flutter on our build infrastructure.
Flutter build results are available at:* https://flutter-dashboard.appspot.com/#/build - Aggregate dashboard of the separate CI systems used by Flutter.* https://cirrus-ci.com/github/flutter/flutter/master - Testing is done on PRs and submitted changes on GitHub.
Flutter infra requires special permissions to retrigger builds on the[build dashboard](https://flutter-dashboard.appspot.com/#/build). File an[infra ticket](https://github.com/flutter/flutter/wiki/Infra-Ticket-Queue) torequest permission.
The [Cirrus](https://cirrus-ci.org)-based bots run the [`test.dart`](test.dart)script for each PR and submission. This does testing for the tools, for theframework, and (for submitted changes only) rebuilds and updates the mainbranch API docs [staging site](https://main-api.flutter.dev/).For tagged dev and beta builds, it also builds and deploys the gallery app tothe app stores. It is configured by the [.cirrus.yml](/.cirrus.yml).
The build dashboard includes post-commit testing run on physical devices. See[//dev/devicelab](../devicelab/README.md) for more information.
## LUCI (Layered Universal Continuous Integration)
A [set of infra scripts](https://flutter.googlesource.com/recipes/)run on Windows, Linux, and Mac machines. The configuration for how manymachines and what kind are managed internally by Google. File an[infra ticket](https://github.com/flutter/flutter/wiki/Infra-Ticket-Queue)to request new machine types to be added. Both of these technologies are highlyspecific to the [LUCI](https://github.com/luci) project, which is the successorto Chromium's infra and the foundation to Flutter's infrastructure.
### Prerequisites
To work on this infrastructure you will need:
- [depot_tools](https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up)- Python package installer: `sudo apt-get install python-pip`- Python coverage package (only needed for `training_simulation`): `sudo pip install coverage`
To run `prepare_package.dart` locally:
- Make sure the `depot_tools` is in your `PATH`. If you're on Windows, you also need an environment variable called `DEPOT_TOOLS` with the path to `depot_tools` as value.- Run `gsutil.py config` (or `python3 %DEPOT_TOOLS%\gsutil.py` on Windows) to authenticate with your auth token.- Create a local temp directory. `cd` into it.- Run `dart [path to your normal Flutter repo]/dev/bots/prepare_package.dart --temp_dir=. --revision=[revision to package] --branch=[branch to deploy to] --publish`.- If you're running into `gsutil` permission issues, check with @Hixie to make sure you have the right push permissions.
### Editing a recipe
Flutter has several recipes depending on the test. The recipes share commonactions through `recipe_modules`. Searching the builder config in [infra](https://flutter.googlesource.com/infra/+/refs/heads/main)will indicate the recipe used for a test.
Recipes are just Python with some limitations on what can be imported. They are[documented](https://github.com/luci/recipes-py/blob/master/doc/user_guide.md)by the [luci/recipes-py GitHub project](https://github.com/luci/recipes-py).
The typical cycle for editing a recipe is:
1. Check out the recipes project using `git clone https://flutter.googlesource.com/recipes`.2. Make your edits (probably to files in `//recipes/recipes`).3. Update the tests. Run `recipes.py test train` to update the existing expected output to match the new output. Verify completely new test cases by altering the `GenTests` method of the recipe. The recipe is required to have 100% test coverage.4. Run `led get-builder 'luci.flutter.staging:BUILDER_NAME' | led edit -pa git_ref='refs/pull/<PR number>/head' | led edit -pa git_url='https://github.com/flutter/<repo>' | led edit-recipe-bundle | led launch`, where `BUILDER_NAME` is the builder name (e.g. `Linux Engine`), and `git_ref`/`git_url` is the ref/url of the intended changes to build. * If `led` fails, ensure that your `depot_tools` checkout is up to date.5. To submit a CL, you need a local branch first (`git checkout -b [some branch name]`).6. Upload the patch (`git commit`, `git cl upload`), and open the outputted URL to the CL.7. Use "Find owners" to get reviewers for the CL
### Android Tools
The Android SDK and NDK used by Flutter's Chrome infra bots are stored in GoogleCloud. During the build, a bot runs the `download_android_tools.py` script thatdownloads the required version of the Android SDK into `dev/bots/android_tools`.
To check which components are currently installed, download the current SDKstored in Google Cloud using the `download_android_tools.py` script, then`dev/bots/android_tools/sdk/tools/bin/sdkmanager --list`. If you find that somecomponents need to be updated or installed, follow the steps below:
#### How to update Android SDK on Google Cloud Storage
1. Run Android SDK Manager and update packages `$ dev/bots/android_tools/sdk/tools/android update sdk` Use `android.bat` on Windows.
2. Use the UI to choose the packages you want to install and/or update.
3. Run `dev/bots/android_tools/sdk/tools/bin/sdkmanager --update`. On Windows, run `sdkmanager.bat` instead. If the process fails with an error saying that it is unable to move files (Windows makes files and directories read-only when another process is holding them open), make a copy of the `dev/bots/android_tools/sdk/tools` directory, run the `sdkmanager.bat` from the copy, and use the `--sdk_root` option pointing at `dev/bots/android_tools/sdk`.
4. Run `dev/bots/android_tools/sdk/tools/bin/sdkmanager --licenses` and accept the licenses for the newly installed components. It also helps to run this command a second time and make sure that it prints "All SDK package licenses accepted".
5. Run upload_android_tools.py -t sdk `$ dev/bots/upload_android_tools.py -t sdk`
#### How to update Android NDK on Google Cloud Storage
1. Download a new NDK binary (e.g. android-ndk-r10e-linux-x86_64.bin)2. cd dev/bots/android_tools `$ cd dev/bots/android_tools`
3. Remove the old ndk directory `$ rm -rf ndk`
4. Run the new NDK binary file `$ ./android-ndk-r10e-linux-x86_64.bin`
5. Rename the extracted directory to ndk `$ mv android-ndk-r10e ndk`
6. Run upload_android_tools.py -t ndk `$ cd ../..` `$ dev/bots/upload_android_tools.py -t ndk`
## Flutter codelabs build test
The Flutter codelabs exercise Material Components in the form of ademo application. The code for the codelabs is similar to, butdistinct from, the code for the Shrine demo app in Flutter Gallery.
The Flutter codelabs build test ensures that the final version of the[Material Components for FlutterCodelabs](https://github.com/material-components/material-components-flutter-codelabs)can be built. This test serves as a smoke test for the Flutterframework and should not fail. If it does, please address any issuesin your PR and rerun the test. If you feel that the test failing isnot a direct result of changes made in your PR or that breaking thistest is absolutely necessary, escalate this issue by [submitting anissue](https://github.com/material-components/material-components-flutter-codelabs/issues/new?title=%5BURGENT%5D%20Flutter%20Framework%20breaking%20PR)to the MDC-Flutter Team.
## Unpublishing published archives
Flutter downloadable archives are built for each release by our continuousintegration systems using the [`prepare_package.dart`](prepare_package.dart)script, but if something goes very wrong, and a release is published that wasn'tintended to be published, the [`unpublish_package.dart`](unpublish_package.dart)script may be used to remove the package or packages from the channels in whichthey were published.
For example To remove a published package corresponding to the git hash`d444a455de87a2e40b7f576dc12ffd9ab82fd491`, first do a dry run of the script tosee what it will do:
```$ dart ./unpublish_package.dart --temp_dir=/tmp/foo --revision d444a455de87a2e40b7f576dc12ffd9ab82fd491```
And once you've verified the output of the dry run to be sure it is what youwant to do, run:
```$ dart ./unpublish_package.dart --confirm --temp_dir=/tmp/foo --revision d444a455de87a2e40b7f576dc12ffd9ab82fd491```
and it will perform the actions. You will of course need to have accessto the cloud storage server and have `gsutil` installed to perform thisoperation. Only runs on Linux or macOS systems.
See `dart ./unpublish_package.dart --help` for more details.
Once the package is unpublished, it will not be available from the website fordownload, and will not be rebuilt (even though there is a tagged revision in therepo still) unless someone forces the packaging build to run again at thatrevision to rebuild the package.1234567891011121314151617181920212223#!/usr/bin/env bash# Copyright 2014 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.
set -e
# This script is only meant to be run by the Cirrus CI system, not locally.# It must be run from the root of the Flutter repo.
function error() { echo "$@" 1>&2}
function accept_android_licenses() { yes "y" | flutter doctor --android-licenses}
echo "Flutter SDK directory is: $PWD"
# Accept licenses.echo "Accepting Android licenses."accept_android_licenses || (error "Accepting Android licenses failed." && false)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354// Copyright 2014 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.
/// The SDK package allowlist for the flutter, flutter_test, flutter_driver, flutter_localizations,/// and integration_test packages.////// The goal of the allowlist is to make it more difficult to accidentally add new dependencies/// to the core SDK packages that users depend on. Any dependencies added to this set can have a/// large impact on the allowed version solving of a given flutter application because of how/// the SDK pins to an exact version.////// Before adding a new Dart Team owned dependency to this set, please clear with natebosch@/// or jakemac53@. For other packages please contact hixie@ or zanderso@.////// You may remove entries from this list at any time, but once removed they must stay removed/// unless the additions are cleared as described above.const Set<String> kCorePackageAllowList = <String>{ // Please keep this list in alphabetical order. 'async', 'boolean_selector', 'characters', 'clock', 'collection', 'fake_async', 'file', 'flutter', 'flutter_driver', 'flutter_localizations', 'flutter_test', 'fuchsia_remote_debug_protocol', 'integration_test', 'intl', 'leak_tracker', 'leak_tracker_flutter_testing', 'leak_tracker_testing', 'matcher', 'material_color_utilities', 'meta', 'path', 'platform', 'process', 'sky_engine', 'source_span', 'stack_trace', 'stream_channel', 'string_scanner', 'sync_http', 'term_glyph', 'test_api', 'vector_math', 'vm_service', 'webdriver',};12345include: ../analysis_options.yaml
linter: rules: avoid_js_rounded_ints: false # CLI code doesn't need to worry about JS issues12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189// Copyright 2014 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:convert';import 'dart:core' hide print;import 'dart:io' hide exit;import 'dart:typed_data';
import 'package:analyzer/dart/analysis/features.dart';import 'package:analyzer/dart/analysis/results.dart';import 'package:analyzer/dart/analysis/utilities.dart';import 'package:analyzer/dart/ast/ast.dart';import 'package:analyzer/dart/ast/visitor.dart';import 'package:crypto/crypto.dart';import 'package:meta/meta.dart';import 'package:path/path.dart' as path;
import 'allowlist.dart';import 'custom_rules/analyze.dart';import 'custom_rules/no_double_clamp.dart';import 'custom_rules/no_stop_watches.dart';import 'run_command.dart';import 'utils.dart';
final String flutterRoot = path.dirname(path.dirname(path.dirname(path.fromUri(Platform.script))));final String flutter = path.join(flutterRoot, 'bin', Platform.isWindows ? 'flutter.bat' : 'flutter');final String flutterPackages = path.join(flutterRoot, 'packages');final String flutterExamples = path.join(flutterRoot, 'examples');
/// The path to the `dart` executable; set at the top of `main`late final String dart;
/// The path to the `pub` executable; set at the top of `main`late final String pub;
/// When you call this, you can pass additional arguments to pass custom/// arguments to flutter analyze. For example, you might want to call this/// script with the parameter --dart-sdk to use custom dart sdk.////// For example:/// bin/cache/dart-sdk/bin/dart dev/bots/analyze.dart --dart-sdk=/tmp/dart-sdkFuture<void> main(List<String> arguments) async { final String dartSdk = path.join( Directory.current.absolute.path, _getDartSdkFromArguments(arguments) ?? path.join(flutterRoot, 'bin', 'cache', 'dart-sdk'), ); dart = path.join(dartSdk, 'bin', Platform.isWindows ? 'dart.exe' : 'dart'); pub = path.join(dartSdk, 'bin', Platform.isWindows ? 'pub.bat' : 'pub'); printProgress('STARTING ANALYSIS'); await run(arguments); if (hasError) { reportErrorsAndExit('${bold}Analysis failed.$reset'); } reportSuccessAndExit('${bold}Analysis successful.$reset');}
/// Scans [arguments] for an argument of the form `--dart-sdk` or/// `--dart-sdk=...` and returns the configured SDK, if any.String? _getDartSdkFromArguments(List<String> arguments) { String? result; for (int i = 0; i < arguments.length; i += 1) { if (arguments[i] == '--dart-sdk') { if (result != null) { foundError(<String>['The --dart-sdk argument must not be used more than once.']); return null; } if (i + 1 < arguments.length) { result = arguments[i + 1]; } else { foundError(<String>['--dart-sdk must be followed by a path.']); return null; } } if (arguments[i].startsWith('--dart-sdk=')) { if (result != null) { foundError(<String>['The --dart-sdk argument must not be used more than once.']); return null; } result = arguments[i].substring('--dart-sdk='.length); } } return result;}
Future<void> run(List<String> arguments) async { bool assertsEnabled = false; assert(() { assertsEnabled = true; return true; }()); if (!assertsEnabled) { foundError(<String>['The analyze.dart script must be run with --enable-asserts.']); }
printProgress('TargetPlatform tool/framework consistency'); await verifyTargetPlatform(flutterRoot);
printProgress('All tool test files end in _test.dart...'); await verifyToolTestsEndInTestDart(flutterRoot);
printProgress('No sync*/async*'); await verifyNoSyncAsyncStar(flutterPackages); await verifyNoSyncAsyncStar(flutterExamples, minimumMatches: 200);
printProgress('No runtimeType in toString...'); await verifyNoRuntimeTypeInToString(flutterRoot);
printProgress('Debug mode instead of checked mode...'); await verifyNoCheckedMode(flutterRoot);
printProgress('Links for creating GitHub issues'); await verifyIssueLinks(flutterRoot);
printProgress('Unexpected binaries...'); await verifyNoBinaries(flutterRoot);
printProgress('Trailing spaces...'); await verifyNoTrailingSpaces(flutterRoot); // assumes no unexpected binaries, so should be after verifyNoBinaries
printProgress('Spaces after flow control statements...'); await verifySpacesAfterFlowControlStatements(flutterRoot);
printProgress('Deprecations...'); await verifyDeprecations(flutterRoot);
printProgress('Goldens...'); await verifyGoldenTags(flutterPackages);
printProgress('Skip test comments...'); await verifySkipTestComments(flutterRoot);
printProgress('Licenses...'); await verifyNoMissingLicense(flutterRoot);
printProgress('Test imports...'); await verifyNoTestImports(flutterRoot);
printProgress('Bad imports (framework)...'); await verifyNoBadImportsInFlutter(flutterRoot);
printProgress('Bad imports (tools)...'); await verifyNoBadImportsInFlutterTools(flutterRoot);
printProgress('Internationalization...'); await verifyInternationalizations(flutterRoot, dart);
printProgress('Integration test timeouts...'); await verifyIntegrationTestTimeouts(flutterRoot);
printProgress('null initialized debug fields...'); await verifyNullInitializedDebugExpensiveFields(flutterRoot);
printProgress('Taboo words...'); await verifyTabooDocumentation(flutterRoot);
// Ensure that all package dependencies are in sync. printProgress('Package dependencies...'); await runCommand(flutter, <String>['update-packages', '--verify-only'], workingDirectory: flutterRoot, );
/// Ensure that no new dependencies have been accidentally /// added to core packages. printProgress('Package Allowlist...'); await _checkConsumerDependencies();
// Analyze all the Dart code in the repo. printProgress('Dart analysis...'); final CommandResult dartAnalyzeResult = await _runFlutterAnalyze(flutterRoot, options: <String>[ '--flutter-repo', ...arguments, ]);
if (dartAnalyzeResult.exitCode == 0) { // Only run the private lints when the code is free of type errors. The // lints are easier to write when they can assume, for example, there is no // inheritance cycles. final List<AnalyzeRule> rules = <AnalyzeRule>[noDoubleClamp, noStopwatches]; final String ruleNames = rules.map((AnalyzeRule rule) => '\n * $rule').join(); printProgress('Analyzing code in the framework with the following rules:$ruleNames'); await analyzeWithRules(flutterRoot, rules, includePaths: <String>['packages/flutter/lib'], excludePaths: <String>['packages/flutter/lib/fix_data'], ); final List<AnalyzeRule> testRules = <AnalyzeRule>[noStopwatches]; final String testRuleNames = testRules.map((AnalyzeRule rule) => '\n * $rule').join(); printProgress('Analyzing code in the test folder with the following rules:$testRuleNames'); await analyzeWithRules(flutterRoot, testRules, includePaths: <String>['packages/flutter/test'], ); } else { printProgress('Skipped performing further analysis in the framework because "flutter analyze" finished with a non-zero exit code.'); }
printProgress('Executable allowlist...'); await _checkForNewExecutables();
// Try with the --watch analyzer, to make sure it returns success also. // The --benchmark argument exits after one run. // We specify a failureMessage so that the actual output is muted in the case where _runFlutterAnalyze above already failed. printProgress('Dart analysis (with --watch)...'); await _runFlutterAnalyze(flutterRoot, failureMessage: 'Dart analyzer failed when --watch was used.', options: <String>[ '--flutter-repo', '--watch', '--benchmark', ...arguments, ]);
// Analyze the code in `{@tool snippet}` sections in the repo. printProgress('Snippet code...'); await runCommand(dart, <String>['--enable-asserts', path.join(flutterRoot, 'dev', 'bots', 'analyze_snippet_code.dart'), '--verbose'], workingDirectory: flutterRoot, );
// Make sure that all of the existing samples are linked from at least one API doc comment. printProgress('Code sample link validation...'); await runCommand(dart, <String>['--enable-asserts', path.join(flutterRoot, 'dev', 'bots', 'check_code_samples.dart')], workingDirectory: flutterRoot, );
// Try analysis against a big version of the gallery; generate into a temporary directory. printProgress('Dart analysis (mega gallery)...'); final Directory outDir = Directory.systemTemp.createTempSync('flutter_mega_gallery.'); try { await runCommand(dart, <String>[ path.join(flutterRoot, 'dev', 'tools', 'mega_gallery.dart'), '--out', outDir.path, ], workingDirectory: flutterRoot, ); await _runFlutterAnalyze(outDir.path, failureMessage: 'Dart analyzer failed on mega_gallery benchmark.', options: <String>[ '--watch', '--benchmark', ...arguments, ]); } finally { outDir.deleteSync(recursive: true); }
// Ensure gen_default links the correct files printProgress('Correct file names in gen_defaults.dart...'); await verifyTokenTemplatesUpdateCorrectFiles(flutterRoot);
// Ensure integration test files are up-to-date with the app template. printProgress('Up to date integration test template files...'); await verifyIntegrationTestTemplateFiles(flutterRoot);}
// TESTS
FeatureSet _parsingFeatureSet() => FeatureSet.latestLanguageVersion();
_Line _getLine(ParseStringResult parseResult, int offset) { final int lineNumber = parseResult.lineInfo.getLocation(offset).lineNumber; final String content = parseResult.content.substring( parseResult.lineInfo.getOffsetOfLine(lineNumber - 1), parseResult.lineInfo.getOffsetOfLine(lineNumber) - 1, ); return _Line(lineNumber, content);}
Future<void> verifyTargetPlatform(String workingDirectory) async { final File framework = File('$workingDirectory/packages/flutter/lib/src/foundation/platform.dart'); final Set<String> frameworkPlatforms = <String>{}; List<String> lines = framework.readAsLinesSync(); int index = 0; while (true) { if (index >= lines.length) { foundError(<String>['${framework.path}: Can no longer find TargetPlatform enum.']); return; } if (lines[index].startsWith('enum TargetPlatform {')) { index += 1; break; } index += 1; } while (true) { if (index >= lines.length) { foundError(<String>['${framework.path}: Could not find end of TargetPlatform enum.']); return; } String line = lines[index].trim(); final int comment = line.indexOf('//'); if (comment >= 0) { line = line.substring(0, comment); } if (line == '}') { break; } if (line.isNotEmpty) { if (line.endsWith(',')) { frameworkPlatforms.add(line.substring(0, line.length - 1)); } else { foundError(<String>['${framework.path}:$index: unparseable line when looking for TargetPlatform values']); } } index += 1; } final File tool = File('$workingDirectory/packages/flutter_tools/lib/src/resident_runner.dart'); final Set<String> toolPlatforms = <String>{}; lines = tool.readAsLinesSync(); index = 0; while (true) { if (index >= lines.length) { foundError(<String>['${tool.path}: Can no longer find nextPlatform logic.']); return; } if (lines[index].trim().startsWith('const List<String> platforms = <String>[')) { index += 1; break; } index += 1; } while (true) { if (index >= lines.length) { foundError(<String>['${tool.path}: Could not find end of nextPlatform logic.']); return; } final String line = lines[index].trim(); if (line.startsWith("'") && line.endsWith("',")) { toolPlatforms.add(line.substring(1, line.length - 2)); } else if (line == '];') { break; } else { foundError(<String>['${tool.path}:$index: unparseable line when looking for nextPlatform values']); } index += 1; } final Set<String> frameworkExtra = frameworkPlatforms.difference(toolPlatforms); if (frameworkExtra.isNotEmpty) { foundError(<String>['TargetPlatform has some extra values not found in the tool: ${frameworkExtra.join(", ")}']); } final Set<String> toolExtra = toolPlatforms.difference(frameworkPlatforms); if (toolExtra.isNotEmpty) { foundError(<String>['The nextPlatform logic in the tool has some extra values not found in TargetPlatform: ${toolExtra.join(", ")}']); }}
/// Verify Token Templates are mapped to correct file names while generating/// M3 defaults in /dev/tools/gen_defaults/bin/gen_defaults.dart.Future<void> verifyTokenTemplatesUpdateCorrectFiles(String workingDirectory) async { final List<String> errors = <String>[];
String getMaterialDirPath(List<String> lines) { final String line = lines.firstWhere((String line) => line.contains('String materialLib')); final String relativePath = line.substring(line.indexOf("'") + 1, line.lastIndexOf("'")); return path.join(workingDirectory, relativePath); }
String getFileName(String line) { const String materialLibString = r"'$materialLib/"; final String leftClamp = line.substring(line.indexOf(materialLibString) + materialLibString.length); return leftClamp.substring(0, leftClamp.indexOf("'")); }
final String genDefaultsBinDir = '$workingDirectory/dev/tools/gen_defaults/bin'; final File file = File(path.join(genDefaultsBinDir, 'gen_defaults.dart')); final List<String> lines = file.readAsLinesSync(); final String materialDirPath = getMaterialDirPath(lines); bool atLeastOneTargetLineExists = false;
for (final String line in lines) { if (line.contains('updateFile();')) { atLeastOneTargetLineExists = true; final String fileName = getFileName(line); final String filePath = path.join(materialDirPath, fileName); final File file = File(filePath);
if (!file.existsSync()) { errors.add('file $filePath does not exist.'); } } }
assert(atLeastOneTargetLineExists, 'No lines exist that this test expects to ' 'verify. Check if the target file is correct or remove this test');
// Fail if any errors if (errors.isNotEmpty) { final String s = errors.length > 1 ? 's' : ''; final String itThem = errors.length > 1 ? 'them' : 'it'; foundError(<String>[ ...errors, '${bold}Please correct the file name$s or remove $itThem from /dev/tools/gen_defaults/bin/gen_defaults.dart$reset', ]); }}
/// Verify tool test files end in `_test.dart`.////// The test runner will only recognize files ending in `_test.dart` as tests to/// be run: https://github.com/dart-lang/test/tree/master/pkgs/test#running-testsFuture<void> verifyToolTestsEndInTestDart(String workingDirectory) async { final String toolsTestPath = path.join( workingDirectory, 'packages', 'flutter_tools', 'test', ); final List<String> violations = <String>[];
// detect files that contains calls to test(), testUsingContext(), and testWithoutContext() final RegExp callsTestFunctionPattern = RegExp(r'(test\(.*\)|testUsingContext\(.*\)|testWithoutContext\(.*\))');
await for (final File file in _allFiles(toolsTestPath, 'dart', minimumMatches: 300)) { final bool isValidTestFile = file.path.endsWith('_test.dart'); if (isValidTestFile) { continue; }
final bool isTestData = file.path.contains(r'test_data'); if (isTestData) { continue; }
final bool isInTestShard = file.path.contains(r'.shard/'); if (!isInTestShard) { continue; }
final bool callsTestFunction = file.readAsStringSync().contains(callsTestFunctionPattern); if (!callsTestFunction) { continue; }
violations.add(file.path); } if (violations.isNotEmpty) { foundError(<String>[ '${bold}Found flutter_tools tests that do not end in `_test.dart`; these will not be run by the test runner$reset', ...violations, ]); }}
Future<void> verifyNoSyncAsyncStar(String workingDirectory, {int minimumMatches = 2000 }) async { final RegExp syncPattern = RegExp(r'\s*?a?sync\*\s*?{'); final RegExp ignorePattern = RegExp(r'^\s*?// The following uses a?sync\* because:? '); final RegExp commentPattern = RegExp(r'^\s*?//'); final List<String> errors = <String>[]; await for (final File file in _allFiles(workingDirectory, 'dart', minimumMatches: minimumMatches)) { if (file.path.contains('test')) { continue; } final List<String> lines = file.readAsLinesSync(); for (int index = 0; index < lines.length; index += 1) { final String line = lines[index]; if (line.startsWith(commentPattern)) { continue; } if (line.contains(syncPattern)) { int lookBehindIndex = index - 1; bool hasExplanation = false; while (lookBehindIndex >= 0 && lines[lookBehindIndex].startsWith(commentPattern)) { if (lines[lookBehindIndex].startsWith(ignorePattern)) { hasExplanation = true; break; } lookBehindIndex -= 1; } if (!hasExplanation) { errors.add('${file.path}:$index: sync*/async* without an explanation.'); } } } } if (errors.isNotEmpty) { foundError(<String>[ '${bold}Do not use sync*/async* methods. See https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#avoid-syncasync for details.$reset', ...errors, ]); }}
final RegExp _findGoldenTestPattern = RegExp(r'matchesGoldenFile\(');final RegExp _findGoldenDefinitionPattern = RegExp(r'matchesGoldenFile\(Object');final RegExp _leadingComment = RegExp(r'//');final RegExp _goldenTagPattern1 = RegExp(r'@Tags\(');final RegExp _goldenTagPattern2 = RegExp(r"'reduced-test-set'");
/// Only golden file tests in the flutter package are subject to reduced testing,/// for example, invocations in flutter_test to validate comparator/// functionality do not require tagging.const String _ignoreGoldenTag = '// flutter_ignore: golden_tag (see analyze.dart)';const String _ignoreGoldenTagForFile = '// flutter_ignore_for_file: golden_tag (see analyze.dart)';
Future<void> verifyGoldenTags(String workingDirectory, { int minimumMatches = 2000 }) async { final List<String> errors = <String>[]; await for (final File file in _allFiles(workingDirectory, 'dart', minimumMatches: minimumMatches)) { bool needsTag = false; bool hasTagNotation = false; bool hasReducedTag = false; bool ignoreForFile = false; final List<String> lines = file.readAsLinesSync(); for (final String line in lines) { if (line.contains(_goldenTagPattern1)) { hasTagNotation = true; } if (line.contains(_goldenTagPattern2)) { hasReducedTag = true; } if (line.contains(_findGoldenTestPattern) && !line.contains(_findGoldenDefinitionPattern) && !line.contains(_leadingComment) && !line.contains(_ignoreGoldenTag)) { needsTag = true; } if (line.contains(_ignoreGoldenTagForFile)) { ignoreForFile = true; } // If the file is being ignored or a reduced test tag is already accounted // for, skip parsing the rest of the lines for golden file tests. if (ignoreForFile || (hasTagNotation && hasReducedTag)) { break; } } // If a reduced test tag is already accounted for, move on to the next file. if (ignoreForFile || (hasTagNotation && hasReducedTag)) { continue; } // If there are golden file tests, ensure they are tagged for all reduced // test environments. if (needsTag) { if (!hasTagNotation) { errors.add('${file.path}: Files containing golden tests must be tagged using ' "@Tags(<String>['reduced-test-set']) at the top of the file before import statements."); } else if (!hasReducedTag) { errors.add('${file.path}: Files containing golden tests must be tagged with ' "'reduced-test-set'."); } } } if (errors.isNotEmpty) { foundError(<String>[ ...errors, '${bold}See: https://github.com/flutter/flutter/wiki/Writing-a-golden-file-test-for-package:flutter$reset', ]); }}
final RegExp _findDeprecationPattern = RegExp(r'@[Dd]eprecated');final RegExp _deprecationStartPattern = RegExp(r'^(?<indent> *)@Deprecated\($'); // flutter_ignore: deprecation_syntax (see analyze.dart)final RegExp _deprecationMessagePattern = RegExp(r"^ *'(?<message>.+) '$");final RegExp _deprecationVersionPattern = RegExp(r"^ *'This feature was deprecated after v(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(?<build>-\d+\.\d+\.pre)?\.',?$");final RegExp _deprecationEndPattern = RegExp(r'^ *\)$');
/// Some deprecation notices are special, for example they're used to annotate members that/// will never go away and were never allowed but which we are trying to show messages for./// (One example would be a library that intentionally conflicts with a member in another/// library to indicate that it is incompatible with that other library. Another would be/// the regexp just above...)const String _ignoreDeprecation = ' // flutter_ignore: deprecation_syntax (see analyze.dart)';
/// Some deprecation notices are exempt for historical reasons. They must have an issue listed.final RegExp _legacyDeprecation = RegExp(r' // flutter_ignore: deprecation_syntax, https://github.com/flutter/flutter/issues/\d+$');
Future<void> verifyDeprecations(String workingDirectory, { int minimumMatches = 2000 }) async { final List<String> errors = <String>[]; await for (final File file in _allFiles(workingDirectory, 'dart', minimumMatches: minimumMatches)) { int lineNumber = 0; final List<String> lines = file.readAsLinesSync(); final List<int> linesWithDeprecations = <int>[]; for (final String line in lines) { if (line.contains(_findDeprecationPattern) && !line.endsWith(_ignoreDeprecation) && !line.contains(_legacyDeprecation)) { linesWithDeprecations.add(lineNumber); } lineNumber += 1; } for (int lineNumber in linesWithDeprecations) { try { final RegExpMatch? startMatch = _deprecationStartPattern.firstMatch(lines[lineNumber]); if (startMatch == null) { throw 'Deprecation notice does not match required pattern.'; } final String indent = startMatch.namedGroup('indent')!; lineNumber += 1; if (lineNumber >= lines.length) { throw 'Incomplete deprecation notice.'; } RegExpMatch? versionMatch; String? message; do { final RegExpMatch? messageMatch = _deprecationMessagePattern.firstMatch(lines[lineNumber]); if (messageMatch == null) { String possibleReason = ''; if (lines[lineNumber].trimLeft().startsWith('"')) { possibleReason = ' You might have used double quotes (") for the string instead of single quotes (\').'; } else if (!lines[lineNumber].contains("'")) { possibleReason = ' It might be missing the line saying "This feature was deprecated after...".'; } else if (!lines[lineNumber].trimRight().endsWith(" '")) { if (lines[lineNumber].contains('This feature was deprecated')) { possibleReason = ' There might not be an explanatory message.'; } else { possibleReason = ' There might be a missing space character at the end of the line.'; } } throw 'Deprecation notice does not match required pattern.$possibleReason'; } if (!lines[lineNumber].startsWith("$indent '")) { throw 'Unexpected deprecation notice indent.'; } if (message == null) { message = messageMatch.namedGroup('message'); final String firstChar = String.fromCharCode(message!.runes.first); if (firstChar.toUpperCase() != firstChar) { throw 'Deprecation notice should be a grammatically correct sentence and start with a capital letter; see style guide: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo'; } } else { message += messageMatch.namedGroup('message')!; } lineNumber += 1; if (lineNumber >= lines.length) { throw 'Incomplete deprecation notice.'; } versionMatch = _deprecationVersionPattern.firstMatch(lines[lineNumber]); } while (versionMatch == null); final int major = int.parse(versionMatch.namedGroup('major')!); final int minor = int.parse(versionMatch.namedGroup('minor')!); final int patch = int.parse(versionMatch.namedGroup('patch')!); final bool hasBuild = versionMatch.namedGroup('build') != null; // There was a beta release that was mistakenly labeled 3.1.0 without a build. final bool specialBeta = major == 3 && minor == 1 && patch == 0; if (!specialBeta && (major > 1 || (major == 1 && minor >= 20))) { if (!hasBuild) { throw 'Deprecation notice does not accurately indicate a beta branch version number; please see https://flutter.dev/docs/development/tools/sdk/releases to find the latest beta build version number.'; } } if (!message.endsWith('.') && !message.endsWith('!') && !message.endsWith('?')) { throw 'Deprecation notice should be a grammatically correct sentence and end with a period; notice appears to be "$message".'; } if (!lines[lineNumber].startsWith("$indent '")) { throw 'Unexpected deprecation notice indent.'; } lineNumber += 1; if (lineNumber >= lines.length) { throw 'Incomplete deprecation notice.'; } if (!lines[lineNumber].contains(_deprecationEndPattern)) { throw 'End of deprecation notice does not match required pattern.'; } if (!lines[lineNumber].startsWith('$indent)')) { throw 'Unexpected deprecation notice indent.'; } } catch (error) { errors.add('${file.path}:${lineNumber + 1}: $error'); } } } // Fail if any errors if (errors.isNotEmpty) { foundError(<String>[ ...errors, '${bold}See: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes$reset', ]); }}
String _generateLicense(String prefix) { return '${prefix}Copyright 2014 The Flutter Authors. All rights reserved.\n' '${prefix}Use of this source code is governed by a BSD-style license that can be\n' '${prefix}found in the LICENSE file.';}
Future<void> verifyNoMissingLicense(String workingDirectory, { bool checkMinimums = true }) async { final int? overrideMinimumMatches = checkMinimums ? null : 0; await _verifyNoMissingLicenseForExtension(workingDirectory, 'dart', overrideMinimumMatches ?? 2000, _generateLicense('// ')); await _verifyNoMissingLicenseForExtension(workingDirectory, 'java', overrideMinimumMatches ?? 39, _generateLicense('// ')); await _verifyNoMissingLicenseForExtension(workingDirectory, 'h', overrideMinimumMatches ?? 30, _generateLicense('// ')); await _verifyNoMissingLicenseForExtension(workingDirectory, 'm', overrideMinimumMatches ?? 30, _generateLicense('// ')); await _verifyNoMissingLicenseForExtension(workingDirectory, 'cc', overrideMinimumMatches ?? 10, _generateLicense('// ')); await _verifyNoMissingLicenseForExtension(workingDirectory, 'cpp', overrideMinimumMatches ?? 0, _generateLicense('// ')); await _verifyNoMissingLicenseForExtension(workingDirectory, 'swift', overrideMinimumMatches ?? 10, _generateLicense('// ')); await _verifyNoMissingLicenseForExtension(workingDirectory, 'gradle', overrideMinimumMatches ?? 80, _generateLicense('// ')); await _verifyNoMissingLicenseForExtension(workingDirectory, 'gn', overrideMinimumMatches ?? 0, _generateLicense('# ')); await _verifyNoMissingLicenseForExtension(workingDirectory, 'sh', overrideMinimumMatches ?? 1, _generateLicense('# '), header: r'#!/usr/bin/env bash\n',); await _verifyNoMissingLicenseForExtension(workingDirectory, 'bat', overrideMinimumMatches ?? 1, _generateLicense('REM '), header: r'@ECHO off\n'); await _verifyNoMissingLicenseForExtension(workingDirectory, 'ps1', overrideMinimumMatches ?? 1, _generateLicense('# ')); await _verifyNoMissingLicenseForExtension(workingDirectory, 'html', overrideMinimumMatches ?? 1, '<!-- ${_generateLicense('')} -->', trailingBlank: false, header: r'<!DOCTYPE HTML>\n'); await _verifyNoMissingLicenseForExtension(workingDirectory, 'xml', overrideMinimumMatches ?? 1, '<!-- ${_generateLicense('')} -->', header: r'(<\?xml version="1.0" encoding="utf-8"\?>\n)?'); await _verifyNoMissingLicenseForExtension(workingDirectory, 'frag', overrideMinimumMatches ?? 1, _generateLicense('// '), header: r'#version 320 es(\n)+');}
Future<void> _verifyNoMissingLicenseForExtension( String workingDirectory, String extension, int minimumMatches, String license, { bool trailingBlank = true, // The "header" is a regular expression matching the header that comes before // the license in some files. String header = '',}) async { assert(!license.endsWith('\n')); final String licensePattern = RegExp.escape('$license\n${trailingBlank ? '\n' : ''}'); final List<String> errors = <String>[]; await for (final File file in _allFiles(workingDirectory, extension, minimumMatches: minimumMatches)) { final String contents = file.readAsStringSync().replaceAll('\r\n', '\n'); if (contents.isEmpty) { continue; // let's not go down the /bin/true rabbit hole } if (!contents.startsWith(RegExp(header + licensePattern))) { errors.add(file.path); } } // Fail if any errors if (errors.isNotEmpty) { final String fileDoes = errors.length == 1 ? 'file does' : '${errors.length} files do'; foundError(<String>[ '${bold}The following $fileDoes not have the right license header for $extension files:$reset', ...errors.map<String>((String error) => ' $error'), 'The expected license header is:', if (header.isNotEmpty) 'A header matching the regular expression "$header",', if (header.isNotEmpty) 'followed by the following license text:', license, if (trailingBlank) '...followed by a blank line.', ]); }}
class _Line { _Line(this.line, this.content);
final int line; final String content;}
Iterable<_Line> _getTestSkips(File file) { final ParseStringResult parseResult = parseFile( featureSet: _parsingFeatureSet(), path: file.absolute.path, ); final _TestSkipLinesVisitor<CompilationUnit> visitor = _TestSkipLinesVisitor<CompilationUnit>(parseResult); visitor.visitCompilationUnit(parseResult.unit); return visitor.skips;}
class _TestSkipLinesVisitor<T> extends RecursiveAstVisitor<T> { _TestSkipLinesVisitor(this.parseResult) : skips = <_Line>{};
final ParseStringResult parseResult; final Set<_Line> skips;
static bool isTestMethod(String name) { return name.startsWith('test') || name == 'group' || name == 'expect'; }
@override T? visitMethodInvocation(MethodInvocation node) { if (isTestMethod(node.methodName.toString())) { for (final Expression argument in node.argumentList.arguments) { if (argument is NamedExpression && argument.name.label.name == 'skip') { skips.add(_getLine(parseResult, argument.beginToken.charOffset)); } } } return super.visitMethodInvocation(node); }}
final RegExp _skipTestCommentPattern = RegExp(r'//(.*)$');const Pattern _skipTestIntentionalPattern = '[intended]';final Pattern _skipTestTrackingBugPattern = RegExp(r'https+?://github.com/.*/issues/\d+');
Future<void> verifySkipTestComments(String workingDirectory) async { final List<String> errors = <String>[]; final Stream<File> testFiles =_allFiles(workingDirectory, 'dart', minimumMatches: 1500) .where((File f) => f.path.endsWith('_test.dart'));
await for (final File file in testFiles) { for (final _Line skip in _getTestSkips(file)) { final Match? match = _skipTestCommentPattern.firstMatch(skip.content); final String? skipComment = match?.group(1); if (skipComment == null || !(skipComment.contains(_skipTestIntentionalPattern) || skipComment.contains(_skipTestTrackingBugPattern))) { errors.add('${file.path}:${skip.line}: skip test without a justification comment.'); } } }
// Fail if any errors if (errors.isNotEmpty) { foundError(<String>[ ...errors, '\n${bold}See: https://github.com/flutter/flutter/wiki/Tree-hygiene#skipped-tests$reset', ]); }}
final RegExp _testImportPattern = RegExp(r'''import (['"])([^'"]+_test\.dart)\1''');const Set<String> _exemptTestImports = <String>{ 'package:flutter_test/flutter_test.dart', 'hit_test.dart', 'package:test_api/src/backend/live_test.dart', 'package:integration_test/integration_test.dart',};
Future<void> verifyNoTestImports(String workingDirectory) async { final List<String> errors = <String>[]; assert("// foo\nimport 'binding_test.dart' as binding;\n'".contains(_testImportPattern)); final List<File> dartFiles = await _allFiles(path.join(workingDirectory, 'packages'), 'dart', minimumMatches: 1500).toList(); for (final File file in dartFiles) { for (final String line in file.readAsLinesSync()) { final Match? match = _testImportPattern.firstMatch(line); if (match != null && !_exemptTestImports.contains(match.group(2))) { errors.add(file.path); } } } // Fail if any errors if (errors.isNotEmpty) { final String s = errors.length == 1 ? '' : 's'; foundError(<String>[ '${bold}The following file$s import a test directly. Test utilities should be in their own file.$reset', ...errors, ]); }}
Future<void> verifyNoBadImportsInFlutter(String workingDirectory) async { final List<String> errors = <String>[]; final String libPath = path.join(workingDirectory, 'packages', 'flutter', 'lib'); final String srcPath = path.join(workingDirectory, 'packages', 'flutter', 'lib', 'src'); // Verify there's one libPath/*.dart for each srcPath/*/. final List<String> packages = Directory(libPath).listSync() .where((FileSystemEntity entity) => entity is File && path.extension(entity.path) == '.dart') .map<String>((FileSystemEntity entity) => path.basenameWithoutExtension(entity.path)) .toList()..sort(); final List<String> directories = Directory(srcPath).listSync() .whereType<Directory>() .map<String>((Directory entity) => path.basename(entity.path)) .toList()..sort(); if (!_listEquals<String>(packages, directories)) { errors.add(<String>[ 'flutter/lib/*.dart does not match flutter/lib/src/*/:', 'These are the exported packages:', ...packages.map<String>((String path) => ' lib/$path.dart'), 'These are the directories:', ...directories.map<String>((String path) => ' lib/src/$path/'), ].join('\n')); } // Verify that the imports are well-ordered. final Map<String, Set<String>> dependencyMap = <String, Set<String>>{}; for (final String directory in directories) { dependencyMap[directory] = await _findFlutterDependencies(path.join(srcPath, directory), errors, checkForMeta: directory != 'foundation'); } assert(dependencyMap['material']!.contains('widgets') && dependencyMap['widgets']!.contains('rendering') && dependencyMap['rendering']!.contains('painting')); // to make sure we're convinced _findFlutterDependencies is finding some for (final String package in dependencyMap.keys) { if (dependencyMap[package]!.contains(package)) { errors.add( 'One of the files in the $yellow$package$reset package imports that package recursively.' ); } }
for (final String key in dependencyMap.keys) { for (final String dependency in dependencyMap[key]!) { if (dependencyMap[dependency] != null) { continue; } // Sanity check before performing _deepSearch, to ensure there's no rogue // dependencies. final String validFilenames = dependencyMap.keys.map((String name) => '$name.dart').join(', '); errors.add( '$key imported package:flutter/$dependency.dart ' 'which is not one of the valid exports { $validFilenames }.\n' 'Consider changing $dependency.dart to one of them.' ); } }
for (final String package in dependencyMap.keys) { final List<String>? loop = _deepSearch<String>(dependencyMap, package); if (loop != null) { errors.add('${yellow}Dependency loop:$reset ${loop.join(' depends on ')}'); } } // Fail if any errors if (errors.isNotEmpty) { foundError(<String>[ if (errors.length == 1) '${bold}An error was detected when looking at import dependencies within the Flutter package:$reset' else '${bold}Multiple errors were detected when looking at import dependencies within the Flutter package:$reset', ...errors, ]); }}
Future<void> verifyNoBadImportsInFlutterTools(String workingDirectory) async { final List<String> errors = <String>[]; final List<File> files = await _allFiles(path.join(workingDirectory, 'packages', 'flutter_tools', 'lib'), 'dart', minimumMatches: 200).toList(); for (final File file in files) { if (file.readAsStringSync().contains('package:flutter_tools/')) { errors.add('$yellow${file.path}$reset imports flutter_tools.'); } } // Fail if any errors if (errors.isNotEmpty) { foundError(<String>[ if (errors.length == 1) '${bold}An error was detected when looking at import dependencies within the flutter_tools package:$reset' else '${bold}Multiple errors were detected when looking at import dependencies within the flutter_tools package:$reset', ...errors.map((String paragraph) => '$paragraph\n'), ]); }}
Future<void> verifyIntegrationTestTimeouts(String workingDirectory) async { final List<String> errors = <String>[]; final String dev = path.join(workingDirectory, 'dev'); final List<File> files = await _allFiles(dev, 'dart', minimumMatches: 1) .where((File file) => file.path.contains('test_driver') && (file.path.endsWith('_test.dart') || file.path.endsWith('util.dart'))) .toList(); for (final File file in files) { final String contents = file.readAsStringSync(); final int testCount = ' test('.allMatches(contents).length; final int timeoutNoneCount = 'timeout: Timeout.none'.allMatches(contents).length; if (testCount != timeoutNoneCount) { errors.add('$yellow${file.path}$reset has at least $testCount test(s) but only $timeoutNoneCount `Timeout.none`(s).'); } } if (errors.isNotEmpty) { foundError(<String>[ if (errors.length == 1) '${bold}An error was detected when looking at integration test timeouts:$reset' else '${bold}Multiple errors were detected when looking at integration test timeouts:$reset', ...errors.map((String paragraph) => '$paragraph\n'), ]); }}
Future<void> verifyInternationalizations(String workingDirectory, String dartExecutable) async { final EvalResult materialGenResult = await _evalCommand( dartExecutable, <String>[ path.join('dev', 'tools', 'localization', 'bin', 'gen_localizations.dart'), '--material', '--remove-undefined', ], workingDirectory: workingDirectory, ); final EvalResult cupertinoGenResult = await _evalCommand( dartExecutable, <String>[ path.join('dev', 'tools', 'localization', 'bin', 'gen_localizations.dart'), '--cupertino', '--remove-undefined', ], workingDirectory: workingDirectory, );
final String materialLocalizationsFile = path.join(workingDirectory, 'packages', 'flutter_localizations', 'lib', 'src', 'l10n', 'generated_material_localizations.dart'); final String cupertinoLocalizationsFile = path.join(workingDirectory, 'packages', 'flutter_localizations', 'lib', 'src', 'l10n', 'generated_cupertino_localizations.dart'); final String expectedMaterialResult = await File(materialLocalizationsFile).readAsString(); final String expectedCupertinoResult = await File(cupertinoLocalizationsFile).readAsString();
if (materialGenResult.stdout.trim() != expectedMaterialResult.trim()) { foundError(<String>[ '<<<<<<< $materialLocalizationsFile', expectedMaterialResult.trim(), '=======', materialGenResult.stdout.trim(), '>>>>>>> gen_localizations', 'The contents of $materialLocalizationsFile are different from that produced by gen_localizations.', '', 'Did you forget to run gen_localizations.dart after updating a .arb file?', ]); } if (cupertinoGenResult.stdout.trim() != expectedCupertinoResult.trim()) { foundError(<String>[ '<<<<<<< $cupertinoLocalizationsFile', expectedCupertinoResult.trim(), '=======', cupertinoGenResult.stdout.trim(), '>>>>>>> gen_localizations', 'The contents of $cupertinoLocalizationsFile are different from that produced by gen_localizations.', '', 'Did you forget to run gen_localizations.dart after updating a .arb file?', ]); }}
/// Verifies that all instances of "checked mode" have been migrated to "debug mode".Future<void> verifyNoCheckedMode(String workingDirectory) async { final String flutterPackages = path.join(workingDirectory, 'packages'); final List<File> files = await _allFiles(flutterPackages, 'dart', minimumMatches: 400) .where((File file) => path.extension(file.path) == '.dart') .toList(); final List<String> problems = <String>[]; for (final File file in files) { int lineCount = 0; for (final String line in file.readAsLinesSync()) { if (line.toLowerCase().contains('checked mode')) { problems.add('${file.path}:$lineCount uses deprecated "checked mode" instead of "debug mode".'); } lineCount += 1; } } if (problems.isNotEmpty) { foundError(problems); }}
Future<void> verifyNoRuntimeTypeInToString(String workingDirectory) async { final String flutterLib = path.join(workingDirectory, 'packages', 'flutter', 'lib'); final Set<String> excludedFiles = <String>{ path.join(flutterLib, 'src', 'foundation', 'object.dart'), // Calls this from within an assert. }; final List<File> files = await _allFiles(flutterLib, 'dart', minimumMatches: 400) .where((File file) => !excludedFiles.contains(file.path)) .toList(); final RegExp toStringRegExp = RegExp(r'^\s+String\s+to(.+?)?String(.+?)?\(\)\s+(\{|=>)'); final List<String> problems = <String>[]; for (final File file in files) { final List<String> lines = file.readAsLinesSync(); for (int index = 0; index < lines.length; index++) { if (toStringRegExp.hasMatch(lines[index])) { final int sourceLine = index + 1; bool checkForRuntimeType(String line) { if (line.contains(r'$runtimeType') || line.contains('runtimeType.toString()')) { problems.add('${file.path}:$sourceLine}: toString calls runtimeType.toString'); return true; } return false; } if (checkForRuntimeType(lines[index])) { continue; } if (lines[index].contains('=>')) { while (!lines[index].contains(';')) { index++; assert(index < lines.length, 'Source file $file has unterminated toString method.'); if (checkForRuntimeType(lines[index])) { break; } } } else { int openBraceCount = '{'.allMatches(lines[index]).length - '}'.allMatches(lines[index]).length; while (!lines[index].contains('}') && openBraceCount > 0) { index++; assert(index < lines.length, 'Source file $file has unbalanced braces in a toString method.'); if (checkForRuntimeType(lines[index])) { break; } openBraceCount += '{'.allMatches(lines[index]).length; openBraceCount -= '}'.allMatches(lines[index]).length; } } } } } if (problems.isNotEmpty) { foundError(problems); }}
Future<void> verifyNoTrailingSpaces(String workingDirectory, { int minimumMatches = 4000 }) async { final List<File> files = await _allFiles(workingDirectory, null, minimumMatches: minimumMatches) .where((File file) => path.basename(file.path) != 'serviceaccount.enc') .where((File file) => path.basename(file.path) != 'Ahem.ttf') .where((File file) => path.extension(file.path) != '.snapshot') .where((File file) => path.extension(file.path) != '.png') .where((File file) => path.extension(file.path) != '.jpg') .where((File file) => path.extension(file.path) != '.ico') .where((File file) => path.extension(file.path) != '.jar') .where((File file) => path.extension(file.path) != '.swp') .toList(); final List<String> problems = <String>[]; for (final File file in files) { final List<String> lines = file.readAsLinesSync(); for (int index = 0; index < lines.length; index += 1) { if (lines[index].endsWith(' ')) { problems.add('${file.path}:${index + 1}: trailing U+0020 space character'); } else if (lines[index].endsWith('\t')) { problems.add('${file.path}:${index + 1}: trailing U+0009 tab character'); } } if (lines.isNotEmpty && lines.last == '') { problems.add('${file.path}:${lines.length}: trailing blank line'); } } if (problems.isNotEmpty) { foundError(problems); }}
final RegExp _flowControlStatementWithoutSpace = RegExp(r'(^|[ \t])(if|switch|for|do|while|catch)\(', multiLine: true);
Future<void> verifySpacesAfterFlowControlStatements(String workingDirectory, { int minimumMatches = 4000 }) async { const Set<String> extensions = <String>{ '.dart', '.java', '.js', '.kt', '.swift', '.c', '.cc', '.cpp', '.h', '.m', }; final List<File> files = await _allFiles(workingDirectory, null, minimumMatches: minimumMatches) .where((File file) => extensions.contains(path.extension(file.path))) .toList(); final List<String> problems = <String>[]; for (final File file in files) { final List<String> lines = file.readAsLinesSync(); for (int index = 0; index < lines.length; index += 1) { if (lines[index].contains(_flowControlStatementWithoutSpace)) { problems.add('${file.path}:${index + 1}: no space after flow control statement'); } } } if (problems.isNotEmpty) { foundError(problems); }}
String _bullets(String value) => ' * $value';
Future<void> verifyIssueLinks(String workingDirectory) async { const String issueLinkPrefix = 'https://github.com/flutter/flutter/issues/new'; const Set<String> stops = <String>{ '\n', ' ', "'", '"', r'\', ')', '>' }; assert(!stops.contains('.')); // instead of "visit https://foo." say "visit: https://", it copy-pastes better const String kGiveTemplates = 'Prefer to provide a link either to $issueLinkPrefix/choose (the list of issue ' 'templates) or to a specific template directly ($issueLinkPrefix?template=...).\n'; final Set<String> templateNames = Directory(path.join(workingDirectory, '.github', 'ISSUE_TEMPLATE')) .listSync() .whereType<File>() .where((File file) => path.extension(file.path) == '.md' || path.extension(file.path) == '.yml') .map<String>((File file) => path.basename(file.path)) .toSet(); final String kTemplates = 'The available templates are:\n${templateNames.map(_bullets).join("\n")}'; final List<String> problems = <String>[]; final Set<String> suggestions = <String>{}; final List<File> files = await _gitFiles(workingDirectory); for (final File file in files) { if (path.basename(file.path).endsWith('_test.dart') || path.basename(file.path) == 'analyze.dart') { continue; // Skip tests, they're not public-facing. } final Uint8List bytes = file.readAsBytesSync(); // We allow invalid UTF-8 here so that binaries don't trip us up. // There's a separate test in this file that verifies that all text // files are actually valid UTF-8 (see verifyNoBinaries below). final String contents = utf8.decode(bytes, allowMalformed: true); int start = 0; while ((start = contents.indexOf(issueLinkPrefix, start)) >= 0) { int end = start + issueLinkPrefix.length; while (end < contents.length && !stops.contains(contents[end])) { end += 1; } final String url = contents.substring(start, end); if (url == issueLinkPrefix) { if (file.path != path.join(workingDirectory, 'dev', 'bots', 'analyze.dart')) { problems.add('${file.path} contains a direct link to $issueLinkPrefix.'); suggestions.add(kGiveTemplates); suggestions.add(kTemplates); } } else if (url.startsWith('$issueLinkPrefix?')) { final Uri parsedUrl = Uri.parse(url); final List<String>? templates = parsedUrl.queryParametersAll['template']; if (templates == null) { problems.add('${file.path} contains $url, which has no "template" argument specified.'); suggestions.add(kGiveTemplates); suggestions.add(kTemplates); } else if (templates.length != 1) { problems.add('${file.path} contains $url, which has ${templates.length} templates specified.'); suggestions.add(kGiveTemplates); suggestions.add(kTemplates); } else if (!templateNames.contains(templates.single)) { problems.add('${file.path} contains $url, which specifies a non-existent template ("${templates.single}").'); suggestions.add(kTemplates); } else if (parsedUrl.queryParametersAll.keys.length > 1) { problems.add('${file.path} contains $url, which the analyze.dart script is not sure how to handle.'); suggestions.add('Update analyze.dart to handle the URLs above, or change them to the expected pattern.'); } } else if (url != '$issueLinkPrefix/choose') { problems.add('${file.path} contains $url, which the analyze.dart script is not sure how to handle.'); suggestions.add('Update analyze.dart to handle the URLs above, or change them to the expected pattern.'); } start = end; } } assert(problems.isEmpty == suggestions.isEmpty); if (problems.isNotEmpty) { foundError(<String>[ ...problems, ...suggestions, ]); }}
@immutableclass Hash256 { const Hash256(this.a, this.b, this.c, this.d);
factory Hash256.fromDigest(Digest digest) { assert(digest.bytes.length == 32); return Hash256( digest.bytes[ 0] << 56 | digest.bytes[ 1] << 48 | digest.bytes[ 2] << 40 | digest.bytes[ 3] << 32 | digest.bytes[ 4] << 24 | digest.bytes[ 5] << 16 | digest.bytes[ 6] << 8 | digest.bytes[ 7] << 0, digest.bytes[ 8] << 56 | digest.bytes[ 9] << 48 | digest.bytes[10] << 40 | digest.bytes[11] << 32 | digest.bytes[12] << 24 | digest.bytes[13] << 16 | digest.bytes[14] << 8 | digest.bytes[15] << 0, digest.bytes[16] << 56 | digest.bytes[17] << 48 | digest.bytes[18] << 40 | digest.bytes[19] << 32 | digest.bytes[20] << 24 | digest.bytes[21] << 16 | digest.bytes[22] << 8 | digest.bytes[23] << 0, digest.bytes[24] << 56 | digest.bytes[25] << 48 | digest.bytes[26] << 40 | digest.bytes[27] << 32 | digest.bytes[28] << 24 | digest.bytes[29] << 16 | digest.bytes[30] << 8 | digest.bytes[31] << 0, ); }
final int a; final int b; final int c; final int d;
@override bool operator ==(Object other) { if (other.runtimeType != runtimeType) { return false; } return other is Hash256 && other.a == a && other.b == b && other.c == c && other.d == d; }
@override int get hashCode => Object.hash(a, b, c, d);}
// DO NOT ADD ANY ENTRIES TO THIS LIST.// We have a policy of not checking in binaries into this repository.// If you are adding/changing template images, use the flutter_template_images// package and a .img.tmpl placeholder instead.// If you have other binaries to add, please consult Hixie for advice.final Set<Hash256> _legacyBinaries = <Hash256>{ // DEFAULT ICON IMAGES
// packages/flutter_tools/templates/app/android.tmpl/app/src/main/res/mipmap-hdpi/ic_launcher.png // packages/flutter_tools/templates/module/android/host_app_common/app.tmpl/src/main/res/mipmap-hdpi/ic_launcher.png // (also used by many examples) const Hash256(0x6A7C8F0D703E3682, 0x108F9662F8133022, 0x36240D3F8F638BB3, 0x91E32BFB96055FEF),
// packages/flutter_tools/templates/app/android.tmpl/app/src/main/res/mipmap-mdpi/ic_launcher.png // (also used by many examples) const Hash256(0xC7C0C0189145E4E3, 0x2A401C61C9BDC615, 0x754B0264E7AFAE24, 0xE834BB81049EAF81),
// packages/flutter_tools/templates/app/android.tmpl/app/src/main/res/mipmap-xhdpi/ic_launcher.png // (also used by many examples) const Hash256(0xE14AA40904929BF3, 0x13FDED22CF7E7FFC, 0xBF1D1AAC4263B5EF, 0x1BE8BFCE650397AA),
// packages/flutter_tools/templates/app/android.tmpl/app/src/main/res/mipmap-xxhdpi/ic_launcher.png // (also used by many examples) const Hash256(0x4D470BF22D5C17D8, 0x4EDC5F82516D1BA8, 0xA1C09559CD761CEF, 0xB792F86D9F52B540),
// packages/flutter_tools/templates/app/android.tmpl/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png // (also used by many examples) const Hash256(0x3C34E1F298D0C9EA, 0x3455D46DB6B7759C, 0x8211A49E9EC6E44B, 0x635FC5C87DFB4180),
// packages/flutter_tools/templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png // packages/flutter_tools/templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png // (also used by a few examples) const Hash256(0x7770183009E91411, 0x2DE7D8EF1D235A6A, 0x30C5834424858E0D, 0x2F8253F6B8D31926),
// packages/flutter_tools/templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png // packages/flutter_tools/templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png // (also used by many examples) const Hash256(0x5925DAB509451F9E, 0xCBB12CE8A625F9D4, 0xC104718EE20CAFF8, 0xB1B51032D1CD8946),
// packages/flutter_tools/templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png // packages/flutter_tools/templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png // packages/flutter_tools/templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png // packages/flutter_tools/templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png // (also used by many examples) const Hash256(0xC4D9A284C12301D0, 0xF50E248EC53ED51A, 0x19A10147B774B233, 0x08399250B0D44C55),
// packages/flutter_tools/templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png // packages/flutter_tools/templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png // (also used by many examples) const Hash256(0xBF97F9D3233F33E1, 0x389B09F7B8ADD537, 0x41300CB834D6C7A5, 0xCA32CBED363A4FB2),
// packages/flutter_tools/templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png // packages/flutter_tools/templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png // (also used by many examples) const Hash256(0x285442F69A06B45D, 0x9D79DF80321815B5, 0x46473548A37B7881, 0x9B68959C7B8ED237),
// packages/flutter_tools/templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png // packages/flutter_tools/templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png // (also used by many examples) const Hash256(0x2AB64AF8AC727EA9, 0x9C6AB9EAFF847F46, 0xFBF2A9A0A78A0ABC, 0xBF3180F3851645B4),
// packages/flutter_tools/templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png // packages/flutter_tools/templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png // (also used by many examples) const Hash256(0x9DCA09F4E5ED5684, 0xD3C4DFF41F4E8B7C, 0xB864B438172D72BE, 0x069315FA362930F9),
// packages/flutter_tools/templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png // packages/flutter_tools/templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png // (also used by many examples) const Hash256(0xD5AD04DE321EF37C, 0xACC5A7B960AFCCE7, 0x1BDCB96FA020C482, 0x49C1545DD1A0F497),
// packages/flutter_tools/templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png // packages/flutter_tools/templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png // packages/flutter_tools/templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png // packages/flutter_tools/templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png // (also used by many examples) const Hash256(0x809ABFE75C440770, 0xC13C4E2E46D09603, 0xC22053E9D4E0E227, 0x5DCB9C1DCFBB2C75),
// packages/flutter_tools/templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png // packages/flutter_tools/templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png // (also used by many examples) const Hash256(0x3DB08CB79E7B01B9, 0xE81F956E3A0AE101, 0x48D0FAFDE3EA7AA7, 0x0048DF905AA52CFD),
// packages/flutter_tools/templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png // packages/flutter_tools/templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png // (also used by many examples) const Hash256(0x23C13D463F5DCA5C, 0x1F14A14934003601, 0xC29F1218FD461016, 0xD8A22CEF579A665F),
// packages/flutter_tools/templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png // packages/flutter_tools/templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png // (also used by many examples) const Hash256(0x6DB7726530D71D3F, 0x52CB59793EB69131, 0x3BAA04796E129E1E, 0x043C0A58A1BFFD2F),
// packages/flutter_tools/templates/app/ios.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png // packages/flutter_tools/templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png // (also used by many examples) const Hash256(0xCEE565F5E6211656, 0x9B64980B209FD5CA, 0x4B3D3739011F5343, 0x250B33A1A2C6EB65),
// packages/flutter_tools/templates/app/ios.tmpl/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png // packages/flutter_tools/templates/app/ios.tmpl/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png // packages/flutter_tools/templates/app/ios.tmpl/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png // packages/flutter_tools/templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/LaunchImage.imageset/LaunchImage.png // packages/flutter_tools/templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png // packages/flutter_tools/templates/module/ios/host_app_ephemeral/Runner.tmpl/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png // (also used by many examples) const Hash256(0x93AE7D494FAD0FB3, 0x0CBF3AE746A39C4B, 0xC7A0F8BBF87FBB58, 0x7A3F3C01F3C5CE20),
// packages/flutter_tools/templates/app/macos.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png // (also used by a few examples) const Hash256(0xB18BEBAAD1AD6724, 0xE48BCDF699BA3927, 0xDF3F258FEBE646A3, 0xAB5C62767C6BAB40),
// packages/flutter_tools/templates/app/macos.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png // (also used by a few examples) const Hash256(0xF90D839A289ECADB, 0xF2B0B3400DA43EB8, 0x08B84908335AE4A0, 0x07457C4D5A56A57C),
// packages/flutter_tools/templates/app/macos.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png // (also used by a few examples) const Hash256(0x592C2ABF84ADB2D3, 0x91AED8B634D3233E, 0x2C65369F06018DCD, 0x8A4B27BA755EDCBE),
// packages/flutter_tools/templates/app/macos.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png // (also used by a few examples) const Hash256(0x75D9A0C034113CA8, 0xA1EC11C24B81F208, 0x6630A5A5C65C7D26, 0xA5DC03A1C0A4478C),
// packages/flutter_tools/templates/app/macos.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png // (also used by a few examples) const Hash256(0xA896E65745557732, 0xC72BD4EE3A10782F, 0xE2AA95590B5AF659, 0x869E5808DB9C01C1),
// packages/flutter_tools/templates/app/macos.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png // (also used by a few examples) const Hash256(0x3A69A8A1AAC5D9A8, 0x374492AF4B6D07A4, 0xCE637659EB24A784, 0x9C4DFB261D75C6A3),
// packages/flutter_tools/templates/app/macos.tmpl/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png // (also used by a few examples) const Hash256(0xD29D4E0AF9256DC9, 0x2D0A8F8810608A5E, 0x64A132AD8B397CA2, 0xC4DDC0B1C26A68C3),
// packages/flutter_tools/templates/app/web/icons/Icon-192.png.copy.tmpl // dev/integration_tests/flutter_gallery/web/icons/Icon-192.png const Hash256(0x3DCE99077602F704, 0x21C1C6B2A240BC9B, 0x83D64D86681D45F2, 0x154143310C980BE3),
// packages/flutter_tools/templates/app/web/icons/Icon-512.png.copy.tmpl // dev/integration_tests/flutter_gallery/web/icons/Icon-512.png const Hash256(0xBACCB205AE45f0B4, 0x21BE1657259B4943, 0xAC40C95094AB877F, 0x3BCBE12CD544DCBE),
// packages/flutter_tools/templates/app/web/favicon.png.copy.tmpl // dev/integration_tests/flutter_gallery/web/favicon.png const Hash256(0x7AB2525F4B86B65D, 0x3E4C70358A17E5A1, 0xAAF6F437f99CBCC0, 0x46DAD73d59BB9015),
// GALLERY ICONS
// dev/integration_tests/flutter_gallery/android/app/src/main/res/mipmap-hdpi/ic_background.png const Hash256(0x03CFDE53C249475C, 0x277E8B8E90AC8A13, 0xE5FC13C358A94CCB, 0x67CA866C9862A0DD),
// dev/integration_tests/flutter_gallery/android/app/src/main/res/mipmap-hdpi/ic_foreground.png const Hash256(0x86A83E23A505EFCC, 0x39C358B699EDE12F, 0xC088EE516A1D0C73, 0xF3B5D74DDAD164B1),
// dev/integration_tests/flutter_gallery/android/app/src/main/res/mipmap-hdpi/ic_launcher.png const Hash256(0xD813B1A77320355E, 0xB68C485CD47D0F0F, 0x3C7E1910DCD46F08, 0x60A6401B8DC13647),
// dev/integration_tests/flutter_gallery/android/app/src/main/res/mipmap-xhdpi/ic_background.png const Hash256(0x35AFA76BD5D6053F, 0xEE927436C78A8794, 0xA8BA5F5D9FC9653B, 0xE5B96567BB7215ED),
// dev/integration_tests/flutter_gallery/android/app/src/main/res/mipmap-xhdpi/ic_foreground.png const Hash256(0x263CE9B4F1F69B43, 0xEBB08AE9FE8F80E7, 0x95647A59EF2C040B, 0xA8AEB246861A7DFF),
// dev/integration_tests/flutter_gallery/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png const Hash256(0x5E1A93C3653BAAFF, 0x1AAC6BCEB8DCBC2F, 0x2AE7D68ECB07E507, 0xCB1FA8354B28313A),
// dev/integration_tests/flutter_gallery/android/app/src/main/res/mipmap-xxhdpi/ic_background.png const Hash256(0xA5C77499151DDEC6, 0xDB40D0AC7321FD74, 0x0646C0C0F786743F, 0x8F3C3C408CAC5E8C),
// dev/integration_tests/flutter_gallery/android/app/src/main/res/mipmap-xxhdpi/ic_foreground.png const Hash256(0x33DE450980A2A16B, 0x1982AC7CDC1E7B01, 0x919E07E0289C2139, 0x65F85BCED8895FEF),
// dev/integration_tests/flutter_gallery/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png const Hash256(0xC3B8577F4A89BA03, 0x830944FB06C3566B, 0x4C99140A2CA52958, 0x089BFDC3079C59B7),
// dev/integration_tests/flutter_gallery/android/app/src/main/res/mipmap-xxxhdpi/ic_background.png const Hash256(0xDEBC241D6F9C5767, 0x8980FDD46FA7ED0C, 0x5B8ACD26BCC5E1BC, 0x473C89B432D467AD),
// dev/integration_tests/flutter_gallery/android/app/src/main/res/mipmap-xxxhdpi/ic_foreground.png const Hash256(0xBEFE5F7E82BF8B64, 0x148D869E3742004B, 0xF821A9F5A1BCDC00, 0x357D246DCC659DC2),
// dev/integration_tests/flutter_gallery/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png const Hash256(0xC385404341FF9EDD, 0x30FBE76F0EC99155, 0x8EA4F4AFE8CC0C60, 0x1CA3EDEF177E1DA8),
// dev/integration_tests/flutter_gallery/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-1024.png const Hash256(0x6BE5751A29F57A80, 0x36A4B31CC542C749, 0x984E49B22BD65CAA, 0x75AE8B2440848719),
// dev/integration_tests/flutter_gallery/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-120.png const Hash256(0x9972A2264BFA8F8D, 0x964AFE799EADC1FA, 0x2247FB31097F994A, 0x1495DC32DF071793),
// dev/integration_tests/flutter_gallery/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-152.png const Hash256(0x4C7CC9B09BEEDA24, 0x45F57D6967753910, 0x57D68E1A6B883D2C, 0x8C52701A74F1400F),
// dev/integration_tests/flutter_gallery/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-167.png const Hash256(0x66DACAC1CFE4D349, 0xDBE994CB9125FFD7, 0x2D795CFC9CF9F739, 0xEDBB06CE25082E9C),
// dev/integration_tests/flutter_gallery/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-180.png const Hash256(0x5188621015EBC327, 0xC9EF63AD76E60ECE, 0xE82BDC3E4ABF09E2, 0xEE0139FA7C0A2BE5),
// dev/integration_tests/flutter_gallery/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-20.png const Hash256(0x27D2752D04EE9A6B, 0x78410E208F74A6CD, 0xC90D9E03B73B8C60, 0xD05F7D623E790487),
// dev/integration_tests/flutter_gallery/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-29.png const Hash256(0xBB20556B2826CF85, 0xD5BAC73AA69C2AC3, 0x8E71DAD64F15B855, 0xB30CB73E0AF89307),
// dev/integration_tests/flutter_gallery/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-40.png const Hash256(0x623820FA45CDB0AC, 0x808403E34AD6A53E, 0xA3E9FDAE83EE0931, 0xB020A3A4EF2CDDE7),
// dev/integration_tests/flutter_gallery/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-58.png const Hash256(0xC6D631D1E107215E, 0xD4A58FEC5F3AA4B5, 0x0AE9724E07114C0C, 0x453E5D87C2CAD3B3),
// dev/integration_tests/flutter_gallery/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-60.png const Hash256(0x4B6F58D1EB8723C6, 0xE717A0D09FEC8806, 0x90C6D1EF4F71836E, 0x618672827979B1A2),
// dev/integration_tests/flutter_gallery/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-76.png const Hash256(0x0A1744CC7634D508, 0xE85DD793331F0C8A, 0x0B7C6DDFE0975D8F, 0x29E91C905BBB1BED),
// dev/integration_tests/flutter_gallery/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-80.png const Hash256(0x24032FBD1E6519D6, 0x0BA93C0D5C189554, 0xF50EAE23756518A2, 0x3FABACF4BD5DAF08),
// dev/integration_tests/flutter_gallery/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-87.png const Hash256(0xC17BAE6DF6BB234A, 0xE0AF4BEB0B805F12, 0x14E74EB7AA9A30F1, 0x5763689165DA7DDF),
// STOCKS ICONS
// dev/benchmarks/test_apps/stocks/android/app/src/main/res/mipmap-hdpi/ic_launcher.png const Hash256(0x74052AB5241D4418, 0x7085180608BC3114, 0xD12493C50CD8BBC7, 0x56DED186C37ACE84),
// dev/benchmarks/test_apps/stocks/android/app/src/main/res/mipmap-mdpi/ic_launcher.png const Hash256(0xE37947332E3491CB, 0x82920EE86A086FEA, 0xE1E0A70B3700A7DA, 0xDCAFBDD8F40E2E19),
// dev/benchmarks/test_apps/stocks/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png const Hash256(0xE608CDFC0C8579FB, 0xE38873BAAF7BC944, 0x9C9D2EE3685A4FAE, 0x671EF0C8BC41D17C),
// dev/benchmarks/test_apps/stocks/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png const Hash256(0xBD53D86977DF9C54, 0xF605743C5ABA114C, 0x9D51D1A8BB917E1A, 0x14CAA26C335CAEBD),
// dev/benchmarks/test_apps/stocks/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png const Hash256(0x64E4D02262C4F3D0, 0xBB4FDC21CD0A816C, 0x4CD2A0194E00FB0F, 0x1C3AE4142FAC0D15),
// dev/benchmarks/test_apps/stocks/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png // dev/benchmarks/test_apps/stocks/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-Small-40@3x.png const Hash256(0x5BA3283A76918FC0, 0xEE127D0F22D7A0B6, 0xDF03DAED61669427, 0x93D89DDD87A08117),
// dev/benchmarks/test_apps/stocks/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png const Hash256(0xCD7F26ED31DEA42A, 0x535D155EC6261499, 0x34E6738255FDB2C4, 0xBD8D4BDDE9A99B05),
// dev/benchmarks/test_apps/stocks/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-76.png const Hash256(0x3FA1225FC9A96A7E, 0xCD071BC42881AB0E, 0x7747EB72FFB72459, 0xA37971BBAD27EE24),
// dev/benchmarks/test_apps/stocks/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-76@2x.png const Hash256(0xCD867001ACD7BBDB, 0x25CDFD452AE89FA2, 0x8C2DC980CAF55F48, 0x0B16C246CFB389BC),
// dev/benchmarks/test_apps/stocks/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-83.5@2x.png const Hash256(0x848E9736E5C4915A, 0x7945BCF6B32FD56B, 0x1F1E7CDDD914352E, 0xC9681D38EF2A70DA),
// dev/benchmarks/test_apps/stocks/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-Notification.png const Hash256(0x654BA7D6C4E05CA0, 0x7799878884EF8F11, 0xA383E1F24CEF5568, 0x3C47604A966983C8),
// dev/benchmarks/test_apps/stocks/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-Notification@2x.png // dev/benchmarks/test_apps/stocks/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-Small-40.png const Hash256(0x743056FE7D83FE42, 0xA2990825B6AD0415, 0x1AF73D0D43B227AA, 0x07EBEA9B767381D9),
// dev/benchmarks/test_apps/stocks/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-Notification@3x.png const Hash256(0xA7E1570812D119CF, 0xEF4B602EF28DD0A4, 0x100D066E66F5B9B9, 0x881765DC9303343B),
// dev/benchmarks/test_apps/stocks/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-Small-40@2x.png const Hash256(0xB4102839A1E41671, 0x62DACBDEFA471953, 0xB1EE89A0AB7594BE, 0x1D9AC1E67DC2B2CE),
// dev/benchmarks/test_apps/stocks/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-Small.png const Hash256(0x70AC6571B593A967, 0xF1CBAEC9BC02D02D, 0x93AD766D8290ADE6, 0x840139BF9F219019),
// dev/benchmarks/test_apps/stocks/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-Small@2x.png const Hash256(0x5D87A78386DA2C43, 0xDDA8FEF2CA51438C, 0xE5A276FE28C6CF0A, 0xEBE89085B56665B6),
// dev/benchmarks/test_apps/stocks/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-Small@3x.png const Hash256(0x4D9F5E81F668DA44, 0xB20A77F8BF7BA2E1, 0xF384533B5AD58F07, 0xB3A2F93F8635CD96),
// LEGACY ICONS
// dev/benchmarks/complex_layout/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@3x.png // dev/benchmarks/microbenchmarks/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@3x.png // examples/flutter_view/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@3x.png // (not really sure where this came from, or why neither the template nor most examples use them) const Hash256(0x6E645DC9ED913AAD, 0xB50ED29EEB16830D, 0xB32CA12F39121DB9, 0xB7BC1449DDDBF8B8),
// dev/benchmarks/macrobenchmarks/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png // dev/integration_tests/codegen/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png // dev/integration_tests/ios_add2app/ios_add2app/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png // dev/integration_tests/release_smoke_test/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png const Hash256(0xDEFAC77E08EC71EC, 0xA04CCA3C95D1FC33, 0xB9F26E1CB15CB051, 0x47DEFC79CDD7C158),
// examples/flutter_view/ios/Runner/ic_add.png // examples/platform_view/ios/Runner/ic_add.png const Hash256(0x3CCE7450334675E2, 0xE3AABCA20B028993, 0x127BE82FE0EB3DFF, 0x8B027B3BAF052F2F),
// examples/image_list/images/coast.jpg const Hash256(0xDA957FD30C51B8D2, 0x7D74C2C918692DC4, 0xD3C5C99BB00F0D6B, 0x5EBB30395A6EDE82),
// examples/image_list/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png const Hash256(0xB5792CA06F48A431, 0xD4379ABA2160BD5D, 0xE92339FC64C6A0D3, 0x417AA359634CD905),
// TEST ASSETS
// dev/benchmarks/macrobenchmarks/assets/999x1000.png const Hash256(0x553E9C36DFF3E610, 0x6A608BDE822A0019, 0xDE4F1769B6FBDB97, 0xBC3C20E26B839F59),
// dev/bots/test/analyze-test-input/root/packages/foo/serviceaccount.enc const Hash256(0xA8100AE6AA1940D0, 0xB663BB31CD466142, 0xEBBDBD5187131B92, 0xD93818987832EB89),
// dev/automated_tests/icon/test.png const Hash256(0xE214B4A0FEEEC6FA, 0x8E7AA8CC9BFBEC40, 0xBCDAC2F2DEBC950F, 0x75AF8EBF02BCE459),
// dev/integration_tests/android_splash_screens/splash_screen_kitchen_sink/android/app/src/main/res/drawable-land-xxhdpi/flutter_splash_screen.png // dev/integration_tests/android_splash_screens/splash_screen_kitchen_sink/android/app/src/main/res/mipmap-land-xxhdpi/flutter_splash_screen.png const Hash256(0x2D4F8D7A3DFEF9D3, 0xA0C66938E169AB58, 0x8C6BBBBD1973E34E, 0x03C428416D010182),
// dev/integration_tests/android_splash_screens/splash_screen_kitchen_sink/android/app/src/main/res/drawable-xxhdpi/flutter_splash_screen.png // dev/integration_tests/android_splash_screens/splash_screen_kitchen_sink/android/app/src/main/res/mipmap-xxhdpi/flutter_splash_screen.png const Hash256(0xCD46C01BAFA3B243, 0xA6AA1645EEDDE481, 0x143AC8ABAB1A0996, 0x22CAA9D41F74649A),
// dev/integration_tests/flutter_driver_screenshot_test/assets/red_square.png const Hash256(0x40054377E1E084F4, 0x4F4410CE8F44C210, 0xABA945DFC55ED0EF, 0x23BDF9469E32F8D3),
// dev/integration_tests/flutter_driver_screenshot_test/test_driver/goldens/red_square_image/iPhone7,2.png const Hash256(0x7F9D27C7BC418284, 0x01214E21CA886B2F, 0x40D9DA2B31AE7754, 0x71D68375F9C8A824),
// examples/flutter_view/assets/flutter-mark-square-64.png // examples/platform_view/assets/flutter-mark-square-64.png const Hash256(0xF416B0D8AC552EC8, 0x819D1F492D1AB5E6, 0xD4F20CF45DB47C22, 0x7BB431FEFB5B67B2),
// packages/flutter_tools/test/data/intellij/plugins/Dart/lib/Dart.jar const Hash256(0x576E489D788A13DB, 0xBF40E4A39A3DAB37, 0x15CCF0002032E79C, 0xD260C69B29E06646),
// packages/flutter_tools/test/data/intellij/plugins/flutter-intellij.jar const Hash256(0x4C67221E25626CB2, 0x3F94E1F49D34E4CF, 0x3A9787A514924FC5, 0x9EF1E143E5BC5690),
// MISCELLANEOUS
// dev/bots/serviceaccount.enc const Hash256(0x1F19ADB4D80AFE8C, 0xE61899BA776B1A8D, 0xCA398C75F5F7050D, 0xFB0E72D7FBBBA69B),
// dev/docs/favicon.ico const Hash256(0x67368CA1733E933A, 0xCA3BC56EF0695012, 0xE862C371AD4412F0, 0x3EC396039C609965),
// dev/snippets/assets/code_sample.png const Hash256(0xAB2211A47BDA001D, 0x173A52FD9C75EBC7, 0xE158942FFA8243AD, 0x2A148871990D4297),
// dev/snippets/assets/code_snippet.png const Hash256(0xDEC70574DA46DFBB, 0xFA657A771F3E1FBD, 0xB265CFC6B2AA5FE3, 0x93BA4F325D1520BA),
// packages/flutter_tools/static/Ahem.ttf const Hash256(0x63D2ABD0041C3E3B, 0x4B52AD8D382353B5, 0x3C51C6785E76CE56, 0xED9DACAD2D2E31C4),};
Future<void> verifyNoBinaries(String workingDirectory, { Set<Hash256>? legacyBinaries }) async { // Please do not add anything to the _legacyBinaries set above. // We have a policy of not checking in binaries into this repository. // If you are adding/changing template images, use the flutter_template_images // package and a .img.tmpl placeholder instead. // If you have other binaries to add, please consult Hixie for advice. assert( _legacyBinaries .expand<int>((Hash256 hash) => <int>[hash.a, hash.b, hash.c, hash.d]) .reduce((int value, int element) => value ^ element) == 0x606B51C908B40BFA // Please do not modify this line. ); legacyBinaries ??= _legacyBinaries; if (!Platform.isWindows) { // TODO(ianh): Port this to Windows final List<File> files = await _gitFiles(workingDirectory); final List<String> problems = <String>[]; for (final File file in files) { final Uint8List bytes = file.readAsBytesSync(); try { utf8.decode(bytes); } on FormatException catch (error) { final Digest digest = sha256.convert(bytes); if (!legacyBinaries.contains(Hash256.fromDigest(digest))) { problems.add('${file.path}:${error.offset}: file is not valid UTF-8'); } } } if (problems.isNotEmpty) { foundError(<String>[ ...problems, 'All files in this repository must be UTF-8. In particular, images and other binaries', 'must not be checked into this repository. This is because we are very sensitive to the', 'size of the repository as it is distributed to all our developers. If you have a binary', 'to which you need access, you should consider how to fetch it from another repository;', 'for example, the "assets-for-api-docs" repository is used for images in API docs.', 'To add assets to flutter_tools templates, see the instructions in the wiki:', 'https://github.com/flutter/flutter/wiki/Managing-template-image-assets', ]); } }}
// UTILITY FUNCTIONS
bool _listEquals<T>(List<T> a, List<T> b) { if (a.length != b.length) { return false; } for (int index = 0; index < a.length; index += 1) { if (a[index] != b[index]) { return false; } } return true;}
Future<List<File>> _gitFiles(String workingDirectory, {bool runSilently = true}) async { final EvalResult evalResult = await _evalCommand( 'git', <String>['ls-files', '-z'], workingDirectory: workingDirectory, runSilently: runSilently, ); if (evalResult.exitCode != 0) { foundError(<String>[ 'git ls-files failed with exit code ${evalResult.exitCode}', '${bold}stdout:$reset', evalResult.stdout, '${bold}stderr:$reset', evalResult.stderr, ]); } final List<String> filenames = evalResult .stdout .split('\x00'); assert(filenames.last.isEmpty); // git ls-files gives a trailing blank 0x00 filenames.removeLast(); return filenames .map<File>((String filename) => File(path.join(workingDirectory, filename))) .toList();}
Stream<File> _allFiles(String workingDirectory, String? extension, { required int minimumMatches }) async* { final Set<String> gitFileNamesSet = <String>{}; gitFileNamesSet.addAll((await _gitFiles(workingDirectory)).map((File f) => path.canonicalize(f.absolute.path)));
assert(extension == null || !extension.startsWith('.'), 'Extension argument should not start with a period.'); final Set<FileSystemEntity> pending = <FileSystemEntity>{ Directory(workingDirectory) }; int matches = 0; while (pending.isNotEmpty) { final FileSystemEntity entity = pending.first; pending.remove(entity); if (path.extension(entity.path) == '.tmpl') { continue; } if (entity is File) { if (!gitFileNamesSet.contains(path.canonicalize(entity.absolute.path))) { continue; } if (_isGeneratedPluginRegistrant(entity)) { continue; } if (path.basename(entity.path) == 'flutter_export_environment.sh') { continue; } if (path.basename(entity.path) == 'gradlew.bat') { continue; } if (path.basename(entity.path) == '.DS_Store') { continue; } if (extension == null || path.extension(entity.path) == '.$extension') { matches += 1; yield entity; } } else if (entity is Directory) { if (File(path.join(entity.path, '.dartignore')).existsSync()) { continue; } if (path.basename(entity.path) == '.git') { continue; } if (path.basename(entity.path) == '.idea') { continue; } if (path.basename(entity.path) == '.gradle') { continue; } if (path.basename(entity.path) == '.dart_tool') { continue; } if (path.basename(entity.path) == '.idea') { continue; } if (path.basename(entity.path) == 'build') { continue; } pending.addAll(entity.listSync()); } } assert(matches >= minimumMatches, 'Expected to find at least $minimumMatches files with extension ".$extension" in "$workingDirectory", but only found $matches.');}
class EvalResult { EvalResult({ required this.stdout, required this.stderr, this.exitCode = 0, });
final String stdout; final String stderr; final int exitCode;}
// TODO(ianh): Refactor this to reuse the code in run_command.dartFuture<EvalResult> _evalCommand(String executable, List<String> arguments, { required String workingDirectory, Map<String, String>? environment, bool allowNonZeroExit = false, bool runSilently = false,}) async { final String commandDescription = '${path.relative(executable, from: workingDirectory)} ${arguments.join(' ')}'; final String relativeWorkingDir = path.relative(workingDirectory);
if (!runSilently) { print('RUNNING: cd $cyan$relativeWorkingDir$reset; $green$commandDescription$reset'); }
final Stopwatch time = Stopwatch()..start(); final Process process = await Process.start(executable, arguments, workingDirectory: workingDirectory, environment: environment, );
final Future<List<List<int>>> savedStdout = process.stdout.toList(); final Future<List<List<int>>> savedStderr = process.stderr.toList(); final int exitCode = await process.exitCode; final EvalResult result = EvalResult( stdout: utf8.decode((await savedStdout).expand<int>((List<int> ints) => ints).toList()), stderr: utf8.decode((await savedStderr).expand<int>((List<int> ints) => ints).toList()), exitCode: exitCode, );
if (!runSilently) { print('ELAPSED TIME: $bold${prettyPrintDuration(time.elapsed)}$reset for $commandDescription in $relativeWorkingDir'); }
if (exitCode != 0 && !allowNonZeroExit) { foundError(<String>[ result.stderr, '${bold}ERROR:$red Last command exited with $exitCode.$reset', '${bold}Command:$red $commandDescription$reset', '${bold}Relative working directory:$red $relativeWorkingDir$reset', ]); }
return result;}
Future<void> _checkConsumerDependencies() async { const List<String> kCorePackages = <String>[ 'flutter', 'flutter_test', 'flutter_driver', 'flutter_localizations', 'integration_test', 'fuchsia_remote_debug_protocol', ]; final Set<String> dependencies = <String>{};
// Parse the output of pub deps --json to determine all of the // current packages used by the core set of flutter packages. for (final String package in kCorePackages) { final ProcessResult result = await Process.run(flutter, <String>[ 'pub', 'deps', '--json', '--directory=${path.join(flutterRoot, 'packages', package)}', ]); if (result.exitCode != 0) { foundError(<String>[ result.stdout.toString(), result.stderr.toString(), ]); return; } final Map<String, Object?> rawJson = json.decode(result.stdout as String) as Map<String, Object?>; final Map<String, Map<String, Object?>> dependencyTree = <String, Map<String, Object?>>{ for (final Map<String, Object?> package in (rawJson['packages']! as List<Object?>).cast<Map<String, Object?>>()) package['name']! as String : package, }; final List<Map<String, Object?>> workset = <Map<String, Object?>>[]; workset.add(dependencyTree[package]!);
while (workset.isNotEmpty) { final Map<String, Object?> currentPackage = workset.removeLast(); if (currentPackage['kind'] == 'dev') { continue; } dependencies.add(currentPackage['name']! as String);
final List<String> currentDependencies = (currentPackage['dependencies']! as List<Object?>).cast<String>(); for (final String dependency in currentDependencies) { // Don't add dependencies we've already seen or we will get stuck // forever if there are any circular references. // TODO(dantup): Consider failing gracefully with the names of the // packages once the cycle between test_api and matcher is resolved. // https://github.com/dart-lang/test/issues/1979 if (!dependencies.contains(dependency)) { workset.add(dependencyTree[dependency]!); } } } }
final Set<String> removed = kCorePackageAllowList.difference(dependencies); final Set<String> added = dependencies.difference(kCorePackageAllowList);
String plural(int n, String s, String p) => n == 1 ? s : p;
if (added.isNotEmpty) { foundError(<String>[ 'The transitive closure of package dependencies contains ${plural(added.length, "a non-allowlisted package", "non-allowlisted packages")}:', ' ${added.join(', ')}', 'We strongly desire to keep the number of dependencies to a minimum and', 'therefore would much prefer not to add new dependencies.', 'See dev/bots/allowlist.dart for instructions on how to update the package', 'allowlist if you nonetheless believe this is a necessary addition.', ]); }
if (removed.isNotEmpty) { foundError(<String>[ 'Excellent news! ${plural(removed.length, "A package dependency has been removed!", "Multiple package dependencies have been removed!")}', ' ${removed.join(', ')}', 'To make sure we do not accidentally add ${plural(removed.length, "this dependency", "these dependencies")} back in the future,', 'please remove ${plural(removed.length, "this", "these")} packages from the allow-list in dev/bots/allowlist.dart.', 'Thanks!', ]); }}
const String _kDebugOnlyAnnotation = '@_debugOnly';final RegExp _nullInitializedField = RegExp(r'kDebugMode \? [\w<> ,{}()]+ : null;');
Future<void> verifyNullInitializedDebugExpensiveFields(String workingDirectory, {int minimumMatches = 400}) async { final String flutterLib = path.join(workingDirectory, 'packages', 'flutter', 'lib'); final List<File> files = await _allFiles(flutterLib, 'dart', minimumMatches: minimumMatches) .toList(); final List<String> errors = <String>[]; for (final File file in files) { final List<String> lines = file.readAsLinesSync(); for (int index = 0; index < lines.length; index += 1) { final String line = lines[index]; if (!line.contains(_kDebugOnlyAnnotation)) { continue; } final String nextLine = lines[index + 1]; if (_nullInitializedField.firstMatch(nextLine) == null) { errors.add('${file.path}:$index'); } } } if (errors.isNotEmpty) { foundError(<String>[ '${bold}ERROR: ${red}fields annotated with @_debugOnly must null initialize.$reset', 'to ensure both the field and initializer are removed from profile/release mode.', 'These fields should be written as:\n', 'field = kDebugMode ? <DebugValue> : null;\n', 'Errors were found in the following files:', ...errors, ]); }}
final RegExp tabooPattern = RegExp(r'^ *///.*\b(simply|note:|note that)\b', caseSensitive: false);
Future<void> verifyTabooDocumentation(String workingDirectory, { int minimumMatches = 100 }) async { final List<String> errors = <String>[]; await for (final File file in _allFiles(workingDirectory, 'dart', minimumMatches: minimumMatches)) { final List<String> lines = file.readAsLinesSync(); for (int index = 0; index < lines.length; index += 1) { final String line = lines[index]; final Match? match = tabooPattern.firstMatch(line); if (match != null) { errors.add('${file.path}:${index + 1}: Found use of the taboo word "${match.group(1)}" in documentation string.'); } } } if (errors.isNotEmpty) { foundError(<String>[ '${bold}Avoid the word "simply" in documentation. See https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#use-the-passive-voice-recommend-do-not-require-never-say-things-are-simple for details.$reset', '${bold}In many cases these words can be omitted without loss of generality; in other cases it may require a bit of rewording to avoid implying that the task is simple.$reset', '${bold}Similarly, avoid using "note:" or the phrase "note that". See https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#avoid-empty-prose for details.$reset', ...errors, ]); }}
const List<String> _kIgnoreList = <String>[ 'Runner.rc.tmpl', 'flutter_window.cpp',];final String _kIntegrationTestsRelativePath = path.join('dev', 'integration_tests');final String _kTemplateRelativePath = path.join('packages', 'flutter_tools', 'templates', 'app_shared', 'windows.tmpl', 'runner');final String _kWindowsRunnerSubPath = path.join('windows', 'runner');const String _kProjectNameKey = '{{projectName}}';const String _kTmplExt = '.tmpl';final String _kLicensePath = path.join('dev', 'conductor', 'core', 'lib', 'src', 'proto', 'license_header.txt');
String _getFlutterLicense(String flutterRoot) { return '${File(path.join(flutterRoot, _kLicensePath)).readAsLinesSync().join("\n")}\n\n';}
String _removeLicenseIfPresent(String fileContents, String license) { if (fileContents.startsWith(license)) { return fileContents.substring(license.length); } return fileContents;}
Future<void> verifyIntegrationTestTemplateFiles(String flutterRoot) async { final List<String> errors = <String>[]; final String license = _getFlutterLicense(flutterRoot); final String integrationTestsPath = path.join(flutterRoot, _kIntegrationTestsRelativePath); final String templatePath = path.join(flutterRoot, _kTemplateRelativePath); final Iterable<Directory>subDirs = Directory(integrationTestsPath).listSync().toList().whereType<Directory>(); for (final Directory testPath in subDirs) { final String projectName = path.basename(testPath.path); final String runnerPath = path.join(testPath.path, _kWindowsRunnerSubPath); final Directory runner = Directory(runnerPath); if (!runner.existsSync()) { continue; } final Iterable<File> files = Directory(templatePath).listSync().toList().whereType<File>(); for (final File templateFile in files) { final String fileName = path.basename(templateFile.path); if (_kIgnoreList.contains(fileName)) { continue; } String templateFileContents = templateFile.readAsLinesSync().join('\n'); String appFilePath = path.join(runnerPath, fileName); if (fileName.endsWith(_kTmplExt)) { appFilePath = appFilePath.substring(0, appFilePath.length - _kTmplExt.length); // Remove '.tmpl' from app file path templateFileContents = templateFileContents.replaceAll(_kProjectNameKey, projectName); // Substitute template project name } String appFileContents = File(appFilePath).readAsLinesSync().join('\n'); appFileContents = _removeLicenseIfPresent(appFileContents, license); if (appFileContents != templateFileContents) { int indexOfDifference; for (indexOfDifference = 0; indexOfDifference < appFileContents.length; indexOfDifference++) { if (indexOfDifference >= templateFileContents.length || templateFileContents.codeUnitAt(indexOfDifference) != appFileContents.codeUnitAt(indexOfDifference)) { break; } } final String error = '''Error: file $fileName mismatched for integration test $testPathVerify the integration test has been migrated to the latest app template.=====$appFilePath======$appFileContents=====${templateFile.path}======$templateFileContents==========Diff at character #$indexOfDifference '''; errors.add(error); } } } if (errors.isNotEmpty) { foundError(errors); }}
Future<CommandResult> _runFlutterAnalyze(String workingDirectory, { List<String> options = const <String>[], String? failureMessage,}) async { return runCommand( flutter, <String>['analyze', ...options], workingDirectory: workingDirectory, failureMessage: failureMessage, );}
// These files legitimately require executable permissionsconst Set<String> kExecutableAllowlist = <String>{ 'bin/dart', 'bin/flutter', 'bin/internal/update_dart_sdk.sh',
'dev/bots/accept_android_sdk_licenses.sh', 'dev/bots/codelabs_build_test.sh', 'dev/bots/docs.sh',
'dev/conductor/bin/conductor', 'dev/conductor/bin/packages_autoroller', 'dev/conductor/core/lib/src/proto/compile_proto.sh',
'dev/customer_testing/ci.sh',
'dev/integration_tests/flutter_gallery/tool/run_instrumentation_test.sh',
'dev/integration_tests/ios_add2app_life_cycle/build_and_test.sh',
'dev/integration_tests/deferred_components_test/download_assets.sh', 'dev/integration_tests/deferred_components_test/run_release_test.sh',
'dev/tools/gen_keycodes/bin/gen_keycodes', 'dev/tools/repackage_gradle_wrapper.sh',
'packages/flutter_tools/bin/macos_assemble.sh', 'packages/flutter_tools/bin/tool_backend.sh', 'packages/flutter_tools/bin/xcode_backend.sh',};
Future<void> _checkForNewExecutables() async { // 0b001001001 const int executableBitMask = 0x49; final List<File> files = await _gitFiles(flutterRoot); final List<String> errors = <String>[]; for (final File file in files) { final String relativePath = path.relative( file.path, from: flutterRoot, ); final FileStat stat = file.statSync(); final bool isExecutable = stat.mode & executableBitMask != 0x0; if (isExecutable && !kExecutableAllowlist.contains(relativePath)) { errors.add('$relativePath is executable: ${(stat.mode & 0x1FF).toRadixString(2)}'); } } if (errors.isNotEmpty) { throw Exception( '${errors.join('\n')}\n' 'found ${errors.length} unexpected executable file' '${errors.length == 1 ? '' : 's'}! If this was intended, you ' 'must add this file to kExecutableAllowlist in dev/bots/analyze.dart', ); }}
final RegExp _importPattern = RegExp(r'''^\s*import (['"])package:flutter/([^.]+)\.dart\1''');final RegExp _importMetaPattern = RegExp(r'''^\s*import (['"])package:meta/meta\.dart\1''');
Future<Set<String>> _findFlutterDependencies(String srcPath, List<String> errors, { bool checkForMeta = false }) async { return _allFiles(srcPath, 'dart', minimumMatches: 1) .map<Set<String>>((File file) { final Set<String> result = <String>{}; for (final String line in file.readAsLinesSync()) { Match? match = _importPattern.firstMatch(line); if (match != null) { result.add(match.group(2)!); } if (checkForMeta) { match = _importMetaPattern.firstMatch(line); if (match != null) { errors.add( '${file.path}\nThis package imports the ${yellow}meta$reset package.\n' 'You should instead import the "foundation.dart" library.' ); } } } return result; }) .reduce((Set<String>? value, Set<String> element) { value ??= <String>{}; value.addAll(element); return value; });}
List<T>? _deepSearch<T>(Map<T, Set<T>> map, T start, [ Set<T>? seen ]) { if (map[start] == null) { return null; // We catch these separately. }
for (final T key in map[start]!) { if (key == start) { continue; // we catch these separately } if (seen != null && seen.contains(key)) { return <T>[start, key]; } final List<T>? result = _deepSearch<T>( map, key, <T>{ if (seen == null) start else ...seen, key, }, ); if (result != null) { result.insert(0, start); // Only report the shortest chains. // For example a->b->a, rather than c->a->b->a. // Since we visit every node, we know the shortest chains are those // that start and end on the loop. if (result.first == result.last) { return result; } } } return null;}
bool _isGeneratedPluginRegistrant(File file) { final String filename = path.basename(file.path); return !file.path.contains('.pub-cache') && (filename == 'GeneratedPluginRegistrant.java' || filename == 'GeneratedPluginRegistrant.swift' || filename == 'GeneratedPluginRegistrant.h' || filename == 'GeneratedPluginRegistrant.m' || filename == 'generated_plugin_registrant.dart' || filename == 'generated_plugin_registrant.h' || filename == 'generated_plugin_registrant.cc');}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199// Copyright 2014 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.
// To run this, from the root of the Flutter repository:// bin/cache/dart-sdk/bin/dart --enable-asserts dev/bots/analyze_snippet_code.dart
// In general, please prefer using full linked examples in API docs.//// For documentation on creating sample code, see ../../examples/api/README.md// See also our style guide's discussion on documentation and sample code:// https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#documentation-dartdocs-javadocs-etc//// This tool is used to analyze smaller snippets of code in the API docs.// Such snippets are wrapped in ```dart ... ``` blocks, which may themselves// be wrapped in {@tool snippet} ... {@end-tool} blocks to set them apart// in the rendered output.//// Such snippets://// * If they start with `import` are treated as full application samples; avoid// doing this in general, it's better to use samples as described above. (One// exception might be in dart:ui where the sample code would end up in a// different repository which would be awkward.)//// * If they start with a comment that says `// continuing from previous example...`,// they automatically import the previous test's file.//// * If they start with a comment that says `// (e.g. in a stateful widget)`,// are analyzed after being inserted into a class that inherits from State.//// * If they start with what looks like a getter, function declaration, or// other top-level keyword (`class`, `typedef`, etc), or if they start with// the keyword `final`, they are analyzed directly.//// * If they end with a trailing semicolon or have a line starting with a// statement keyword like `while` or `try`, are analyzed after being inserted// into a function body.//// * If they start with the word `static`, are placed in a class body before// analysis.//// * Otherwise, are used as an initializer for a global variable for the// purposes of analysis; in this case, any leading label (`foo:`)// and any trailing comma are removed.//// In particular, these rules imply that starting an example with `const` means// it is an _expression_, not a top-level declaration. This is because mostly// `const` indicates a Widget.//// A line that contains just a comment with an ellipsis (`// ...`) adds an ignore// for the `non_abstract_class_inherits_abstract_member` error for the snippet.// This is useful when you're writing an example that extends an abstract class// with lots of members, but you only care to show one.//// At the top of a file you can say `// Examples can assume:` and then list some// commented-out declarations that will be included in the analysis for snippets// in that file. This section may also contain explicit import statements.//// For files without an `// Examples can assume:` section or if that section// contains no explicit imports, the snippets will implicitly import all the// main Flutter packages (including material and flutter_test), as well as most// core Dart packages with the usual prefixes.//// When invoked without an additional path argument, the script will analyze// the code snippets for all packages in the "packages" subdirectory that do// not specify "nodoc: true" in their pubspec.yaml (i.e. all packages for which// we publish docs will have their doc code snippets analyzed).
import 'dart:async';import 'dart:convert';import 'dart:io';
import 'package:args/args.dart';import 'package:meta/meta.dart';import 'package:path/path.dart' as path;import 'package:watcher/watcher.dart';
final String _flutterRoot = path.dirname(path.dirname(path.dirname(path.fromUri(Platform.script))));final String _packageFlutter = path.join(_flutterRoot, 'packages', 'flutter', 'lib');final String _defaultDartUiLocation = path.join(_flutterRoot, 'bin', 'cache', 'pkg', 'sky_engine', 'lib', 'ui');final String _flutter = path.join(_flutterRoot, 'bin', Platform.isWindows ? 'flutter.bat' : 'flutter');
Future<void> main(List<String> arguments) async { bool asserts = false; assert(() { asserts = true; return true; }()); if (!asserts) { print('You must run this script with asserts enabled.'); exit(1); } int width; try { width = stdout.terminalColumns; } on StdoutException { width = 80; } final ArgParser argParser = ArgParser(usageLineLength: width); argParser.addOption( 'temp', valueHelp: 'path', help: 'A location where temporary files may be written. Defaults to a ' 'directory in the system temp folder. If specified, will not be ' 'automatically removed at the end of execution.', ); argParser.addFlag( 'verbose', negatable: false, help: 'Print verbose output for the analysis process.', ); argParser.addOption( 'dart-ui-location', defaultsTo: _defaultDartUiLocation, valueHelp: 'path', help: 'A location where the dart:ui dart files are to be found. Defaults to ' 'the sky_engine directory installed in this flutter repo. This ' 'is typically the engine/src/flutter/lib/ui directory in an engine dev setup. ' 'Implies --include-dart-ui.', ); argParser.addFlag( 'include-dart-ui', defaultsTo: true, help: 'Includes the dart:ui code supplied by the engine in the analysis.', ); argParser.addFlag( 'help', negatable: false, help: 'Print help for this command.', ); argParser.addOption( 'interactive', abbr: 'i', valueHelp: 'file', help: 'Analyzes the snippet code in a specified file interactively.', );
final ArgResults parsedArguments; try { parsedArguments = argParser.parse(arguments); } on FormatException catch (e) { print(e.message); print('dart --enable-asserts analyze_snippet_code.dart [options]'); print(argParser.usage); exit(1); }
if (parsedArguments['help'] as bool) { print('dart --enable-asserts analyze_snippet_code.dart [options]'); print(argParser.usage); exit(0); }
final List<Directory> flutterPackages; if (parsedArguments.rest.length == 1) { // Used for testing. flutterPackages = <Directory>[Directory(parsedArguments.rest.single)]; } else { // By default analyze snippets in all packages in the packages subdirectory // that do not specify "nodoc: true" in their pubspec.yaml. flutterPackages = <Directory>[]; final String packagesRoot = path.join(_flutterRoot, 'packages'); for (final FileSystemEntity entity in Directory(packagesRoot).listSync()) { if (entity is! Directory) { continue; } final File pubspec = File(path.join(entity.path, 'pubspec.yaml')); if (!pubspec.existsSync()) { throw StateError("Unexpected package '${entity.path}' found in packages directory"); } if (!pubspec.readAsStringSync().contains('nodoc: true')) { flutterPackages.add(Directory(path.join(entity.path, 'lib'))); } } assert(flutterPackages.length >= 4); }
final bool includeDartUi = parsedArguments.wasParsed('dart-ui-location') || parsedArguments['include-dart-ui'] as bool; late Directory dartUiLocation; if (((parsedArguments['dart-ui-location'] ?? '') as String).isNotEmpty) { dartUiLocation = Directory( path.absolute(parsedArguments['dart-ui-location'] as String)); } else { dartUiLocation = Directory(_defaultDartUiLocation); } if (!dartUiLocation.existsSync()) { stderr.writeln('Unable to find dart:ui directory ${dartUiLocation.path}'); exit(1); }
if (parsedArguments['interactive'] != null) { await _runInteractive( flutterPackages: flutterPackages, tempDirectory: parsedArguments['temp'] as String?, filePath: parsedArguments['interactive'] as String, dartUiLocation: includeDartUi ? dartUiLocation : null, ); } else { if (await _SnippetChecker( flutterPackages, tempDirectory: parsedArguments['temp'] as String?, verbose: parsedArguments['verbose'] as bool, dartUiLocation: includeDartUi ? dartUiLocation : null, ).checkSnippets()) { stderr.writeln('See the documentation at the top of dev/bots/analyze_snippet_code.dart for details.'); exit(1); } }}
/// A class to represent a line of input code.@immutableclass _Line { const _Line({this.code = '', this.line = -1, this.indent = 0}) : generated = false; const _Line.generated({this.code = ''}) : line = -1, indent = 0, generated = true;
final int line; final int indent; final String code; final bool generated;
String asLocation(String filename, int column) { return '$filename:$line:${column + indent}'; }
@override String toString() => code;
@override bool operator ==(Object other) { if (other.runtimeType != runtimeType) { return false; } return other is _Line && other.line == line && other.indent == indent && other.code == code && other.generated == generated; }
@override int get hashCode => Object.hash(line, indent, code, generated);}
@immutableclass _ErrorBase implements Comparable<Object> { const _ErrorBase({this.file, this.line, this.column}); final String? file; final int? line; final int? column;
@override int compareTo(Object other) { if (other is _ErrorBase) { if (other.file != file) { if (other.file == null) { return -1; } if (file == null) { return 1; } return file!.compareTo(other.file!); } if (other.line != line) { if (other.line == null) { return -1; } if (line == null) { return 1; } return line!.compareTo(other.line!); } if (other.column != column) { if (other.column == null) { return -1; } if (column == null) { return 1; } return column!.compareTo(other.column!); } } return toString().compareTo(other.toString()); }}
@immutableclass _SnippetCheckerException extends _ErrorBase implements Exception { const _SnippetCheckerException(this.message, {super.file, super.line}); final String message;
@override String toString() { if (file != null || line != null) { final String fileStr = file == null ? '' : '$file:'; final String lineStr = line == null ? '' : '$line:'; return '$fileStr$lineStr $message'; } else { return message; } }
@override bool operator ==(Object other) { if (other.runtimeType != runtimeType) { return false; } return other is _SnippetCheckerException && other.message == message && other.file == file && other.line == line; }
@override int get hashCode => Object.hash(message, file, line);}
/// A class representing an analysis error along with the context of the error.////// Changes how it converts to a string based on the source of the error.@immutableclass _AnalysisError extends _ErrorBase { const _AnalysisError( String file, int line, int column, this.message, this.errorCode, this.source, ) : super(file: file, line: line, column: column);
final String message; final String errorCode; final _Line source;
@override String toString() { return '${source.asLocation(file!, column!)}: $message ($errorCode)'; }
@override bool operator ==(Object other) { if (other.runtimeType != runtimeType) { return false; } return other is _AnalysisError && other.file == file && other.line == line && other.column == column && other.message == message && other.errorCode == errorCode && other.source == source; }
@override int get hashCode => Object.hash(file, line, column, message, errorCode, source);}
/// Checks code snippets for analysis errors.////// Extracts dartdoc content from flutter package source code, identifies code/// sections, and writes them to a temporary directory, where 'flutter analyze'/// is used to analyze the sources for problems. If problems are found, the/// error output from the analyzer is parsed for details, and the problem/// locations are translated back to the source location.class _SnippetChecker { /// Creates a [_SnippetChecker]. /// /// The positional argument is the path to the package directory for the /// flutter package within the Flutter root dir. /// /// The optional `tempDirectory` argument supplies the location for the /// temporary files to be written and analyzed. If not supplied, it defaults /// to a system generated temp directory. /// /// The optional `verbose` argument indicates whether or not status output /// should be emitted while doing the check. /// /// The optional `dartUiLocation` argument indicates the location of the /// `dart:ui` code to be analyzed along with the framework code. If not /// supplied, the default location of the `dart:ui` code in the Flutter /// repository is used (i.e. "<flutter repo>/bin/cache/pkg/sky_engine/lib/ui"). _SnippetChecker( this._flutterPackages, { String? tempDirectory, this.verbose = false, Directory? dartUiLocation, }) : _tempDirectory = _createTempDirectory(tempDirectory), _keepTmp = tempDirectory != null, _dartUiLocation = dartUiLocation;
/// The prefix of each comment line static const String _dartDocPrefix = '///';
/// The prefix of each comment line with a space appended. static const String _dartDocPrefixWithSpace = '$_dartDocPrefix ';
/// A RegExp that matches the beginning of a dartdoc snippet. static final RegExp _dartDocSnippetBeginRegex = RegExp(r'{@tool ([^ }]+)(?:| ([^}]*))}');
/// A RegExp that matches the end of a dartdoc snippet. static final RegExp _dartDocSnippetEndRegex = RegExp(r'{@end-tool}');
/// A RegExp that matches the start of a code block within dartdoc. static final RegExp _codeBlockStartRegex = RegExp(r'^ */// *```dart$');
/// A RegExp that matches the start of a code block within a regular comment. /// Such blocks are not analyzed. They can be used to give sample code for /// internal (private) APIs where visibility would make analyzing the sample /// code problematic. static final RegExp _uncheckedCodeBlockStartRegex = RegExp(r'^ *// *```dart$');
/// A RegExp that matches the end of a code block within dartdoc. static final RegExp _codeBlockEndRegex = RegExp(r'^ */// *``` *$');
/// A RegExp that matches a line starting with a comment or annotation static final RegExp _nonCodeRegExp = RegExp(r'^ *(//|@)');
/// A RegExp that matches things that look like a function declaration. static final RegExp _maybeFunctionDeclarationRegExp = RegExp(r'^([A-Z][A-Za-z0-9_<>, ?]*|int|double|num|bool|void)\?? (_?[a-z][A-Za-z0-9_<>]*)\(.*');
/// A RegExp that matches things that look like a getter. static final RegExp _maybeGetterDeclarationRegExp = RegExp(r'^([A-Z][A-Za-z0-9_<>?]*|int|double|num|bool)\?? get (_?[a-z][A-Za-z0-9_<>]*) (?:=>|{).*');
/// A RegExp that matches an identifier followed by a colon, potentially with two spaces of indent. static final RegExp _namedArgumentRegExp = RegExp(r'^(?: )?([a-zA-Z0-9_]+): ');
/// A RegExp that matches things that look unambiguously like top-level declarations. static final RegExp _topLevelDeclarationRegExp = RegExp(r'^(abstract|class|mixin|enum|typedef|final|extension) ');
/// A RegExp that matches things that look unambiguously like statements. static final RegExp _statementRegExp = RegExp(r'^(if|while|for|try) ');
/// A RegExp that matches things that look unambiguously like declarations that must be in a class. static final RegExp _classDeclarationRegExp = RegExp(r'^(static) ');
/// A RegExp that matches a line that ends with a comma (and maybe a comment) static final RegExp _trailingCommaRegExp = RegExp(r'^(.*),(| *//.*)$');
/// A RegExp that matches a line that ends with a semicolon (and maybe a comment) static final RegExp _trailingSemicolonRegExp = RegExp(r'^(.*);(| *//.*)$');
/// A RegExp that matches a line that ends with a closing brace (and maybe a comment) static final RegExp _trailingCloseBraceRegExp = RegExp(r'^(.*)}(| *//.*)$');
/// A RegExp that matches a line that only contains a commented-out ellipsis /// (and maybe whitespace). Has three groups: before, ellipsis, after. static final RegExp _ellipsisRegExp = RegExp(r'^( *)(// \.\.\.)( *)$');
/// Whether or not to print verbose output. final bool verbose;
/// Whether or not to keep the temp directory around after running. /// /// Defaults to false. final bool _keepTmp;
/// The temporary directory where all output is written. This will be deleted /// automatically if there are no errors unless _keepTmp is true. final Directory _tempDirectory;
/// The package directories within the flutter root dir that will be checked. final List<Directory> _flutterPackages;
/// The directory for the dart:ui code to be analyzed with the flutter code. /// /// If this is null, then no dart:ui code is included in the analysis. It /// defaults to the location inside of the flutter bin/cache directory that /// contains the dart:ui code supplied by the engine. final Directory? _dartUiLocation;
static List<File> _listDartFiles(Directory directory, {bool recursive = false}) { return directory.listSync(recursive: recursive, followLinks: false).whereType<File>().where((File file) => path.extension(file.path) == '.dart').toList(); }
static const List<String> ignoresDirectives = <String>[ '// ignore_for_file: directives_ordering', '// ignore_for_file: duplicate_ignore', '// ignore_for_file: no_leading_underscores_for_local_identifiers', '// ignore_for_file: prefer_final_locals', '// ignore_for_file: unnecessary_import', '// ignore_for_file: unreachable_from_main', '// ignore_for_file: unused_element', '// ignore_for_file: unused_element_parameter', '// ignore_for_file: unused_local_variable', ];
/// Computes the headers needed for each snippet file. List<_Line> get headersWithoutImports { return _headersWithoutImports ??= ignoresDirectives.map<_Line>((String code) => _Line.generated(code: code)).toList(); } List<_Line>? _headersWithoutImports;
/// Computes the headers needed for each snippet file. List<_Line> get headersWithImports { return _headersWithImports ??= <String>[ ...ignoresDirectives, '// ignore_for_file: unused_import', "import 'dart:async';", "import 'dart:convert';", "import 'dart:io';", "import 'dart:math' as math;", "import 'dart:typed_data';", "import 'dart:ui' as ui;", "import 'package:flutter_test/flutter_test.dart';", for (final File file in _listDartFiles(Directory(_packageFlutter))) "import 'package:flutter/${path.basename(file.path)}';", ].map<_Line>((String code) => _Line.generated(code: code)).toList(); } List<_Line>? _headersWithImports;
/// Checks all the snippets in the Dart files in [_flutterPackage] for errors. /// Returns true if any errors are found, false otherwise. Future<bool> checkSnippets() async { final Map<String, _SnippetFile> snippets = <String, _SnippetFile>{}; if (_dartUiLocation != null && !_dartUiLocation.existsSync()) { stderr.writeln('Unable to analyze engine dart snippets at ${_dartUiLocation.path}.'); } final List<File> filesToAnalyze = <File>[ for (final Directory flutterPackage in _flutterPackages) ..._listDartFiles(flutterPackage, recursive: true), if (_dartUiLocation != null && _dartUiLocation.existsSync()) ..._listDartFiles(_dartUiLocation, recursive: true), ]; final Set<Object> errors = <Object>{}; errors.addAll(await _extractSnippets(filesToAnalyze, snippetMap: snippets)); errors.addAll(_analyze(snippets)); (errors.toList()..sort()).map(_stringify).forEach(stderr.writeln); stderr.writeln('Found ${errors.length} snippet code errors.'); cleanupTempDirectory(); return errors.isNotEmpty; }
static Directory _createTempDirectory(String? tempArg) { if (tempArg != null) { final Directory tempDirectory = Directory(path.join(Directory.systemTemp.absolute.path, path.basename(tempArg))); if (path.basename(tempArg) != tempArg) { stderr.writeln('Supplied temporary directory name should be a name, not a path. Using ${tempDirectory.absolute.path} instead.'); } print('Leaving temporary output in ${tempDirectory.absolute.path}.'); // Make sure that any directory left around from a previous run is cleared out. if (tempDirectory.existsSync()) { tempDirectory.deleteSync(recursive: true); } tempDirectory.createSync(); return tempDirectory; } return Directory.systemTemp.createTempSync('flutter_analyze_snippet_code.'); }
void recreateTempDirectory() { _tempDirectory.deleteSync(recursive: true); _tempDirectory.createSync(); }
void cleanupTempDirectory() { if (_keepTmp) { print('Leaving temporary directory ${_tempDirectory.path} around for your perusal.'); } else { try { _tempDirectory.deleteSync(recursive: true); } on FileSystemException catch (e) { stderr.writeln('Failed to delete ${_tempDirectory.path}: $e'); } } }
/// Creates a name for the snippets tool to use for the snippet ID from a /// filename and starting line number. String _createNameFromSource(String prefix, String filename, int start) { String snippetId = path.split(filename).join('.'); snippetId = path.basenameWithoutExtension(snippetId); snippetId = '$prefix.$snippetId.$start'; return snippetId; }
/// Extracts the snippets from the Dart files in [files], writes them /// to disk, and adds them to the [snippetMap]. Future<List<Object>> _extractSnippets( List<File> files, { required Map<String, _SnippetFile> snippetMap, }) async { final List<Object> errors = <Object>[]; _SnippetFile? lastExample; for (final File file in files) { try { final String relativeFilePath = path.relative(file.path, from: _flutterRoot); final List<String> fileLines = file.readAsLinesSync(); final List<_Line> ignorePreambleLinesOnly = <_Line>[]; final List<_Line> preambleLines = <_Line>[]; final List<_Line> customImports = <_Line>[]; bool inExamplesCanAssumePreamble = false; // Whether or not we're in the file-wide preamble section ("Examples can assume"). bool inToolSection = false; // Whether or not we're in a code snippet bool inDartSection = false; // Whether or not we're in a '```dart' segment. bool inOtherBlock = false; // Whether we're in some other '```' segment. int lineNumber = 0; final List<String> block = <String>[]; late _Line startLine; for (final String line in fileLines) { lineNumber += 1; final String trimmedLine = line.trim(); if (inExamplesCanAssumePreamble) { if (line.isEmpty) { // end of preamble inExamplesCanAssumePreamble = false; } else if (!line.startsWith('// ')) { throw _SnippetCheckerException('Unexpected content in snippet code preamble.', file: relativeFilePath, line: lineNumber); } else { final _Line newLine = _Line(line: lineNumber, indent: 3, code: line.substring(3)); if (newLine.code.startsWith('import ')) { customImports.add(newLine); } else { preambleLines.add(newLine); } if (line.startsWith('// // ignore_for_file: ')) { ignorePreambleLinesOnly.add(newLine); } } } else if (trimmedLine.startsWith(_dartDocSnippetEndRegex)) { if (!inToolSection) { throw _SnippetCheckerException('{@tool-end} marker detected without matching {@tool}.', file: relativeFilePath, line: lineNumber); } if (inDartSection) { throw _SnippetCheckerException("Dart section didn't terminate before end of snippet", file: relativeFilePath, line: lineNumber); } inToolSection = false; } else if (inDartSection) { final RegExpMatch? snippetMatch = _dartDocSnippetBeginRegex.firstMatch(trimmedLine); if (snippetMatch != null) { throw _SnippetCheckerException('{@tool} found inside Dart section', file: relativeFilePath, line: lineNumber); } if (trimmedLine.startsWith(_codeBlockEndRegex)) { inDartSection = false; final _SnippetFile snippet = _processBlock(startLine, block, preambleLines, ignorePreambleLinesOnly, relativeFilePath, lastExample, customImports); final String path = _writeSnippetFile(snippet).path; assert(!snippetMap.containsKey(path)); snippetMap[path] = snippet; block.clear(); lastExample = snippet; } else if (trimmedLine == _dartDocPrefix) { block.add(''); } else { final int index = line.indexOf(_dartDocPrefixWithSpace); if (index < 0) { throw _SnippetCheckerException( 'Dart section inexplicably did not contain "$_dartDocPrefixWithSpace" prefix.', file: relativeFilePath, line: lineNumber, ); } block.add(line.substring(index + 4)); } } else if (trimmedLine.startsWith(_codeBlockStartRegex)) { if (inOtherBlock) { throw _SnippetCheckerException( 'Found "```dart" section in another "```" section.', file: relativeFilePath, line: lineNumber, ); } assert(block.isEmpty); startLine = _Line( line: lineNumber + 1, indent: line.indexOf(_dartDocPrefixWithSpace) + _dartDocPrefixWithSpace.length, ); inDartSection = true; } else if (line.contains('```')) { if (inOtherBlock) { inOtherBlock = false; } else if (line.contains('```yaml') || line.contains('```ascii') || line.contains('```java') || line.contains('```objectivec') || line.contains('```kotlin') || line.contains('```swift') || line.contains('```glsl') || line.contains('```json') || line.contains('```csv')) { inOtherBlock = true; } else if (line.startsWith(_uncheckedCodeBlockStartRegex)) { // this is an intentionally-unchecked block that doesn't appear in the API docs. inOtherBlock = true; } else { throw _SnippetCheckerException( 'Found "```" in code but it did not match $_codeBlockStartRegex so something is wrong. Line was: "$line"', file: relativeFilePath, line: lineNumber, ); } } else if (!inToolSection) { final RegExpMatch? snippetMatch = _dartDocSnippetBeginRegex.firstMatch(trimmedLine); if (snippetMatch != null) { inToolSection = true; } else if (line == '// Examples can assume:') { if (inToolSection || inDartSection) { throw _SnippetCheckerException( '"// Examples can assume:" sections must come before all sample code.', file: relativeFilePath, line: lineNumber, ); } inExamplesCanAssumePreamble = true; } } } } on _SnippetCheckerException catch (e) { errors.add(e); } } return errors; }
/// Process one block of snippet code (the part inside of "```" markers). Uses /// a primitive heuristic to make snippet blocks into valid Dart code. /// /// `block` argument will get mutated, but is copied before this function returns. _SnippetFile _processBlock(_Line startingLine, List<String> block, List<_Line> assumptions, List<_Line> ignoreAssumptionsOnly, String filename, _SnippetFile? lastExample, List<_Line> customImports) { if (block.isEmpty) { throw _SnippetCheckerException('${startingLine.asLocation(filename, 0)}: Empty ```dart block in snippet code.'); } bool hasEllipsis = false; for (int index = 0; index < block.length; index += 1) { final Match? match = _ellipsisRegExp.matchAsPrefix(block[index]); if (match != null) { hasEllipsis = true; // in case the "..." is implying some overridden members, add an ignore to silence relevant warnings break; } } bool hasStatefulWidgetComment = false; bool importPreviousExample = false; int index = startingLine.line; for (final String line in block) { if (line == '// (e.g. in a stateful widget)') { if (hasStatefulWidgetComment) { throw _SnippetCheckerException('Example says it is in a stateful widget twice.', file: filename, line: index); } hasStatefulWidgetComment = true; } else if (line == '// continuing from previous example...') { if (importPreviousExample) { throw _SnippetCheckerException('Example says it continues from the previous example twice.', file: filename, line: index); } if (lastExample == null) { throw _SnippetCheckerException('Example says it continues from the previous example but it is the first example in the file.', file: filename, line: index); } importPreviousExample = true; } else { break; } index += 1; } final List<_Line> preamble; if (importPreviousExample) { preamble = <_Line>[ ...lastExample!.code, // includes assumptions if (hasEllipsis || hasStatefulWidgetComment) const _Line.generated(code: '// ignore_for_file: non_abstract_class_inherits_abstract_member'), ]; } else { preamble = <_Line>[ if (hasEllipsis || hasStatefulWidgetComment) const _Line.generated(code: '// ignore_for_file: non_abstract_class_inherits_abstract_member'), ...assumptions, ]; } final String firstCodeLine = block.firstWhere((String line) => !line.startsWith(_nonCodeRegExp)).trim(); final String lastCodeLine = block.lastWhere((String line) => !line.startsWith(_nonCodeRegExp)).trim(); if (firstCodeLine.startsWith('import ')) { // probably an entire program if (importPreviousExample) { throw _SnippetCheckerException('An example cannot both be self-contained (with its own imports) and say it wants to import the previous example.', file: filename, line: startingLine.line); } if (hasStatefulWidgetComment) { throw _SnippetCheckerException('An example cannot both be self-contained (with its own imports) and say it is in a stateful widget.', file: filename, line: startingLine.line); } return _SnippetFile.fromStrings( startingLine, block.toList(), headersWithoutImports, <_Line>[ ...ignoreAssumptionsOnly, if (hasEllipsis) const _Line.generated(code: '// ignore_for_file: non_abstract_class_inherits_abstract_member'), ], 'self-contained program', filename, ); }
final List<_Line> headers = switch ((importPreviousExample, customImports.length)) { (true, _) => <_Line>[], (false, 0) => headersWithImports, (false, _) => <_Line>[ ...headersWithoutImports, const _Line.generated(code: '// ignore_for_file: unused_import'), ...customImports, ] }; if (hasStatefulWidgetComment) { return _SnippetFile.fromStrings( startingLine, prefix: 'class _State extends State<StatefulWidget> {', block.toList(), postfix: '}', headers, preamble, 'stateful widget', filename, ); } else if (firstCodeLine.startsWith(_maybeGetterDeclarationRegExp) || (firstCodeLine.startsWith(_maybeFunctionDeclarationRegExp) && lastCodeLine.startsWith(_trailingCloseBraceRegExp)) || block.any((String line) => line.startsWith(_topLevelDeclarationRegExp))) { // probably a top-level declaration return _SnippetFile.fromStrings( startingLine, block.toList(), headers, preamble, 'top-level declaration', filename, ); } else if (lastCodeLine.startsWith(_trailingSemicolonRegExp) || block.any((String line) => line.startsWith(_statementRegExp))) { // probably a statement return _SnippetFile.fromStrings( startingLine, prefix: 'Future<void> function() async {', block.toList(), postfix: '}', headers, preamble, 'statement', filename, ); } else if (firstCodeLine.startsWith(_classDeclarationRegExp)) { // probably a static method return _SnippetFile.fromStrings( startingLine, prefix: 'class Class {', block.toList(), postfix: '}', headers, <_Line>[ ...preamble, const _Line.generated(code: '// ignore_for_file: avoid_classes_with_only_static_members'), ], 'class declaration', filename, ); } else { // probably an expression if (firstCodeLine.startsWith(_namedArgumentRegExp)) { // This is for snippets like: // // ```dart // // bla bla // foo: 2, // ``` // // This section removes the label. for (int index = 0; index < block.length; index += 1) { final Match? prefix = _namedArgumentRegExp.matchAsPrefix(block[index]); if (prefix != null) { block[index] = block[index].substring(prefix.group(0)!.length); break; } } } // strip trailing comma, if any for (int index = block.length - 1; index >= 0; index -= 1) { if (!block[index].startsWith(_nonCodeRegExp)) { final Match? lastLine = _trailingCommaRegExp.matchAsPrefix(block[index]); if (lastLine != null) { block[index] = lastLine.group(1)! + lastLine.group(2)!; } break; } } return _SnippetFile.fromStrings( startingLine, prefix: 'dynamic expression = ', block.toList(), postfix: ';', headers, preamble, 'expression', filename, ); } }
/// Creates the configuration files necessary for the analyzer to consider /// the temporary directory a package, and sets which lint rules to enforce. void _createConfigurationFiles() { final File targetPubSpec = File(path.join(_tempDirectory.path, 'pubspec.yaml')); if (!targetPubSpec.existsSync()) { // Copying pubspec.yaml from examples/api into temp directory. final File sourcePubSpec = File(path.join(_flutterRoot, 'examples', 'api', 'pubspec.yaml')); if (!sourcePubSpec.existsSync()) { throw 'Cannot find pubspec.yaml at ${sourcePubSpec.path}, which is also used to analyze code snippets.'; } sourcePubSpec.copySync(targetPubSpec.path); } final File targetAnalysisOptions = File(path.join(_tempDirectory.path, 'analysis_options.yaml')); if (!targetAnalysisOptions.existsSync()) { // Use the same analysis_options.yaml configuration that's used for examples/api. final File sourceAnalysisOptions = File(path.join(_flutterRoot, 'examples', 'api', 'analysis_options.yaml')); if (!sourceAnalysisOptions.existsSync()) { throw 'Cannot find analysis_options.yaml at ${sourceAnalysisOptions.path}, which is also used to analyze code snippets.'; } targetAnalysisOptions ..createSync(recursive: true) ..writeAsStringSync('include: ${sourceAnalysisOptions.absolute.path}'); } }
/// Writes out a snippet section to the disk and returns the file. File _writeSnippetFile(_SnippetFile snippetFile) { final String snippetFileId = _createNameFromSource('snippet', snippetFile.filename, snippetFile.indexLine); final File outputFile = File(path.join(_tempDirectory.path, '$snippetFileId.dart'))..createSync(recursive: true); final String contents = snippetFile.code.map<String>((_Line line) => line.code).join('\n').trimRight(); outputFile.writeAsStringSync('$contents\n'); return outputFile; }
/// Starts the analysis phase of checking the snippets by invoking the analyzer /// and parsing its output. Returns the errors, if any. List<Object> _analyze(Map<String, _SnippetFile> snippets) { final List<String> analyzerOutput = _runAnalyzer(); final List<Object> errors = <Object>[]; final String kBullet = Platform.isWindows ? ' - ' : ' • '; // RegExp to match an error output line of the analyzer. final RegExp errorPattern = RegExp( '^ *(?<type>[a-z]+)' '$kBullet(?<description>.+)' '$kBullet(?<file>.+):(?<line>[0-9]+):(?<column>[0-9]+)' '$kBullet(?<code>[-a-z_]+)\$', caseSensitive: false, );
for (final String error in analyzerOutput) { final RegExpMatch? match = errorPattern.firstMatch(error); if (match == null) { errors.add(_SnippetCheckerException('Could not parse analyzer output: $error')); continue; } final String message = match.namedGroup('description')!; final File file = File(path.join(_tempDirectory.path, match.namedGroup('file'))); final List<String> fileContents = file.readAsLinesSync(); final String lineString = match.namedGroup('line')!; final String columnString = match.namedGroup('column')!; final String errorCode = match.namedGroup('code')!; final int lineNumber = int.parse(lineString, radix: 10); final int columnNumber = int.parse(columnString, radix: 10);
if (lineNumber < 1 || lineNumber > fileContents.length + 1) { errors.add(_AnalysisError( file.path, lineNumber, columnNumber, message, errorCode, _Line(line: lineNumber), )); errors.add(_SnippetCheckerException('Error message points to non-existent line number: $error', file: file.path, line: lineNumber)); continue; }
final _SnippetFile? snippet = snippets[file.path]; if (snippet == null) { errors.add(_SnippetCheckerException( "Unknown section for ${file.path}. Maybe the temporary directory wasn't empty?", file: file.path, line: lineNumber, )); continue; } if (fileContents.length != snippet.code.length) { errors.add(_SnippetCheckerException( 'Unexpected file contents for ${file.path}. File has ${fileContents.length} lines but we generated ${snippet.code.length} lines:\n${snippet.code.join("\n")}', file: file.path, line: lineNumber, )); continue; }
late final _Line actualSource; late final int actualLine; late final int actualColumn; late final String actualMessage; int delta = 0; while (true) { // find the nearest non-generated line to the error if ((lineNumber - delta > 0) && (lineNumber - delta <= snippet.code.length) && !snippet.code[lineNumber - delta - 1].generated) { actualSource = snippet.code[lineNumber - delta - 1]; actualLine = actualSource.line; actualColumn = delta == 0 ? columnNumber : actualSource.code.length + 1; actualMessage = delta == 0 ? message : '$message -- in later generated code'; break; } if ((lineNumber + delta < snippet.code.length) && (lineNumber + delta >= 0) && !snippet.code[lineNumber + delta].generated) { actualSource = snippet.code[lineNumber + delta]; actualLine = actualSource.line; actualColumn = 1; actualMessage = '$message -- in earlier generated code'; break; } delta += 1; assert((lineNumber - delta > 0) || (lineNumber + delta < snippet.code.length)); } errors.add(_AnalysisError( snippet.filename, actualLine, actualColumn, '$actualMessage (${snippet.generatorComment})', errorCode, actualSource, )); } return errors; }
/// Invokes the analyzer on the given [directory] and returns the stdout (with some lines filtered). List<String> _runAnalyzer() { _createConfigurationFiles(); // Run pub get to avoid output from getting dependencies in the analyzer // output. Process.runSync( _flutter, <String>['pub', 'get'], workingDirectory: _tempDirectory.absolute.path, ); final ProcessResult result = Process.runSync( _flutter, <String>['--no-wrap', 'analyze', '--no-preamble', '--no-congratulate', '.'], workingDirectory: _tempDirectory.absolute.path, ); final List<String> stderr = result.stderr.toString().trim().split('\n'); final List<String> stdout = result.stdout.toString().trim().split('\n'); // Remove output from building the flutter tool. stderr.removeWhere((String line) { return line.startsWith('Building flutter tool...') || line.startsWith('Waiting for another flutter command to release the startup lock...') || line.startsWith('Flutter assets will be downloaded from '); }); // Check out the stderr to see if the analyzer had it's own issues. if (stderr.isNotEmpty && stderr.first.contains(RegExp(r' issues? found\. \(ran in '))) { stderr.removeAt(0); if (stderr.isNotEmpty && stderr.last.isEmpty) { stderr.removeLast(); } } if (stderr.isNotEmpty && stderr.any((String line) => line.isNotEmpty)) { throw _SnippetCheckerException('Cannot analyze dartdocs; unexpected error output:\n$stderr'); } if (stdout.isNotEmpty && stdout.first == 'Building flutter tool...') { stdout.removeAt(0); } if (stdout.isNotEmpty && stdout.first.isEmpty) { stdout.removeAt(0); } return stdout; }}
/// A class to represent a section of snippet code, marked by "```dart ... ```", that ends up/// in a file we then analyze (each snippet is in its own file).class _SnippetFile { const _SnippetFile(this.code, this.generatorComment, this.filename, this.indexLine);
factory _SnippetFile.fromLines( List<_Line> code, List<_Line> headers, List<_Line> preamble, String generatorComment, String filename, ) { while (code.isNotEmpty && code.last.code.isEmpty) { code.removeLast(); } assert(code.isNotEmpty); final _Line firstLine = code.firstWhere((_Line line) => !line.generated); return _SnippetFile( <_Line>[ ...headers, const _Line.generated(), // blank line if (preamble.isNotEmpty) ...preamble, if (preamble.isNotEmpty) const _Line.generated(), // blank line _Line.generated(code: '// From: $filename:${firstLine.line}'), ...code, ], generatorComment, filename, firstLine.line, ); }
factory _SnippetFile.fromStrings( _Line firstLine, List<String> code, List<_Line> headers, List<_Line> preamble, String generatorComment, String filename, { String? prefix, String? postfix, }) { final List<_Line> codeLines = <_Line>[ if (prefix != null) _Line.generated(code: prefix), for (int i = 0; i < code.length; i += 1) _Line(code: code[i], line: firstLine.line + i, indent: firstLine.indent), if (postfix != null) _Line.generated(code: postfix), ]; return _SnippetFile.fromLines(codeLines, headers, preamble, generatorComment, filename); }
final List<_Line> code; final String generatorComment; final String filename; final int indexLine;}
Future<void> _runInteractive({ required String? tempDirectory, required List<Directory> flutterPackages, required String filePath, required Directory? dartUiLocation,}) async { filePath = path.isAbsolute(filePath) ? filePath : path.join(path.current, filePath); final File file = File(filePath); if (!file.existsSync()) { stderr.writeln('Specified file ${file.absolute.path} does not exist or is not a file.'); exit(1); } if (!path.isWithin(_flutterRoot, file.absolute.path) && (dartUiLocation == null || !path.isWithin(dartUiLocation.path, file.absolute.path))) { stderr.writeln( 'Specified file ${file.absolute.path} is not within the flutter root: ' "$_flutterRoot${dartUiLocation != null ? ' or the dart:ui location: $dartUiLocation' : ''}" ); exit(1); }
print('Starting up in interactive mode on ${path.relative(filePath, from: _flutterRoot)} ...'); print('Type "q" to quit, or "r" to force a reload.');
final _SnippetChecker checker = _SnippetChecker(flutterPackages, tempDirectory: tempDirectory) .._createConfigurationFiles();
ProcessSignal.sigint.watch().listen((_) { checker.cleanupTempDirectory(); exit(0); });
bool busy = false; Future<void> rerun() async { assert(!busy); try { busy = true; print('\nAnalyzing...'); checker.recreateTempDirectory(); final Map<String, _SnippetFile> snippets = <String, _SnippetFile>{}; final Set<Object> errors = <Object>{}; errors.addAll(await checker._extractSnippets(<File>[file], snippetMap: snippets)); errors.addAll(checker._analyze(snippets)); stderr.writeln('\u001B[2J\u001B[H'); // Clears the old results from the terminal. if (errors.isNotEmpty) { (errors.toList()..sort()).map(_stringify).forEach(stderr.writeln); stderr.writeln('Found ${errors.length} errors.'); } else { stderr.writeln('No issues found.'); } } finally { busy = false; } } await rerun();
stdin.lineMode = false; stdin.echoMode = false; stdin.transform(utf8.decoder).listen((String input) async { switch (input.trim()) { case 'q': checker.cleanupTempDirectory(); exit(0); case 'r': if (!busy) { rerun(); } } }); Watcher(file.absolute.path).events.listen((_) => rerun());}
String _stringify(Object object) => object.toString();1234567891011121314<?xml version="1.0" encoding="UTF-8"?><module type="WEB_MODULE" version="4"> <component name="NewModuleRootManager" inherit-compiler-output="true"> <exclude-output /> <content url="file://$MODULE_DIR$"> <excludeFolder url="file://$MODULE_DIR$/build" /> </content> <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="library" name="Dart SDK" level="project" /> <orderEntry type="library" name="Dart Packages" level="project" /> <orderEntry type="library" name="Flutter Plugins" level="project" /> </component></module>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109// Copyright 2014 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:async';import 'dart:io' as io;
import 'package:flutter_devicelab/framework/browser.dart';import 'package:shelf/shelf.dart';import 'package:shelf/shelf_io.dart' as shelf_io;import 'package:shelf_static/shelf_static.dart';
/// Runs Chrome, opens the given `appUrl`, and returns the result reported by the/// app.////// The app is served from the `appDirectory`. Typically, the app is built/// using `flutter build web` and served from `build/web`.////// The launched app is expected to report the result by sending an HTTP POST/// request to "/test-result" containing result data as plain text body of the/// request. This function has no opinion about what that string contains.Future<String> evalTestAppInChrome({ required String appUrl, required String appDirectory, int serverPort = 8080, int browserDebugPort = 8081,}) async { io.HttpServer? server; Chrome? chrome; try { final Completer<String> resultCompleter = Completer<String>(); server = await io.HttpServer.bind('localhost', serverPort); final Cascade cascade = Cascade() .add((Request request) async { if (request.requestedUri.path.endsWith('/test-result')) { resultCompleter.complete(await request.readAsString()); return Response.ok('Test results received'); } return Response.notFound(''); }) .add(createStaticHandler(appDirectory)); shelf_io.serveRequests(server, cascade.handler); final io.Directory userDataDirectory = io.Directory.systemTemp.createTempSync('flutter_chrome_user_data.'); chrome = await Chrome.launch(ChromeOptions( headless: true, debugPort: browserDebugPort, url: appUrl, userDataDirectory: userDataDirectory.path, windowHeight: 500, windowWidth: 500, ), onError: resultCompleter.completeError); return await resultCompleter.future; } finally { chrome?.stop(); await server?.close(); }}
typedef ServerRequestListener = void Function(Request);
class AppServer { AppServer._(this._server, this.chrome, this.onChromeError);
static Future<AppServer> start({ required String appUrl, required String appDirectory, required String cacheControl, int serverPort = 8080, int browserDebugPort = 8081, bool headless = true, List<Handler>? additionalRequestHandlers, }) async { io.HttpServer server; Chrome chrome; server = await io.HttpServer.bind('localhost', serverPort); final Handler staticHandler = createStaticHandler(appDirectory, defaultDocument: 'index.html'); Cascade cascade = Cascade(); if (additionalRequestHandlers != null) { for (final Handler handler in additionalRequestHandlers) { cascade = cascade.add(handler); } } cascade = cascade.add((Request request) async { final Response response = await staticHandler(request); return response.change(headers: <String, Object>{ 'cache-control': cacheControl, }); }); shelf_io.serveRequests(server, cascade.handler); final io.Directory userDataDirectory = io.Directory.systemTemp.createTempSync('flutter_chrome_user_data.'); final Completer<String> chromeErrorCompleter = Completer<String>(); chrome = await Chrome.launch(ChromeOptions( headless: headless, debugPort: browserDebugPort, url: appUrl, userDataDirectory: userDataDirectory.path, ), onError: chromeErrorCompleter.complete); return AppServer._(server, chrome, chromeErrorCompleter.future); }
final Future<String> onChromeError; final io.HttpServer _server; final Chrome chrome;
Future<void> stop() async { chrome.stop(); await _server.close(); }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494// Copyright 2014 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.
// To run this, from the root of the Flutter repository:// bin/cache/dart-sdk/bin/dart --enable-asserts dev/bots/check_code_sample_links.dart
import 'dart:io';
import 'package:args/args.dart';import 'package:file/file.dart';import 'package:file/local.dart';import 'package:path/path.dart' as path;
import 'utils.dart';
final String _scriptLocation = path.fromUri(Platform.script);final String _flutterRoot = path.dirname(path.dirname(path.dirname(_scriptLocation)));final String _exampleDirectoryPath = path.join(_flutterRoot, 'examples', 'api');final String _packageDirectoryPath = path.join(_flutterRoot, 'packages');final String _dartUIDirectoryPath = path.join(_flutterRoot, 'bin', 'cache', 'pkg', 'sky_engine', 'lib');
final List<String> _knownUnlinkedExamples = <String>[ // These are template files that aren't expected to be linked. 'examples/api/lib/sample_templates/cupertino.0.dart', 'examples/api/lib/sample_templates/widgets.0.dart', 'examples/api/lib/sample_templates/material.0.dart',];
void main(List<String> args) { final ArgParser argParser = ArgParser(); argParser.addFlag( 'help', negatable: false, help: 'Print help for this command.', ); argParser.addOption( 'examples', valueHelp: 'path', defaultsTo: _exampleDirectoryPath, help: 'A location where the API doc examples are found.', ); argParser.addOption( 'packages', valueHelp: 'path', defaultsTo: _packageDirectoryPath, help: 'A location where the source code that should link the API doc examples is found.', ); argParser.addOption( 'dart-ui', valueHelp: 'path', defaultsTo: _dartUIDirectoryPath, help: 'A location where the source code that should link the API doc examples is found.', ); argParser.addOption( 'flutter-root', valueHelp: 'path', defaultsTo: _flutterRoot, help: 'The path to the root of the Flutter repo.', ); final ArgResults parsedArgs;
void usage() { print('dart --enable-asserts ${path.basename(_scriptLocation)} [options]'); print(argParser.usage); }
try { parsedArgs = argParser.parse(args); } on FormatException catch (e) { print(e.message); usage(); exit(1); }
if (parsedArgs['help'] as bool) { usage(); exit(0); }
const FileSystem filesystem = LocalFileSystem(); final Directory examples = filesystem.directory(parsedArgs['examples']! as String); final Directory packages = filesystem.directory(parsedArgs['packages']! as String); final Directory dartUIPath = filesystem.directory(parsedArgs['dart-ui']! as String); final Directory flutterRoot = filesystem.directory(parsedArgs['flutter-root']! as String);
final SampleChecker checker = SampleChecker( examples: examples, packages: packages, dartUIPath: dartUIPath, flutterRoot: flutterRoot, );
if (!checker.checkCodeSamples()) { reportErrorsAndExit('Some errors were found in the API docs code samples.'); } reportSuccessAndExit('All examples are linked and have tests.');}
class LinkInfo { const LinkInfo(this.link, this.file, this.line);
final String link; final File file; final int line;
@override String toString() { return '${file.path}:$line: $link'; }}
class SampleChecker { SampleChecker({ required this.examples, required this.packages, required this.dartUIPath, required this.flutterRoot, this.filesystem = const LocalFileSystem(), });
final Directory examples; final Directory packages; final Directory dartUIPath; final Directory flutterRoot; final FileSystem filesystem;
bool checkCodeSamples() { filesystem.currentDirectory = flutterRoot;
// Get a list of all the filenames in the source directory that end in "[0-9]+.dart". final List<File> exampleFilenames = getExampleFilenames(examples);
// Get a list of all the example link paths that appear in the source files. final (Set<String> exampleLinks, Set<LinkInfo> malformedLinks) = getExampleLinks(packages); // Also add in any that might be found in the dart:ui directory. final (Set<String> uiExampleLinks, Set<LinkInfo> uiMalformedLinks) = getExampleLinks(dartUIPath);
exampleLinks.addAll(uiExampleLinks); malformedLinks.addAll(uiMalformedLinks);
// Get a list of the filenames that were not found in the source files. final List<String> missingFilenames = checkForMissingLinks(exampleFilenames, exampleLinks);
// Get a list of any tests that are missing, as well as any that used to be // missing, but have been implemented. final (List<File> missingTests, List<File> noLongerMissing) = checkForMissingTests(exampleFilenames);
// Remove any that we know are exceptions (examples that aren't expected to be // linked into any source files). These are typically template files used to // generate new examples. missingFilenames.removeWhere((String file) => _knownUnlinkedExamples.contains(file));
if (missingFilenames.isEmpty && missingTests.isEmpty && noLongerMissing.isEmpty && malformedLinks.isEmpty) { return true; }
if (noLongerMissing.isNotEmpty) { final StringBuffer buffer = StringBuffer('The following tests have been implemented! Huzzah!:\n'); for (final File name in noLongerMissing) { buffer.writeln(' ${getRelativePath(name)}'); } buffer.writeln('However, they now need to be removed from the _knownMissingTests'); buffer.write('list in the script $_scriptLocation.'); foundError(buffer.toString().split('\n')); }
if (missingTests.isNotEmpty) { final StringBuffer buffer = StringBuffer('The following example test files are missing:\n'); for (final File name in missingTests) { buffer.writeln(' ${getRelativePath(name)}'); } foundError(buffer.toString().trimRight().split('\n')); }
if (missingFilenames.isNotEmpty) { final StringBuffer buffer = StringBuffer('The following examples are not linked from any source file API doc comments:\n'); for (final String name in missingFilenames) { buffer.writeln(' $name'); } buffer.write('Either link them to a source file API doc comment, or remove them.'); foundError(buffer.toString().split('\n')); }
if (malformedLinks.isNotEmpty) { final StringBuffer buffer = StringBuffer('The following malformed links were found in API doc comments:\n'); for (final LinkInfo link in malformedLinks) { buffer.writeln(' $link'); } buffer.write( 'Correct the formatting of these links so that they match the exact pattern:\n' r" r'\*\* See code in (?<path>.+) \*\*'" ); foundError(buffer.toString().split('\n')); } return false; }
String getRelativePath(File file, [Directory? root]) { root ??= flutterRoot; return path.relative(file.absolute.path, from: root.absolute.path); }
List<File> getFiles(Directory directory, [Pattern? filenamePattern]) { final List<File> filenames = directory .listSync(recursive: true) .map((FileSystemEntity entity) { if (entity is File) { return entity; } else { return null; } }) .where((File? filename) => filename != null && (filenamePattern == null || filename.absolute.path.contains(filenamePattern))) .map<File>((File? s) => s!) .toList(); return filenames; }
List<File> getExampleFilenames(Directory directory) { return getFiles( directory.childDirectory('lib'), RegExp(r'\d+\.dart$'), ); }
(Set<String>, Set<LinkInfo>) getExampleLinks(Directory searchDirectory) { final List<File> files = getFiles(searchDirectory, RegExp(r'\.dart$')); final Set<String> searchStrings = <String>{}; final Set<LinkInfo> malformedStrings = <LinkInfo>{}; final RegExp validExampleRe = RegExp(r'\*\* See code in (?<path>.+) \*\*'); // Looks for some common broken versions of example links. This looks for // something that is at minimum "///*seecode<something>*" to indicate that it // looks like an example link. It should be narrowed if we start gettting false // positives. final RegExp malformedLinkRe = RegExp(r'^(?<malformed>\s*///\s*\*\*?\s*[sS][eE][eE]\s*[Cc][Oo][Dd][Ee].+\*\*?)'); for (final File file in files) { final String contents = file.readAsStringSync(); final List<String> lines = contents.split('\n'); int count = 0; for (final String line in lines) { count += 1; final RegExpMatch? validMatch = validExampleRe.firstMatch(line); if (validMatch != null) { searchStrings.add(validMatch.namedGroup('path')!); } final RegExpMatch? malformedMatch = malformedLinkRe.firstMatch(line); // It's only malformed if it doesn't match the valid RegExp. if (malformedMatch != null && validMatch == null) { malformedStrings.add(LinkInfo(malformedMatch.namedGroup('malformed')!, file, count)); } } } return (searchStrings, malformedStrings); }
List<String> checkForMissingLinks(List<File> exampleFilenames, Set<String> searchStrings) { final List<String> missingFilenames = <String>[]; for (final File example in exampleFilenames) { final String relativePath = getRelativePath(example); if (!searchStrings.contains(relativePath)) { missingFilenames.add(relativePath); } } return missingFilenames; }
String getTestNameForExample(File example, Directory examples) { final String testPath = path.dirname( path.join( examples.absolute.path, 'test', getRelativePath(example, examples.childDirectory('lib')), ), ); return '${path.join(testPath, path.basenameWithoutExtension(example.path))}_test.dart'; }
(List<File>, List<File>) checkForMissingTests(List<File> exampleFilenames) { final List<File> missingTests = <File>[]; final List<File> noLongerMissingTests = <File>[]; for (final File example in exampleFilenames) { final File testFile = filesystem.file(getTestNameForExample(example, examples)); final String name = path.relative(testFile.absolute.path, from: flutterRoot.absolute.path); if (!testFile.existsSync()) { missingTests.add(testFile); } else if (_knownMissingTests.contains(name.replaceAll(r'\', '/'))) { noLongerMissingTests.add(testFile); } } // Skip any that we know are missing. missingTests.removeWhere( (File test) { final String name = path.relative(test.absolute.path, from: flutterRoot.absolute.path).replaceAll(r'\', '/'); return _knownMissingTests.contains(name); }, ); return (missingTests, noLongerMissingTests); }}
// These tests are known to be missing. They should all eventually be// implemented, but until they are we allow them, so that we can catch any new// examples that are added without tests.//// TODO(gspencergoog): implement the missing tests.// See https://github.com/flutter/flutter/issues/130459final Set<String> _knownMissingTests = <String>{ 'examples/api/test/material/bottom_app_bar/bottom_app_bar.2_test.dart', 'examples/api/test/material/bottom_app_bar/bottom_app_bar.1_test.dart', 'examples/api/test/material/theme/theme_extension.1_test.dart', 'examples/api/test/material/material_state/material_state_border_side.0_test.dart', 'examples/api/test/material/material_state/material_state_mouse_cursor.0_test.dart', 'examples/api/test/material/material_state/material_state_outlined_border.0_test.dart', 'examples/api/test/material/material_state/material_state_property.0_test.dart', 'examples/api/test/material/selectable_region/selectable_region.0_test.dart', 'examples/api/test/material/text_field/text_field.2_test.dart', 'examples/api/test/material/text_field/text_field.1_test.dart', 'examples/api/test/material/button_style/button_style.0_test.dart', 'examples/api/test/material/range_slider/range_slider.0_test.dart', 'examples/api/test/material/selection_container/selection_container_disabled.0_test.dart', 'examples/api/test/material/selection_container/selection_container.0_test.dart', 'examples/api/test/material/color_scheme/dynamic_content_color.0_test.dart', 'examples/api/test/material/platform_menu_bar/platform_menu_bar.0_test.dart', 'examples/api/test/material/menu_anchor/menu_anchor.2_test.dart', 'examples/api/test/material/stepper/stepper.controls_builder.0_test.dart', 'examples/api/test/material/flexible_space_bar/flexible_space_bar.0_test.dart', 'examples/api/test/material/floating_action_button_location/standard_fab_location.0_test.dart', 'examples/api/test/material/chip/deletable_chip_attributes.on_deleted.0_test.dart', 'examples/api/test/material/snack_bar/snack_bar.2_test.dart', 'examples/api/test/material/snack_bar/snack_bar.1_test.dart', 'examples/api/test/material/icon_button/icon_button.3_test.dart', 'examples/api/test/material/expansion_panel/expansion_panel_list.expansion_panel_list_radio.0_test.dart', 'examples/api/test/material/input_decorator/input_decoration.1_test.dart', 'examples/api/test/material/input_decorator/input_decoration.prefix_icon_constraints.0_test.dart', 'examples/api/test/material/input_decorator/input_decoration.material_state.0_test.dart', 'examples/api/test/material/input_decorator/input_decoration.2_test.dart', 'examples/api/test/material/input_decorator/input_decoration.0_test.dart', 'examples/api/test/material/input_decorator/input_decoration.label.0_test.dart', 'examples/api/test/material/input_decorator/input_decoration.suffix_icon_constraints.0_test.dart', 'examples/api/test/material/input_decorator/input_decoration.3_test.dart', 'examples/api/test/material/input_decorator/input_decoration.material_state.1_test.dart', 'examples/api/test/material/text_form_field/text_form_field.1_test.dart', 'examples/api/test/material/scrollbar/scrollbar.1_test.dart', 'examples/api/test/material/dropdown_menu/dropdown_menu.1_test.dart', 'examples/api/test/material/radio/radio.toggleable.0_test.dart', 'examples/api/test/material/search_anchor/search_anchor.0_test.dart', 'examples/api/test/material/search_anchor/search_anchor.1_test.dart', 'examples/api/test/material/search_anchor/search_anchor.2_test.dart', 'examples/api/test/material/about/about_list_tile.0_test.dart', 'examples/api/test/material/tab_controller/tab_controller.1_test.dart', 'examples/api/test/material/selection_area/selection_area.0_test.dart', 'examples/api/test/material/scaffold/scaffold.end_drawer.0_test.dart', 'examples/api/test/material/scaffold/scaffold.drawer.0_test.dart', 'examples/api/test/material/scaffold/scaffold.1_test.dart', 'examples/api/test/material/scaffold/scaffold.of.0_test.dart', 'examples/api/test/material/scaffold/scaffold_messenger.of.0_test.dart', 'examples/api/test/material/scaffold/scaffold_messenger.0_test.dart', 'examples/api/test/material/scaffold/scaffold.0_test.dart', 'examples/api/test/material/scaffold/scaffold_state.show_bottom_sheet.0_test.dart', 'examples/api/test/material/scaffold/scaffold.2_test.dart', 'examples/api/test/material/scaffold/scaffold_messenger_state.show_material_banner.0_test.dart', 'examples/api/test/material/scaffold/scaffold.of.1_test.dart', 'examples/api/test/material/scaffold/scaffold_messenger.of.1_test.dart', 'examples/api/test/material/scaffold/scaffold_messenger_state.show_snack_bar.0_test.dart', 'examples/api/test/material/segmented_button/segmented_button.0_test.dart', 'examples/api/test/material/app_bar/sliver_app_bar.2_test.dart', 'examples/api/test/material/app_bar/sliver_app_bar.3_test.dart', 'examples/api/test/material/banner/material_banner.1_test.dart', 'examples/api/test/material/banner/material_banner.0_test.dart', 'examples/api/test/material/checkbox/checkbox.1_test.dart', 'examples/api/test/material/checkbox/checkbox.0_test.dart', 'examples/api/test/material/navigation_rail/navigation_rail.extended_animation.0_test.dart', 'examples/api/test/material/text_button/text_button.0_test.dart', 'examples/api/test/rendering/growth_direction/growth_direction.0_test.dart', 'examples/api/test/rendering/sliver_grid/sliver_grid_delegate_with_fixed_cross_axis_count.0_test.dart', 'examples/api/test/rendering/sliver_grid/sliver_grid_delegate_with_fixed_cross_axis_count.1_test.dart', 'examples/api/test/rendering/scroll_direction/scroll_direction.0_test.dart', 'examples/api/test/painting/axis_direction/axis_direction.0_test.dart', 'examples/api/test/painting/linear_border/linear_border.0_test.dart', 'examples/api/test/painting/gradient/linear_gradient.0_test.dart', 'examples/api/test/painting/star_border/star_border.0_test.dart', 'examples/api/test/painting/borders/border_side.stroke_align.0_test.dart', 'examples/api/test/widgets/autocomplete/raw_autocomplete.focus_node.0_test.dart', 'examples/api/test/widgets/autocomplete/raw_autocomplete.2_test.dart', 'examples/api/test/widgets/autocomplete/raw_autocomplete.1_test.dart', 'examples/api/test/widgets/autocomplete/raw_autocomplete.0_test.dart', 'examples/api/test/widgets/navigator/navigator.restorable_push_and_remove_until.0_test.dart', 'examples/api/test/widgets/navigator/navigator.0_test.dart', 'examples/api/test/widgets/navigator/navigator.restorable_push.0_test.dart', 'examples/api/test/widgets/navigator/navigator_state.restorable_push_replacement.0_test.dart', 'examples/api/test/widgets/navigator/navigator_state.restorable_push_and_remove_until.0_test.dart', 'examples/api/test/widgets/navigator/navigator.restorable_push_replacement.0_test.dart', 'examples/api/test/widgets/navigator/restorable_route_future.0_test.dart', 'examples/api/test/widgets/navigator/navigator_state.restorable_push.0_test.dart', 'examples/api/test/widgets/focus_manager/focus_node.unfocus.0_test.dart', 'examples/api/test/widgets/focus_manager/focus_node.0_test.dart', 'examples/api/test/widgets/framework/build_owner.0_test.dart', 'examples/api/test/widgets/framework/error_widget.0_test.dart', 'examples/api/test/widgets/inherited_theme/inherited_theme.0_test.dart', 'examples/api/test/widgets/sliver/decorated_sliver.0_test.dart', 'examples/api/test/widgets/autofill/autofill_group.0_test.dart', 'examples/api/test/widgets/drag_target/draggable.0_test.dart', 'examples/api/test/widgets/shared_app_data/shared_app_data.1_test.dart', 'examples/api/test/widgets/shared_app_data/shared_app_data.0_test.dart', 'examples/api/test/widgets/form/form.0_test.dart', 'examples/api/test/widgets/nested_scroll_view/nested_scroll_view_state.0_test.dart', 'examples/api/test/widgets/nested_scroll_view/nested_scroll_view.2_test.dart', 'examples/api/test/widgets/nested_scroll_view/nested_scroll_view.1_test.dart', 'examples/api/test/widgets/nested_scroll_view/nested_scroll_view.0_test.dart', 'examples/api/test/widgets/scroll_position/scroll_metrics_notification.0_test.dart', 'examples/api/test/widgets/media_query/media_query_data.system_gesture_insets.0_test.dart', 'examples/api/test/widgets/async/stream_builder.0_test.dart', 'examples/api/test/widgets/async/future_builder.0_test.dart', 'examples/api/test/widgets/restoration_properties/restorable_value.0_test.dart', 'examples/api/test/widgets/animated_size/animated_size.0_test.dart', 'examples/api/test/widgets/table/table.0_test.dart', 'examples/api/test/widgets/animated_switcher/animated_switcher.0_test.dart', 'examples/api/test/widgets/transitions/relative_positioned_transition.0_test.dart', 'examples/api/test/widgets/transitions/positioned_transition.0_test.dart', 'examples/api/test/widgets/transitions/sliver_fade_transition.0_test.dart', 'examples/api/test/widgets/transitions/align_transition.0_test.dart', 'examples/api/test/widgets/transitions/fade_transition.0_test.dart', 'examples/api/test/widgets/transitions/animated_builder.0_test.dart', 'examples/api/test/widgets/transitions/rotation_transition.0_test.dart', 'examples/api/test/widgets/transitions/animated_widget.0_test.dart', 'examples/api/test/widgets/transitions/slide_transition.0_test.dart', 'examples/api/test/widgets/transitions/listenable_builder.2_test.dart', 'examples/api/test/widgets/transitions/scale_transition.0_test.dart', 'examples/api/test/widgets/transitions/default_text_style_transition.0_test.dart', 'examples/api/test/widgets/transitions/decorated_box_transition.0_test.dart', 'examples/api/test/widgets/transitions/size_transition.0_test.dart', 'examples/api/test/widgets/animated_list/animated_list.0_test.dart', 'examples/api/test/widgets/focus_traversal/focus_traversal_group.0_test.dart', 'examples/api/test/widgets/focus_traversal/ordered_traversal_policy.0_test.dart', 'examples/api/test/widgets/image/image.error_builder.0_test.dart', 'examples/api/test/widgets/image/image.frame_builder.0_test.dart', 'examples/api/test/widgets/image/image.loading_builder.0_test.dart', 'examples/api/test/widgets/shortcuts/logical_key_set.0_test.dart', 'examples/api/test/widgets/shortcuts/shortcuts.0_test.dart', 'examples/api/test/widgets/shortcuts/single_activator.single_activator.0_test.dart', 'examples/api/test/widgets/shortcuts/shortcuts.1_test.dart', 'examples/api/test/widgets/shortcuts/character_activator.0_test.dart', 'examples/api/test/widgets/shortcuts/callback_shortcuts.0_test.dart', 'examples/api/test/widgets/page_storage/page_storage.0_test.dart', 'examples/api/test/widgets/scrollbar/raw_scrollbar.1_test.dart', 'examples/api/test/widgets/scrollbar/raw_scrollbar.2_test.dart', 'examples/api/test/widgets/scrollbar/raw_scrollbar.desktop.0_test.dart', 'examples/api/test/widgets/scrollbar/raw_scrollbar.shape.0_test.dart', 'examples/api/test/widgets/scrollbar/raw_scrollbar.0_test.dart', 'examples/api/test/widgets/sliver_fill/sliver_fill_remaining.2_test.dart', 'examples/api/test/widgets/sliver_fill/sliver_fill_remaining.1_test.dart', 'examples/api/test/widgets/sliver_fill/sliver_fill_remaining.3_test.dart', 'examples/api/test/widgets/sliver_fill/sliver_fill_remaining.0_test.dart', 'examples/api/test/widgets/interactive_viewer/interactive_viewer.constrained.0_test.dart', 'examples/api/test/widgets/interactive_viewer/interactive_viewer.transformation_controller.0_test.dart', 'examples/api/test/widgets/interactive_viewer/interactive_viewer.0_test.dart', 'examples/api/test/widgets/notification_listener/notification.0_test.dart', 'examples/api/test/widgets/gesture_detector/gesture_detector.1_test.dart', 'examples/api/test/widgets/gesture_detector/gesture_detector.0_test.dart', 'examples/api/test/widgets/editable_text/text_editing_controller.0_test.dart', 'examples/api/test/widgets/editable_text/editable_text.on_changed.0_test.dart', 'examples/api/test/widgets/undo_history/undo_history_controller.0_test.dart', 'examples/api/test/widgets/overscroll_indicator/glowing_overscroll_indicator.1_test.dart', 'examples/api/test/widgets/overscroll_indicator/glowing_overscroll_indicator.0_test.dart', 'examples/api/test/widgets/tween_animation_builder/tween_animation_builder.0_test.dart', 'examples/api/test/widgets/single_child_scroll_view/single_child_scroll_view.1_test.dart', 'examples/api/test/widgets/single_child_scroll_view/single_child_scroll_view.0_test.dart', 'examples/api/test/widgets/overflow_bar/overflow_bar.0_test.dart', 'examples/api/test/widgets/restoration/restoration_mixin.0_test.dart', 'examples/api/test/widgets/actions/actions.0_test.dart', 'examples/api/test/widgets/actions/action_listener.0_test.dart', 'examples/api/test/widgets/actions/focusable_action_detector.0_test.dart', 'examples/api/test/widgets/color_filter/color_filtered.0_test.dart', 'examples/api/test/widgets/focus_scope/focus.2_test.dart', 'examples/api/test/widgets/focus_scope/focus.0_test.dart', 'examples/api/test/widgets/focus_scope/focus.1_test.dart', 'examples/api/test/widgets/focus_scope/focus_scope.0_test.dart', 'examples/api/test/widgets/implicit_animations/animated_fractionally_sized_box.0_test.dart', 'examples/api/test/widgets/implicit_animations/animated_align.0_test.dart', 'examples/api/test/widgets/implicit_animations/animated_positioned.0_test.dart', 'examples/api/test/widgets/implicit_animations/animated_padding.0_test.dart', 'examples/api/test/widgets/implicit_animations/sliver_animated_opacity.0_test.dart', 'examples/api/test/widgets/implicit_animations/animated_container.0_test.dart', 'examples/api/test/widgets/dismissible/dismissible.0_test.dart', 'examples/api/test/widgets/scroll_view/custom_scroll_view.1_test.dart', 'examples/api/test/widgets/preferred_size/preferred_size.0_test.dart', 'examples/api/test/widgets/inherited_notifier/inherited_notifier.0_test.dart', 'examples/api/test/animation/curves/curve2_d.0_test.dart', 'examples/api/test/gestures/pointer_signal_resolver/pointer_signal_resolver.0_test.dart',};1234567891011121314151617181920212223242526272829303132333435363738394041424344#!/usr/bin/env bash# Copyright 2014 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.
set -ex
readonly SCRIPTS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"readonly ROOT_DIR="$SCRIPTS_DIR/.."
function is_expected_failure() { # A test target was specified with the 'build' command. grep --quiet "is not configured for Running" "$1"}
log_file="build_log_for_104_complete.txt"build_command="flutter build bundle"
# Attempt to build 104-complete Shrine app from the Flutter codelabsgit clone https://github.com/material-components/material-components-flutter-codelabs.gitcd material-components-flutter-codelabs/mdc_100_series/git checkout 104-complete
all_builds_ok=1echo "$build_command"$build_command 2>&1 | tee "$log_file"
if [ ${PIPESTATUS[0]} -eq 0 ] || is_expected_failure "$log_file"; then rm "$log_file"else all_builds_ok=0 echo "View https://github.com/flutter/flutter/blob/master/dev/bots/README.md for steps to resolve this failed build test." >> ${log_file} echo echo "Log left in $log_file." echofi
# If any build failed, exit with a failure exit status so continuous integration# tools can react appropriately.if [ "$all_builds_ok" -eq 1 ]; then exit 0else exit 1fi123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154#!/usr/bin/env bash# Copyright 2014 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.
set -e
function script_location() { local script_location="${BASH_SOURCE[0]}" # Resolve symlinks while [[ -h "$script_location" ]]; do DIR="$(cd -P "$( dirname "$script_location")" >/dev/null && pwd)" script_location="$(readlink "$script_location")" [[ "$script_location" != /* ]] && script_location="$DIR/$script_location" done cd -P "$(dirname "$script_location")" >/dev/null && pwd}
# So that users can run this script from anywhere and it will work as expected.SCRIPT_LOCATION="$(script_location)"# Sets the Flutter root to be "$(script_location)/../..": This script assumes# that it resides two directory levels down from the root, so if that changes,# then this line will need to as well.FLUTTER_ROOT="$(dirname "$(dirname "$SCRIPT_LOCATION")")"export FLUTTER_ROOT
echo "$(date): Running docs.sh"
if [[ ! -d "$FLUTTER_ROOT" || ! -f "$FLUTTER_ROOT/bin/flutter" ]]; then >&2 echo "Unable to locate the Flutter installation (using FLUTTER_ROOT: $FLUTTER_ROOT)" exit 1fi
FLUTTER_BIN="$FLUTTER_ROOT/bin"DART_BIN="$FLUTTER_ROOT/bin/cache/dart-sdk/bin"FLUTTER="$FLUTTER_BIN/flutter"DART="$DART_BIN/dart"PATH="$FLUTTER_BIN:$DART_BIN:$PATH"
# Make sure dart is installed by invoking Flutter to download it if it is missing.# Also make sure the flutter command is ready to run before capturing output from# it: if it has to rebuild itself or something, it'll spoil our JSON output."$FLUTTER" > /dev/null 2>&1FLUTTER_VERSION="$("$FLUTTER" --version --machine)"export FLUTTER_VERSION
# If the pub cache directory exists in the root, then use that.FLUTTER_PUB_CACHE="$FLUTTER_ROOT/.pub-cache"if [[ -d "$FLUTTER_PUB_CACHE" ]]; then # This has to be exported, because pub interprets setting it to the empty # string in the same way as setting it to ".". PUB_CACHE="${PUB_CACHE:-"$FLUTTER_PUB_CACHE"}" export PUB_CACHEfi
function usage() { echo "Usage: $(basename "${BASH_SOURCE[0]}") [--keep-temp] [--output <output.zip>]" echo "" echo " --keep-staging Do not delete the staging directory created while generating" echo " docs. Normally the script deletes the staging directory after" echo " generating the output ZIP file." echo " --output <output.zip> specifies where the output ZIP file containing the documentation" echo " data will be written." echo " --staging-dir <directory> specifies where the temporary output files will be written while" echo " generating docs. This directory will be deleted after generation" echo " unless --keep-staging is also specified." echo ""}
function parse_args() { local arg local args=() STAGING_DIR= KEEP_STAGING=0 DESTINATION="$FLUTTER_ROOT/dev/docs/api_docs.zip" while (( "$#" )); do case "$1" in --help) usage exit 0 ;; --staging-dir) STAGING_DIR="$2" shift ;; --keep-staging) KEEP_STAGING=1 ;; --output) DESTINATION="$2" shift ;; *) args=("${args[@]}" "$1") ;; esac shift done if [[ -z $STAGING_DIR ]]; then STAGING_DIR=$(mktemp -d /tmp/dartdoc.XXXXX) fi DOC_DIR="$STAGING_DIR/doc" if [[ ${#args[@]} != 0 ]]; then >&2 echo "ERROR: Unknown arguments: ${args[@]}" usage exit 1 fi}
function generate_docs() { # Install and activate dartdoc. # When updating to a new dartdoc version, please also update # `dartdoc_options.yaml` to include newly introduced error and warning types. "$DART" pub global activate dartdoc 8.0.2
# Install and activate the snippets tool, which resides in the # assets-for-api-docs repo: # https://github.com/flutter/assets-for-api-docs/tree/master/packages/snippets "$DART" pub global activate snippets 0.4.0
# This script generates a unified doc set, and creates # a custom index.html, placing everything into DOC_DIR.
# Make sure that create_api_docs.dart has all the dependencies it needs. (cd "$FLUTTER_ROOT/dev/tools" && "$FLUTTER" pub get) (cd "$FLUTTER_ROOT" && "$DART" --disable-dart-dev --enable-asserts "$FLUTTER_ROOT/dev/tools/create_api_docs.dart" --output-dir="$DOC_DIR")}
function main() { echo "Writing docs build temporary output to $DOC_DIR" mkdir -p "$DOC_DIR" generate_docs # If the destination isn't an absolute path, make it into one. if ! [[ "$DESTINATION" =~ ^/ ]]; then DESTINATION="$PWD/$DESTINATION" fi
# Make sure the destination has .zip as an extension, because zip will add it # anyhow, and we want to print the correct output location. DESTINATION=${DESTINATION%.zip}.zip
# Zip up doc directory and write the output to the destination. (cd "$STAGING_DIR"; zip -r -9 -q "$DESTINATION" ./doc) if [[ $KEEP_STAGING -eq 1 ]]; then echo "Staging documentation output left in $STAGING_DIR" else echo "Removing staging documentation output from $STAGING_DIR" rm -rf "$STAGING_DIR" fi echo "Wrote docs ZIP file to $DESTINATION"}
parse_args "$@"main123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157// Copyright 2014 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:convert';import 'dart:io';import 'package:intl/intl.dart';import 'package:meta/meta.dart';
import 'package:path/path.dart' as path;import 'package:platform/platform.dart' as platform;
import 'package:process/process.dart';
class CommandException implements Exception {}
Future<void> main() async { await postProcess();}
/// Post-processes an APIs documentation zip file to modify the footer and version/// strings for commits promoted to either beta or stable channels.Future<void> postProcess() async { final String revision = await gitRevision(fullLength: true); print('Docs revision being processed: $revision'); final Directory tmpFolder = Directory.systemTemp.createTempSync(); final String zipDestination = path.join(tmpFolder.path, 'api_docs.zip');
if (!Platform.environment.containsKey('SDK_CHECKOUT_PATH')) { print('SDK_CHECKOUT_PATH env variable is required for this script'); exit(1); } final String checkoutPath = Platform.environment['SDK_CHECKOUT_PATH']!; final String docsPath = path.join(checkoutPath, 'dev', 'docs'); await runProcessWithValidations( <String>[ 'curl', '-L', 'https://storage.googleapis.com/flutter_infra_release/flutter/$revision/api_docs.zip', '--output', zipDestination, '--fail', ], docsPath, );
// Unzip to docs folder. await runProcessWithValidations( <String>[ 'unzip', '-o', zipDestination, ], docsPath, );
// Generate versions file. await runProcessWithValidations( <String>['flutter', '--version'], docsPath, ); final File versionFile = File('version'); final String version = versionFile.readAsStringSync(); // Recreate footer final String publishPath = path.join(docsPath, '..', 'docs', 'doc', 'flutter', 'footer.js'); final File footerFile = File(publishPath)..createSync(recursive: true); createFooter(footerFile, version);}
/// Gets the git revision of the current checkout. [fullLength] if true will return/// the full commit hash, if false it will return the first 10 characters only.Future<String> gitRevision({ bool fullLength = false, @visibleForTesting platform.Platform platform = const platform.LocalPlatform(), @visibleForTesting ProcessManager processManager = const LocalProcessManager(),}) async { const int kGitRevisionLength = 10;
final ProcessResult gitResult = processManager.runSync(<String>['git', 'rev-parse', 'HEAD']); if (gitResult.exitCode != 0) { throw 'git rev-parse exit with non-zero exit code: ${gitResult.exitCode}'; } final String gitRevision = (gitResult.stdout as String).trim(); if (fullLength) { return gitRevision; } return gitRevision.length > kGitRevisionLength ? gitRevision.substring(0, kGitRevisionLength) : gitRevision;}
/// Wrapper function to run a subprocess checking exit code and printing stderr and stdout./// [executable] is a string with the script/binary to execute, [args] is the list of flags/arguments/// and [workingDirectory] is as string to the working directory where the subprocess will be run.Future<void> runProcessWithValidations( List<String> command, String workingDirectory, { @visibleForTesting ProcessManager processManager = const LocalProcessManager(), bool verbose = true,}) async { final ProcessResult result = processManager.runSync(command, stdoutEncoding: utf8, workingDirectory: workingDirectory); if (result.exitCode == 0) { if (verbose) { print('stdout: ${result.stdout}'); } } else { if (verbose) { print('stderr: ${result.stderr}'); } throw CommandException(); }}
/// Get the name of the release branch.////// On LUCI builds, the git HEAD is detached, so first check for the env/// variable "LUCI_BRANCH"; if it is not set, fall back to calling git.Future<String> getBranchName({ @visibleForTesting platform.Platform platform = const platform.LocalPlatform(), @visibleForTesting ProcessManager processManager = const LocalProcessManager(),}) async { final RegExp gitBranchRegexp = RegExp(r'^## (.*)'); final String? luciBranch = platform.environment['LUCI_BRANCH']; if (luciBranch != null && luciBranch.trim().isNotEmpty) { return luciBranch.trim(); } final ProcessResult gitResult = processManager.runSync(<String>['git', 'status', '-b', '--porcelain']); if (gitResult.exitCode != 0) { throw 'git status exit with non-zero exit code: ${gitResult.exitCode}'; } final RegExpMatch? gitBranchMatch = gitBranchRegexp.firstMatch((gitResult.stdout as String).trim().split('\n').first); return gitBranchMatch == null ? '' : gitBranchMatch.group(1)!.split('...').first;}
/// Updates the footer of the api documentation with the correct branch and versions./// [footerPath] is the path to the location of the footer js file and [version] is a/// string with the version calculated by the flutter tool.Future<void> createFooter(File footerFile, String version, {@visibleForTesting String? timestampParam, @visibleForTesting String? branchParam, @visibleForTesting String? revisionParam}) async { final String timestamp = timestampParam ?? DateFormat('yyyy-MM-dd HH:mm').format(DateTime.now()); final String gitBranch = branchParam ?? await getBranchName(); final String revision = revisionParam ?? await gitRevision(); final String gitBranchOut = gitBranch.isEmpty ? '' : '• $gitBranch'; footerFile.writeAsStringSync('''(function() { var span = document.querySelector('footer>span'); if (span) { span.innerText = 'Flutter $version • $timestamp • $revision $gitBranchOut'; } var sourceLink = document.querySelector('a.source-link'); if (sourceLink) { sourceLink.href = sourceLink.href.replace('/master/', '/$revision/'); }})();''');}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164// Copyright 2014 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:async';import 'dart:io' show exit, stderr;
import 'package:args/args.dart';import 'package:file/file.dart';import 'package:file/local.dart';
import 'prepare_package/archive_creator.dart';import 'prepare_package/archive_publisher.dart';import 'prepare_package/common.dart';
const FileSystem fs = LocalFileSystem();
/// Prepares a flutter git repo to be packaged up for distribution. It mainly/// serves to populate the .pub-preload-cache with any appropriate Dart/// packages, and the flutter cache in bin/cache with the appropriate/// dependencies and snapshots.////// Archives contain the executables and customizations for the platform that/// they are created on.Future<void> main(List<String> rawArguments) async { final ArgParser argParser = ArgParser(); argParser.addOption( 'temp_dir', help: 'A location where temporary files may be written. Defaults to a ' 'directory in the system temp folder. Will write a few GiB of data, ' 'so it should have sufficient free space. If a temp_dir is not ' 'specified, then the default temp_dir will be created, used, and ' 'removed automatically.', ); argParser.addOption('revision', help: 'The Flutter git repo revision to build the ' 'archive with. Must be the full 40-character hash. Required.'); argParser.addOption( 'branch', allowed: Branch.values.map<String>((Branch branch) => branch.name), help: 'The Flutter branch to build the archive with. Required.', ); argParser.addOption( 'output', help: 'The path to the directory where the output archive should be ' 'written. If --output is not specified, the archive will be written to ' "the current directory. If the output directory doesn't exist, it, and " 'the path to it, will be created.', ); argParser.addFlag( 'publish', help: 'If set, will publish the archive to Google Cloud Storage upon ' 'successful creation of the archive. Will publish under this ' 'directory: $baseUrl$releaseFolder', ); argParser.addFlag( 'force', abbr: 'f', help: 'Overwrite a previously uploaded package.', ); argParser.addFlag( 'dry_run', negatable: false, help: 'Prints gsutil commands instead of executing them.', ); argParser.addFlag( 'help', negatable: false, help: 'Print help for this command.', );
final ArgResults parsedArguments = argParser.parse(rawArguments);
if (parsedArguments['help'] as bool) { print(argParser.usage); exit(0); }
void errorExit(String message, {int exitCode = -1}) { stderr.write('Error: $message\n\n'); stderr.write('${argParser.usage}\n'); exit(exitCode); }
if (!parsedArguments.wasParsed('revision')) { errorExit('Invalid argument: --revision must be specified.'); } final String revision = parsedArguments['revision'] as String; if (revision.length != 40) { errorExit('Invalid argument: --revision must be the entire hash, not just a prefix.'); }
if (!parsedArguments.wasParsed('branch')) { errorExit('Invalid argument: --branch must be specified.'); }
final String? tempDirArg = parsedArguments['temp_dir'] as String?; final Directory tempDir; bool removeTempDir = false; if (tempDirArg == null || tempDirArg.isEmpty) { tempDir = fs.systemTempDirectory.createTempSync('flutter_package.'); removeTempDir = true; } else { tempDir = fs.directory(tempDirArg); if (!tempDir.existsSync()) { errorExit("Temporary directory $tempDirArg doesn't exist."); } }
final Directory outputDir; if (parsedArguments['output'] == null) { outputDir = tempDir; } else { outputDir = fs.directory(parsedArguments['output'] as String); if (!outputDir.existsSync()) { outputDir.createSync(recursive: true); } }
final bool publish = parsedArguments['publish'] as bool; final bool dryRun = parsedArguments['dry_run'] as bool; final Branch branch = Branch.values.byName(parsedArguments['branch'] as String); final ArchiveCreator creator = ArchiveCreator( tempDir, outputDir, revision, branch, fs: fs, strict: publish && !dryRun, ); int exitCode = 0; late String message; try { final Map<String, String> version = await creator.initializeRepo(); final File outputFile = await creator.createArchive(); final ArchivePublisher publisher = ArchivePublisher( tempDir, revision, branch, version, outputFile, dryRun, fs: fs, ); await publisher.generateLocalMetadata(); if (parsedArguments['publish'] as bool) { await publisher.publishArchive(parsedArguments['force'] as bool); } } on PreparePackageException catch (e) { exitCode = e.exitCode; message = e.message; } catch (e) { exitCode = -1; message = e.toString(); } finally { if (removeTempDir) { tempDir.deleteSync(recursive: true); } if (exitCode != 0) { errorExit(message, exitCode: exitCode); } exit(0); }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524# Generated by pub# See https://dart.dev/tools/pub/glossary#lockfilepackages: _discoveryapis_commons: dependency: "direct main" description: name: _discoveryapis_commons sha256: f8bb1fdbd77f3d5c1d62b5b0eca75fbf1e41bf4f6c62628f880582e2182ae45d url: "https://pub.dev" source: hosted version: "1.0.6" _fe_analyzer_shared: dependency: "direct main" description: name: _fe_analyzer_shared sha256: "36a321c3d2cbe01cbcb3540a87b8843846e0206df3e691fa7b23e19e78de6d49" url: "https://pub.dev" source: hosted version: "65.0.0" analyzer: dependency: "direct main" description: name: analyzer sha256: dfe03b90ec022450e22513b5e5ca1f01c0c01de9c3fba2f7fd233cb57a6b9a07 url: "https://pub.dev" source: hosted version: "6.3.0" archive: dependency: "direct main" description: name: archive sha256: "80e5141fafcb3361653ce308776cfd7d45e6e9fbb429e14eec571382c0c5fecb" url: "https://pub.dev" source: hosted version: "3.3.2" args: dependency: "direct main" description: name: args sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 url: "https://pub.dev" source: hosted version: "2.4.2" async: dependency: "direct main" description: name: async sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted version: "2.11.0" boolean_selector: dependency: "direct main" description: name: boolean_selector sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" url: "https://pub.dev" source: hosted version: "2.1.1" checked_yaml: dependency: "direct main" description: name: checked_yaml sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff url: "https://pub.dev" source: hosted version: "2.0.3" clock: dependency: "direct main" description: name: clock sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf url: "https://pub.dev" source: hosted version: "1.1.1" collection: dependency: "direct main" description: name: collection sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted version: "1.18.0" convert: dependency: "direct main" description: name: convert sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" url: "https://pub.dev" source: hosted version: "3.1.1" coverage: dependency: "direct main" description: name: coverage sha256: "8acabb8306b57a409bf4c83522065672ee13179297a6bb0cb9ead73948df7c76" url: "https://pub.dev" source: hosted version: "1.7.2" crypto: dependency: "direct main" description: name: crypto sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab url: "https://pub.dev" source: hosted version: "3.0.3" file: dependency: "direct main" description: name: file sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" url: "https://pub.dev" source: hosted version: "7.0.0" flutter_devicelab: dependency: "direct main" description: path: "../devicelab" relative: true source: path version: "0.0.0" frontend_server_client: dependency: "direct main" description: name: frontend_server_client sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612" url: "https://pub.dev" source: hosted version: "3.2.0" gcloud: dependency: "direct main" description: name: gcloud sha256: "94cc7901dba3bcc9cd1c0530caf2d87e733392ce8f93734ccb23d82ef9f2a3e2" url: "https://pub.dev" source: hosted version: "0.8.11" glob: dependency: "direct main" description: name: glob sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" url: "https://pub.dev" source: hosted version: "2.1.2" googleapis: dependency: "direct main" description: name: googleapis sha256: d738182a9fb1143910abc2301c2041c7c4e294e4701db69a65a2ecf044ec57e1 url: "https://pub.dev" source: hosted version: "3.0.0" googleapis_auth: dependency: "direct main" description: name: googleapis_auth sha256: af7c3a3edf9d0de2e1e0a77e994fae0a581c525fa7012af4fa0d4a52ed9484da url: "https://pub.dev" source: hosted version: "1.4.1" http: dependency: "direct main" description: name: http sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2" url: "https://pub.dev" source: hosted version: "0.13.6" http_multi_server: dependency: "direct main" description: name: http_multi_server sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" url: "https://pub.dev" source: hosted version: "3.2.1" http_parser: dependency: "direct main" description: name: http_parser sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" url: "https://pub.dev" source: hosted version: "4.0.2" intl: dependency: "direct main" description: name: intl sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" url: "https://pub.dev" source: hosted version: "0.18.1" io: dependency: "direct main" description: name: io sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" url: "https://pub.dev" source: hosted version: "1.0.4" js: dependency: "direct main" description: name: js sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 url: "https://pub.dev" source: hosted version: "0.6.7" json_annotation: dependency: "direct main" description: name: json_annotation sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 url: "https://pub.dev" source: hosted version: "4.8.1" logging: dependency: "direct main" description: name: logging sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" url: "https://pub.dev" source: hosted version: "1.2.0" matcher: dependency: "direct main" description: name: matcher sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted version: "0.12.16+1" meta: dependency: "direct main" description: name: meta sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 url: "https://pub.dev" source: hosted version: "1.11.0" metrics_center: dependency: "direct main" description: name: metrics_center sha256: b72e1ce6f5bc7f9cedde6d8ddca842220977254dcc767eebf07a27ffad70883f url: "https://pub.dev" source: hosted version: "1.0.12" mime: dependency: "direct main" description: name: mime sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e url: "https://pub.dev" source: hosted version: "1.0.4" node_preamble: dependency: "direct main" description: name: node_preamble sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" url: "https://pub.dev" source: hosted version: "2.0.2" package_config: dependency: "direct main" description: name: package_config sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" url: "https://pub.dev" source: hosted version: "2.1.0" path: dependency: "direct main" description: name: path sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted version: "1.9.0" petitparser: dependency: "direct main" description: name: petitparser sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27 url: "https://pub.dev" source: hosted version: "6.0.2" platform: dependency: "direct main" description: name: platform sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec" url: "https://pub.dev" source: hosted version: "3.1.4" pool: dependency: "direct main" description: name: pool sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" url: "https://pub.dev" source: hosted version: "1.5.1" process: dependency: "direct main" description: name: process sha256: "21e54fd2faf1b5bdd5102afd25012184a6793927648ea81eea80552ac9405b32" url: "https://pub.dev" source: hosted version: "5.0.2" pub_semver: dependency: "direct main" description: name: pub_semver sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" url: "https://pub.dev" source: hosted version: "2.1.4" pubspec_parse: dependency: "direct main" description: name: pubspec_parse sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367 url: "https://pub.dev" source: hosted version: "1.2.3" retry: dependency: "direct main" description: name: retry sha256: "822e118d5b3aafed083109c72d5f484c6dc66707885e07c0fbcb8b986bba7efc" url: "https://pub.dev" source: hosted version: "3.1.2" shelf: dependency: "direct main" description: name: shelf sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 url: "https://pub.dev" source: hosted version: "1.4.1" shelf_packages_handler: dependency: "direct main" description: name: shelf_packages_handler sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" url: "https://pub.dev" source: hosted version: "3.0.2" shelf_static: dependency: "direct main" description: name: shelf_static sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e url: "https://pub.dev" source: hosted version: "1.1.2" shelf_web_socket: dependency: "direct main" description: name: shelf_web_socket sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" url: "https://pub.dev" source: hosted version: "1.0.4" source_map_stack_trace: dependency: "direct main" description: name: source_map_stack_trace sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae" url: "https://pub.dev" source: hosted version: "2.1.1" source_maps: dependency: "direct main" description: name: source_maps sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703" url: "https://pub.dev" source: hosted version: "0.10.12" source_span: dependency: "direct main" description: name: source_span sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" url: "https://pub.dev" source: hosted version: "1.10.0" stack_trace: dependency: "direct main" description: name: stack_trace sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted version: "1.11.1" standard_message_codec: dependency: "direct main" description: name: standard_message_codec sha256: fc7dd712d191b7e33196a0ecf354c4573492bb95995e7166cb6f73b047f9cae0 url: "https://pub.dev" source: hosted version: "0.0.1+4" stream_channel: dependency: "direct main" description: name: stream_channel sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted version: "2.1.2" string_scanner: dependency: "direct main" description: name: string_scanner sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" url: "https://pub.dev" source: hosted version: "1.2.0" term_glyph: dependency: "direct main" description: name: term_glyph sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 url: "https://pub.dev" source: hosted version: "1.2.1" test: dependency: "direct main" description: name: test sha256: a1f7595805820fcc05e5c52e3a231aedd0b72972cb333e8c738a8b1239448b6f url: "https://pub.dev" source: hosted version: "1.24.9" test_api: dependency: "direct dev" description: name: test_api sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" url: "https://pub.dev" source: hosted version: "0.6.1" test_core: dependency: "direct main" description: name: test_core sha256: a757b14fc47507060a162cc2530d9a4a2f92f5100a952c7443b5cad5ef5b106a url: "https://pub.dev" source: hosted version: "0.5.9" typed_data: dependency: "direct main" description: name: typed_data sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c url: "https://pub.dev" source: hosted version: "1.3.2" vm_service: dependency: "direct main" description: name: vm_service sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 url: "https://pub.dev" source: hosted version: "13.0.0" watcher: dependency: "direct main" description: name: watcher sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" url: "https://pub.dev" source: hosted version: "1.1.0" web: dependency: "direct main" description: name: web sha256: edc8a9573dd8c5a83a183dae1af2b6fd4131377404706ca4e5420474784906fa url: "https://pub.dev" source: hosted version: "0.4.0" web_socket_channel: dependency: "direct main" description: name: web_socket_channel sha256: "045ec2137c27bf1a32e6ffa0e734d532a6677bf9016a0d1a406c54e499ff945b" url: "https://pub.dev" source: hosted version: "2.4.1" webkit_inspection_protocol: dependency: "direct main" description: name: webkit_inspection_protocol sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572" url: "https://pub.dev" source: hosted version: "1.2.1" xml: dependency: "direct main" description: name: xml sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226 url: "https://pub.dev" source: hosted version: "6.5.0" yaml: dependency: "direct main" description: name: yaml sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" url: "https://pub.dev" source: hosted version: "3.1.2"sdks: dart: ">=3.2.0 <4.0.0"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778name: tests_on_botsdescription: Scripts which run on bots.
environment: sdk: '>=3.2.0-0 <4.0.0'
dependencies: analyzer: 6.3.0 args: 2.4.2 crypto: 3.0.3 intl: 0.18.1 file: 7.0.0 flutter_devicelab: path: ../devicelab http_parser: 4.0.2 meta: 1.11.0 path: 1.9.0 platform: 3.1.4 process: 5.0.2 test: 1.24.9
_discoveryapis_commons: 1.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" _fe_analyzer_shared: 65.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" archive: 3.3.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" async: 2.11.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" checked_yaml: 2.0.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" clock: 1.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.18.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 3.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" coverage: 1.7.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" frontend_server_client: 3.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" gcloud: 0.8.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" googleapis: 3.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" googleapis_auth: 1.4.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http: 0.13.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 3.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" json_annotation: 4.8.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" logging: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" matcher: 0.12.16+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" metrics_center: 1.0.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" node_preamble: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" package_config: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" petitparser: 6.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 2.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pubspec_parse: 1.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" retry: 3.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf: 1.4.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 3.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_static: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_web_socket: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_map_stack_trace: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_maps: 0.10.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.10.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.11.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" standard_message_codec: 0.0.1+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stream_channel: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" test_core: 0.5.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.3.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vm_service: 13.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" web: 0.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" web_socket_channel: 2.4.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" webkit_inspection_protocol: 1.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" xml: 6.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 3.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
dev_dependencies: test_api: 0.6.1
# PUBSPEC CHECKSUM: 65d5123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224// Copyright 2014 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:async';import 'dart:convert';import 'dart:core' hide print;import 'dart:io' as io;
import 'package:path/path.dart' as path;
import 'utils.dart';
/// Runs the `executable` and returns standard output as a stream of lines.////// The returned stream reaches its end immediately after the command exits.////// If `expectNonZeroExit` is false and the process exits with a non-zero exit/// code fails the test immediately by exiting the test process with exit code/// 1.Stream<String> runAndGetStdout(String executable, List<String> arguments, { String? workingDirectory, Map<String, String>? environment, bool expectNonZeroExit = false,}) async* { final StreamController<String> output = StreamController<String>(); final Future<CommandResult?> command = runCommand( executable, arguments, workingDirectory: workingDirectory, environment: environment, expectNonZeroExit: expectNonZeroExit, // Capture the output so it's not printed to the console by default. outputMode: OutputMode.capture, outputListener: (String line, io.Process process) { output.add(line); }, );
// Close the stream controller after the command is complete. Otherwise, // the yield* will never finish. command.whenComplete(output.close);
yield* output.stream;}
/// Represents a running process launched using [startCommand].class Command { Command._(this.process, this._time, this._savedStdout, this._savedStderr);
/// The raw process that was launched for this command. final io.Process process; final Stopwatch _time; final Future<String> _savedStdout; final Future<String> _savedStderr;}
/// The result of running a command using [startCommand] and [runCommand];class CommandResult { CommandResult._(this.exitCode, this.elapsedTime, this.flattenedStdout, this.flattenedStderr);
/// The exit code of the process. final int exitCode;
/// The amount of time it took the process to complete. final Duration elapsedTime;
/// Standard output decoded as a string using UTF8 decoder. final String? flattenedStdout;
/// Standard error output decoded as a string using UTF8 decoder. final String? flattenedStderr;}
/// Starts the `executable` and returns a command object representing the/// running process.////// `outputListener` is called for every line of standard output from the/// process, and is given the [Process] object. This can be used to interrupt/// an indefinitely running process, for example, by waiting until the process/// emits certain output.////// `outputMode` controls where the standard output from the command process/// goes. See [OutputMode].Future<Command> startCommand(String executable, List<String> arguments, { String? workingDirectory, Map<String, String>? environment, OutputMode outputMode = OutputMode.print, bool Function(String)? removeLine, void Function(String, io.Process)? outputListener,}) async { final String relativeWorkingDir = path.relative(workingDirectory ?? io.Directory.current.path); final String commandDescription = '${path.relative(executable, from: workingDirectory)} ${arguments.join(' ')}'; print('RUNNING: cd $cyan$relativeWorkingDir$reset; $green$commandDescription$reset');
final Stopwatch time = Stopwatch()..start(); print('workingDirectory: $workingDirectory, executable: $executable, arguments: $arguments'); final io.Process process = await io.Process.start(executable, arguments, workingDirectory: workingDirectory, environment: environment, ); return Command._( process, time, process.stdout .transform<String>(const Utf8Decoder()) .transform(const LineSplitter()) .where((String line) => removeLine == null || !removeLine(line)) .map<String>((String line) { final String formattedLine = '$line\n'; if (outputListener != null) { outputListener(formattedLine, process); } switch (outputMode) { case OutputMode.print: print(line); case OutputMode.capture: break; } return line; }) .join('\n'), process.stderr .transform<String>(const Utf8Decoder()) .transform(const LineSplitter()) .map<String>((String line) { switch (outputMode) { case OutputMode.print: print(line); case OutputMode.capture: break; } return line; }) .join('\n'), );}
/// Runs the `executable` and waits until the process exits.////// If the process exits with a non-zero exit code and `expectNonZeroExit` is/// false, calls foundError (which does not terminate execution!).////// `outputListener` is called for every line of standard output from the/// process, and is given the [Process] object. This can be used to interrupt/// an indefinitely running process, for example, by waiting until the process/// emits certain output.////// Returns the result of the finished process.////// `outputMode` controls where the standard output from the command process/// goes. See [OutputMode].Future<CommandResult> runCommand(String executable, List<String> arguments, { String? workingDirectory, Map<String, String>? environment, bool expectNonZeroExit = false, int? expectedExitCode, String? failureMessage, OutputMode outputMode = OutputMode.print, bool Function(String)? removeLine, void Function(String, io.Process)? outputListener,}) async { final String commandDescription = '${path.relative(executable, from: workingDirectory)} ${arguments.join(' ')}'; final String relativeWorkingDir = workingDirectory ?? path.relative(io.Directory.current.path);
final Command command = await startCommand(executable, arguments, workingDirectory: workingDirectory, environment: environment, outputMode: outputMode, removeLine: removeLine, outputListener: outputListener, );
final CommandResult result = CommandResult._( await command.process.exitCode, command._time.elapsed, await command._savedStdout, await command._savedStderr, );
if ((result.exitCode == 0) == expectNonZeroExit || (expectedExitCode != null && result.exitCode != expectedExitCode)) { // Print the output when we get unexpected results (unless output was // printed already). switch (outputMode) { case OutputMode.print: break; case OutputMode.capture: print(result.flattenedStdout); print(result.flattenedStderr); } final String allOutput = '${result.flattenedStdout}\n${result.flattenedStderr}'; foundError(<String>[ if (failureMessage != null) failureMessage, '${bold}Command: $green$commandDescription$reset', if (failureMessage == null) '$bold${red}Command exited with exit code ${result.exitCode} but expected ${expectNonZeroExit ? (expectedExitCode ?? 'non-zero') : 'zero'} exit code.$reset', '${bold}Working directory: $cyan${path.absolute(relativeWorkingDir)}$reset', if (allOutput.isNotEmpty && allOutput.length < 512) '${bold}stdout and stderr output:\n$allOutput', ]); } else { print('ELAPSED TIME: ${prettyPrintDuration(result.elapsedTime)} for $green$commandDescription$reset in $cyan$relativeWorkingDir$reset'); } return result;}
/// Specifies what to do with the command output from [runCommand] and [startCommand].enum OutputMode { /// Forwards standard output and standard error streams to the test process' /// standard output stream (i.e. stderr is redirected to stdout). /// /// Use this mode if all you want is print the output of the command to the /// console. The output is no longer available after the process exits. print,
/// Saves standard output and standard error streams in memory. /// /// Captured output can be retrieved from the [CommandResult] object. /// /// Use this mode in tests that need to inspect the output of a command, or /// when the output should not be printed to console. capture,}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838// Copyright 2014 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:core' hide print;import 'dart:io' hide exit;
import 'package:path/path.dart' as path;import 'package:shelf/shelf.dart';
import 'browser.dart';import 'run_command.dart';import 'test/common.dart';import 'utils.dart';
final String _bat = Platform.isWindows ? '.bat' : '';final String _flutterRoot = path.dirname(path.dirname(path.dirname(path.fromUri(Platform.script))));final String _flutter = path.join(_flutterRoot, 'bin', 'flutter$_bat');final String _testAppDirectory = path.join(_flutterRoot, 'dev', 'integration_tests', 'web');final String _testAppWebDirectory = path.join(_testAppDirectory, 'web');final String _appBuildDirectory = path.join(_testAppDirectory, 'build', 'web');final String _target = path.join('lib', 'service_worker_test.dart');final String _targetWithCachedResources = path.join('lib', 'service_worker_test_cached_resources.dart');final String _targetWithBlockedServiceWorkers = path.join('lib', 'service_worker_test_blocked_service_workers.dart');final String _targetPath = path.join(_testAppDirectory, _target);
enum ServiceWorkerTestType { // Mocks how FF disables service workers. blockedServiceWorkers, // Drops the main.dart.js directly on the page. withoutFlutterJs, // Uses the standard, promise-based, flutterJS initialization. withFlutterJs, // Uses the shorthand engineInitializer.autoStart(); withFlutterJsShort, // Uses onEntrypointLoaded callback instead of returned promise. withFlutterJsEntrypointLoadedEvent, // Same as withFlutterJsEntrypointLoadedEvent, but with TrustedTypes enabled. withFlutterJsTrustedTypesOn, // Same as withFlutterJsEntrypointLoadedEvent, but with nonce required. withFlutterJsNonceOn, // Uses custom serviceWorkerVersion. withFlutterJsCustomServiceWorkerVersion, // Entrypoint generated by `flutter create`. generatedEntrypoint,}
// Run a web service worker test as a standalone Dart program.Future<void> main() async { // When updating this list, also update `dev/bots/test.dart`. This `main()` // function is only here for convenience. Adding tests here will not add them // to LUCI. await runWebServiceWorkerTest(headless: false, testType: ServiceWorkerTestType.withoutFlutterJs); await runWebServiceWorkerTest(headless: false, testType: ServiceWorkerTestType.withFlutterJs); await runWebServiceWorkerTest(headless: false, testType: ServiceWorkerTestType.withFlutterJsShort); await runWebServiceWorkerTest(headless: false, testType: ServiceWorkerTestType.withFlutterJsEntrypointLoadedEvent); await runWebServiceWorkerTest(headless: false, testType: ServiceWorkerTestType.withFlutterJsTrustedTypesOn); await runWebServiceWorkerTest(headless: false, testType: ServiceWorkerTestType.withFlutterJsNonceOn); await runWebServiceWorkerTestWithCachingResources(headless: false, testType: ServiceWorkerTestType.withoutFlutterJs); await runWebServiceWorkerTestWithCachingResources(headless: false, testType: ServiceWorkerTestType.withFlutterJs); await runWebServiceWorkerTestWithCachingResources(headless: false, testType: ServiceWorkerTestType.withFlutterJsShort); await runWebServiceWorkerTestWithCachingResources(headless: false, testType: ServiceWorkerTestType.withFlutterJsEntrypointLoadedEvent); await runWebServiceWorkerTestWithCachingResources(headless: false, testType: ServiceWorkerTestType.withFlutterJsTrustedTypesOn); await runWebServiceWorkerTestWithGeneratedEntrypoint(headless: false); await runWebServiceWorkerTestWithBlockedServiceWorkers(headless: false); await runWebServiceWorkerTestWithCustomServiceWorkerVersion(headless: false);
if (hasError) { reportErrorsAndExit('${bold}One or more tests failed.$reset'); } reportSuccessAndExit('${bold}Tests successful.$reset');}
// Regression test for https://github.com/flutter/flutter/issues/109093.//// Tests the entrypoint that's generated by `flutter create`.Future<void> runWebServiceWorkerTestWithGeneratedEntrypoint({ required bool headless,}) async { await _generateEntrypoint(); await runWebServiceWorkerTestWithCachingResources(headless: headless, testType: ServiceWorkerTestType.generatedEntrypoint);}
Future<void> _generateEntrypoint() async { final Directory tempDirectory = Directory.systemTemp.createTempSync('flutter_web_generated_entrypoint.'); await runCommand( _flutter, <String>[ 'create', 'generated_entrypoint_test' ], workingDirectory: tempDirectory.path, ); final File generatedEntrypoint = File(path.join(tempDirectory.path, 'generated_entrypoint_test', 'web', 'index.html')); final String generatedEntrypointCode = generatedEntrypoint.readAsStringSync(); final File testEntrypoint = File(path.join( _testAppWebDirectory, _testTypeToIndexFile(ServiceWorkerTestType.generatedEntrypoint), )); testEntrypoint.writeAsStringSync(generatedEntrypointCode); tempDirectory.deleteSync(recursive: true);}
Future<void> _setAppVersion(int version) async { final File targetFile = File(_targetPath); await targetFile.writeAsString( (await targetFile.readAsString()).replaceFirst( RegExp(r'CLOSE\?version=\d+'), 'CLOSE?version=$version', ) );}
String _testTypeToIndexFile(ServiceWorkerTestType type) { return switch (type) { ServiceWorkerTestType.blockedServiceWorkers => 'index_with_blocked_service_workers.html', ServiceWorkerTestType.withFlutterJs => 'index_with_flutterjs.html', ServiceWorkerTestType.withoutFlutterJs => 'index_without_flutterjs.html', ServiceWorkerTestType.withFlutterJsShort => 'index_with_flutterjs_short.html', ServiceWorkerTestType.withFlutterJsEntrypointLoadedEvent => 'index_with_flutterjs_entrypoint_loaded.html', ServiceWorkerTestType.withFlutterJsTrustedTypesOn => 'index_with_flutterjs_el_tt_on.html', ServiceWorkerTestType.withFlutterJsNonceOn => 'index_with_flutterjs_el_nonce.html', ServiceWorkerTestType.withFlutterJsCustomServiceWorkerVersion => 'index_with_flutterjs_custom_sw_version.html', ServiceWorkerTestType.generatedEntrypoint => 'generated_entrypoint.html', };}
Future<void> _rebuildApp({ required int version, required ServiceWorkerTestType testType, required String target }) async { await _setAppVersion(version); await runCommand( _flutter, <String>[ 'clean' ], workingDirectory: _testAppDirectory, ); await runCommand( 'cp', <String>[ _testTypeToIndexFile(testType), 'index.html', ], workingDirectory: _testAppWebDirectory, ); await runCommand( _flutter, <String>['build', 'web', '--web-resources-cdn', '--profile', '-t', target], workingDirectory: _testAppDirectory, environment: <String, String>{ 'FLUTTER_WEB': 'true', }, );}
void _expectRequestCounts( Map<String, int> expectedCounts, Map<String, int> requestedPathCounts,) { expect(requestedPathCounts, expectedCounts); requestedPathCounts.clear();}
Future<void> _waitForAppToLoad( Map<String, int> waitForCounts, Map<String, int> requestedPathCounts, AppServer? server) async { print('Waiting for app to load $waitForCounts'); await Future.any(<Future<Object?>>[ () async { while (!waitForCounts.entries.every((MapEntry<String, int> entry) => (requestedPathCounts[entry.key] ?? 0) >= entry.value)) { await Future<void>.delayed(const Duration(milliseconds: 100)); } }(), server!.onChromeError.then((String error) { throw Exception('Chrome error: $error'); }), ]);}
/// A drop-in replacement for `package:test` expect that can run outside the/// test zone.void expect(Object? actual, Object? expected) { final Matcher matcher = wrapMatcher(expected); // matchState needs to be of type <Object?, Object?>, see https://github.com/flutter/flutter/issues/99522 final Map<Object?, Object?> matchState = <Object?, Object?>{}; if (matcher.matches(actual, matchState)) { return; } final StringDescription mismatchDescription = StringDescription(); matcher.describeMismatch(actual, mismatchDescription, matchState, true); throw TestFailure(mismatchDescription.toString());}
Future<void> runWebServiceWorkerTest({ required bool headless, required ServiceWorkerTestType testType,}) async { final Map<String, int> requestedPathCounts = <String, int>{}; void expectRequestCounts(Map<String, int> expectedCounts) => _expectRequestCounts(expectedCounts, requestedPathCounts);
AppServer? server; Future<void> waitForAppToLoad(Map<String, int> waitForCounts) async => _waitForAppToLoad(waitForCounts, requestedPathCounts, server);
String? reportedVersion;
Future<void> startAppServer({ required String cacheControl, }) async { final int serverPort = await findAvailablePortAndPossiblyCauseFlakyTests(); final int browserDebugPort = await findAvailablePortAndPossiblyCauseFlakyTests(); server = await AppServer.start( headless: headless, cacheControl: cacheControl, // TODO(yjbanov): use a better port disambiguation strategy than trying // to guess what ports other tests use. appUrl: 'http://localhost:$serverPort/index.html', serverPort: serverPort, browserDebugPort: browserDebugPort, appDirectory: _appBuildDirectory, additionalRequestHandlers: <Handler>[ (Request request) { final String requestedPath = request.url.path; requestedPathCounts.putIfAbsent(requestedPath, () => 0); requestedPathCounts[requestedPath] = requestedPathCounts[requestedPath]! + 1; if (requestedPath == 'CLOSE') { reportedVersion = request.url.queryParameters['version']; return Response.ok('OK'); } return Response.notFound(''); }, ], ); }
// Preserve old index.html as index_og.html so we can restore it later for other tests await runCommand( 'mv', <String>[ 'index.html', 'index_og.html', ], workingDirectory: _testAppWebDirectory, );
final bool shouldExpectFlutterJs = testType != ServiceWorkerTestType.withoutFlutterJs;
print('BEGIN runWebServiceWorkerTest(headless: $headless, testType: $testType)');
try { ///// // Attempt to load a different version of the service worker! ///// await _rebuildApp(version: 1, testType: testType, target: _target);
print('Call update() on the current web worker'); await startAppServer(cacheControl: 'max-age=0'); await waitForAppToLoad(<String, int> { if (shouldExpectFlutterJs) 'flutter.js': 1, 'CLOSE': 1, }); expect(reportedVersion, '1'); reportedVersion = null;
await server!.chrome.reloadPage(ignoreCache: true); await waitForAppToLoad(<String, int> { if (shouldExpectFlutterJs) 'flutter.js': 2, 'CLOSE': 2, }); expect(reportedVersion, '1'); reportedVersion = null;
await _rebuildApp(version: 2, testType: testType, target: _target);
await server!.chrome.reloadPage(ignoreCache: true); await waitForAppToLoad(<String, int>{ if (shouldExpectFlutterJs) 'flutter.js': 3, 'CLOSE': 3, }); expect(reportedVersion, '2');
reportedVersion = null; requestedPathCounts.clear(); await server!.stop();
////////////////////////////////////////////////////// // Caching server ////////////////////////////////////////////////////// await _rebuildApp(version: 1, testType: testType, target: _target);
print('With cache: test first page load'); await startAppServer(cacheControl: 'max-age=3600'); await waitForAppToLoad(<String, int>{ 'CLOSE': 1, 'flutter_service_worker.js': 1, });
expectRequestCounts(<String, int>{ // Even though the server is caching index.html is downloaded twice, // once by the initial page load, and once by the service worker. // Other resources are loaded once only by the service worker. 'index.html': 2, if (shouldExpectFlutterJs) 'flutter.js': 1, 'main.dart.js': 1, 'flutter_service_worker.js': 1, 'assets/FontManifest.json': 1, 'assets/AssetManifest.bin.json': 1, 'assets/fonts/MaterialIcons-Regular.otf': 1, 'CLOSE': 1, // In headless mode Chrome does not load 'manifest.json' and 'favicon.ico'. if (!headless) ...<String, int>{ 'manifest.json': 1, 'favicon.ico': 1, }, }); expect(reportedVersion, '1'); reportedVersion = null;
print('With cache: test page reload'); await server!.chrome.reloadPage(); await waitForAppToLoad(<String, int>{ 'CLOSE': 1, 'flutter_service_worker.js': 1, });
expectRequestCounts(<String, int>{ 'flutter_service_worker.js': 1, 'CLOSE': 1, }); expect(reportedVersion, '1'); reportedVersion = null;
print('With cache: test page reload after rebuild'); await _rebuildApp(version: 2, testType: testType, target: _target);
// Since we're caching, we need to ignore cache when reloading the page. await server!.chrome.reloadPage(ignoreCache: true); await waitForAppToLoad(<String, int>{ 'CLOSE': 1, 'flutter_service_worker.js': 2, }); expectRequestCounts(<String, int>{ 'index.html': 2, if (shouldExpectFlutterJs) 'flutter.js': 1, 'flutter_service_worker.js': 2, 'main.dart.js': 1, 'assets/AssetManifest.bin.json': 1, 'assets/FontManifest.json': 1, 'CLOSE': 1, if (!headless) 'favicon.ico': 1, });
expect(reportedVersion, '2'); reportedVersion = null; await server!.stop();
////////////////////////////////////////////////////// // Non-caching server ////////////////////////////////////////////////////// print('No cache: test first page load'); await _rebuildApp(version: 3, testType: testType, target: _target); await startAppServer(cacheControl: 'max-age=0'); await waitForAppToLoad(<String, int>{ 'CLOSE': 1, 'flutter_service_worker.js': 1, });
expectRequestCounts(<String, int>{ 'index.html': 2, if (shouldExpectFlutterJs) 'flutter.js': 1, 'main.dart.js': 1, 'assets/FontManifest.json': 1, 'flutter_service_worker.js': 1, 'assets/AssetManifest.bin.json': 1, 'assets/fonts/MaterialIcons-Regular.otf': 1, 'CLOSE': 1, // In headless mode Chrome does not load 'manifest.json' and 'favicon.ico'. if (!headless) ...<String, int>{ 'manifest.json': 1, 'favicon.ico': 1, }, });
expect(reportedVersion, '3'); reportedVersion = null;
print('No cache: test page reload'); await server!.chrome.reloadPage(); await waitForAppToLoad(<String, int>{ 'CLOSE': 1, if (shouldExpectFlutterJs) 'flutter.js': 1, 'flutter_service_worker.js': 1, });
expectRequestCounts(<String, int>{ if (shouldExpectFlutterJs) 'flutter.js': 1, 'flutter_service_worker.js': 1, 'CLOSE': 1, if (!headless) 'manifest.json': 1, }); expect(reportedVersion, '3'); reportedVersion = null;
print('No cache: test page reload after rebuild'); await _rebuildApp(version: 4, testType: testType, target: _target);
// TODO(yjbanov): when running Chrome with DevTools protocol, for some // reason a hard refresh is still required. This works without a hard // refresh when running Chrome manually as normal. At the time of writing // this test I wasn't able to figure out what's wrong with the way we run // Chrome from tests. await server!.chrome.reloadPage(ignoreCache: true); await waitForAppToLoad(<String, int>{ 'CLOSE': 1, 'flutter_service_worker.js': 1, }); expectRequestCounts(<String, int>{ 'index.html': 2, if (shouldExpectFlutterJs) 'flutter.js': 1, 'flutter_service_worker.js': 2, 'main.dart.js': 1, 'assets/AssetManifest.bin.json': 1, 'assets/FontManifest.json': 1, 'CLOSE': 1, if (!headless) ...<String, int>{ 'manifest.json': 1, 'favicon.ico': 1, }, });
expect(reportedVersion, '4'); reportedVersion = null; } finally { await runCommand( 'mv', <String>[ 'index_og.html', 'index.html', ], workingDirectory: _testAppWebDirectory, ); await _setAppVersion(1); await server?.stop(); }
print('END runWebServiceWorkerTest(headless: $headless, testType: $testType)');}
Future<void> runWebServiceWorkerTestWithCachingResources({ required bool headless, required ServiceWorkerTestType testType}) async { final Map<String, int> requestedPathCounts = <String, int>{}; void expectRequestCounts(Map<String, int> expectedCounts) => _expectRequestCounts(expectedCounts, requestedPathCounts);
AppServer? server; Future<void> waitForAppToLoad(Map<String, int> waitForCounts) async => _waitForAppToLoad(waitForCounts, requestedPathCounts, server);
Future<void> startAppServer({ required String cacheControl, }) async { final int serverPort = await findAvailablePortAndPossiblyCauseFlakyTests(); final int browserDebugPort = await findAvailablePortAndPossiblyCauseFlakyTests(); server = await AppServer.start( headless: headless, cacheControl: cacheControl, // TODO(yjbanov): use a better port disambiguation strategy than trying // to guess what ports other tests use. appUrl: 'http://localhost:$serverPort/index.html', serverPort: serverPort, browserDebugPort: browserDebugPort, appDirectory: _appBuildDirectory, additionalRequestHandlers: <Handler>[ (Request request) { final String requestedPath = request.url.path; requestedPathCounts.putIfAbsent(requestedPath, () => 0); requestedPathCounts[requestedPath] = requestedPathCounts[requestedPath]! + 1; if (requestedPath == 'assets/fonts/MaterialIcons-Regular.otf') { return Response.internalServerError(); } return Response.notFound(''); }, ], ); }
// Preserve old index.html as index_og.html so we can restore it later for other tests await runCommand( 'mv', <String>[ 'index.html', 'index_og.html', ], workingDirectory: _testAppWebDirectory, );
final bool shouldExpectFlutterJs = testType != ServiceWorkerTestType.withoutFlutterJs;
print('BEGIN runWebServiceWorkerTestWithCachingResources(headless: $headless, testType: $testType)');
try { ////////////////////////////////////////////////////// // Caching server ////////////////////////////////////////////////////// await _rebuildApp(version: 1, testType: testType, target: _targetWithCachedResources);
print('With cache: test first page load'); await startAppServer(cacheControl: 'max-age=3600'); await waitForAppToLoad(<String, int>{ 'assets/fonts/MaterialIcons-Regular.otf': 1, 'flutter_service_worker.js': 1, });
expectRequestCounts(<String, int>{ // Even though the server is caching index.html is downloaded twice, // once by the initial page load, and once by the service worker. // Other resources are loaded once only by the service worker. 'index.html': 2, if (shouldExpectFlutterJs) 'flutter.js': 1, 'main.dart.js': 1, 'flutter_service_worker.js': 1, 'assets/FontManifest.json': 1, 'assets/AssetManifest.bin.json': 1, 'assets/fonts/MaterialIcons-Regular.otf': 1, // In headless mode Chrome does not load 'manifest.json' and 'favicon.ico'. if (!headless) ...<String, int>{ 'manifest.json': 1, 'favicon.ico': 1, }, });
print('With cache: test first page reload'); await server!.chrome.reloadPage(); await waitForAppToLoad(<String, int>{ 'assets/fonts/MaterialIcons-Regular.otf': 1, 'flutter_service_worker.js': 1, }); expectRequestCounts(<String, int>{ 'assets/fonts/MaterialIcons-Regular.otf': 1, 'flutter_service_worker.js': 1, });
print('With cache: test second page reload'); await server!.chrome.reloadPage(); await waitForAppToLoad(<String, int>{ 'assets/fonts/MaterialIcons-Regular.otf': 1, 'flutter_service_worker.js': 1, }); expectRequestCounts(<String, int>{ 'assets/fonts/MaterialIcons-Regular.otf': 1, 'flutter_service_worker.js': 1, });
print('With cache: test third page reload'); await server!.chrome.reloadPage(); await waitForAppToLoad(<String, int>{ 'assets/fonts/MaterialIcons-Regular.otf': 1, 'flutter_service_worker.js': 1, }); expectRequestCounts(<String, int>{ 'assets/fonts/MaterialIcons-Regular.otf': 1, 'flutter_service_worker.js': 1, });
print('With cache: test page reload after rebuild'); await _rebuildApp(version: 1, testType: testType, target: _targetWithCachedResources);
// Since we're caching, we need to ignore cache when reloading the page. await server!.chrome.reloadPage(ignoreCache: true); await waitForAppToLoad(<String, int>{ 'assets/fonts/MaterialIcons-Regular.otf': 1, 'flutter_service_worker.js': 1, }); expectRequestCounts(<String, int>{ 'index.html': 2, if (shouldExpectFlutterJs) 'flutter.js': 1, 'main.dart.js': 1, 'flutter_service_worker.js': 2, 'assets/FontManifest.json': 1, 'assets/AssetManifest.bin.json': 1, 'assets/fonts/MaterialIcons-Regular.otf': 1, // In headless mode Chrome does not load 'manifest.json' and 'favicon.ico'. if (!headless) ...<String, int>{ 'favicon.ico': 1, }, }); } finally { await runCommand( 'mv', <String>[ 'index_og.html', 'index.html', ], workingDirectory: _testAppWebDirectory, ); await server?.stop(); }
print('END runWebServiceWorkerTestWithCachingResources(headless: $headless, testType: $testType)');}
Future<void> runWebServiceWorkerTestWithBlockedServiceWorkers({ required bool headless}) async { final Map<String, int> requestedPathCounts = <String, int>{}; void expectRequestCounts(Map<String, int> expectedCounts) => _expectRequestCounts(expectedCounts, requestedPathCounts);
AppServer? server; Future<void> waitForAppToLoad(Map<String, int> waitForCounts) async => _waitForAppToLoad(waitForCounts, requestedPathCounts, server);
Future<void> startAppServer({ required String cacheControl, }) async { final int serverPort = await findAvailablePortAndPossiblyCauseFlakyTests(); final int browserDebugPort = await findAvailablePortAndPossiblyCauseFlakyTests(); server = await AppServer.start( headless: headless, cacheControl: cacheControl, // TODO(yjbanov): use a better port disambiguation strategy than trying // to guess what ports other tests use. appUrl: 'http://localhost:$serverPort/index.html', serverPort: serverPort, browserDebugPort: browserDebugPort, appDirectory: _appBuildDirectory, additionalRequestHandlers: <Handler>[ (Request request) { final String requestedPath = request.url.path; requestedPathCounts.putIfAbsent(requestedPath, () => 0); requestedPathCounts[requestedPath] = requestedPathCounts[requestedPath]! + 1; if (requestedPath == 'CLOSE') { return Response.ok('OK'); } return Response.notFound(''); }, ], ); }
// Preserve old index.html as index_og.html so we can restore it later for other tests await runCommand( 'mv', <String>[ 'index.html', 'index_og.html', ], workingDirectory: _testAppWebDirectory, );
print('BEGIN runWebServiceWorkerTestWithBlockedServiceWorkers(headless: $headless)'); try { await _rebuildApp(version: 1, testType: ServiceWorkerTestType.blockedServiceWorkers, target: _targetWithBlockedServiceWorkers);
print('Ensure app starts (when service workers are blocked)'); await startAppServer(cacheControl: 'max-age=3600'); await waitForAppToLoad(<String, int>{ 'CLOSE': 1, }); expectRequestCounts(<String, int>{ 'index.html': 1, 'flutter.js': 1, 'main.dart.js': 1, 'assets/FontManifest.json': 1, 'assets/fonts/MaterialIcons-Regular.otf': 1, 'CLOSE': 1, // In headless mode Chrome does not load 'manifest.json' and 'favicon.ico'. if (!headless) ...<String, int>{ 'manifest.json': 1, 'favicon.ico': 1, }, }); } finally { await runCommand( 'mv', <String>[ 'index_og.html', 'index.html', ], workingDirectory: _testAppWebDirectory, ); await server?.stop(); } print('END runWebServiceWorkerTestWithBlockedServiceWorkers(headless: $headless)');}
/// Regression test for https://github.com/flutter/flutter/issues/130212.Future<void> runWebServiceWorkerTestWithCustomServiceWorkerVersion({ required bool headless,}) async { final Map<String, int> requestedPathCounts = <String, int>{}; void expectRequestCounts(Map<String, int> expectedCounts) => _expectRequestCounts(expectedCounts, requestedPathCounts);
AppServer? server; Future<void> waitForAppToLoad(Map<String, int> waitForCounts) async => _waitForAppToLoad(waitForCounts, requestedPathCounts, server);
Future<void> startAppServer({ required String cacheControl, }) async { final int serverPort = await findAvailablePortAndPossiblyCauseFlakyTests(); final int browserDebugPort = await findAvailablePortAndPossiblyCauseFlakyTests(); server = await AppServer.start( headless: headless, cacheControl: cacheControl, // TODO(yjbanov): use a better port disambiguation strategy than trying // to guess what ports other tests use. appUrl: 'http://localhost:$serverPort/index.html', serverPort: serverPort, browserDebugPort: browserDebugPort, appDirectory: _appBuildDirectory, additionalRequestHandlers: <Handler>[ (Request request) { final String requestedPath = request.url.path; requestedPathCounts.putIfAbsent(requestedPath, () => 0); requestedPathCounts[requestedPath] = requestedPathCounts[requestedPath]! + 1; if (requestedPath == 'CLOSE') { return Response.ok('OK'); } return Response.notFound(''); }, ], ); }
// Preserve old index.html as index_og.html so we can restore it later for other tests await runCommand( 'mv', <String>[ 'index.html', 'index_og.html', ], workingDirectory: _testAppWebDirectory, );
print('BEGIN runWebServiceWorkerTestWithCustomServiceWorkerVersion(headless: $headless)'); try { await _rebuildApp(version: 1, testType: ServiceWorkerTestType.withFlutterJsCustomServiceWorkerVersion, target: _target);
print('Test page load'); await startAppServer(cacheControl: 'max-age=0'); await waitForAppToLoad(<String, int>{ 'CLOSE': 1, 'flutter_service_worker.js': 1, 'assets/fonts/MaterialIcons-Regular.otf': 1, }); expectRequestCounts(<String, int>{ 'index.html': 2, 'flutter.js': 1, 'main.dart.js': 1, 'CLOSE': 1, 'flutter_service_worker.js': 1, 'assets/FontManifest.json': 1, 'assets/AssetManifest.bin.json': 1, 'assets/fonts/MaterialIcons-Regular.otf': 1, // In headless mode Chrome does not load 'manifest.json' and 'favicon.ico'. if (!headless) ...<String, int>{ 'manifest.json': 1, 'favicon.ico': 1, }, });
print('Test page reload, ensure service worker is not reloaded'); await server!.chrome.reloadPage(ignoreCache: true); await waitForAppToLoad(<String, int>{ 'CLOSE': 1, 'flutter.js': 1, }); expectRequestCounts(<String, int>{ 'index.html': 1, 'flutter.js': 1, 'main.dart.js': 1, 'assets/FontManifest.json': 1, 'assets/fonts/MaterialIcons-Regular.otf': 1, 'CLOSE': 1, // In headless mode Chrome does not load 'manifest.json' and 'favicon.ico'. if (!headless) ...<String, int>{ 'manifest.json': 1, 'favicon.ico': 1, }, });
print('Test page reload after rebuild, ensure service worker is not reloaded'); await _rebuildApp(version: 1, testType: ServiceWorkerTestType.withFlutterJsCustomServiceWorkerVersion, target: _target); await server!.chrome.reloadPage(ignoreCache: true); await waitForAppToLoad(<String, int>{ 'CLOSE': 1, 'flutter.js': 1, }); expectRequestCounts(<String, int>{ 'index.html': 1, 'flutter.js': 1, 'main.dart.js': 1, 'assets/FontManifest.json': 1, 'assets/fonts/MaterialIcons-Regular.otf': 1, 'CLOSE': 1, // In headless mode Chrome does not load 'manifest.json' and 'favicon.ico'. if (!headless) ...<String, int>{ 'manifest.json': 1, 'favicon.ico': 1, }, }); } finally { await runCommand( 'mv', <String>[ 'index_og.html', 'index.html', ], workingDirectory: _testAppWebDirectory, ); await server?.stop(); } print('END runWebServiceWorkerTestWithCustomServiceWorkerVersion(headless: $headless)');}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102// Copyright 2014 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:convert';import 'dart:io';
class TestSpecs {
TestSpecs({ required this.path, required this.startTime, });
final String path; int startTime; int? _endTime;
int get milliseconds { return endTime - startTime; }
set endTime(int value) { _endTime = value; }
int get endTime { if (_endTime == null) { return 0; } return _endTime!; }
String toJson() { return json.encode( <String, String>{'path': path, 'runtime': milliseconds.toString()} ); }}
class TestFileReporterResults { TestFileReporterResults._({ required this.allTestSpecs, required this.hasFailedTests, required this.errors, });
/// Intended to parse the output file of `dart test --file-reporter json:file_name factory TestFileReporterResults.fromFile(File metrics) { if (!metrics.existsSync()) { throw Exception('${metrics.path} does not exist'); }
final Map<int, TestSpecs> testSpecs = <int, TestSpecs>{}; bool hasFailedTests = true; final List<String> errors = <String>[];
for (final String metric in metrics.readAsLinesSync()) { final Map<String, Object?> entry = json.decode(metric) as Map<String, Object?>; if (entry.containsKey('suite')) { final Map<String, Object?> suite = entry['suite']! as Map<String, Object?>; addTestSpec(suite, entry['time']! as int, testSpecs); } else if (isMetricDone(entry, testSpecs)) { final Map<String, Object?> group = entry['group']! as Map<String, Object?>; final int suiteID = group['suiteID']! as int; addMetricDone(suiteID, entry['time']! as int, testSpecs); } else if (entry.containsKey('error')) { final String stackTrace = entry.containsKey('stackTrace') ? entry['stackTrace']! as String : ''; errors.add('${entry['error']}\n $stackTrace'); } else if (entry.containsKey('success') && entry['success'] == true) { hasFailedTests = false; } }
return TestFileReporterResults._(allTestSpecs: testSpecs, hasFailedTests: hasFailedTests, errors: errors); }
final Map<int, TestSpecs> allTestSpecs; final bool hasFailedTests; final List<String> errors;
static void addTestSpec(Map<String, Object?> suite, int time, Map<int, TestSpecs> allTestSpecs) { allTestSpecs[suite['id']! as int] = TestSpecs( path: suite['path']! as String, startTime: time, ); }
static void addMetricDone(int suiteID, int time, Map<int, TestSpecs> allTestSpecs) { final TestSpecs testSpec = allTestSpecs[suiteID]!; testSpec.endTime = time; }
static bool isMetricDone(Map<String, Object?> entry, Map<int, TestSpecs> allTestSpecs) { if (entry.containsKey('group') && entry['type']! as String == 'group') { final Map<String, Object?> group = entry['group']! as Map<String, Object?>; return allTestSpecs.containsKey(group['suiteID']! as int); } return false; }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504// Copyright 2014 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.
/// This script removes published archives from the cloud storage and the/// corresponding JSON metadata file that the website uses to determine what/// releases are available.////// If asked to remove a release that is currently the release on that channel,/// it will replace that release with the next most recent release on that/// channel.library;
import 'dart:async';import 'dart:convert';import 'dart:io' hide Platform;
import 'package:args/args.dart';import 'package:path/path.dart' as path;import 'package:platform/platform.dart' show LocalPlatform, Platform;import 'package:process/process.dart';
const String gsBase = 'gs://flutter_infra_release';const String releaseFolder = '/releases';const String gsReleaseFolder = '$gsBase$releaseFolder';const String baseUrl = 'https://storage.googleapis.com/flutter_infra_release';
/// Exception class for when a process fails to run, so we can catch/// it and provide something more readable than a stack trace.class UnpublishException implements Exception { UnpublishException(this.message, [this.result]);
final String message; final ProcessResult? result; int get exitCode => result?.exitCode ?? -1;
@override String toString() { String output = runtimeType.toString(); output += ': $message'; final String stderr = result?.stderr as String? ?? ''; if (stderr.isNotEmpty) { output += ':\n$stderr'; } return output; }}
enum Channel { dev, beta, stable }
String getChannelName(Channel channel) { return switch (channel) { Channel.beta => 'beta', Channel.dev => 'dev', Channel.stable => 'stable', };}
Channel fromChannelName(String? name) { return switch (name) { 'beta' => Channel.beta, 'dev' => Channel.dev, 'stable' => Channel.stable, _ => throw ArgumentError('Invalid channel name.'), };}
enum PublishedPlatform { linux, macos, windows }
String getPublishedPlatform(PublishedPlatform platform) { return switch (platform) { PublishedPlatform.linux => 'linux', PublishedPlatform.macos => 'macos', PublishedPlatform.windows => 'windows', };}
PublishedPlatform fromPublishedPlatform(String name) { return switch (name) { 'linux' => PublishedPlatform.linux, 'macos' => PublishedPlatform.macos, 'windows' => PublishedPlatform.windows, _ => throw ArgumentError('Invalid published platform name.'), };}
/// A helper class for classes that want to run a process, optionally have the/// stderr and stdout reported as the process runs, and capture the stdout/// properly without dropping any.class ProcessRunner { /// Creates a [ProcessRunner]. /// /// The [processManager], [subprocessOutput], and [platform] arguments must /// not be null. ProcessRunner({ this.processManager = const LocalProcessManager(), this.subprocessOutput = true, this.defaultWorkingDirectory, this.platform = const LocalPlatform(), }) { environment = Map<String, String>.from(platform.environment); }
/// The platform to use for a starting environment. final Platform platform;
/// Set [subprocessOutput] to show output as processes run. Stdout from the /// process will be printed to stdout, and stderr printed to stderr. final bool subprocessOutput;
/// Set the [processManager] in order to inject a test instance to perform /// testing. final ProcessManager processManager;
/// Sets the default directory used when `workingDirectory` is not specified /// to [runProcess]. final Directory? defaultWorkingDirectory;
/// The environment to run processes with. late Map<String, String> environment;
/// Run the command and arguments in `commandLine` as a sub-process from /// `workingDirectory` if set, or the [defaultWorkingDirectory] if not. Uses /// [Directory.current] if [defaultWorkingDirectory] is not set. /// /// Set `failOk` if [runProcess] should not throw an exception when the /// command completes with a non-zero exit code. Future<String> runProcess( List<String> commandLine, { Directory? workingDirectory, bool failOk = false, }) async { workingDirectory ??= defaultWorkingDirectory ?? Directory.current; if (subprocessOutput) { stderr.write('Running "${commandLine.join(' ')}" in ${workingDirectory.path}.\n'); } final List<int> output = <int>[]; final Completer<void> stdoutComplete = Completer<void>(); final Completer<void> stderrComplete = Completer<void>(); late Process process; Future<int> allComplete() async { await stderrComplete.future; await stdoutComplete.future; return process.exitCode; }
try { process = await processManager.start( commandLine, workingDirectory: workingDirectory.absolute.path, environment: environment, ); process.stdout.listen( (List<int> event) { output.addAll(event); if (subprocessOutput) { stdout.add(event); } }, onDone: () async => stdoutComplete.complete(), ); if (subprocessOutput) { process.stderr.listen( (List<int> event) { stderr.add(event); }, onDone: () async => stderrComplete.complete(), ); } else { stderrComplete.complete(); } } on ProcessException catch (e) { final String message = 'Running "${commandLine.join(' ')}" in ${workingDirectory.path} ' 'failed with:\n$e'; throw UnpublishException(message); } on ArgumentError catch (e) { final String message = 'Running "${commandLine.join(' ')}" in ${workingDirectory.path} ' 'failed with:\n$e'; throw UnpublishException(message); }
final int exitCode = await allComplete(); if (exitCode != 0 && !failOk) { final String message = 'Running "${commandLine.join(' ')}" in ${workingDirectory.path} failed'; throw UnpublishException( message, ProcessResult(0, exitCode, null, 'returned $exitCode'), ); } return utf8.decoder.convert(output).trim(); }}
class ArchiveUnpublisher { ArchiveUnpublisher( this.tempDir, this.revisionsBeingRemoved, this.channels, this.platform, { this.confirmed = false, ProcessManager? processManager, bool subprocessOutput = true, }) : assert(revisionsBeingRemoved.length == 40), metadataGsPath = '$gsReleaseFolder/${getMetadataFilename(platform)}', _processRunner = ProcessRunner( processManager: processManager ?? const LocalProcessManager(), subprocessOutput: subprocessOutput, );
final PublishedPlatform platform; final String metadataGsPath; final Set<Channel> channels; final Set<String> revisionsBeingRemoved; final bool confirmed; final Directory tempDir; final ProcessRunner _processRunner; static String getMetadataFilename(PublishedPlatform platform) => 'releases_${getPublishedPlatform(platform)}.json';
/// Remove the archive from Google Storage. Future<void> unpublishArchive() async { final Map<String, dynamic> jsonData = await _loadMetadata(); final List<Map<String, String>> releases = (jsonData['releases'] as List<dynamic>).map<Map<String, String>>((dynamic entry) { final Map<String, dynamic> mapEntry = entry as Map<String, dynamic>; return mapEntry.cast<String, String>(); }).toList(); final Map<Channel, Map<String, String>> paths = await _getArchivePaths(releases); releases.removeWhere((Map<String, String> value) => revisionsBeingRemoved.contains(value['hash']) && channels.contains(fromChannelName(value['channel']))); releases.sort((Map<String, String> a, Map<String, String> b) { final DateTime aDate = DateTime.parse(a['release_date']!); final DateTime bDate = DateTime.parse(b['release_date']!); return bDate.compareTo(aDate); }); jsonData['releases'] = releases; for (final Channel channel in channels) { if (!revisionsBeingRemoved.contains((jsonData['current_release'] as Map<String, dynamic>)[getChannelName(channel)])) { // Don't replace the current release if it's not one of the revisions we're removing. continue; } final Map<String, String> replacementRelease = releases.firstWhere((Map<String, String> value) => value['channel'] == getChannelName(channel)); (jsonData['current_release'] as Map<String, dynamic>)[getChannelName(channel)] = replacementRelease['hash']; print( '${confirmed ? 'Reverting' : 'Would revert'} current ${getChannelName(channel)} ' '${getPublishedPlatform(platform)} release to ${replacementRelease['hash']} (version ${replacementRelease['version']}).' ); } await _cloudRemoveArchive(paths); await _updateMetadata(jsonData); }
Future<Map<Channel, Map<String, String>>> _getArchivePaths(List<Map<String, String>> releases) async { final Set<String> hashes = <String>{}; final Map<Channel, Map<String, String>> paths = <Channel, Map<String, String>>{}; for (final Map<String, String> revision in releases) { final String hash = revision['hash']!; final Channel channel = fromChannelName(revision['channel']); hashes.add(hash); if (revisionsBeingRemoved.contains(hash) && channels.contains(channel)) { paths[channel] ??= <String, String>{}; paths[channel]![hash] = revision['archive']!; } } final Set<String> missingRevisions = revisionsBeingRemoved.difference(hashes.intersection(revisionsBeingRemoved)); if (missingRevisions.isNotEmpty) { final bool plural = missingRevisions.length > 1; throw UnpublishException('Revision${plural ? 's' : ''} $missingRevisions ${plural ? 'are' : 'is'} not present in the server metadata.'); } return paths; }
Future<Map<String, dynamic>> _loadMetadata() async { final File metadataFile = File( path.join(tempDir.absolute.path, getMetadataFilename(platform)), ); // Always run this, even in dry runs. await _runGsUtil(<String>['cp', metadataGsPath, metadataFile.absolute.path], confirm: true); final String currentMetadata = metadataFile.readAsStringSync(); if (currentMetadata.isEmpty) { throw UnpublishException('Empty metadata received from server'); }
Map<String, dynamic> jsonData; try { jsonData = json.decode(currentMetadata) as Map<String, dynamic>; } on FormatException catch (e) { throw UnpublishException('Unable to parse JSON metadata received from cloud: $e'); }
return jsonData; }
Future<void> _updateMetadata(Map<String, dynamic> jsonData) async { // We can't just cat the metadata from the server with 'gsutil cat', because // Windows wants to echo the commands that execute in gsutil.bat to the // stdout when we do that. So, we copy the file locally and then read it // back in. final File metadataFile = File( path.join(tempDir.absolute.path, getMetadataFilename(platform)), ); const JsonEncoder encoder = JsonEncoder.withIndent(' '); metadataFile.writeAsStringSync(encoder.convert(jsonData)); print('${confirmed ? 'Overwriting' : 'Would overwrite'} $metadataGsPath with contents of ${metadataFile.absolute.path}'); await _cloudReplaceDest(metadataFile.absolute.path, metadataGsPath); }
Future<String> _runGsUtil( List<String> args, { Directory? workingDirectory, bool failOk = false, bool confirm = false, }) async { final List<String> command = <String>['gsutil', '--', ...args]; if (confirm) { return _processRunner.runProcess( command, workingDirectory: workingDirectory, failOk: failOk, ); } else { print('Would run: ${command.join(' ')}'); return ''; } }
Future<void> _cloudRemoveArchive(Map<Channel, Map<String, String>> paths) async { final List<String> files = <String>[]; print('${confirmed ? 'Removing' : 'Would remove'} the following release archives:'); for (final Channel channel in paths.keys) { final Map<String, String> hashes = paths[channel]!; for (final String hash in hashes.keys) { final String file = '$gsReleaseFolder/${hashes[hash]}'; files.add(file); print(' $file'); } } await _runGsUtil(<String>['rm', ...files], failOk: true, confirm: confirmed); }
Future<String> _cloudReplaceDest(String src, String dest) async { assert(dest.startsWith('gs:'), '_cloudReplaceDest must have a destination in cloud storage.'); assert(!src.startsWith('gs:'), '_cloudReplaceDest must have a local source file.'); // We often don't have permission to overwrite, but // we have permission to remove, so that's what we do first. await _runGsUtil(<String>['rm', dest], failOk: true, confirm: confirmed); String? mimeType; if (dest.endsWith('.tar.xz')) { mimeType = 'application/x-gtar'; } if (dest.endsWith('.zip')) { mimeType = 'application/zip'; } if (dest.endsWith('.json')) { mimeType = 'application/json'; } final List<String> args = <String>[ // Use our preferred MIME type for the files we care about // and let gsutil figure it out for anything else. if (mimeType != null) ...<String>['-h', 'Content-Type:$mimeType'], ...<String>['cp', src, dest], ]; return _runGsUtil(args, confirm: confirmed); }}
void _printBanner(String message) { final String banner = '*** $message ***'; print('\n'); print('*' * banner.length); print(banner); print('*' * banner.length); print('\n');}
/// Prepares a flutter git repo to be removed from the published cloud storage.Future<void> main(List<String> rawArguments) async { final List<String> allowedChannelValues = Channel.values.map<String>((Channel channel) => getChannelName(channel)).toList(); final List<String> allowedPlatformNames = PublishedPlatform.values.map<String>((PublishedPlatform platform) => getPublishedPlatform(platform)).toList(); final ArgParser argParser = ArgParser(); argParser.addOption( 'temp_dir', help: 'A location where temporary files may be written. Defaults to a ' 'directory in the system temp folder. If a temp_dir is not ' 'specified, then by default a generated temporary directory will be ' 'created, used, and removed automatically when the script exits.', ); argParser.addMultiOption('revision', help: 'The Flutter git repo revisions to remove from the published site. ' 'Must be full 40-character hashes. More than one may be specified, ' 'either by giving the option more than once, or by giving a comma ' 'separated list. Required.'); argParser.addMultiOption( 'channel', allowed: allowedChannelValues, help: 'The Flutter channels to remove the archives corresponding to the ' 'revisions given with --revision. More than one may be specified, ' 'either by giving the option more than once, or by giving a ' 'comma separated list. If not specified, then the archives from all ' 'channels that a revision appears in will be removed.', ); argParser.addMultiOption( 'platform', allowed: allowedPlatformNames, help: 'The Flutter platforms to remove the archive from. May specify more ' 'than one, either by giving the option more than once, or by giving a ' 'comma separated list. If not specified, then the archives from all ' 'platforms that a revision appears in will be removed.', ); argParser.addFlag( 'confirm', help: 'If set, will actually remove the archive from Google Cloud Storage ' 'upon successful execution of this script. Published archives will be ' 'removed from this directory: $baseUrl$releaseFolder. This option ' 'must be set to perform any action on the server, otherwise only a dry ' 'run is performed.', ); argParser.addFlag( 'help', negatable: false, help: 'Print help for this command.', );
final ArgResults parsedArguments = argParser.parse(rawArguments);
if (parsedArguments['help'] as bool) { print(argParser.usage); exit(0); }
void errorExit(String message, {int exitCode = -1}) { stderr.write('Error: $message\n\n'); stderr.write('${argParser.usage}\n'); exit(exitCode); }
final List<String> revisions = parsedArguments['revision'] as List<String>; if (revisions.isEmpty) { errorExit('Invalid argument: at least one --revision must be specified.'); } for (final String revision in revisions) { if (revision.length != 40) { errorExit('Invalid argument: --revision "$revision" must be the entire hash, not just a prefix.'); } if (revision.contains(RegExp(r'[^a-fA-F0-9]'))) { errorExit('Invalid argument: --revision "$revision" contains non-hex characters.'); } }
final String tempDirArg = parsedArguments['temp_dir'] as String; Directory tempDir; bool removeTempDir = false; if (tempDirArg.isEmpty) { tempDir = Directory.systemTemp.createTempSync('flutter_package.'); removeTempDir = true; } else { tempDir = Directory(tempDirArg); if (!tempDir.existsSync()) { errorExit("Temporary directory $tempDirArg doesn't exist."); } }
if (!(parsedArguments['confirm'] as bool)) { _printBanner('This will be just a dry run. To actually perform the changes below, re-run with --confirm argument.'); }
final List<String> channelArg = parsedArguments['channel'] as List<String>; final List<String> channelOptions = channelArg.isNotEmpty ? channelArg : allowedChannelValues; final Set<Channel> channels = channelOptions.map<Channel>((String value) => fromChannelName(value)).toSet(); final List<String> platformArg = parsedArguments['platform'] as List<String>; final List<String> platformOptions = platformArg.isNotEmpty ? platformArg : allowedPlatformNames; final List<PublishedPlatform> platforms = platformOptions.map<PublishedPlatform>((String value) => fromPublishedPlatform(value)).toList(); int exitCode = 0; late String message; late String stack; try { for (final PublishedPlatform platform in platforms) { final ArchiveUnpublisher publisher = ArchiveUnpublisher( tempDir, revisions.toSet(), channels, platform, confirmed: parsedArguments['confirm'] as bool, ); await publisher.unpublishArchive(); } } on UnpublishException catch (e, s) { exitCode = e.exitCode; message = e.message; stack = s.toString(); } catch (e, s) { exitCode = -1; message = e.toString(); stack = s.toString(); } finally { if (removeTempDir) { tempDir.deleteSync(recursive: true); } if (exitCode != 0) { errorExit('$message\n$stack', exitCode: exitCode); } if (!(parsedArguments['confirm'] as bool)) { _printBanner('This was just a dry run. To actually perform the above changes, re-run with --confirm argument.'); } exit(0); }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255// Copyright 2014 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:async';import 'dart:core' hide print;import 'dart:io' as system show exit;import 'dart:io' hide exit;import 'dart:math' as math;
import 'package:meta/meta.dart';
const Duration _quietTimeout = Duration(minutes: 10); // how long the output should be hidden between calls to printProgress before just being verbose
// If running from LUCI set to False.final bool isLuci = Platform.environment['LUCI_CI'] == 'True';final bool hasColor = stdout.supportsAnsiEscapes && !isLuci;
final String bold = hasColor ? '\x1B[1m' : ''; // shard titlesfinal String red = hasColor ? '\x1B[31m' : ''; // errorsfinal String green = hasColor ? '\x1B[32m' : ''; // section titles, commandsfinal String yellow = hasColor ? '\x1B[33m' : ''; // indications that a test was skipped (usually renders orange or brown)final String cyan = hasColor ? '\x1B[36m' : ''; // pathsfinal String reverse = hasColor ? '\x1B[7m' : ''; // clocksfinal String gray = hasColor ? '\x1B[30m' : ''; // subtle decorative items (usually renders as dark gray)final String white = hasColor ? '\x1B[37m' : ''; // last log line (usually renders as light gray)final String reset = hasColor ? '\x1B[0m' : '';
const int kESC = 0x1B;const int kOpenSquareBracket = 0x5B;const int kCSIParameterRangeStart = 0x30;const int kCSIParameterRangeEnd = 0x3F;const int kCSIIntermediateRangeStart = 0x20;const int kCSIIntermediateRangeEnd = 0x2F;const int kCSIFinalRangeStart = 0x40;const int kCSIFinalRangeEnd = 0x7E;
String get redLine { if (hasColor) { return '$red${'━' * stdout.terminalColumns}$reset'; } return '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━';}
String get clock { final DateTime now = DateTime.now(); return '$reverse▌' '${now.hour.toString().padLeft(2, "0")}:' '${now.minute.toString().padLeft(2, "0")}:' '${now.second.toString().padLeft(2, "0")}' '▐$reset';}
String prettyPrintDuration(Duration duration) { String result = ''; final int minutes = duration.inMinutes; if (minutes > 0) { result += '${minutes}min '; } final int seconds = duration.inSeconds - minutes * 60; final int milliseconds = duration.inMilliseconds - (seconds * 1000 + minutes * 60 * 1000); result += '$seconds.${milliseconds.toString().padLeft(3, "0")}s'; return result;}
typedef PrintCallback = void Function(Object? line);typedef VoidCallback = void Function();
// Allow print() to be overridden, for tests.//// Files that import this library should not import `print` from dart:core// and should not use dart:io's `stdout` or `stderr`.//// By default this hides log lines between `printProgress` calls unless a// timeout expires or anything calls `foundError`.//// Also used to implement `--verbose` in test.dart.PrintCallback print = _printQuietly;
// Called by foundError and used to implement `--abort-on-error` in test.dart.VoidCallback? onError;
bool get hasError => _hasError;bool _hasError = false;
List<List<String>> _errorMessages = <List<String>>[];
final List<String> _pendingLogs = <String>[];Timer? _hideTimer; // When this is null, the output is verbose.
void foundError(List<String> messages) { assert(messages.isNotEmpty); // Make the error message easy to notice in the logs by // wrapping it in a red box. final int width = math.max(15, (hasColor ? stdout.terminalColumns : 80) - 1); final String title = 'ERROR #${_errorMessages.length + 1}'; print('$red╔═╡$bold$title$reset$red╞═${"═" * (width - 4 - title.length)}'); for (final String message in messages.expand((String line) => line.split('\n'))) { print('$red║$reset $message'); } print('$red╚${"═" * width}'); // Normally, "print" actually prints to the log. To make the errors visible, // and to include useful context, print the entire log up to this point, and // clear it. Subsequent messages will continue to not be logged until there is // another error. _pendingLogs.forEach(_printLoudly); _pendingLogs.clear(); _errorMessages.add(messages); _hasError = true; onError?.call();}
@visibleForTestingvoid resetErrorStatus() { _hasError = false; _errorMessages.clear(); _pendingLogs.clear(); _hideTimer?.cancel(); _hideTimer = null;}
Never reportSuccessAndExit(String message) { _hideTimer?.cancel(); _hideTimer = null; print('$clock $message$reset'); system.exit(0);}
Never reportErrorsAndExit(String message) { _hideTimer?.cancel(); _hideTimer = null; print('$clock $message$reset'); print(redLine); print('${red}For your convenience, the error messages reported above are repeated here:$reset'); final bool printSeparators = _errorMessages.any((List<String> messages) => messages.length > 1); if (printSeparators) { print(' 🙙 🙛 '); } for (int index = 0; index < _errorMessages.length * 2 - 1; index += 1) { if (index.isEven) { _errorMessages[index ~/ 2].forEach(print); } else if (printSeparators) { print(' 🙙 🙛 '); } } print(redLine); print('You may find the errors by searching for "╡ERROR #" in the logs.'); system.exit(1);}
void printProgress(String message) { _pendingLogs.clear(); _hideTimer?.cancel(); _hideTimer = null; print('$clock $message$reset'); if (hasColor) { // This sets up a timer to switch to verbose mode when the tests take too long, // so that if a test hangs we can see the logs. // (This is only supported with a color terminal. When the terminal doesn't // support colors, the scripts just print everything verbosely, that way in // CI there's nothing hidden.) _hideTimer = Timer(_quietTimeout, () { _hideTimer = null; _pendingLogs.forEach(_printLoudly); _pendingLogs.clear(); }); }}
final Pattern _lineBreak = RegExp(r'[\r\n]');
void _printQuietly(Object? message) { // The point of this function is to avoid printing its output unless the timer // has gone off in which case the function assumes verbose mode is active and // prints everything. To show that progress is still happening though, rather // than showing nothing at all, it instead shows the last line of output and // keeps overwriting it. To do this in color mode, carefully measures the line // of text ignoring color codes, which is what the parser below does. if (_hideTimer != null) { _pendingLogs.add(message.toString()); String line = '$message'.trimRight(); final int start = line.lastIndexOf(_lineBreak) + 1; int index = start; int length = 0; while (index < line.length && length < stdout.terminalColumns) { if (line.codeUnitAt(index) == kESC) { // 0x1B index += 1; if (index < line.length && line.codeUnitAt(index) == kOpenSquareBracket) { // 0x5B, [ // That was the start of a CSI sequence. index += 1; while (index < line.length && line.codeUnitAt(index) >= kCSIParameterRangeStart && line.codeUnitAt(index) <= kCSIParameterRangeEnd) { // 0x30..0x3F index += 1; // ...parameter bytes... } while (index < line.length && line.codeUnitAt(index) >= kCSIIntermediateRangeStart && line.codeUnitAt(index) <= kCSIIntermediateRangeEnd) { // 0x20..0x2F index += 1; // ...intermediate bytes... } if (index < line.length && line.codeUnitAt(index) >= kCSIFinalRangeStart && line.codeUnitAt(index) <= kCSIFinalRangeEnd) { // 0x40..0x7E index += 1; // ...final byte. } } } else { index += 1; length += 1; } } line = line.substring(start, index); if (line.isNotEmpty) { stdout.write('\r\x1B[2K$white$line$reset'); } } else { _printLoudly('$message'); }}
void _printLoudly(String message) { if (hasColor) { // Overwrite the last line written by _printQuietly. stdout.writeln('\r\x1B[2K$reset${message.trimRight()}'); } else { stdout.writeln(message); }}
// THE FOLLOWING CODE IS A VIOLATION OF OUR STYLE GUIDE// BECAUSE IT INTRODUCES A VERY FLAKY RACE CONDITION// https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#never-check-if-a-port-is-available-before-using-it-never-add-timeouts-and-other-race-conditions// DO NOT USE THE FOLLOWING FUNCTIONS// DO NOT WRITE CODE LIKE THE FOLLOWING FUNCTIONS// https://github.com/flutter/flutter/issues/109474
int _portCounter = 8080;
/// Finds the next available local port.Future<int> findAvailablePortAndPossiblyCauseFlakyTests() async { while (!await _isPortAvailable(_portCounter)) { _portCounter += 1; } return _portCounter++;}
Future<bool> _isPortAvailable(int port) async { try { final RawSocket socket = await RawSocket.connect('localhost', port); socket.shutdown(SocketDirection.both); await socket.close(); return false; } on SocketException { return true; }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118# Flutter Conductor
Command-line tool for managing a release of the Flutter SDK. Also seehttps://github.com/flutter/flutter/wiki/Release-process for more information onthe release process.
## Requirements
Some basic requirements to conduct a release are:
- a Linux or macOS computer set up for Flutter development. The conductor does not support Windows.- git- Mirrors on GitHub of the Flutter [framework](https://github.com/flutter/flutter) and [engine](https://github.com/flutter/engine) repositories.
For the best experience, it is recommended to use ssh protocol for connecting toGitHub remote repositories (i.e. for `--framework-mirror` and `--engine-mirror`specify the remote with the format `git@github.com:username/reponame`). If yourlocal ssh key is password-protected, it is recommended to use ssh-agent tounlock your ssh key for the session; if you do not, each time the conductorattempts to interact with a remote, the user will be prompted to enter their sshkey password.
## Usage
The main entrypoint for the conductor is [bin/conductor](bin/conductor). Forbrevity, the rest of this document will assume that this entrypoint is on theshell path.
All available commands can be seen via:
`conductor help`
Releases are initialized with the `start` sub-command, like:
```conductor start \ --candidate-branch=flutter-2.2-candidate.10 \ --release-channel=beta \ --github-username=kingOfDevelopers \ --engine-cherrypicks=72114dafe28c8700f1d5d629c6ae9d34172ba395 \ --framework-cherrypicks=a3e66b396746f6581b2b7efd1b0d0f0074215128,d8d853436206e86f416236b930e97779b143a100 \ --dart-revision=4511eb2a779a612d9d6b2012123575013e0aef12 \```
The conductor will, based on the release channel and the presence/lack ofprevious tags, determine which part of the release version should beincremented. In the cases where this is not correct, the version can beoverridden with `--version-override=3.0.0`.
For more details on these command line arguments, see `conductor help start`.This command will write to disk a state file that will persist until the releaseis completed. If you already have a persistent state file, this command willfail with an error message. To see the current status of the release (at anytime), issue the command:
`conductor status`
To delete a persistent state file (either because the release was successfullycompleted or abandoned), use the command:
`conductor clean`
Once initializing the release, the conductor tool will issue instructions formanual steps that must be executed by the user. At any time these instructionscan be seen via `conductor status`. Once these manual steps have been completed,you can proceed to the next step by using the command:
`conductor next`
## Steps
Once the user has finished manual steps for each step, they proceed to the nextstep with the command:
`conductor next`
### Apply Engine Cherrypicks
The tool will attempt to auto-apply all engine cherrypicks. However, anycherrypicks that result in a merge conflict will be reverted and it is left tothe user to manually cherry-pick them (with the command `git cherry-pick$REVISION`) and resolve the merge conflict in their checkout.
Once a PR is opened, the user must validate CI builds. If there are regressions(or if the `licenses_check` fails, then`//engine/ci/licenses_golden/licenses_third_party` must be updated to match theoutput of the failing test), then the user must fix these tests in their localcheckout and push their changes again.
### Apply Framework Cherrypicks
The tool will attempt to auto-apply all framework cherrypicks. However, anycherrypicks that result in a merge conflict will be reverted and it is left tothe user to manually cherry-pick them (with the command `git cherry-pick$REVISION`) and resolve the merge conflict in their checkout.
### Publish Version
This step will add a version git tag to the final Framework commit and push itto the upstream repository. The presence of a tag affects what the flutter CLItool reports the current version is.
### Publish Channel
This step will push the Framework candidate branch to the upstream releasebranch (e.g. the `stable` branch). Once this push happens upstream, the releasehas officially been published, and the code will be available to existingFlutter users via `flutter upgrade`.
### Verify Release
For the final step, the user must manually verify that packaging builds havefinished successfully. The SDK compressed archives will not be available fromthe website until the packaging build has finished. The conductor will producelinks to the dashboards for monitoring CI builds.123456789101112131415161718192021222324252627@ECHO off
REM Copyright 2014 The Flutter Authors. All rights reserved.
REM Use of this source code is governed by a BSD-style license that can be
REM found in the LICENSE file.
REM This should match the ci.sh file in this directory.
REM This is called from the LUCI recipes:
REM https://flutter.googlesource.com/recipes/+/refs/heads/master/recipe_modules/adhoc_validation/resources/customer_testing.bat
ECHO.
ECHO Updating pub packages...
CALL dart pub get
CD ..\tools
CALL dart pub get
CD ..\customer_testing
ECHO.
ECHO Finding correct version of customer tests...
CMD /S /C "IF EXIST "..\..\bin\cache\pkg\tests\" RMDIR /S /Q ..\..\bin\cache\pkg\tests"
git clone https://github.com/flutter/tests.git ..\..\bin\cache\pkg\tests
FOR /F "usebackq tokens=*" %%a IN (`dart --enable-asserts ..\tools\bin\find_commit.dart . master ..\..\bin\cache\pkg\tests main`) DO git -C ..\..\bin\cache\pkg\tests checkout %%a
ECHO.
ECHO Running tests...
CD ..\..\bin\cache\pkg\tests
CALL dart --enable-asserts ..\..\..\..\dev\customer_testing\run_tests.dart --verbose --skip-on-fetch-failure --skip-template registry/*.test12345678910111213141516171819202122232425262728293031323334353637#!/usr/bin/env bash# Copyright 2014 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.
# This should match the ci.bat file in this directory.
# This is called from .cirrus.yml and the LUCI recipes:# https://flutter.googlesource.com/recipes/+/refs/heads/master/recipe_modules/adhoc_validation/resources/customer_testing.sh
set -ex
# This script does not assume that "flutter update-packages" has been# run, to allow CIs to save time by skipping that steps since it's# largely not needed to run the flutter/tests tests.## However, we do need to update this directory and the tools directory.dart pub get(cd ../tools; dart pub get) # used for find_commit.dart below
# Next we need to update the flutter/tests checkout.## We use find_commit.dart so that we pull the version of flutter/tests# that was contemporary when the branch we are on was created. That# way, we can still run the tests on long-lived branches without being# affected by breaking changes on trunk causing changes to the tests# that wouldn't work on the long-lived branch.## (This also prevents trunk from suddenly failing when tests are# revved on flutter/tests -- if you rerun a passing customer_tests# shard, it should still pass, even if we rolled one of the tests.)rm -rf ../../bin/cache/pkg/testsgit clone https://github.com/flutter/tests.git ../../bin/cache/pkg/testsgit -C ../../bin/cache/pkg/tests checkout `dart --enable-asserts ../tools/bin/find_commit.dart . master ../../bin/cache/pkg/tests main`
# Finally, run the tests.dart --enable-asserts run_tests.dart --verbose --skip-on-fetch-failure --skip-template ../../bin/cache/pkg/tests/registry/*.test123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373# Generated by pub# See https://dart.dev/tools/pub/glossary#lockfilepackages: _fe_analyzer_shared: dependency: "direct dev" description: name: _fe_analyzer_shared sha256: "36a321c3d2cbe01cbcb3540a87b8843846e0206df3e691fa7b23e19e78de6d49" url: "https://pub.dev" source: hosted version: "65.0.0" analyzer: dependency: "direct dev" description: name: analyzer sha256: dfe03b90ec022450e22513b5e5ca1f01c0c01de9c3fba2f7fd233cb57a6b9a07 url: "https://pub.dev" source: hosted version: "6.3.0" args: dependency: "direct main" description: name: args sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 url: "https://pub.dev" source: hosted version: "2.4.2" async: dependency: "direct main" description: name: async sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted version: "2.11.0" boolean_selector: dependency: "direct dev" description: name: boolean_selector sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" url: "https://pub.dev" source: hosted version: "2.1.1" collection: dependency: "direct main" description: name: collection sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted version: "1.18.0" convert: dependency: "direct dev" description: name: convert sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" url: "https://pub.dev" source: hosted version: "3.1.1" coverage: dependency: "direct dev" description: name: coverage sha256: "8acabb8306b57a409bf4c83522065672ee13179297a6bb0cb9ead73948df7c76" url: "https://pub.dev" source: hosted version: "1.7.2" crypto: dependency: "direct dev" description: name: crypto sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab url: "https://pub.dev" source: hosted version: "3.0.3" file: dependency: "direct main" description: name: file sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" url: "https://pub.dev" source: hosted version: "7.0.0" frontend_server_client: dependency: "direct dev" description: name: frontend_server_client sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612" url: "https://pub.dev" source: hosted version: "3.2.0" glob: dependency: "direct main" description: name: glob sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" url: "https://pub.dev" source: hosted version: "2.1.2" http_multi_server: dependency: "direct dev" description: name: http_multi_server sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" url: "https://pub.dev" source: hosted version: "3.2.1" http_parser: dependency: "direct dev" description: name: http_parser sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" url: "https://pub.dev" source: hosted version: "4.0.2" io: dependency: "direct dev" description: name: io sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" url: "https://pub.dev" source: hosted version: "1.0.4" js: dependency: "direct dev" description: name: js sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 url: "https://pub.dev" source: hosted version: "0.6.7" logging: dependency: "direct dev" description: name: logging sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" url: "https://pub.dev" source: hosted version: "1.2.0" matcher: dependency: "direct dev" description: name: matcher sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted version: "0.12.16+1" meta: dependency: "direct main" description: name: meta sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 url: "https://pub.dev" source: hosted version: "1.11.0" mime: dependency: "direct dev" description: name: mime sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e url: "https://pub.dev" source: hosted version: "1.0.4" node_preamble: dependency: "direct dev" description: name: node_preamble sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" url: "https://pub.dev" source: hosted version: "2.0.2" package_config: dependency: "direct dev" description: name: package_config sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" url: "https://pub.dev" source: hosted version: "2.1.0" path: dependency: "direct main" description: name: path sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted version: "1.9.0" pool: dependency: "direct dev" description: name: pool sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" url: "https://pub.dev" source: hosted version: "1.5.1" pub_semver: dependency: "direct dev" description: name: pub_semver sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" url: "https://pub.dev" source: hosted version: "2.1.4" shelf: dependency: "direct dev" description: name: shelf sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 url: "https://pub.dev" source: hosted version: "1.4.1" shelf_packages_handler: dependency: "direct dev" description: name: shelf_packages_handler sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" url: "https://pub.dev" source: hosted version: "3.0.2" shelf_static: dependency: "direct dev" description: name: shelf_static sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e url: "https://pub.dev" source: hosted version: "1.1.2" shelf_web_socket: dependency: "direct dev" description: name: shelf_web_socket sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" url: "https://pub.dev" source: hosted version: "1.0.4" source_map_stack_trace: dependency: "direct dev" description: name: source_map_stack_trace sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae" url: "https://pub.dev" source: hosted version: "2.1.1" source_maps: dependency: "direct dev" description: name: source_maps sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703" url: "https://pub.dev" source: hosted version: "0.10.12" source_span: dependency: "direct main" description: name: source_span sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" url: "https://pub.dev" source: hosted version: "1.10.0" stack_trace: dependency: "direct dev" description: name: stack_trace sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted version: "1.11.1" stream_channel: dependency: "direct dev" description: name: stream_channel sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted version: "2.1.2" string_scanner: dependency: "direct main" description: name: string_scanner sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" url: "https://pub.dev" source: hosted version: "1.2.0" term_glyph: dependency: "direct main" description: name: term_glyph sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 url: "https://pub.dev" source: hosted version: "1.2.1" test: dependency: "direct dev" description: name: test sha256: a1f7595805820fcc05e5c52e3a231aedd0b72972cb333e8c738a8b1239448b6f url: "https://pub.dev" source: hosted version: "1.24.9" test_api: dependency: "direct dev" description: name: test_api sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" url: "https://pub.dev" source: hosted version: "0.6.1" test_core: dependency: "direct dev" description: name: test_core sha256: a757b14fc47507060a162cc2530d9a4a2f92f5100a952c7443b5cad5ef5b106a url: "https://pub.dev" source: hosted version: "0.5.9" typed_data: dependency: "direct dev" description: name: typed_data sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c url: "https://pub.dev" source: hosted version: "1.3.2" vm_service: dependency: "direct dev" description: name: vm_service sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 url: "https://pub.dev" source: hosted version: "13.0.0" watcher: dependency: "direct dev" description: name: watcher sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" url: "https://pub.dev" source: hosted version: "1.1.0" web: dependency: "direct dev" description: name: web sha256: edc8a9573dd8c5a83a183dae1af2b6fd4131377404706ca4e5420474784906fa url: "https://pub.dev" source: hosted version: "0.4.0" web_socket_channel: dependency: "direct dev" description: name: web_socket_channel sha256: "045ec2137c27bf1a32e6ffa0e734d532a6677bf9016a0d1a406c54e499ff945b" url: "https://pub.dev" source: hosted version: "2.4.1" webkit_inspection_protocol: dependency: "direct dev" description: name: webkit_inspection_protocol sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572" url: "https://pub.dev" source: hosted version: "1.2.1" yaml: dependency: "direct dev" description: name: yaml sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" url: "https://pub.dev" source: hosted version: "3.1.2"sdks: dart: ">=3.2.0 <4.0.0"1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859name: customer_testingdescription: Tool to run the tests listed in the flutter/tests repository.
environment: sdk: '>=3.2.0-0 <4.0.0'
dependencies: args: 2.4.2 path: 1.9.0 glob: 2.1.2 meta: 1.11.0
async: 2.11.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.18.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" file: 7.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.10.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
dev_dependencies: test: 1.24.9
_fe_analyzer_shared: 65.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" analyzer: 6.3.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 3.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" coverage: 1.7.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 3.0.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" frontend_server_client: 3.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 3.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 4.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" logging: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" matcher: 0.12.16+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" node_preamble: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" package_config: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 2.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf: 1.4.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 3.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_static: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_web_socket: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_map_stack_trace: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_maps: 0.10.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stack_trace: 1.11.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stream_channel: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" test_api: 0.6.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" test_core: 0.5.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.3.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vm_service: 13.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" web: 0.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" web_socket_channel: 2.4.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" webkit_inspection_protocol: 1.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 3.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
# PUBSPEC CHECKSUM: fb60123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137// Copyright 2014 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:io';
import 'package:args/args.dart';import 'package:file/local.dart';import 'package:glob/glob.dart';import 'package:path/path.dart' as path;
import 'lib/runner.dart';
Future<void> main(List<String> arguments) async { exit(await run(arguments) ? 0 : 1);}
// Return true if successful, false if failed.Future<bool> run(List<String> arguments) async { final ArgParser argParser = ArgParser( allowTrailingOptions: false, usageLineLength: 72, ) ..addOption( 'repeat', defaultsTo: '1', help: 'How many times to run each test. Set to a high value to look for flakes. If a test specifies a number of iterations, the lower of the two values is used.', valueHelp: 'count', ) ..addOption( 'shards', defaultsTo: '1', help: 'How many shards to split the tests into. Used in continuous integration.', valueHelp: 'count', ) ..addOption( 'shard-index', defaultsTo: '0', help: 'The current shard to run the tests with the range [0 .. shards - 1]. Used in continuous integration.', valueHelp: 'count', ) ..addFlag( 'skip-on-fetch-failure', help: 'Whether to skip tests that we fail to download.', ) ..addFlag( 'skip-template', help: 'Whether to skip tests named "template.test".', ) ..addFlag( 'verbose', help: 'Describe what is happening in detail.', ) ..addFlag( 'help', negatable: false, help: 'Print this help message.', );
void printHelp() { print('run_tests.dart [options...] path/to/file1.test path/to/file2.test...'); print('For details on the test registry format, see:'); print(' https://github.com/flutter/tests/blob/master/registry/template.test'); print(''); print(argParser.usage); print(''); }
ArgResults parsedArguments; try { parsedArguments = argParser.parse(arguments); } on ArgParserException catch (error) { printHelp(); print('Error: ${error.message} Use --help for usage information.'); exit(1); }
final int? repeat = int.tryParse(parsedArguments['repeat'] as String); final bool skipOnFetchFailure = parsedArguments['skip-on-fetch-failure'] as bool; final bool skipTemplate = parsedArguments['skip-template'] as bool; final bool verbose = parsedArguments['verbose'] as bool; final bool help = parsedArguments['help'] as bool; final int? numberShards = int.tryParse(parsedArguments['shards'] as String); final int? shardIndex = int.tryParse(parsedArguments['shard-index'] as String); final List<File> files = parsedArguments .rest .expand((String path) => Glob(path).listFileSystemSync(const LocalFileSystem())) .whereType<File>() .where((File file) => !skipTemplate || path.basename(file.path) != 'template.test') .toList();
if (help || repeat == null || files.isEmpty || numberShards == null || numberShards <= 0 || shardIndex == null || shardIndex < 0) { printHelp(); if (verbose) { if (repeat == null) { print('Error: Could not parse repeat count ("${parsedArguments['repeat']}")'); } if (numberShards == null) { print('Error: Could not parse shards count ("${parsedArguments['shards']}")'); } else if (numberShards < 1) { print('Error: The specified shards count ($numberShards) is less than 1. It must be greater than zero.'); } if (shardIndex == null) { print('Error: Could not parse shard index ("${parsedArguments['shard-index']}")'); } else if (shardIndex < 0) { print('Error: The specified shard index ($shardIndex) is negative. It must be in the range [0 .. shards - 1].'); } if (parsedArguments.rest.isEmpty) { print('Error: No file arguments specified.'); } else if (files.isEmpty) { print('Error: File arguments ("${parsedArguments.rest.join('", "')}") did not identify any real files.'); } } return help; }
if (shardIndex > numberShards - 1) { print( 'Error: The specified shard index ($shardIndex) is more than the specified number of shards ($numberShards). ' 'It must be in the range [0 .. shards - 1].' ); return false; }
if (files.length < numberShards) { print('Warning: There are more shards than tests. Some shards will not run any tests.'); }
return runTests( repeat: repeat, skipOnFetchFailure: skipOnFetchFailure, verbose: verbose, numberShards: numberShards, shardIndex: shardIndex, files: files, );}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259# Flutter DeviceLab
DeviceLab is a physical lab that tests Flutter on real devices.
This package contains the code for the test framework and tests. More generallythe tests are referred to as "tasks" in the API, but since we primarily use itfor testing, this document refers to them as "tests".
Current statuses for the devicelab are available at<https://flutter-dashboard.appspot.com/#/build>. See [dashboard userguide](https://github.com/flutter/cocoon/blob/main/dashboard/USER_GUIDE.md)for information on using the dashboards.
## Table of Contents
* [How the DeviceLab runs tests](#how-the-devicelab-runs-tests)* [Running tests locally](#running-tests-locally)* [Writing tests](#writing-tests)* [Adding tests to continuous integration](#adding-tests-to-continuous-integration)* [Adding tests to presubmit](#adding-tests-to-presubmit)* [Migrating to build and test model](#migrating-to-build-and-test-model)
## How the DeviceLab runs tests
DeviceLab tests are run against physical devices in Flutter's lab (the"DeviceLab").
Tasks specify the type of device they are to run on (`linux_android`, `mac_ios`,`mac_android`, `windows_android`, etc). When a device in the lab is free, itwill pickup tasks that need to be completed.
1. If the task succeeds, the test runner reports the success and uploads itsperformance metrics to Flutter's infrastructure. Not all tasks recordperformance metrics.2. If task fails, an auto rerun happens. Whenever the last run succeeds, thetask will be reported as a success. For this case, a flake will be flagged andpopulated to the test result.3. If the task fails in all reruns, the test runner reports the failure to Flutter's infrastructure and no performance metrics are collected
## Running tests locally
Do make sure your tests pass locally before deploying to the CI environment.Below is a handful of commands that run tests in a similar way to how theCI environment runs them. These commands are also useful when you need toreproduce a CI test failure locally.
### Prerequisites
You must set the `ANDROID_SDK_ROOT` environment variable to runtests on Android. If you have a local build of the Flutter engine, then you havea copy of the Android SDK at `.../engine/src/third_party/android_tools/sdk`.
You can find where your Android SDK is using `flutter doctor -v`.
### Warnings
Running the devicelab will do things to your environment.
Notably, it will start and stop Gradle, for instance.
### Running specific tests
To run a test, use option `-t` (`--task`):
```sh# from the .../flutter/dev/devicelab directory../../bin/cache/dart-sdk/bin/dart bin/test_runner.dart test -t {NAME_OF_TEST}```
Where `NAME_OR_PATH_OF_TEST` is the name of a task, which is a file'sbasename in `bin/tasks`. Example: `complex_layout__start_up`.
To run multiple tests, repeat option `-t` (`--task`) multiple times:
```sh../../bin/cache/dart-sdk/bin/dart bin/run.dart -t test1 -t test2 -t test3```
### Running tests against a local engine build
To run device lab tests against a local engine build, pass the appropriateflags to `bin/run.dart`:
```sh../../bin/cache/dart-sdk/bin/dart bin/run.dart --task=[some_task] \ --local-engine-src-path=[path_to_local]/engine/src \ --local-engine=[local_engine_architecture] \ --local-engine-host=[local_engine_host_architecture]```
An example of a local engine architecture is `android_debug_unopt_x86` andan example of a local engine host architecture is `host_debug_unopt`.
### Running an A/B test for engine changes
You can run an A/B test that compares the performance of the default engineagainst a local engine build. The test runs the same benchmark a specifiednumber of times against both engines, then outputs a tab-separated spreadsheetwith the results and stores them in a JSON file for future reference. Theresults can be copied to a Google Spreadsheet for further inspection and theJSON file can be reprocessed with the `summarize.dart` command for more detailedoutput.
Example:
```sh../../bin/cache/dart-sdk/bin/dart bin/run.dart --ab=10 \ --local-engine=host_debug_unopt \ --local-engine-host=host_debug_unopt \ -t bin/tasks/web_benchmarks_canvaskit.dart```
The `--ab=10` tells the runner to run an A/B test 10 times.
`--local-engine=host_debug_unopt` tells the A/B test to use the`host_debug_unopt` engine build. `--local-engine-host=host_debug_unopt` usesthe same engine build to run the `frontend_server` (in this example).`--local-engine` is required for A/B test.
`--ab-result-file=filename` can be used to provide an alternate location tooutput the JSON results file (defaults to `ABresults#.json`). A single `#`character can be used to indicate where to insert a serial number if a file withthat name already exists, otherwise, the file will be overwritten.
A/B can run exactly one task. Multiple tasks are not supported.
Example output:
```textScore Average A (noise) Average B (noise) Speed-upbench_card_infinite_scroll.canvaskit.drawFrameDuration.average 2900.20 (8.44%) 2426.70 (8.94%) 1.20xbench_card_infinite_scroll.canvaskit.totalUiFrame.average 4964.00 (6.29%) 4098.00 (8.03%) 1.21xdraw_rect.canvaskit.windowRenderDuration.average 1959.45 (16.56%) 2286.65 (0.61%) 0.86xdraw_rect.canvaskit.sceneBuildDuration.average 1969.45 (16.37%) 2294.90 (0.58%) 0.86xdraw_rect.canvaskit.drawFrameDuration.average 5335.20 (17.59%) 6437.60 (0.59%) 0.83xdraw_rect.canvaskit.totalUiFrame.average 6832.00 (13.16%) 7932.00 (0.34%) 0.86x```
The output contains averages and noises for each score. More importantly, itcontains the speed-up value, i.e. how much _faster_ is the local engine thanthe default engine. Values less than 1.0 indicate a slow-down. For example,0.5x means the local engine is twice as slow as the default engine, and 2.0xmeans it's twice as fast. Higher is better.
Summarize tool example:
```sh../../bin/cache/dart-sdk/bin/dart bin/summarize.dart --[no-]tsv-table --[no-]raw-summary \ ABresults.json ABresults1.json ABresults2.json ...```
`--[no-]tsv-table` tells the tool to print the summary in a table with tabs foreasy spreadsheet entry. (defaults to on)
`--[no-]raw-summary` tells the tool to print all per-run data collected by theA/B test formatted with tabs for easy spreadsheet entry. (defaults to on)
Multiple trailing filenames can be specified and each such results file will beprocessed in turn.
## Reproducing broken builds locally
To reproduce the breakage locally `git checkout` the corresponding Flutterrevision. Note the name of the test that failed. In the example above thefailing test is `flutter_gallery__transition_perf`. This name can be passed tothe `run.dart` command. For example:
```sh../../bin/cache/dart-sdk/bin/dart bin/run.dart -t flutter_gallery__transition_perf```
## Writing tests
A test is a simple Dart program that lives under `bin/tasks` and uses`package:flutter_devicelab/framework/framework.dart` to define and run a _task_.
Example:
```dartimport 'dart:async';
import 'package:flutter_devicelab/framework/framework.dart';
Future<void> main() async { await task(() async { ... do something interesting ...
// Aggregate results into a JSONable Map structure. Map<String, dynamic> testResults = ...;
// Report success. return new TaskResult.success(testResults);
// Or you can also report a failure. return new TaskResult.failure('Something went wrong!'); });}```
Only one `task` is permitted per program. However, that task can run any numberof tests internally. A task has a name. It succeeds and fails independently ofother tasks, and is reported to the dashboard independently of other tasks.
A task runs in its own standalone Dart VM and reports results via Dart VMservice protocol. This ensures that tasks do not interfere with each other andlets the CI system time out and clean up tasks that get stuck.
## Adding tests to continuous integration
Host only tests should be added to `flutter_tools`.
There are several PRs needed to add a DeviceLab task to CI.
_TASK_- the name of your test that also matches the name of the file in `bin/tasks` without the `.dart` extension.
1. Add target to [.ci.yaml](https://github.com/flutter/flutter/blob/master/.ci.yaml) * Mirror an existing one that has the recipe `devicelab_drone`
If your test needs to run on multiple operating systems, create a separatetarget for each operating system.
## Adding tests to presubmit
Flutter's DeviceLab has a limited capacity in presubmit. File an infra ticketto investigate feasibility of adding a test to presubmit.
## Migrating to build and test model
To better utilize limited DeviceLab testbed resources and speed up commit validationtime, it is now supported to separate building artifacts (.apk/.app) from testing them.The artifact will be built on a host only bot, a VM or physical bot without a device,and the test will run based on the artifact against a testbed with a device.
Steps:
1. Update the task class to extend [`BuildTestTask`](https://github.com/flutter/flutter/blob/master/dev/devicelab/lib/tasks/build_test_task.dart) - Override function `getBuildArgs` - Override function `getTestArgs` - Override function `parseTaskResult` - Override function `getApplicationBinaryPath`2. Update the `bin/tasks/{TEST}.dart` to point to the new task class3. Validate the task locally - build only: `dart bin/test_runner.dart test -t {NAME_OR_PATH_OF_TEST} --task-args build --task-args application-binary-path={PATH_TO_ARTIFACT}` - test only: `dart bin/test_runner.dart test -t {NAME_OR_PATH_OF_TEST} --task-args test --task-args application-binary-path={PATH_TO_ARTIFACT}`4. Add tasks to continuous integration - Mirror a target with platform `Linux_build_test` or `Mac_build_test` - The only difference from regular targets is the artifact property: if omitted, it will use the `task_name`.5. Once validated in CI, enable the target in `PROD` by removing `bringup: true` and deleting the old target entry without build+test model.
Take gallery tasks for example:
1. Linux android - Separating PR: https://github.com/flutter/flutter/pull/103550 - Switching PR: https://github.com/flutter/flutter/pull/1105332. Mac iOS: https://github.com/flutter/flutter/pull/11116412345include: ../analysis_options.yaml
linter: rules: - unawaited_futures1234567891011121314<?xml version="1.0" encoding="UTF-8"?><module type="WEB_MODULE" version="4"> <component name="NewModuleRootManager" inherit-compiler-output="true"> <exclude-output /> <content url="file://$MODULE_DIR$"> <excludeFolder url="file://$MODULE_DIR$/build" /> </content> <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="library" name="Dart SDK" level="project" /> <orderEntry type="library" name="Dart Packages" level="project" /> <orderEntry type="library" name="Flutter Plugins" level="project" /> </component></module>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501# Generated by pub# See https://dart.dev/tools/pub/glossary#lockfilepackages: _discoveryapis_commons: dependency: "direct main" description: name: _discoveryapis_commons sha256: f8bb1fdbd77f3d5c1d62b5b0eca75fbf1e41bf4f6c62628f880582e2182ae45d url: "https://pub.dev" source: hosted version: "1.0.6" _fe_analyzer_shared: dependency: "direct dev" description: name: _fe_analyzer_shared sha256: "36a321c3d2cbe01cbcb3540a87b8843846e0206df3e691fa7b23e19e78de6d49" url: "https://pub.dev" source: hosted version: "65.0.0" analyzer: dependency: "direct dev" description: name: analyzer sha256: dfe03b90ec022450e22513b5e5ca1f01c0c01de9c3fba2f7fd233cb57a6b9a07 url: "https://pub.dev" source: hosted version: "6.3.0" archive: dependency: "direct main" description: name: archive sha256: "80e5141fafcb3361653ce308776cfd7d45e6e9fbb429e14eec571382c0c5fecb" url: "https://pub.dev" source: hosted version: "3.3.2" args: dependency: "direct main" description: name: args sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 url: "https://pub.dev" source: hosted version: "2.4.2" async: dependency: "direct main" description: name: async sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted version: "2.11.0" boolean_selector: dependency: "direct dev" description: name: boolean_selector sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" url: "https://pub.dev" source: hosted version: "2.1.1" checked_yaml: dependency: "direct main" description: name: checked_yaml sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff url: "https://pub.dev" source: hosted version: "2.0.3" collection: dependency: "direct main" description: name: collection sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted version: "1.18.0" convert: dependency: "direct main" description: name: convert sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" url: "https://pub.dev" source: hosted version: "3.1.1" coverage: dependency: "direct dev" description: name: coverage sha256: "8acabb8306b57a409bf4c83522065672ee13179297a6bb0cb9ead73948df7c76" url: "https://pub.dev" source: hosted version: "1.7.2" crypto: dependency: "direct main" description: name: crypto sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab url: "https://pub.dev" source: hosted version: "3.0.3" file: dependency: "direct main" description: name: file sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" url: "https://pub.dev" source: hosted version: "7.0.0" frontend_server_client: dependency: "direct dev" description: name: frontend_server_client sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612" url: "https://pub.dev" source: hosted version: "3.2.0" gcloud: dependency: "direct main" description: name: gcloud sha256: "94cc7901dba3bcc9cd1c0530caf2d87e733392ce8f93734ccb23d82ef9f2a3e2" url: "https://pub.dev" source: hosted version: "0.8.11" glob: dependency: "direct dev" description: name: glob sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" url: "https://pub.dev" source: hosted version: "2.1.2" googleapis: dependency: "direct main" description: name: googleapis sha256: d738182a9fb1143910abc2301c2041c7c4e294e4701db69a65a2ecf044ec57e1 url: "https://pub.dev" source: hosted version: "3.0.0" googleapis_auth: dependency: "direct main" description: name: googleapis_auth sha256: af7c3a3edf9d0de2e1e0a77e994fae0a581c525fa7012af4fa0d4a52ed9484da url: "https://pub.dev" source: hosted version: "1.4.1" http: dependency: "direct main" description: name: http sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2" url: "https://pub.dev" source: hosted version: "0.13.6" http_multi_server: dependency: "direct dev" description: name: http_multi_server sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" url: "https://pub.dev" source: hosted version: "3.2.1" http_parser: dependency: "direct main" description: name: http_parser sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" url: "https://pub.dev" source: hosted version: "4.0.2" io: dependency: "direct dev" description: name: io sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" url: "https://pub.dev" source: hosted version: "1.0.4" js: dependency: "direct main" description: name: js sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 url: "https://pub.dev" source: hosted version: "0.6.7" json_annotation: dependency: "direct main" description: name: json_annotation sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 url: "https://pub.dev" source: hosted version: "4.8.1" logging: dependency: "direct main" description: name: logging sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" url: "https://pub.dev" source: hosted version: "1.2.0" matcher: dependency: "direct dev" description: name: matcher sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted version: "0.12.16+1" meta: dependency: "direct main" description: name: meta sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 url: "https://pub.dev" source: hosted version: "1.11.0" metrics_center: dependency: "direct main" description: name: metrics_center sha256: b72e1ce6f5bc7f9cedde6d8ddca842220977254dcc767eebf07a27ffad70883f url: "https://pub.dev" source: hosted version: "1.0.12" mime: dependency: "direct main" description: name: mime sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e url: "https://pub.dev" source: hosted version: "1.0.4" node_preamble: dependency: "direct dev" description: name: node_preamble sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" url: "https://pub.dev" source: hosted version: "2.0.2" package_config: dependency: "direct dev" description: name: package_config sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" url: "https://pub.dev" source: hosted version: "2.1.0" path: dependency: "direct main" description: name: path sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted version: "1.9.0" petitparser: dependency: "direct main" description: name: petitparser sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27 url: "https://pub.dev" source: hosted version: "6.0.2" platform: dependency: "direct main" description: name: platform sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec" url: "https://pub.dev" source: hosted version: "3.1.4" pool: dependency: "direct dev" description: name: pool sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" url: "https://pub.dev" source: hosted version: "1.5.1" process: dependency: "direct main" description: name: process sha256: "21e54fd2faf1b5bdd5102afd25012184a6793927648ea81eea80552ac9405b32" url: "https://pub.dev" source: hosted version: "5.0.2" pub_semver: dependency: "direct main" description: name: pub_semver sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" url: "https://pub.dev" source: hosted version: "2.1.4" pubspec_parse: dependency: "direct main" description: name: pubspec_parse sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367 url: "https://pub.dev" source: hosted version: "1.2.3" retry: dependency: "direct main" description: name: retry sha256: "822e118d5b3aafed083109c72d5f484c6dc66707885e07c0fbcb8b986bba7efc" url: "https://pub.dev" source: hosted version: "3.1.2" shelf: dependency: "direct main" description: name: shelf sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 url: "https://pub.dev" source: hosted version: "1.4.1" shelf_packages_handler: dependency: "direct dev" description: name: shelf_packages_handler sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" url: "https://pub.dev" source: hosted version: "3.0.2" shelf_static: dependency: "direct main" description: name: shelf_static sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e url: "https://pub.dev" source: hosted version: "1.1.2" shelf_web_socket: dependency: "direct dev" description: name: shelf_web_socket sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" url: "https://pub.dev" source: hosted version: "1.0.4" source_map_stack_trace: dependency: "direct dev" description: name: source_map_stack_trace sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae" url: "https://pub.dev" source: hosted version: "2.1.1" source_maps: dependency: "direct dev" description: name: source_maps sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703" url: "https://pub.dev" source: hosted version: "0.10.12" source_span: dependency: "direct main" description: name: source_span sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" url: "https://pub.dev" source: hosted version: "1.10.0" stack_trace: dependency: "direct main" description: name: stack_trace sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted version: "1.11.1" standard_message_codec: dependency: "direct main" description: name: standard_message_codec sha256: fc7dd712d191b7e33196a0ecf354c4573492bb95995e7166cb6f73b047f9cae0 url: "https://pub.dev" source: hosted version: "0.0.1+4" stream_channel: dependency: "direct main" description: name: stream_channel sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted version: "2.1.2" string_scanner: dependency: "direct main" description: name: string_scanner sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" url: "https://pub.dev" source: hosted version: "1.2.0" term_glyph: dependency: "direct main" description: name: term_glyph sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 url: "https://pub.dev" source: hosted version: "1.2.1" test: dependency: "direct dev" description: name: test sha256: a1f7595805820fcc05e5c52e3a231aedd0b72972cb333e8c738a8b1239448b6f url: "https://pub.dev" source: hosted version: "1.24.9" test_api: dependency: "direct dev" description: name: test_api sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" url: "https://pub.dev" source: hosted version: "0.6.1" test_core: dependency: "direct dev" description: name: test_core sha256: a757b14fc47507060a162cc2530d9a4a2f92f5100a952c7443b5cad5ef5b106a url: "https://pub.dev" source: hosted version: "0.5.9" typed_data: dependency: "direct main" description: name: typed_data sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c url: "https://pub.dev" source: hosted version: "1.3.2" vm_service: dependency: "direct main" description: name: vm_service sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 url: "https://pub.dev" source: hosted version: "13.0.0" watcher: dependency: "direct dev" description: name: watcher sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" url: "https://pub.dev" source: hosted version: "1.1.0" web: dependency: "direct main" description: name: web sha256: edc8a9573dd8c5a83a183dae1af2b6fd4131377404706ca4e5420474784906fa url: "https://pub.dev" source: hosted version: "0.4.0" web_socket_channel: dependency: "direct dev" description: name: web_socket_channel sha256: "045ec2137c27bf1a32e6ffa0e734d532a6677bf9016a0d1a406c54e499ff945b" url: "https://pub.dev" source: hosted version: "2.4.1" webkit_inspection_protocol: dependency: "direct main" description: name: webkit_inspection_protocol sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572" url: "https://pub.dev" source: hosted version: "1.2.1" xml: dependency: "direct main" description: name: xml sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226 url: "https://pub.dev" source: hosted version: "6.5.0" yaml: dependency: "direct main" description: name: yaml sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" url: "https://pub.dev" source: hosted version: "3.1.2"sdks: dart: ">=3.2.0 <4.0.0"12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576name: flutter_devicelabdescription: Flutter continuous integration performance and correctness tests.homepage: https://github.com/flutter/flutter
environment: sdk: '>=3.2.0-0 <4.0.0'
dependencies: archive: 3.3.2 args: 2.4.2 file: 7.0.0 http: 0.13.6 logging: 1.2.0 meta: 1.11.0 metrics_center: 1.0.12 path: 1.9.0 platform: 3.1.4 process: 5.0.2 pubspec_parse: 1.2.3 shelf: 1.4.1 shelf_static: 1.1.2 stack_trace: 1.11.1 vm_service: 13.0.0 web: 0.4.0 webkit_inspection_protocol: 1.2.1 xml: 6.5.0 standard_message_codec: 0.0.1+4
_discoveryapis_commons: 1.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" async: 2.11.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" checked_yaml: 2.0.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.18.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 3.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 3.0.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" gcloud: 0.8.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" googleapis: 3.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" googleapis_auth: 1.4.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 4.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" json_annotation: 4.8.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" petitparser: 6.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 2.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" retry: 3.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.10.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" stream_channel: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.3.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" yaml: 3.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
dev_dependencies: test: 1.24.9
_fe_analyzer_shared: 65.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" analyzer: 6.3.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" coverage: 1.7.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" frontend_server_client: 3.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 3.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" matcher: 0.12.16+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" node_preamble: 2.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" package_config: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.5.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 3.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_web_socket: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_map_stack_trace: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_maps: 0.10.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" test_api: 0.6.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" test_core: 0.5.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" watcher: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" web_socket_channel: 2.4.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
# PUBSPEC CHECKSUM: ba43123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596# Welcome to the Flutter API reference documentation!
Flutter is Google's SDK for crafting beautiful, fast user experiences formobile, web, and desktop from a single codebase. Flutter works with existingcode, is used by developers and organizations around the world, and is freeand open source.
This API reference covers all libraries that are exported by the FlutterSDK.
## More Documentation
This site hosts Flutter's API documentation. Other documentation can be found atthe following locations:
* [flutter.dev](https://flutter.dev) (main Flutter site)* [Stable channel API Docs](https://api.flutter.dev)* [Main channel API Docs](https://main-api.flutter.dev)* Engine Embedder API documentation: * [Android Embedder](../javadoc/index.html) * [iOS Embedder](../ios-embedder/index.html) * [macOS Embedder](../macos-embedder/index.html) * [Linux Embedder](../linux-embedder/index.html) * [Windows Embedder](../windows-embedder/index.html) * [Web Embedder](dart-ui_web/dart-ui_web-library.html)* [Installation](https://flutter.dev/docs/get-started/install)* [Codelabs](https://flutter.dev/docs/codelabs)* [Contributing to Flutter](https://github.com/flutter/flutter/blob/master/CONTRIBUTING.md)
## Offline Documentation
In addition to the online sites above, Flutter's documentation can be downloadedas an HTML documentation ZIP file for use when offline or when you have a poorinternet connection.
**Warning: the offline documentation files are quite large, approximately 700 MBto 900 MB.**
Offline HTML documentation ZIP bundles:
* [Stable channel](https://api.flutter.dev/offline/flutter.docs.zip) * [Main channel](https://main-api.flutter.dev/offline/flutter.docs.zip)
Or, you can add Flutter to the open-source [Zeal](https://zealdocs.org/) appusing the following XML configurations. Follow the instructions in theapplication for adding a feed.
* Stable channel Zeal XML configuration URL: <https://api.flutter.dev/offline/flutter.xml> * Main channel Zeal XML configuration URL: <https://main-api.flutter.dev/offline/flutter.xml>
## Importing a Library
### Framework Libraries
Libraries in the "Libraries" section below (or in the left navigation) are partof the core Flutter framework and are imported using`'package:flutter/<library>.dart'`, like so:
```dartimport 'package:flutter/material.dart';import 'package:flutter/services.dart';```
### Dart Libraries
Libraries in the "Dart" section exist in the `dart:` namespace and are importedusing `'dart:<library>'`, like so:
```dartimport 'dart:async';import 'dart:ui';```
Except for `'dart:core'`, you must import a Dart library before you can use it.
### Supporting Libraries
Libraries in other sections are supporting libraries that ship with Flutter.They are organized by package and are imported using`'package:<package>/<library>.dart'`, like so:
```dartimport 'package:flutter_test/flutter_test.dart';import 'package:file/local.dart';```
## Packages on pub.dev
Flutter has a rich ecosystem of packages that have been contributed by theFlutter team and the broader open source community to a central repository.Among the thousands of packages, you'll find support for Firebase, GoogleFonts, hardware services like Bluetooth and camera, new widgets andanimations, and integration with other popular web services. You can browsethose packages at [pub.dev](https://pub.dev).123analyzer: exclude: - 'lib/**'1234<!-- Google Tag Manager (noscript) --><noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-ND4LWWZ"height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript><!-- End Google Tag Manager (noscript) -->1234567<!-- Google Tag Manager --><script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f)})(window,document,'script','dataLayer','GTM-ND4LWWZ');</script><!-- End Google Tag Manager -->12345dartdoc: ignore: # The stub `Flutter` package is expected to have no # documentable libraries. - no-documentable-libraries1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071{ "name": "flutter", "package": "flutter", "author": { "name": "The Flutter Team", "link": "https://flutter.dev" }, "index": "index.html", "icon32x32": "flutter/static-assets/favicon.png", "allowJS": true, "ExternalURL": "https://api.flutter.dev", "selectors": { "#exceptions span.name a": { "type": "Exception" },
"h1 > span.kind-library": { "type": "Library" },
"h1 > span.kind-class": { "type": "Class" },
"h1 > span.kind-function": { "type": "Function" },
"h1 > span.kind-typedef": { "type": "Type" },
"h1 > span.kind-enum": { "type": "Enum" },
"h1 > span.kind-top-level-constant": { "type": "Constant" },
"h1 > span.kind-constant": { "type": "Constant" },
"h1 > span.kind-method": { "type": "Method" },
"h1 > span.kind-property": { "type": "Property" },
"h1 > span.kind-top-level-property": { "type": "Property" },
"h1 > span.kind-constructor": { "type": "Constructor" },
".callables .callable": { "requiretext": "operator ", "type": "Operator", "regexp": "operator ", "replacement": "" } }, "ignore": [ "ABOUT" ]}12345678910111213141516171819202122{ "rules": "firebase_rules.json", "hosting": { "public": "doc", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ], "headers": [ { "source": "snippets/**.dart", "headers": [ { "key": "Access-Control-Allow-Origin", "value": "*" } ] } ] }}123456{ "rules": { ".read": false, ".write": false }}1<link rel="search" type="application/opensearchdescription+xml" title="Flutter API" href="/opensearch.xml"/>novelforge-project/agent-workspace/flutter/dev/a11y_assessments/README.mdAdded+3
novelforge-project/agent-workspace/flutter/dev/a11y_assessments/analysis_options.yamlAdded+1
novelforge-project/agent-workspace/flutter/dev/a11y_assessments/pubspec.lockAdded+188
novelforge-project/agent-workspace/flutter/dev/a11y_assessments/pubspec.yamlAdded+41
novelforge-project/agent-workspace/flutter/dev/automated_tests/README.mdAdded+2
novelforge-project/agent-workspace/flutter/dev/automated_tests/pubspec.lockAdded+504
novelforge-project/agent-workspace/flutter/dev/automated_tests/pubspec.yamlAdded+78
novelforge-project/agent-workspace/flutter/dev/bots/README.mdAdded+188
novelforge-project/agent-workspace/flutter/dev/bots/accept_android_sdk_licenses.shAdded+23
novelforge-project/agent-workspace/flutter/dev/bots/allowlist.dartAdded+54
novelforge-project/agent-workspace/flutter/dev/bots/analysis_options.yamlAdded+5
novelforge-project/agent-workspace/flutter/dev/bots/analyze.dartAdded+2189
novelforge-project/agent-workspace/flutter/dev/bots/analyze_snippet_code.dartAdded+1199
novelforge-project/agent-workspace/flutter/dev/bots/bots.imlAdded+14
novelforge-project/agent-workspace/flutter/dev/bots/browser.dartAdded+109
novelforge-project/agent-workspace/flutter/dev/bots/check_code_samples.dartAdded+494
novelforge-project/agent-workspace/flutter/dev/bots/codelabs_build_test.shAdded+44
novelforge-project/agent-workspace/flutter/dev/bots/docs.shAdded+154
novelforge-project/agent-workspace/flutter/dev/bots/post_process_docs.dartAdded+157
novelforge-project/agent-workspace/flutter/dev/bots/prepare_package.dartAdded+164
novelforge-project/agent-workspace/flutter/dev/bots/pubspec.lockAdded+524
novelforge-project/agent-workspace/flutter/dev/bots/pubspec.yamlAdded+78
novelforge-project/agent-workspace/flutter/dev/bots/run_command.dartAdded+224
novelforge-project/agent-workspace/flutter/dev/bots/service_worker_test.dartAdded+838
novelforge-project/agent-workspace/flutter/dev/bots/serviceaccount.encAdded
novelforge-project/agent-workspace/flutter/dev/bots/test.dartAdded
novelforge-project/agent-workspace/flutter/dev/bots/tool_subsharding.dartAdded+102
novelforge-project/agent-workspace/flutter/dev/bots/unpublish_package.dartAdded+504
novelforge-project/agent-workspace/flutter/dev/bots/utils.dartAdded+255
novelforge-project/agent-workspace/flutter/dev/conductor/README.mdAdded+118
novelforge-project/agent-workspace/flutter/dev/customer_testing/ci.batAdded+27
novelforge-project/agent-workspace/flutter/dev/customer_testing/ci.shAdded+37
novelforge-project/agent-workspace/flutter/dev/customer_testing/pubspec.lockAdded+373
novelforge-project/agent-workspace/flutter/dev/customer_testing/pubspec.yamlAdded+59
novelforge-project/agent-workspace/flutter/dev/customer_testing/run_tests.dartAdded+137
novelforge-project/agent-workspace/flutter/dev/devicelab/README.mdAdded+259
novelforge-project/agent-workspace/flutter/dev/devicelab/analysis_options.yamlAdded+5
novelforge-project/agent-workspace/flutter/dev/devicelab/devicelab.imlAdded+14
novelforge-project/agent-workspace/flutter/dev/devicelab/pubspec.lockAdded+501
novelforge-project/agent-workspace/flutter/dev/devicelab/pubspec.yamlAdded+76
novelforge-project/agent-workspace/flutter/dev/docs/README.mdAdded+96
novelforge-project/agent-workspace/flutter/dev/docs/analysis_options.yamlAdded+3
novelforge-project/agent-workspace/flutter/dev/docs/analytics-footer.htmlAdded+4
novelforge-project/agent-workspace/flutter/dev/docs/analytics-header.htmlAdded+7
novelforge-project/agent-workspace/flutter/dev/docs/dartdoc_options.yamlAdded+5
novelforge-project/agent-workspace/flutter/dev/docs/dashing.jsonAdded+71
novelforge-project/agent-workspace/flutter/dev/docs/favicon.icoAdded
novelforge-project/agent-workspace/flutter/dev/docs/firebase.jsonAdded+22
novelforge-project/agent-workspace/flutter/dev/docs/firebase_rules.jsonAdded+6
novelforge-project/agent-workspace/flutter/dev/docs/opensearch.htmlAdded+1