diff --git a/packages/analysis_defaults/lib/analysis.yaml b/packages/analysis_defaults/lib/analysis.yaml index 1124c9938b6..904b49148b4 100644 --- a/packages/analysis_defaults/lib/analysis.yaml +++ b/packages/analysis_defaults/lib/analysis.yaml @@ -8,10 +8,13 @@ analyzer: linter: rules: + - async_return_with_no_await - deprecated_member_use_from_same_package - discarded_futures + - empty_container_bodies - eol_at_end_of_file - implicit_reopen + - initialize_in_field_declaration - invalid_case_patterns - matching_super_parameters - missing_code_block_language_in_doc_comment @@ -20,7 +23,15 @@ linter: - prefer_final_fields - prefer_final_in_for_each - prefer_final_locals + - prefer_if_elements_to_conditional_expressions + - simple_directive_paths + - simplify_variable_pattern + - specify_nonobvious_property_types + - switch_on_type + - unnecessary_async - unnecessary_breaks - unnecessary_null_aware_operator_on_extension_on_nullable + - unnecessary_primary_constructor_body + - unnecessary_unawaited - use_enums - use_truncating_division diff --git a/packages/analysis_defaults/pubspec.yaml b/packages/analysis_defaults/pubspec.yaml index c40a6861ba1..2abf344f95f 100644 --- a/packages/analysis_defaults/pubspec.yaml +++ b/packages/analysis_defaults/pubspec.yaml @@ -4,7 +4,7 @@ publish_to: none resolution: workspace environment: - sdk: ^3.12.0 + sdk: ^3.13.0 # NOTE: Code isn't allowed in this package. # Don't add dependencies besides the underlying lints package. diff --git a/packages/site_shared/lib/components/blog/client/blog_categories.dart b/packages/site_shared/lib/components/blog/client/blog_categories.dart index 1976a4561d5..2719bde8881 100644 --- a/packages/site_shared/lib/components/blog/client/blog_categories.dart +++ b/packages/site_shared/lib/components/blog/client/blog_categories.dart @@ -152,7 +152,7 @@ class _BlogCategoriesState extends State { [ button( onClick: () => _selectCategory(null), - [const .text('All')], + const [.text('All')], ), ], ), diff --git a/packages/site_shared/lib/components/blog/client/share_button.dart b/packages/site_shared/lib/components/blog/client/share_button.dart index 0eefef47098..bc93b3c1d74 100644 --- a/packages/site_shared/lib/components/blog/client/share_button.dart +++ b/packages/site_shared/lib/components/blog/client/share_button.dart @@ -42,9 +42,9 @@ class ShareButton extends StatelessComponent { to: false, ); }, - [ - const MaterialIcon('content_copy'), - const .text('Copy link'), + const [ + MaterialIcon('content_copy'), + .text('Copy link'), ], ); }, @@ -58,8 +58,8 @@ class ShareButton extends StatelessComponent { href: 'https://twitter.com/intent/tweet?text=${Uri.encodeComponent(title)}&url=${Uri.encodeComponent(url)}', target: Target.blank, - [ - const svg([ + const [ + svg([ Component.element( tag: 'use', attributes: { @@ -67,7 +67,7 @@ class ShareButton extends StatelessComponent { }, ), ]), - const .text('Share on X'), + .text('Share on X'), ], ), ]), @@ -76,8 +76,8 @@ class ShareButton extends StatelessComponent { href: 'https://bsky.app/intent/compose?text=${Uri.encodeComponent("$title $url")}', target: Target.blank, - [ - const svg([ + const [ + svg([ Component.element( tag: 'use', attributes: { @@ -85,7 +85,7 @@ class ShareButton extends StatelessComponent { }, ), ]), - const .text('Share on Bluesky'), + .text('Share on Bluesky'), ], ), ]), @@ -94,8 +94,8 @@ class ShareButton extends StatelessComponent { href: 'https://www.linkedin.com/sharing/share-offsite/?url=${Uri.encodeComponent(url)}', target: Target.blank, - [ - const svg([ + const [ + svg([ Component.element( tag: 'use', attributes: { @@ -103,7 +103,7 @@ class ShareButton extends StatelessComponent { }, ), ]), - const .text('Share on LinkedIn'), + .text('Share on LinkedIn'), ], ), ]), diff --git a/packages/site_shared/lib/components/common/button.dart b/packages/site_shared/lib/components/common/button.dart index 2393c7f4706..9457ea1af56 100644 --- a/packages/site_shared/lib/components/common/button.dart +++ b/packages/site_shared/lib/components/common/button.dart @@ -61,7 +61,7 @@ class Button extends StatelessComponent { final children = [ if (icon case final iconId?) MaterialIcon(iconId), if (content case final contentText?) - asRaw ? RawText(contentText) : .text(contentText), + if (asRaw) RawText(contentText) else .text(contentText), if (trailingIcon case final iconId?) MaterialIcon(iconId), ]; diff --git a/packages/site_shared/lib/components/common/chip.dart b/packages/site_shared/lib/components/common/chip.dart index 080ec351b95..989c1639d44 100644 --- a/packages/site_shared/lib/components/common/chip.dart +++ b/packages/site_shared/lib/components/common/chip.dart @@ -25,7 +25,7 @@ class ChipSet extends StatelessComponent { id: 'reset-filters', classes: 'text-button', events: {'click': (_) => onReset()}, - [const .text('Clear filters')], + const [.text('Clear filters')], ), ]); } @@ -124,8 +124,8 @@ class FilterChip extends StatelessComponent { 'viewBox': iconViewBox, 'aria-hidden': 'true', }, - [ - const Component.element( + const [ + Component.element( tag: 'path', attributes: { 'd': @@ -244,7 +244,7 @@ class _SelectChipState extends State> { width: 24.px, height: 24.px, viewBox: '0 0 24 24', - attributes: {'aria-hidden': 'true'}, + attributes: const {'aria-hidden': 'true'}, [ Component.element( tag: 'path', @@ -322,7 +322,7 @@ class SelectMenuItem { width: iconSize.px, height: iconSize.px, viewBox: iconViewBox, - attributes: {'aria-hidden': 'true'}, + attributes: const {'aria-hidden': 'true'}, [ Component.element( tag: 'path', diff --git a/packages/site_shared/lib/components/common/client/on_this_page_button.dart b/packages/site_shared/lib/components/common/client/on_this_page_button.dart index 54057e24e31..6b90f207519 100644 --- a/packages/site_shared/lib/components/common/client/on_this_page_button.dart +++ b/packages/site_shared/lib/components/common/client/on_this_page_button.dart @@ -26,9 +26,9 @@ final class OnThisPageButton extends StatelessComponent { } }, }, - [ - const MaterialIcon('list'), - const span([.text('On this page')]), + const [ + MaterialIcon('list'), + span([.text('On this page')]), ], ); } diff --git a/packages/site_shared/lib/components/common/client/page_header_options.dart b/packages/site_shared/lib/components/common/client/page_header_options.dart index 6a97eb187a7..d5e050126e7 100644 --- a/packages/site_shared/lib/components/common/client/page_header_options.dart +++ b/packages/site_shared/lib/components/common/client/page_header_options.dart @@ -143,7 +143,7 @@ final class _PageHeaderOptionsState extends State { toggle: const Button(icon: 'more_vert', title: 'View page options.'), content: nav( classes: 'dropdown-menu', - attributes: { + attributes: const { 'role': 'menu', }, [ diff --git a/packages/site_shared/lib/components/common/fragment_target.dart b/packages/site_shared/lib/components/common/fragment_target.dart index 0d706ebe9f3..573c0e74652 100644 --- a/packages/site_shared/lib/components/common/fragment_target.dart +++ b/packages/site_shared/lib/components/common/fragment_target.dart @@ -17,7 +17,7 @@ final class FragmentTarget extends StatelessComponent { Component build(BuildContext context) => a( href: '', id: id, - attributes: {'aria-hidden': 'true'}, - [], + attributes: const {'aria-hidden': 'true'}, + const [], ); } diff --git a/packages/site_shared/lib/components/common/ide_explorer/ide_explorer.dart b/packages/site_shared/lib/components/common/ide_explorer/ide_explorer.dart index 0ac25b3dd21..a926e7a8da1 100644 --- a/packages/site_shared/lib/components/common/ide_explorer/ide_explorer.dart +++ b/packages/site_shared/lib/components/common/ide_explorer/ide_explorer.dart @@ -447,7 +447,7 @@ class _IdeBadgeDot extends StatelessComponent { 'aria-label': badge, 'title': badge, }, - [], + const [], ); } } diff --git a/packages/site_shared/lib/components/common/tooltip.dart b/packages/site_shared/lib/components/common/tooltip.dart index 3cdb63782bf..8f0a1b81635 100644 --- a/packages/site_shared/lib/components/common/tooltip.dart +++ b/packages/site_shared/lib/components/common/tooltip.dart @@ -24,15 +24,15 @@ class Tooltip extends StatefulComponent { } class _TooltipState extends State { - static final isTouchscreen = + static final bool _isTouchscreen = kIsWeb && web.window.matchMedia('(pointer: coarse)').matches; - final wrapperKey = GlobalNodeKey(); - final targetKey = GlobalNodeKey(); - final tooltipKey = GlobalNodeKey(); + final GlobalNodeKey _wrapperKey = GlobalNodeKey(); + final GlobalNodeKey _targetKey = GlobalNodeKey(); + final GlobalNodeKey _tooltipKey = GlobalNodeKey(); - bool isVisible = false; - double tooltipOffset = 0.0; + bool _isVisible = false; + double _tooltipOffset = 0; @override void initState() { @@ -55,29 +55,29 @@ class _TooltipState extends State { /// Adjust the tooltip position to ensure it is fully inside the /// ancestor .content element. void ensureVisible() { - final target = targetKey.currentNode; - final tooltip = tooltipKey.currentNode; + final target = _targetKey.currentNode; + final tooltip = _tooltipKey.currentNode; if (tooltip == null || target == null) return; setState(() { - tooltipOffset = calculateTooltipOffset(target, tooltip); + _tooltipOffset = calculateTooltipOffset(target, tooltip); }); } @override Component build(BuildContext context) { return span( - key: wrapperKey, + key: _wrapperKey, classes: 'tooltip-wrapper', [ span( - key: targetKey, + key: _targetKey, classes: 'tooltip-target', events: { - if (isTouchscreen) + if (_isTouchscreen) 'click': (e) { - if (!isVisible) { - setState(() => isVisible = true); + if (!_isVisible) { + setState(() => _isVisible = true); e.preventDefault(); } }, @@ -87,33 +87,33 @@ class _TooltipState extends State { if (component.content case final content?) GlobalEventListener( // Close tooltip when clicking outside of this wrapper. - onClick: isTouchscreen + onClick: _isTouchscreen ? (e) { - if (wrapperKey.currentNode?.contains( + if (_wrapperKey.currentNode?.contains( e.target as web.Node?, ) == true) { return; } - setState(() => isVisible = false); + setState(() => _isVisible = false); } : null, // On touchscreen devices, close tooltips when scrolling. - onScroll: isTouchscreen + onScroll: _isTouchscreen ? (_) { - setState(() => isVisible = false); + setState(() => _isVisible = false); } : null, span( - key: tooltipKey, - classes: ['tooltip', if (isVisible) 'visible'].toClasses, + key: _tooltipKey, + classes: ['tooltip', if (_isVisible) 'visible'].toClasses, styles: Styles( raw: { - 'left': tooltipOffset == 0 + 'left': _tooltipOffset == 0 ? '50%' - : tooltipOffset > 0 - ? 'calc(50% + ${tooltipOffset}px)' - : 'calc(50% - ${tooltipOffset.abs()}px)', + : _tooltipOffset > 0 + ? 'calc(50% + ${_tooltipOffset}px)' + : 'calc(50% - ${_tooltipOffset.abs()}px)', }, ), [ diff --git a/packages/site_shared/lib/components/common/youtube_embed.dart b/packages/site_shared/lib/components/common/youtube_embed.dart index fffba49ec0e..ce6cc76a1a6 100644 --- a/packages/site_shared/lib/components/common/youtube_embed.dart +++ b/packages/site_shared/lib/components/common/youtube_embed.dart @@ -62,7 +62,7 @@ class YoutubeEmbed with CustomComponentBase { classes: 'lite-youtube-fallback', href: 'https://www.youtube.com/watch/$videoId', target: Target.blank, - attributes: {'rel': 'noopener'}, + attributes: const {'rel': 'noopener'}, [ .text('Watch on YouTube in a new tab: "$videoTitle"'), ], diff --git a/packages/site_shared/lib/components/dartpad/embedded_dartpad.dart b/packages/site_shared/lib/components/dartpad/embedded_dartpad.dart index 1aa7b0d3e88..faa4dd5bdb8 100644 --- a/packages/site_shared/lib/components/dartpad/embedded_dartpad.dart +++ b/packages/site_shared/lib/components/dartpad/embedded_dartpad.dart @@ -147,7 +147,7 @@ class _EmbeddedDartPadState extends State { src: component._iframeUrl, loading: MediaLoading.lazy, allow: 'clipboard-write', - [], + const [], ); } } diff --git a/packages/site_shared/lib/components/layout/site_switcher.dart b/packages/site_shared/lib/components/layout/site_switcher.dart index f968a421452..36405e6d458 100644 --- a/packages/site_shared/lib/components/layout/site_switcher.dart +++ b/packages/site_shared/lib/components/layout/site_switcher.dart @@ -22,7 +22,7 @@ final class SiteSwitcher extends StatelessComponent { toggle: const Button(icon: 'apps', title: 'Visit related sites.'), content: nav( classes: 'dropdown-menu', - attributes: {'role': 'menu'}, + attributes: const {'role': 'menu'}, [ ul([ if (isFlutter) ...[ @@ -124,7 +124,7 @@ class _SiteWordMarkListEntry extends StatelessComponent { ), span( classes: 'name', - attributes: { + attributes: const { 'translate': 'no', }, [.text(name)], diff --git a/packages/site_shared/lib/components/tutorial/client/progress_ring.dart b/packages/site_shared/lib/components/tutorial/client/progress_ring.dart index d208f56557a..9903a48417f 100644 --- a/packages/site_shared/lib/components/tutorial/client/progress_ring.dart +++ b/packages/site_shared/lib/components/tutorial/client/progress_ring.dart @@ -66,7 +66,7 @@ class InteractiveProgressRing extends StatelessComponent { 'stroke-dasharray': '$inactiveLength ${full - inactiveLength}', 'stroke-dashoffset': '${quarter - activeLength - gap * 1.5}', }, - [], + const [], ), // Active portion, drawn from 0° to (progress)° @@ -80,7 +80,7 @@ class InteractiveProgressRing extends StatelessComponent { 'stroke-dasharray': '$activeLength ${full - activeLength}', 'stroke-dashoffset': '${quarter - gap / 2}', }, - [], + const [], ), ], ); diff --git a/packages/site_shared/lib/src/utils/retake_element_web.dart b/packages/site_shared/lib/src/utils/retake_element_web.dart index 5631e5ac73f..37de584eeb8 100644 --- a/packages/site_shared/lib/src/utils/retake_element_web.dart +++ b/packages/site_shared/lib/src/utils/retake_element_web.dart @@ -56,6 +56,9 @@ String extractContent(Element element) { } class RawNode extends Component { + // Identity is important to these components and a + // web node can't be retrieved at compile time anyway. + // ignore: prefer_const_constructors_in_immutables RawNode(this.node, {super.key}); final web.Node node; diff --git a/sites/docs/lib/src/components/layout/toc.dart b/sites/docs/lib/src/components/layout/toc.dart index 0cd4075f9d7..d0ae1ab30b8 100644 --- a/sites/docs/lib/src/components/layout/toc.dart +++ b/sites/docs/lib/src/components/layout/toc.dart @@ -82,7 +82,7 @@ final class PageNavBar extends StatelessComponent { const _DropdownDivider(), if (data.toc case final tocData?) nav( - attributes: {'role': 'menu'}, + attributes: const {'role': 'menu'}, [_TocContents(tocData)], ), ] else ...[ @@ -108,7 +108,7 @@ final class PageNavBar extends StatelessComponent { if (page == currentLinkedPage) 'active', ].toClasses, href: page.url, - attributes: {'role': 'menuitem'}, + attributes: const {'role': 'menuitem'}, [ span(classes: 'page-number', [ .text('${pageEntryNumber++}'), @@ -118,7 +118,7 @@ final class PageNavBar extends StatelessComponent { ), if (data.toc case final tocData? when currentLinkedPage == page) nav( - attributes: {'role': 'menu'}, + attributes: const {'role': 'menu'}, [_TocContents(tocData)], ), ] else ...[ diff --git a/sites/docs/lib/src/components/layout/trailing_content.dart b/sites/docs/lib/src/components/layout/trailing_content.dart index 2efcfc836a8..4cd9ab996cb 100644 --- a/sites/docs/lib/src/components/layout/trailing_content.dart +++ b/sites/docs/lib/src/components/layout/trailing_content.dart @@ -48,8 +48,8 @@ class TrailingContent extends StatelessComponent { if (pageSource != null) ...[ a( href: pageSource, - attributes: {'target': '_blank', 'rel': 'noopener'}, - [const .text('View source')], + attributes: const {'target': '_blank', 'rel': 'noopener'}, + const [.text('View source')], ), const span([.text(' or ')]), ], diff --git a/sites/docs/lib/src/components/pages/architecture_recommendations.dart b/sites/docs/lib/src/components/pages/architecture_recommendations.dart index 39bbd04db7d..91faabffcd3 100644 --- a/sites/docs/lib/src/components/pages/architecture_recommendations.dart +++ b/sites/docs/lib/src/components/pages/architecture_recommendations.dart @@ -54,11 +54,11 @@ class ArchitectureRecommendations extends CustomComponentBase { [ thead([ tr([ - th(styles: Styles(width: 30.percent), [ - const .text('Recommendation'), + th(styles: Styles(width: 30.percent), const [ + .text('Recommendation'), ]), - th(styles: Styles(width: 70.percent), [ - const .text('Description'), + th(styles: Styles(width: 70.percent), const [ + .text('Description'), ]), ]), ]), diff --git a/sites/docs/lib/src/components/pages/archive_table.dart b/sites/docs/lib/src/components/pages/archive_table.dart index fc31805cbdf..7f22bf08b4b 100644 --- a/sites/docs/lib/src/components/pages/archive_table.dart +++ b/sites/docs/lib/src/components/pages/archive_table.dart @@ -148,16 +148,16 @@ class _ArchiveTableState extends State { ]); } - static final windowsCutoff = Date.parse('4/3/2023'); - static final otherOsCutoff = Date.parse('12/15/2022'); + static final int _windowsCutoff = Date.parse('4/3/2023'); + static final int _otherOsCutoff = Date.parse('12/15/2022'); Component buildProvenanceLink(FlutterRelease release) { final dateValue = release.releaseDate.valueOf(); - if (os == 'windows' && dateValue < windowsCutoff) { + if (os == 'windows' && dateValue < _windowsCutoff) { // Provenance not available before 4/3/2023 for Windows return const span([.text('-')]); - } else if (dateValue < otherOsCutoff) { + } else if (dateValue < _otherOsCutoff) { // Provenance not available before 12/15/2022 for macOS and Linux return const span([.text('-')]); } @@ -169,7 +169,7 @@ class _ArchiveTableState extends State { 'flutter_${os}_${release.version}-$channel.' '$archiveExtension.intoto.jsonl', target: Target.blank, - [const .text('Attestation bundle')], + const [.text('Attestation bundle')], ); } } diff --git a/sites/docs/lib/src/components/pages/expansion_list.dart b/sites/docs/lib/src/components/pages/expansion_list.dart index 0fd52bb89d3..a16889c7aad 100644 --- a/sites/docs/lib/src/components/pages/expansion_list.dart +++ b/sites/docs/lib/src/components/pages/expansion_list.dart @@ -170,8 +170,8 @@ class _ExpansionListState extends State { [ DashMarkdown(content: item.content), p([ - a(href: item.url, [ - const .text('Read full article'), + a(href: item.url, const [ + .text('Read full article'), ]), ]), // Required to add "margin" that doesn't cause expansion jank. diff --git a/sites/docs/lib/src/components/pages/learning_resource_index.dart b/sites/docs/lib/src/components/pages/learning_resource_index.dart index 311ef620a49..335e7c01212 100644 --- a/sites/docs/lib/src/components/pages/learning_resource_index.dart +++ b/sites/docs/lib/src/components/pages/learning_resource_index.dart @@ -94,8 +94,8 @@ final class _ResourceCard extends StatelessComponent { classes: 'monochrome-icon', width: 24.px, height: 24.px, - [ - const Component.element( + const [ + Component.element( tag: 'use', attributes: {'href': '/assets/images/social/github.svg#github'}, ), @@ -106,8 +106,8 @@ final class _ResourceCard extends StatelessComponent { width: 24, alt: 'Dart logo', ), - 'Google Codelab' => svg(width: 24.px, height: 24.px, [ - const Component.element( + 'Google Codelab' => svg(width: 24.px, height: 24.px, const [ + Component.element( tag: 'use', attributes: { 'href': @@ -119,8 +119,8 @@ final class _ResourceCard extends StatelessComponent { attributes: {'style': 'color: red'}, width: 24.px, height: 24.px, - [ - const Component.element( + const [ + Component.element( tag: 'use', attributes: {'href': '/assets/images/social/youtube.svg#youtube'}, ), diff --git a/sites/docs/lib/src/components/pages/widget_catalog.dart b/sites/docs/lib/src/components/pages/widget_catalog.dart index fb744f58401..1bee8f5d58f 100644 --- a/sites/docs/lib/src/components/pages/widget_catalog.dart +++ b/sites/docs/lib/src/components/pages/widget_catalog.dart @@ -141,7 +141,7 @@ class WidgetCatalogCard extends StatelessComponent { ? {'style': '--bg-color: ${subcategory?.color}'} : {}; - final placeholder = const img( + const placeholderImage = img( alt: 'Placeholder Flutter logo in place of ' 'missing widget image or visualization.', @@ -158,7 +158,7 @@ class WidgetCatalogCard extends StatelessComponent { if (widget.imageSrc case final imageSrc? when imageSrc.isNotEmpty) img(alt: imageAlt, src: imageSrc) else - placeholder, + placeholderImage, if (widget.hoverBackgroundSrc case final hoverBackgroundSrc? when hoverBackgroundSrc.isNotEmpty) div(classes: 'card-image-material-3-hover', [ @@ -178,7 +178,7 @@ class WidgetCatalogCard extends StatelessComponent { when imageSrc.isNotEmpty) img(alt: imageAlt, src: imageSrc) else - placeholder, + placeholderImage, ], ], ); diff --git a/sites/docs/lib/src/extensions/glossary_link_processor.dart b/sites/docs/lib/src/extensions/glossary_link_processor.dart index af86e036278..2119a50ba48 100644 --- a/sites/docs/lib/src/extensions/glossary_link_processor.dart +++ b/sites/docs/lib/src/extensions/glossary_link_processor.dart @@ -94,7 +94,7 @@ class GlossaryTooltipContent extends StatelessComponent { 'Learn more about \'${entry.term}\' and ' 'find related resources.', }, - [const .text('Learn more')], + const [.text('Learn more')], ), ]), ]); diff --git a/sites/docs/lib/src/extensions/tutorial_structure_processor.dart b/sites/docs/lib/src/extensions/tutorial_structure_processor.dart index 856123a0550..07a70935b22 100644 --- a/sites/docs/lib/src/extensions/tutorial_structure_processor.dart +++ b/sites/docs/lib/src/extensions/tutorial_structure_processor.dart @@ -112,7 +112,7 @@ final class TutorialStructureExtension implements PageExtension { /// Checks if a node is a YouTube video embed bool _isVideoEmbed(Node node) { - if (node case ElementNode(tag: final tag)) { + if (node case ElementNode(:final tag)) { final lowerTag = tag.toLowerCase(); return lowerTag == 'youtubeembed' || lowerTag == 'lite-youtube'; } diff --git a/sites/www/lib/main.server.dart b/sites/www/lib/main.server.dart index 7ff40b2b175..73a77adc2fc 100644 --- a/sites/www/lib/main.server.dart +++ b/sites/www/lib/main.server.dart @@ -45,7 +45,7 @@ import 'src/pages/showcase_page.dart'; import 'src/pages/web_page.dart'; import 'src/utils/asset_utils.dart'; -void main() async { +void main() { Jaspr.initializeApp(options: defaultServerOptions); final assetManager = AssetManager( @@ -54,7 +54,7 @@ void main() async { dataProperties: const {'page.image', 'page.socialImage'}, assetTransformers: [ TrackingAssetTransformer(), - ResizingAssetTransformer(), + const ResizingAssetTransformer(), const HashingAssetTransformer(), ], ); diff --git a/sites/www/lib/src/components/common/newsletter_form.dart b/sites/www/lib/src/components/common/newsletter_form.dart index 58eca36fb10..d239a649998 100644 --- a/sites/www/lib/src/components/common/newsletter_form.dart +++ b/sites/www/lib/src/components/common/newsletter_form.dart @@ -133,7 +133,7 @@ class _NewsletterFormState extends State { Future _sendData() async { try { - // Create multipart request for form submission + // Create multipart request for form submission. final request = http.MultipartRequest('POST', Uri.parse(_formUrl)); request.fields['EmailAddress'] = _email; @@ -147,7 +147,7 @@ class _NewsletterFormState extends State { final response = await http.Response.fromStream(streamedResponse); if (response.statusCode == 200) { - final jsonData = jsonDecode(response.body); + final jsonData = jsonDecode(response.body) as Object?; if (jsonData case {'errors': final Map serverErrors}) { _reverseSetErrors(serverErrors); diff --git a/sites/www/lib/src/utils/asset_utils.dart b/sites/www/lib/src/utils/asset_utils.dart index 19395751d99..d18587c3e1d 100644 --- a/sites/www/lib/src/utils/asset_utils.dart +++ b/sites/www/lib/src/utils/asset_utils.dart @@ -16,9 +16,7 @@ extension AssetExtension on BuildContext { } class TrackingAssetTransformer implements AssetTransformer { - TrackingAssetTransformer(); - - final _trackingFile = File( + final IOSink _trackingFile = File( p.join('tool', 'used_assets.txt'), ).openWrite(mode: FileMode.write); @@ -30,6 +28,8 @@ class TrackingAssetTransformer implements AssetTransformer { } class ResizingAssetTransformer implements AssetTransformer { + const ResizingAssetTransformer(); + @override Asset transform(Asset asset, [Object? aspect]) { final width = aspect is int ? aspect : null; diff --git a/sites/www/tool/get_video_transcript.dart b/sites/www/tool/get_video_transcript.dart index aefb71c3db1..4055f5a89c7 100644 --- a/sites/www/tool/get_video_transcript.dart +++ b/sites/www/tool/get_video_transcript.dart @@ -87,13 +87,13 @@ String? _youtubeVideoIdFromUrl(String url) { String _formatTimestamp(int seconds) { final hours = seconds ~/ 3600; final minutes = (seconds % 3600) ~/ 60; - final secs = (seconds % 60).toInt(); + final secondsInMinute = seconds % 60; String pad(int n) => n.toString().padLeft(2, '0'); if (hours > 0) { - return '[${pad(hours)}:${pad(minutes)}:${pad(secs)}]'; + return '[${pad(hours)}:${pad(minutes)}:${pad(secondsInMinute)}]'; } else { - return '[${pad(minutes)}:${pad(secs)}]'; + return '[${pad(minutes)}:${pad(secondsInMinute)}]'; } } diff --git a/tool/dash_site/lib/src/commands/build.dart b/tool/dash_site/lib/src/commands/build.dart index 25904d6dd69..c93b8bb578b 100644 --- a/tool/dash_site/lib/src/commands/build.dart +++ b/tool/dash_site/lib/src/commands/build.dart @@ -30,7 +30,7 @@ final class BuildSiteCommand extends Command { String get name => 'build'; @override - Future run() async => buildSite( + Future run() => buildSite( selectedSite, productionRelease: argResults.get(_releaseFlag, false), ); diff --git a/tool/dash_site/lib/src/commands/check_link_references.dart b/tool/dash_site/lib/src/commands/check_link_references.dart index fb0d540d893..b41a4c340cb 100644 --- a/tool/dash_site/lib/src/commands/check_link_references.dart +++ b/tool/dash_site/lib/src/commands/check_link_references.dart @@ -83,18 +83,21 @@ Map> _findInvalidLinkReferences(Directory directory) { } List _findInContent(String content) { + var transformedContent = content; for (final replacement in _allReplacements) { - content = content.replaceAll(replacement, ''); + transformedContent = transformedContent.replaceAll(replacement, ''); } - // Use regex to find all links that displayed abnormally, + // Use a regular expression to find all links that displayed abnormally, // since a valid reference link should be an `` tag after rendered: // // - `[flutter.dev][]` // - `[GitHub repo][repo]` // See also: // - https://github.github.com/gfm/#reference-link - final invalidFound = _invalidLinkReferencePattern.allMatches(content); + final invalidFound = _invalidLinkReferencePattern.allMatches( + transformedContent, + ); if (invalidFound.isEmpty) { return const []; @@ -111,14 +114,14 @@ List _findInContent(String content) { /// ```html /// /// ``` -final _htmlCommentPattern = RegExp(r'', dotAll: true); +final RegExp _htmlCommentPattern = RegExp(r'', dotAll: true); /// Ignore blocks with code: /// /// ```dart /// [[highlight]]flutter[[/highlight]] /// ``` -final _codeBlockPattern = RegExp(r'', dotAll: true); +final RegExp _codeBlockPattern = RegExp(r'', dotAll: true); /// Ignore PR titles that look like a link /// directly embedded in a paragraph @@ -130,7 +133,7 @@ final _codeBlockPattern = RegExp(r'', dotAll: true); /// (cla: yes, waiting for tree to go green, platform-web, needs tests) ///

/// ``` -final _pullRequestTitlePattern = RegExp( +final RegExp _pullRequestTitlePattern = RegExp( r'

\d+.*?

', dotAll: true, ); @@ -143,17 +146,17 @@ final _pullRequestTitlePattern = RegExp( ///
  • [docs][FWW] DropdownButton, ScaffoldMessenger, and StatefulBuilder links /// by @craiglabenz in https://github.com/flutter/flutter/pull/100316
  • /// ``` -final _pullRequestTitleInListItemPattern = RegExp( +final RegExp _pullRequestTitleInListItemPattern = RegExp( r'
  • (?:(?!
  • ).)*?in\s+(?:(?!
  • ).)*?
  • ', dotAll: true, ); /// All replacements to run on a file content before finding invalid references. -final _allReplacements = [ +final List _allReplacements = [ _htmlCommentPattern, _codeBlockPattern, _pullRequestTitlePattern, _pullRequestTitleInListItemPattern, ]; -final _invalidLinkReferencePattern = RegExp(r'\[[^\[\]]+]\[[^\[\]]*]'); +final RegExp _invalidLinkReferencePattern = RegExp(r'\[[^\[\]]+]\[[^\[\]]*]'); diff --git a/tool/dash_site/lib/src/commands/check_links.dart b/tool/dash_site/lib/src/commands/check_links.dart index 112cd9cd81a..769e09c8586 100644 --- a/tool/dash_site/lib/src/commands/check_links.dart +++ b/tool/dash_site/lib/src/commands/check_links.dart @@ -32,7 +32,7 @@ final class CheckLinksCommand extends Command { String get name => 'check-links'; @override - Future run() async => _checkLinks( + Future run() => _checkLinks( site: selectedSite, checkExternal: argResults.get(_externalFlag, false), ); diff --git a/tool/dash_site/lib/src/commands/deploy.dart b/tool/dash_site/lib/src/commands/deploy.dart index 32e15181080..858b24aef76 100644 --- a/tool/dash_site/lib/src/commands/deploy.dart +++ b/tool/dash_site/lib/src/commands/deploy.dart @@ -75,6 +75,6 @@ final class DeployCommand extends Command { workingDirectory: path.join(repositoryRoot, selectedSite.directory), mode: ProcessStartMode.inheritStdio, ); - return deploy.exitCode; + return await deploy.exitCode; } } diff --git a/tool/dash_site/lib/src/commands/refresh_excerpts.dart b/tool/dash_site/lib/src/commands/refresh_excerpts.dart index 3f204bf44f3..c9c77cfcff9 100644 --- a/tool/dash_site/lib/src/commands/refresh_excerpts.dart +++ b/tool/dash_site/lib/src/commands/refresh_excerpts.dart @@ -42,7 +42,7 @@ final class RefreshExcerptsCommand extends Command { String get name => 'refresh-excerpts'; @override - Future run() async => _refreshExcerpts( + Future run() => _refreshExcerpts( site: selectedSite, verboseLogging: argResults.get(_verboseFlag, false), dryRun: argResults.get(_dryRunFlag, false), diff --git a/tool/dash_site/lib/src/commands/stage_preview.dart b/tool/dash_site/lib/src/commands/stage_preview.dart index 0feb2e9842f..8da6f5c286e 100644 --- a/tool/dash_site/lib/src/commands/stage_preview.dart +++ b/tool/dash_site/lib/src/commands/stage_preview.dart @@ -179,7 +179,7 @@ final class StagePreviewCommand extends Command { return 0; } - return _commentStagingUrlOnGitHub( + return await _commentStagingUrlOnGitHub( site: selectedSite, stagingUrl: stagingUrl, context: prContext, diff --git a/tool/dash_site/lib/src/commands/test_dart.dart b/tool/dash_site/lib/src/commands/test_dart.dart index 3f86771a5a7..00195d8a8c6 100644 --- a/tool/dash_site/lib/src/commands/test_dart.dart +++ b/tool/dash_site/lib/src/commands/test_dart.dart @@ -28,7 +28,7 @@ final class TestDartCommand extends Command { String get name => 'test-dart'; @override - Future run() async => + Future run() => _testDart(verboseLogging: argResults.get(_verboseFlag, false)); }