mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

Part 2 from https://github.com/flutter/flutter/pull/146085 In preparation to add the lint `missing_code_block_language_in_doc_comment`, added `none` info strings to a bunch of fenced code blocks that have miscellaneous text or output text. Related to issue: https://github.com/dart-lang/linter/issues/4904 ## Pre-launch Checklist - [X] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [X] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [X] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [X] I signed the [CLA]. - [X] I listed at least one issue that this PR fixes in the description above. - [X] I updated/added relevant documentation (doc comments with `///`). - [X] I added new tests to check the change I am making, or this PR is [test-exempt]. - [X] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [Features we expect every widget to implement]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat [Data Driven Fixes]: https://github.com/flutter/flutter/wiki/Data-driven-Fixes
170 lines
4.2 KiB
Dart
170 lines
4.2 KiB
Dart
// 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 file is used by ../analyze_snippet_code_test.dart, which depends on the
|
|
// precise contents (including especially the comments) of this file.
|
|
|
|
// Examples can assume:
|
|
// bool _visible = true;
|
|
// class _Text extends Text {
|
|
// const _Text(super.text);
|
|
// const _Text.__(super.text);
|
|
// }
|
|
|
|
/// A blabla that blabla its blabla blabla blabla.
|
|
///
|
|
/// Bla blabla blabla its blabla into an blabla blabla and then blabla the
|
|
/// blabla back into the blabla blabla blabla.
|
|
///
|
|
/// Bla blabla of blabla blabla than 0.0 and 1.0, this blabla is blabla blabla
|
|
/// blabla it blabla pirates blabla the blabla into of blabla blabla. Bla the
|
|
/// blabla 0.0, the penzance blabla is blabla not blabla at all. Bla the blabla
|
|
/// 1.0, the blabla is blabla blabla blabla an blabla blabla.
|
|
///
|
|
/// {@tool snippet}
|
|
/// Bla blabla blabla some [Text] when the `_blabla` blabla blabla is true, and
|
|
/// blabla it when it is blabla:
|
|
///
|
|
/// ```dart
|
|
/// new Opacity( // error (unnecessary_new)
|
|
/// opacity: _visible ? 1.0 : 0.0,
|
|
/// child: const Text('Poor wandering ones!'),
|
|
/// )
|
|
/// ```
|
|
/// {@end-tool}
|
|
///
|
|
/// {@tool snippet}
|
|
/// Bla blabla blabla some [Text] when the `_blabla` blabla blabla is true, and
|
|
/// blabla it when it is blabla:
|
|
///
|
|
/// ```dart
|
|
/// final GlobalKey globalKey = GlobalKey();
|
|
/// ```
|
|
///
|
|
/// ```dart
|
|
/// // continuing from previous example...
|
|
/// Widget build(BuildContext context) {
|
|
/// return Opacity(
|
|
/// key: globalKey,
|
|
/// opacity: _visible ? 1.0 : 0.0,
|
|
/// child: const Text('Poor wandering ones!'),
|
|
/// );
|
|
/// }
|
|
/// ```
|
|
/// {@end-tool}
|
|
///
|
|
/// {@tool snippet}
|
|
/// Bla blabla blabla some [Text] when the `_blabla` blabla blabla is true, and
|
|
/// blabla finale blabla:
|
|
///
|
|
/// ```dart
|
|
/// Opacity(
|
|
/// opacity: _visible ? 1.0 : 0.0,
|
|
/// child: const Text('Poor wandering ones!'),
|
|
/// )
|
|
/// ```
|
|
/// {@end-tool}
|
|
///
|
|
/// {@tool snippet}
|
|
/// regular const constructor
|
|
///
|
|
/// ```dart
|
|
/// const Text('Poor wandering ones!')
|
|
/// ```
|
|
/// {@end-tool}
|
|
///
|
|
/// {@tool snippet}
|
|
/// const private constructor
|
|
/// ```dart
|
|
/// const _Text('Poor wandering ones!')
|
|
/// ```
|
|
/// {@end-tool}
|
|
///
|
|
/// {@tool snippet}
|
|
/// yet another const private constructor
|
|
/// ```dart
|
|
/// const _Text.__('Poor wandering ones!')
|
|
/// ```
|
|
/// {@end-tool}
|
|
///
|
|
/// {@tool snippet}
|
|
/// const variable
|
|
///
|
|
/// ```dart
|
|
/// const Widget text0 = Text('Poor wandering ones!');
|
|
/// ```
|
|
/// {@end-tool}
|
|
///
|
|
/// {@tool snippet}
|
|
/// more const variables
|
|
///
|
|
/// ```dart
|
|
/// const text1 = _Text('Poor wandering ones!'); // error (always_specify_types)
|
|
/// ```
|
|
/// {@end-tool}
|
|
///
|
|
/// {@tool snippet}
|
|
/// Snippet with null-safe syntax
|
|
///
|
|
/// ```dart
|
|
/// final String? bar = 'Hello'; // error (unnecessary_nullable_for_final_variable_declarations, prefer_const_declarations)
|
|
/// final int foo = null; // error (invalid_assignment, prefer_const_declarations)
|
|
/// ```
|
|
/// {@end-tool}
|
|
///
|
|
/// snippet with trailing comma
|
|
///
|
|
/// ```dart
|
|
/// const SizedBox(),
|
|
/// ```
|
|
///
|
|
/// {@tool dartpad}
|
|
/// Dartpad with null-safe syntax
|
|
///
|
|
/// ```dart
|
|
/// final GlobalKey globalKey = GlobalKey();
|
|
/// ```
|
|
///
|
|
/// ```dart
|
|
/// // not continuing from previous example...
|
|
/// Widget build(BuildContext context) {
|
|
/// final String title;
|
|
/// return Opacity(
|
|
/// key: globalKey, // error (undefined_identifier)
|
|
/// opacity: _visible ? 1.0 : 0.0,
|
|
/// child: Text(title), // error (read_potentially_unassigned_final)
|
|
/// );
|
|
/// }
|
|
/// ```
|
|
/// {@end-tool}
|
|
///
|
|
/// ```csv
|
|
/// this,is,fine
|
|
/// ```
|
|
///
|
|
/// ```dart
|
|
/// import 'dart:io'; // error (unused_import)
|
|
/// final Widget p = Placeholder(); // error (undefined_class, undefined_function)
|
|
/// ```
|
|
///
|
|
/// ```dart
|
|
/// // (e.g. in a stateful widget)
|
|
/// void initState() { // error (must_call_super, annotate_overrides)
|
|
/// widget.toString();
|
|
/// }
|
|
/// ```
|
|
///
|
|
/// ```dart
|
|
/// // not in a stateful widget
|
|
/// void initState() {
|
|
/// widget.toString(); // error (undefined_identifier)
|
|
/// }
|
|
/// ```
|
|
///
|
|
/// ```none
|
|
/// error (something about backticks)
|
|
/// this must be the last error, since it aborts parsing of this file
|
|
/// ```
|
|
String? foo;
|