known_broken_documentation.dart 4.25 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
// This file is used by ../analyze_snippet_code_test.dart, which depends on the
6 7 8 9
// precise contents (including especially the comments) of this file.

// Examples can assume:
// bool _visible = true;
10
// class _Text extends Text {
11 12
//   const _Text(super.text);
//   const _Text.__(super.text);
13
// }
14 15 16 17 18 19 20 21 22 23 24

/// 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.
///
25
/// {@tool snippet}
26 27 28 29
/// Bla blabla blabla some [Text] when the `_blabla` blabla blabla is true, and
/// blabla it when it is blabla:
///
/// ```dart
30
/// new Opacity( // error (unnecessary_new)
31 32 33 34
///   opacity: _visible ? 1.0 : 0.0,
///   child: const Text('Poor wandering ones!'),
/// )
/// ```
35
/// {@end-tool}
36
///
37
/// {@tool snippet}
38 39 40
/// Bla blabla blabla some [Text] when the `_blabla` blabla blabla is true, and
/// blabla it when it is blabla:
///
41
/// ```dart
42 43 44 45
/// final GlobalKey globalKey = GlobalKey();
/// ```
///
/// ```dart
46
/// // continuing from previous example...
47 48 49 50 51 52 53 54 55 56
/// Widget build(BuildContext context) {
///   return Opacity(
///     key: globalKey,
///     opacity: _visible ? 1.0 : 0.0,
///     child: const Text('Poor wandering ones!'),
///   );
/// }
/// ```
/// {@end-tool}
///
57
/// {@tool snippet}
58 59 60 61
/// Bla blabla blabla some [Text] when the `_blabla` blabla blabla is true, and
/// blabla finale blabla:
///
/// ```dart
62
/// Opacity(
63 64
///   opacity: _visible ? 1.0 : 0.0,
///   child: const Text('Poor wandering ones!'),
65
/// )
66
/// ```
67
/// {@end-tool}
68
///
69
/// {@tool snippet}
70 71 72 73 74 75 76
/// regular const constructor
///
/// ```dart
/// const Text('Poor wandering ones!')
/// ```
/// {@end-tool}
///
77
/// {@tool snippet}
78 79 80 81 82 83
/// const private constructor
/// ```dart
/// const             _Text('Poor wandering ones!')
/// ```
/// {@end-tool}
///
84
/// {@tool snippet}
85 86 87 88 89 90
/// yet another const private constructor
/// ```dart
/// const        _Text.__('Poor wandering ones!')
/// ```
/// {@end-tool}
///
91
/// {@tool snippet}
92 93 94
/// const variable
///
/// ```dart
95
/// const Widget text0 = Text('Poor wandering ones!');
96 97 98
/// ```
/// {@end-tool}
///
99
/// {@tool snippet}
100 101 102
/// more const variables
///
/// ```dart
103
/// const text1 = _Text('Poor wandering ones!'); // error (always_specify_types)
104 105
/// ```
/// {@end-tool}
106 107 108 109 110
///
/// {@tool snippet}
/// Snippet with null-safe syntax
///
/// ```dart
111 112
/// final String? bar = 'Hello'; // error (unnecessary_nullable_for_final_variable_declarations, prefer_const_declarations)
/// final int foo = null; // error (invalid_assignment, prefer_const_declarations)
113 114 115
/// ```
/// {@end-tool}
///
116 117 118 119 120 121
/// snippet with trailing comma
///
/// ```dart
/// const SizedBox(),
/// ```
///
122
/// {@tool dartpad}
123 124
/// Dartpad with null-safe syntax
///
125
/// ```dart
126 127 128 129
/// final GlobalKey globalKey = GlobalKey();
/// ```
///
/// ```dart
130
/// // not continuing from previous example...
131 132 133
/// Widget build(BuildContext context) {
///   final String title;
///   return Opacity(
134 135 136
///     key: globalKey, // error (undefined_identifier, argument_type_not_assignable)
///     opacity: _visible ? 1.0 : 0.0,
///     child: Text(title), // error (read_potentially_unassigned_final)
137 138 139 140
///   );
/// }
/// ```
/// {@end-tool}
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
///
/// ```csv
/// this,is,fine
/// ```
///
/// ```dart
/// import 'dart:io'; // error (unused_import)
/// final Widget p = Placeholder(); // error (undefined_class, undefined_function, avoid_dynamic_calls)
/// ```
///
/// ```dart
/// // (e.g. in a stateful widget)
/// void initState() { // error (must_call_super, annotate_overrides)
///   widget.toString(); // error (undefined_identifier, return_of_invalid_type)
/// }
/// ```
///
/// ```dart
/// // not in a stateful widget
/// void initState() {
///   widget.toString(); // error (undefined_identifier)
/// }
/// ```
///
/// ```
/// error (something about backticks)
/// this must be the last error, since it aborts parsing of this file
/// ```