diff --git a/dartdoc_options.yaml b/dartdoc_options.yaml index 90c431695a..49db3df517 100644 --- a/dartdoc_options.yaml +++ b/dartdoc_options.yaml @@ -4,11 +4,11 @@ dartdoc: # The dev/tools/dartdoc.dart script does this automatically. tools: snippet: - command: ["dev/snippets/lib/main.dart", "--type=application"] - description: "Creates application sample code documentation output from embedded documentation samples." + command: ["dev/snippets/lib/main.dart", "--type=snippet"] + description: "Creates sample code documentation output from embedded documentation samples." sample: command: ["dev/snippets/lib/main.dart", "--type=sample"] - description: "Creates sample code documentation output from embedded documentation samples." + description: "Creates full application sample code documentation output from embedded documentation samples." dartpad: - command: ["dev/snippets/lib/main.dart", "--type=application", "--dartpad"] - description: "Creates sample code documentation output from embedded documentation samples and displays it in an embedded DartPad." + command: ["dev/snippets/lib/main.dart", "--type=sample", "--dartpad"] + description: "Creates full application sample code documentation output from embedded documentation samples and displays it in an embedded DartPad." diff --git a/dev/bots/analyze-sample-code.dart b/dev/bots/analyze-sample-code.dart index 2957f26ccf..e0cfdf4998 100644 --- a/dev/bots/analyze-sample-code.dart +++ b/dev/bots/analyze-sample-code.dart @@ -107,10 +107,10 @@ class SampleCheckerException implements Exception { /// error output from the analyzer is parsed for details, and the problem /// locations are translated back to the source location. /// -/// For snippets, the snippets are generated using the snippets tool, and they -/// are analyzed with the samples. If errors are found in snippets, then the -/// line number of the start of the snippet is given instead of the actual error -/// line, since snippets get reformatted when written, and the line numbers +/// For samples, the samples are generated using the snippets tool, and they +/// are analyzed with the snippets. If errors are found in samples, then the +/// line number of the start of the sample is given instead of the actual error +/// line, since samples get reformatted when written, and the line numbers /// don't necessarily match. It does, however, print the source of the /// problematic line. class SampleChecker { @@ -209,7 +209,7 @@ class SampleChecker { Map> errors = >{}; try { final Map sections = {}; - final Map snippets = {}; + final Map snippets = {}; _extractSamples(sections, snippets); errors = _analyze(_tempDirectory, sections, snippets); } finally { @@ -242,10 +242,10 @@ class SampleChecker { /// 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; + String sampleId = path.split(filename).join('.'); + sampleId = path.basenameWithoutExtension(sampleId); + sampleId = '$prefix.$sampleId.$start'; + return sampleId; } // Precompiles the snippets tool if _snippetsSnapshotPath isn't set yet, and @@ -273,42 +273,42 @@ class SampleChecker { } } - /// Writes out the given [snippet] to an output file in the [_tempDirectory] and + /// Writes out the given sample to an output file in the [_tempDirectory] and /// returns the output file. - File _writeSnippet(Snippet snippet) { + File _writeSample(Sample sample) { // Generate the snippet. - final String snippetId = _createNameFromSource('snippet', snippet.start.filename, snippet.start.line); - final String inputName = '$snippetId.input'; + final String sampleId = _createNameFromSource('sample', sample.start.filename, sample.start.line); + final String inputName = '$sampleId.input'; // Now we have a filename like 'lib.src.material.foo_widget.123.dart' for each snippet. final File inputFile = File(path.join(_tempDirectory.path, inputName))..createSync(recursive: true); - inputFile.writeAsStringSync(snippet.input.join('\n')); - final File outputFile = File(path.join(_tempDirectory.path, '$snippetId.dart')); + inputFile.writeAsStringSync(sample.input.join('\n')); + final File outputFile = File(path.join(_tempDirectory.path, '$sampleId.dart')); final List args = [ '--output=${outputFile.absolute.path}', '--input=${inputFile.absolute.path}', - ...snippet.args, + ...sample.args, ]; if (verbose) - print('Generating snippet for ${snippet.start?.filename}:${snippet.start?.line}'); + print('Generating sample for ${sample.start?.filename}:${sample.start?.line}'); final ProcessResult process = _runSnippetsScript(args); if (verbose) stderr.write('${process.stderr}'); if (process.exitCode != 0) { throw SampleCheckerException( - 'Unable to create snippet for ${snippet.start.filename}:${snippet.start.line} ' + 'Unable to create sample for ${sample.start.filename}:${sample.start.line} ' '(using input from ${inputFile.path}):\n${process.stdout}\n${process.stderr}', - file: snippet.start.filename, - line: snippet.start.line, + file: sample.start.filename, + line: sample.start.line, ); } return outputFile; } /// Extracts the samples from the Dart files in [_flutterPackage], writes them - /// to disk, and adds them to the appropriate [sectionMap] or [snippetMap]. - void _extractSamples(Map sectionMap, Map snippetMap) { + /// to disk, and adds them to the appropriate [sectionMap] or [sampleMap]. + void _extractSamples(Map sectionMap, Map sampleMap) { final List
sections =
[]; - final List snippets = []; + final List samples = []; for (final File file in _listDartFiles(_flutterPackage, recursive: true)) { final String relativeFilePath = path.relative(file.path, from: _flutterPackage.path); @@ -334,12 +334,12 @@ class SampleChecker { throw SampleCheckerException('Snippet section unterminated.', file: relativeFilePath, line: lineNumber); } if (_dartDocSampleEndRegex.hasMatch(trimmedLine)) { - snippets.add( - Snippet( + samples.add( + Sample( start: startLine, input: block, args: snippetArgs, - serial: snippets.length, + serial: samples.length, ), ); snippetArgs = []; @@ -407,7 +407,7 @@ class SampleChecker { startLine = Line('', filename: relativeFilePath, line: lineNumber + 1, indent: 3); inPreamble = true; } else if (sampleMatch != null) { - inSnippet = sampleMatch != null && (sampleMatch[1] == 'snippet' || sampleMatch[1] == 'dartpad'); + inSnippet = sampleMatch != null && (sampleMatch[1] == 'sample' || sampleMatch[1] == 'dartpad'); if (inSnippet) { startLine = Line( '', @@ -425,7 +425,7 @@ class SampleChecker { inSampleSection = !inSnippet; } else if (RegExp(r'///\s*#+\s+[Ss]ample\s+[Cc]ode:?$').hasMatch(trimmedLine)) { throw SampleCheckerException( - "Found deprecated '## Sample code' section: use {@tool sample}...{@end-tool} instead.", + "Found deprecated '## Sample code' section: use {@tool snippet}...{@end-tool} instead.", file: relativeFilePath, line: lineNumber, ); @@ -437,10 +437,10 @@ class SampleChecker { for (final Section section in sections) { sectionMap[_writeSection(section).path] = section; } - for (final Snippet snippet in snippets) { - final File snippetFile = _writeSnippet(snippet); - snippet.contents = snippetFile.readAsLinesSync(); - snippetMap[snippetFile.absolute.path] = snippet; + for (final Sample sample in samples) { + final File snippetFile = _writeSample(sample); + sample.contents = snippetFile.readAsLinesSync(); + sampleMap[snippetFile.absolute.path] = sample; } } @@ -506,7 +506,7 @@ linter: /// Writes out a sample section to the disk and returns the file. File _writeSection(Section section) { - final String sectionId = _createNameFromSource('sample', section.start.filename, section.start.line); + final String sectionId = _createNameFromSource('snippet', section.start.filename, section.start.line); final File outputFile = File(path.join(_tempDirectory.path, '$sectionId.dart'))..createSync(recursive: true); final List mainContents = [ ...headers, @@ -520,7 +520,7 @@ linter: /// Invokes the analyzer on the given [directory] and returns the stdout. List _runAnalyzer(Directory directory) { - print('Starting analysis of samples.'); + print('Starting analysis of code samples.'); _createConfigurationFiles(directory); final ProcessResult result = Process.runSync( _flutter, @@ -556,7 +556,7 @@ linter: Map> _analyze( Directory directory, Map sections, - Map snippets, + Map samples, ) { final List errors = _runAnalyzer(directory); final Map> analysisErrors = >{}; @@ -587,7 +587,7 @@ linter: final String line = parts[4]; final String column = parts[5]; final String errorCode = parts[6]; - final int lineNumber = int.parse(line, radix: 10) - (isSample ? headerLength : 0); + final int lineNumber = int.parse(line, radix: 10) - (isSnippet ? headerLength : 0); final int columnNumber = int.parse(column, radix: 10); if (lineNumber < 0 && errorCode == 'unused_import') { // We don't care about unused imports. @@ -621,7 +621,7 @@ linter: // We don't really care if sample code isn't used! continue; } - if (isSnippet) { + if (isSample) { addAnalysisError( file, AnalysisError( @@ -630,7 +630,7 @@ linter: message, errorCode, null, - snippet: snippets[file.path], + sample: samples[file.path], ), ); } else { @@ -794,7 +794,7 @@ class Line { String toString() => '$filename:$line: $code'; } -/// A class to represent a section of sample code, marked by "{@tool sample}...{@end-tool}". +/// A class to represent a section of sample code, marked by "{@tool snippet}...{@end-tool}". class Section { const Section(this.code); factory Section.combine(List
sections) { @@ -841,12 +841,12 @@ class Section { final List code; } -/// A class to represent a snippet in the dartdoc comments, marked by -/// "{@tool snippet ...}...{@end-tool}". Snippets are processed separately from -/// regular samples, because they must be injected into templates in order to be +/// A class to represent a sample in the dartdoc comments, marked by +/// "{@tool sample ...}...{@end-tool}". Samples are processed separately from +/// regular snippets, because they must be injected into templates in order to be /// analyzed. -class Snippet { - Snippet({this.start, List input, List args, this.serial}) { +class Sample { + Sample({this.start, List input, List args, this.serial}) { this.input = input.toList(); this.args = args.toList(); } @@ -858,7 +858,7 @@ class Snippet { @override String toString() { - final StringBuffer buf = StringBuffer('snippet ${args.join(' ')}\n'); + final StringBuffer buf = StringBuffer('sample ${args.join(' ')}\n'); int count = start.line; for (final String line in input) { buf.writeln(' ${count.toString().padLeft(4, ' ')}: $line'); @@ -878,7 +878,7 @@ class AnalysisError { this.message, this.errorCode, this.source, { - this.snippet, + this.sample, }); final int line; @@ -886,15 +886,15 @@ class AnalysisError { final String message; final String errorCode; final Line source; - final Snippet snippet; + final Sample sample; @override String toString() { if (source != null) { return '${source.toStringWithColumn(column)}\n>>> $message ($errorCode)'; - } else if (snippet != null) { - return 'In snippet starting at ' - '${snippet.start.filename}:${snippet.start.line}:${snippet.contents[line - 1]}\n' + } else if (sample != null) { + return 'In sample starting at ' + '${sample.start.filename}:${sample.start.line}:${sample.contents[line - 1]}\n' '>>> $message ($errorCode)'; } else { return ':$line:$column\n>>> $message ($errorCode)'; diff --git a/dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart b/dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart index d15804d8a4..93c0cabe63 100644 --- a/dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart +++ b/dev/bots/test/analyze-sample-code-test-input/known_broken_documentation.dart @@ -22,7 +22,7 @@ /// 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 sample} +/// {@tool snippet} /// Bla blabla blabla some [Text] when the `_blabla` blabla blabla is true, and /// blabla it when it is blabla: /// @@ -54,7 +54,7 @@ /// ``` /// {@end-tool} /// -/// {@tool sample} +/// {@tool snippet} /// Bla blabla blabla some [Text] when the `_blabla` blabla blabla is true, and /// blabla finale blabla: /// @@ -66,7 +66,7 @@ /// ``` /// {@end-tool} /// -/// {@tool sample} +/// {@tool snippet} /// regular const constructor /// /// ```dart @@ -74,21 +74,21 @@ /// ``` /// {@end-tool} /// -/// {@tool sample} +/// {@tool snippet} /// const private constructor /// ```dart /// const _Text('Poor wandering ones!') /// ``` /// {@end-tool} /// -/// {@tool sample} +/// {@tool snippet} /// yet another const private constructor /// ```dart /// const _Text.__('Poor wandering ones!') /// ``` /// {@end-tool} /// -/// {@tool sample} +/// {@tool snippet} /// const variable /// /// ```dart @@ -96,7 +96,7 @@ /// ``` /// {@end-tool} /// -/// {@tool sample} +/// {@tool snippet} /// more const variables /// /// ```dart diff --git a/dev/bots/test/analyze-sample-code_test.dart b/dev/bots/test/analyze-sample-code_test.dart index b9d800a47b..9fd35eb041 100644 --- a/dev/bots/test/analyze-sample-code_test.dart +++ b/dev/bots/test/analyze-sample-code_test.dart @@ -27,7 +27,7 @@ void main() { ]); expect(stdoutLines, [ 'Found 7 sample code sections.', - 'Starting analysis of samples.', + 'Starting analysis of code samples.', '', ]); }, skip: Platform.isWindows); diff --git a/dev/snippets/README.md b/dev/snippets/README.md index 87fe24ea0d..60687bc6ae 100644 --- a/dev/snippets/README.md +++ b/dev/snippets/README.md @@ -9,8 +9,8 @@ in the source code into API documentation, as seen on https://api.flutter.dev/. ## Table of Contents - [Types of code blocks](#types-of-code-blocks) - - [Sample tool](#sample-tool) - [Snippet tool](#snippet-tool) + - [Sample tool](#sample-tool) - [Skeletons](#skeletons) - [Test Doc Generation Workflow](#test-doc-generation-workflow) @@ -18,21 +18,21 @@ in the source code into API documentation, as seen on https://api.flutter.dev/. There's two kinds of code blocks. -* samples, which are more or less context-free snippets that we +* snippets, which are more or less context-free code snippets that we magically determine how to analyze, and -* snippets, which get placed into a full-fledged application, and can +* samples, which get placed into a full-fledged application, and can be actually executed inline in the documentation using DartPad. -### Sample Tool +### Snippet Tool -![Code sample image](assets/code_sample.png) +![Code snippet image](assets/code_snippet.png) -The code `sample` tool generates a block containing a description and example -code. Here is an example of the code `sample` tool in use: +The code `snippet` tool generates a block containing a description and example +code. Here is an example of the code `snippet` tool in use: ```dart -/// {@tool sample} +/// {@tool snippet} /// /// If the avatar is to have an image, the image should be specified in the /// [backgroundImage] property: @@ -48,13 +48,13 @@ code. Here is an example of the code `sample` tool in use: This will generate sample code that can be copied to the clipboard and added to existing applications. -This uses the skeleton for [sample](config/skeletons/sample.html) +This uses the skeleton for [snippet](config/skeletons/snippet.html) snippets when generating the HTML to put into the Dart docs. #### Analysis The `../bots/analyze-sample-code.dart` script finds code inside the -`@tool sample` sections and uses the Dart analyzer to check them. +`@tool snippet` sections and uses the Dart analyzer to check them. There are several kinds of sample code you can specify: @@ -91,16 +91,16 @@ You can assume that the entire Flutter framework and most common `dart:*` packages are imported and in scope; `dart:math` as `math` and `dart:ui` as `ui`. -### Snippet Tool +### Sample Tool -![Code snippet image](assets/code_snippet.png) +![Code sample image](assets/code_sample.png) -The code `snippet` tool can expand sample code into full Flutter applications. +The code `sample` tool can expand sample code into full Flutter applications. These sample applications can be directly copied and used to demonstrate the API's functionality in a sample application: ```dart -/// {@tool snippet --template=stateless_widget_material} +/// {@tool sample --template=stateless_widget_material} /// This example shows how to make a simple [FloatingActionButton] in a /// [Scaffold], with a pink [backgroundColor] and a thumbs up [Icon]. /// @@ -126,10 +126,10 @@ API's functionality in a sample application: /// {@end-tool} ``` -This uses the skeleton for [application](config/skeletons/application.html) +This uses the skeleton for [application](config/skeletons/sample.html) snippets. -Code `snippets` also allow for quick Flutter app generation using the following command: +Code `sample` also allow for quick Flutter app generation using the following command: ```bash flutter create --sample=[directory.File.sampleNumber] [name_of_project_directory] @@ -138,12 +138,12 @@ flutter create --sample=[directory.File.sampleNumber] [name_of_project_directory #### Templates In order to support showing an entire app when you click on the right tab of -the code snippet UI, we have to be able to insert the `snippet` into the template -and instantiate the right parts. +the code sample UI, we have to be able to insert the `sample` block into the +template and instantiate the right parts. To do this, there is a [config/templates](config/templates) directory that contains a list of templates. These templates represent an entire app that the -`snippet` can be placed into, basically a replacement for `lib/main.dart` in a +`sample` can be placed into, basically a replacement for `lib/main.dart` in a flutter app package. For more information about how to create, use, or update templates, see @@ -152,7 +152,7 @@ For more information about how to create, use, or update templates, see #### Analysis The `../bots/analyze-sample-code.dart` script finds code inside the -`@tool snippet` sections and uses the Dart analyzer to check them +`@tool sample` sections and uses the Dart analyzer to check them after applying the specified template. ## Skeletons @@ -161,17 +161,17 @@ A skeleton (in relation to this tool) is an HTML template into which the Dart code blocks and descriptions are interpolated. There is currently one skeleton for -[application](config/skeletons/application.html) `snippets` and one for -[sample](config/skeletons/sample.html) `snippets`, but there could be more. +[application](config/skeletons/sample.html) samples and one for +[snippet](config/skeletons/snippet.html) code samples, but there could be more. Skeletons use mustache notation (e.g. `{{code}}`) to mark where components will be interpolated into the template. It doesn't actually use the mustache package, since these are simple string substitutions, but it uses the same syntax. -The code block generation tools process the source input and emit HTML for output, -which dartdoc places back into the documentation. Any options given to the - `{@tool ...}` directive are passed on verbatim to the tool. +The code block generation tools process the source input and emit HTML for +output, which dartdoc places back into the documentation. Any options given to +the `{@tool ...}` directive are passed on verbatim to the tool. The `snippets` tool renders these examples through a combination of markdown and HTML using the `{@inject-html}` dartdoc directive. diff --git a/dev/snippets/assets/code_sample.png b/dev/snippets/assets/code_sample.png index cc3e125cc5..96bf7e86bf 100644 Binary files a/dev/snippets/assets/code_sample.png and b/dev/snippets/assets/code_sample.png differ diff --git a/dev/snippets/assets/code_snippet.png b/dev/snippets/assets/code_snippet.png index 96bf7e86bf..cc3e125cc5 100644 Binary files a/dev/snippets/assets/code_snippet.png and b/dev/snippets/assets/code_snippet.png differ diff --git a/dev/snippets/config/skeletons/application.html b/dev/snippets/config/skeletons/application.html deleted file mode 100644 index 56b648cc03..0000000000 --- a/dev/snippets/config/skeletons/application.html +++ /dev/null @@ -1,43 +0,0 @@ -{@inject-html} - - -
- - - -
-
-
- {{description}} -
- -
{{code}}
-
-
- -
-{@end-inject-html} diff --git a/dev/snippets/config/skeletons/dartpad-application.html b/dev/snippets/config/skeletons/dartpad-sample.html similarity index 100% rename from dev/snippets/config/skeletons/dartpad-application.html rename to dev/snippets/config/skeletons/dartpad-sample.html diff --git a/dev/snippets/config/skeletons/sample.html b/dev/snippets/config/skeletons/sample.html index 75f87824e4..56b648cc03 100644 --- a/dev/snippets/config/skeletons/sample.html +++ b/dev/snippets/config/skeletons/sample.html @@ -9,16 +9,34 @@
- + + +
-
{{description}} +
+ {{description}}
-
{{code}}
+
{{code}}
+
+
+
diff --git a/dev/snippets/config/skeletons/snippet.html b/dev/snippets/config/skeletons/snippet.html new file mode 100644 index 0000000000..75f87824e4 --- /dev/null +++ b/dev/snippets/config/skeletons/snippet.html @@ -0,0 +1,25 @@ +{@inject-html} + + +
+ +
+
+
{{description}} +
+ +
{{code}}
+
+
+
+{@end-inject-html} diff --git a/dev/snippets/lib/configuration.dart b/dev/snippets/lib/configuration.dart index 19fd93ee5e..efbe8ca19f 100644 --- a/dev/snippets/lib/configuration.dart +++ b/dev/snippets/lib/configuration.dart @@ -11,10 +11,10 @@ import 'package:path/path.dart' as path; enum SnippetType { /// Produces a snippet that includes the code interpolated into an application /// template. - application, + sample, /// Produces a nicely formatted sample code, but no application. - sample, + snippet, } /// Return the name of an enum item. @@ -69,7 +69,7 @@ class Configuration { /// Gets the skeleton file to use for the given [SnippetType] and DartPad preference. File getHtmlSkeletonFile(SnippetType type, {bool showDartPad = false}) { - assert(!showDartPad || type == SnippetType.application, + assert(!showDartPad || type == SnippetType.sample, 'Only application snippets work with dartpad.'); final String filename = '${showDartPad ? 'dartpad-' : ''}${getEnumName(type)}.html'; diff --git a/dev/snippets/lib/main.dart b/dev/snippets/lib/main.dart index e9f9d8adc6..fd5f8dd4e1 100644 --- a/dev/snippets/lib/main.dart +++ b/dev/snippets/lib/main.dart @@ -32,13 +32,13 @@ void main(List argList) { SnippetType.values.map((SnippetType type) => getEnumName(type)).toList(); parser.addOption( _kTypeOption, - defaultsTo: getEnumName(SnippetType.application), + defaultsTo: getEnumName(SnippetType.sample), allowed: snippetTypes, allowedHelp: { - getEnumName(SnippetType.application): - 'Produce a code snippet complete with embedding the sample in an ' - 'application template.', getEnumName(SnippetType.sample): + 'Produce a code sample application complete with embedding the sample in an ' + 'application template.', + getEnumName(SnippetType.snippet): 'Produce a nicely formatted piece of sample code. Does not embed the ' 'sample into an application template.', }, @@ -52,7 +52,7 @@ void main(List argList) { parser.addOption( _kOutputOption, defaultsTo: null, - help: 'The output path for the generated snippet application. Overrides ' + help: 'The output path for the generated sample application. Overrides ' 'the naming generated by the --package/--library/--element arguments. ' 'Metadata will be written alongside in a .json file. ' 'The basename of this argument is used as the ID', @@ -60,22 +60,22 @@ void main(List argList) { parser.addOption( _kInputOption, defaultsTo: environment['INPUT'], - help: 'The input file containing the snippet code to inject.', + help: 'The input file containing the sample code to inject.', ); parser.addOption( _kPackageOption, defaultsTo: environment['PACKAGE_NAME'], - help: 'The name of the package that this snippet belongs to.', + help: 'The name of the package that this sample belongs to.', ); parser.addOption( _kLibraryOption, defaultsTo: environment['LIBRARY_NAME'], - help: 'The name of the library that this snippet belongs to.', + help: 'The name of the library that this sample belongs to.', ); parser.addOption( _kElementOption, defaultsTo: environment['ELEMENT_NAME'], - help: 'The name of the element that this snippet belongs to.', + help: 'The name of the element that this sample belongs to.', ); parser.addOption( _kSerialOption, @@ -92,9 +92,9 @@ void main(List argList) { _kShowDartPad, defaultsTo: false, negatable: false, - help: 'Indicates whether DartPad should be included in the snippet\'s ' + help: 'Indicates whether DartPad should be included in the sample\'s ' 'final HTML output. This flag only applies when the type parameter is ' - '"application".', + '"sample".', ); final ArgResults args = parser.parse(argList); @@ -108,9 +108,9 @@ void main(List argList) { .firstWhere((SnippetType type) => getEnumName(type) == args[_kTypeOption], orElse: () => null); assert(snippetType != null, "Unable to find '${args[_kTypeOption]}' in SnippetType enum."); - if (args[_kShowDartPad] == true && snippetType != SnippetType.application) { + if (args[_kShowDartPad] == true && snippetType != SnippetType.sample) { errorExit('${args[_kTypeOption]} was selected, but the --dartpad flag is only valid ' - 'for application snippets.'); + 'for application sample code.'); } if (args[_kInputOption] == null) { @@ -125,12 +125,12 @@ void main(List argList) { } String template; - if (snippetType == SnippetType.application) { + if (snippetType == SnippetType.sample) { final String templateArg = args[_kTemplateOption] as String; if (templateArg == null || templateArg.isEmpty) { stderr.writeln(parser.usage); errorExit('The --$_kTemplateOption option must be specified on the command ' - 'line for application snippets.'); + 'line for application samples.'); } template = templateArg.replaceAll(RegExp(r'.tmpl$'), ''); } diff --git a/dev/snippets/lib/snippets.dart b/dev/snippets/lib/snippets.dart index b21c795c36..946ac3da34 100644 --- a/dev/snippets/lib/snippets.dart +++ b/dev/snippets/lib/snippets.dart @@ -48,7 +48,7 @@ class SnippetGenerator { static DartFormatter formatter = DartFormatter(pageWidth: 80, fixes: StyleFix.all); /// This returns the output file for a given snippet ID. Only used for - /// [SnippetType.application] snippets. + /// [SnippetType.sample] snippets. File getOutputFile(String id) => File(path.join(configuration.outputDirectory.path, '$id.dart')); /// Gets the path to the template file requested. @@ -60,7 +60,7 @@ class SnippetGenerator { /// Injects the [injections] into the [template], and turning the /// "description" injection into a comment. Only used for - /// [SnippetType.application] snippets. + /// [SnippetType.sample] snippets. String interpolateTemplate(List<_ComponentTuple> injections, String template, Map metadata) { final RegExp moustacheRegExp = RegExp('{{([^}]+)}}'); return template.replaceAllMapped(moustacheRegExp, (Match match) { @@ -99,7 +99,7 @@ class SnippetGenerator { /// components, and we care about the order of the injections. /// /// Takes into account the [type] and doesn't substitute in the id and the app - /// if not a [SnippetType.application] snippet. + /// if not a [SnippetType.sample] snippet. String interpolateSkeleton(SnippetType type, List<_ComponentTuple> injections, String skeleton, Map metadata) { final List result = []; const HtmlEscape htmlEscape = HtmlEscape(); @@ -133,7 +133,7 @@ class SnippetGenerator { 'element': metadata['element'] as String ?? '', 'app': '', }; - if (type == SnippetType.application) { + if (type == SnippetType.sample) { substitutions ..['serial'] = metadata['serial']?.toString() ?? '0' ..['app'] = htmlEscape.convert(injections.firstWhere((_ComponentTuple tuple) => tuple.name == 'app').mergedContent); @@ -201,20 +201,20 @@ class SnippetGenerator { /// comment markers). /// /// The [type] is the type of snippet to create: either a - /// [SnippetType.application] or a [SnippetType.sample]. + /// [SnippetType.sample] or a [SnippetType.snippet]. /// /// [showDartPad] indicates whether DartPad should be shown where possible. /// Currently, this value only has an effect if [type] is - /// [SnippetType.application], in which case an alternate skeleton file is + /// [SnippetType.sample], in which case an alternate skeleton file is /// used to create the final HTML output. /// /// The [template] must not be null if the [type] is - /// [SnippetType.application], and specifies the name of the template to use + /// [SnippetType.sample], and specifies the name of the template to use /// for the application code. /// /// The [id] is a string ID to use for the output file, and to tell the user /// about in the `flutter create` hint. It must not be null if the [type] is - /// [SnippetType.application]. + /// [SnippetType.sample]. String generate( File input, SnippetType type, { @@ -223,14 +223,14 @@ class SnippetGenerator { File output, @required Map metadata, }) { - assert(template != null || type != SnippetType.application); + assert(template != null || type != SnippetType.sample); assert(metadata != null && metadata['id'] != null); assert(input != null); - assert(!showDartPad || type == SnippetType.application, + assert(!showDartPad || type == SnippetType.sample, 'Only application snippets work with dartpad.'); final List<_ComponentTuple> snippetData = parseInput(_loadFileAsUtf8(input)); switch (type) { - case SnippetType.application: + case SnippetType.sample: final Directory templatesDir = configuration.templatesDirectory; if (templatesDir == null) { stderr.writeln('Unable to find the templates directory.'); @@ -272,7 +272,7 @@ class SnippetGenerator { }); metadataFile.writeAsStringSync(jsonEncoder.convert(metadata)); break; - case SnippetType.sample: + case SnippetType.snippet: break; } final String skeleton = diff --git a/dev/snippets/test/configuration_test.dart b/dev/snippets/test/configuration_test.dart index 6aefbb8635..6db97d6a65 100644 --- a/dev/snippets/test/configuration_test.dart +++ b/dev/snippets/test/configuration_test.dart @@ -32,22 +32,22 @@ void main() { matches(RegExp(r'[/\\]flutter sdk[/\\]dev[/\\]snippets[/\\]config[/\\]templates'))); }); test('html skeleton file for sample is correct', () async { + expect( + config.getHtmlSkeletonFile(SnippetType.snippet).path, + matches(RegExp( + r'[/\\]flutter sdk[/\\]dev[/\\]snippets[/\\]config[/\\]skeletons[/\\]snippet.html'))); + }); + test('html skeleton file for app with no dartpad is correct', () async { expect( config.getHtmlSkeletonFile(SnippetType.sample).path, matches(RegExp( r'[/\\]flutter sdk[/\\]dev[/\\]snippets[/\\]config[/\\]skeletons[/\\]sample.html'))); }); - test('html skeleton file for app with no dartpad is correct', () async { - expect( - config.getHtmlSkeletonFile(SnippetType.application).path, - matches(RegExp( - r'[/\\]flutter sdk[/\\]dev[/\\]snippets[/\\]config[/\\]skeletons[/\\]application.html'))); - }); test('html skeleton file for app with dartpad is correct', () async { expect( - config.getHtmlSkeletonFile(SnippetType.application, showDartPad: true).path, + config.getHtmlSkeletonFile(SnippetType.sample, showDartPad: true).path, matches(RegExp( - r'[/\\]flutter sdk[/\\]dev[/\\]snippets[/\\]config[/\\]skeletons[/\\]dartpad-application.html'))); + r'[/\\]flutter sdk[/\\]dev[/\\]snippets[/\\]config[/\\]skeletons[/\\]dartpad-sample.html'))); }); }); } diff --git a/dev/snippets/test/snippets_test.dart b/dev/snippets/test/snippets_test.dart index 3d93f024c1..18960c2640 100644 --- a/dev/snippets/test/snippets_test.dart +++ b/dev/snippets/test/snippets_test.dart @@ -37,20 +37,20 @@ main() { {{code}} } '''); - configuration.getHtmlSkeletonFile(SnippetType.application).writeAsStringSync(''' + configuration.getHtmlSkeletonFile(SnippetType.sample).writeAsStringSync('''
HTML Bits
{{description}}
{{code}}
{{app}}
More HTML Bits
'''); - configuration.getHtmlSkeletonFile(SnippetType.sample).writeAsStringSync(''' + configuration.getHtmlSkeletonFile(SnippetType.snippet).writeAsStringSync('''
HTML Bits
{{description}}
{{code}}
More HTML Bits
'''); - configuration.getHtmlSkeletonFile(SnippetType.application, showDartPad: true).writeAsStringSync(''' + configuration.getHtmlSkeletonFile(SnippetType.sample, showDartPad: true).writeAsStringSync('''
HTML Bits (DartPad-style)
More HTML Bits
@@ -83,7 +83,7 @@ void main() { final String html = generator.generate( inputFile, - SnippetType.application, + SnippetType.sample, template: 'template', metadata: { 'id': 'id', @@ -126,7 +126,7 @@ void main() { final String html = generator.generate( inputFile, - SnippetType.sample, + SnippetType.snippet, metadata: {'id': 'id'}, ); expect(html, contains('
HTML Bits
')); @@ -155,7 +155,7 @@ void main() { final String html = generator.generate( inputFile, - SnippetType.application, + SnippetType.sample, showDartPad: true, template: 'template', metadata: {'id': 'id'}, @@ -185,7 +185,7 @@ void main() { generator.generate( inputFile, - SnippetType.application, + SnippetType.sample, template: 'template', output: outputFile, metadata: {'sourcePath': 'some/path.dart', 'id': 'id'}, diff --git a/packages/flutter/lib/src/animation/animation.dart b/packages/flutter/lib/src/animation/animation.dart index 229f031e24..9f6785528b 100644 --- a/packages/flutter/lib/src/animation/animation.dart +++ b/packages/flutter/lib/src/animation/animation.dart @@ -106,7 +106,7 @@ abstract class Animation extends Listenable implements ValueListenable { /// argument to the method (`child`), whose value is derived by applying the /// given [Tween] to the value of this [Animation]. /// - /// {@tool sample} + /// {@tool snippet} /// /// Given an [AnimationController] `_controller`, the following code creates /// an `Animation` that swings from top left to top right as the @@ -121,7 +121,7 @@ abstract class Animation extends Listenable implements ValueListenable { /// ); /// ``` /// {@end-tool} - /// {@tool sample} + /// {@tool snippet} /// /// The `_alignment.value` could then be used in a widget's build method, for /// instance, to position a child using an [Align] widget such that the @@ -141,7 +141,7 @@ abstract class Animation extends Listenable implements ValueListenable { /// Animation _alignment2 = _controller.drive(_tween); /// ``` /// {@end-tool} - /// {@tool sample} + /// {@tool snippet} /// /// The following code is exactly equivalent, and is typically clearer when /// the tweens are created inline, as might be preferred when the tweens have diff --git a/packages/flutter/lib/src/animation/animation_controller.dart b/packages/flutter/lib/src/animation/animation_controller.dart index d2fa734426..3ecab46f48 100644 --- a/packages/flutter/lib/src/animation/animation_controller.dart +++ b/packages/flutter/lib/src/animation/animation_controller.dart @@ -124,7 +124,7 @@ enum AnimationBehavior { /// This can be used to write code such as the `fadeOutAndUpdateState` method /// below. /// -/// {@tool sample} +/// {@tool snippet} /// /// Here is a stateful `Foo` widget. Its [State] uses the /// [SingleTickerProviderStateMixin] to implement the necessary @@ -175,7 +175,7 @@ enum AnimationBehavior { /// } /// ``` /// {@end-tool} -/// {@tool sample} +/// {@tool snippet} /// /// The following method (for a [State] subclass) drives two animation /// controllers using Dart's asynchronous syntax for awaiting [Future] objects: diff --git a/packages/flutter/lib/src/animation/animations.dart b/packages/flutter/lib/src/animation/animations.dart index 91cbf97e2e..7541916a5c 100644 --- a/packages/flutter/lib/src/animation/animations.dart +++ b/packages/flutter/lib/src/animation/animations.dart @@ -327,7 +327,7 @@ class ReverseAnimation extends Animation /// /// If you want to apply a [Curve] to a [Tween], consider using [CurveTween]. /// -/// {@tool sample} +/// {@tool snippet} /// /// The following code snippet shows how you can apply a curve to a linear /// animation produced by an [AnimationController] `controller`. @@ -339,7 +339,7 @@ class ReverseAnimation extends Animation /// ); /// ``` /// {@end-tool} -/// {@tool sample} +/// {@tool snippet} /// /// This second code snippet shows how to apply a different curve in the forward /// direction than in the reverse direction. This can't be done using a diff --git a/packages/flutter/lib/src/animation/curves.dart b/packages/flutter/lib/src/animation/curves.dart index 9849eefa54..1213ebb812 100644 --- a/packages/flutter/lib/src/animation/curves.dart +++ b/packages/flutter/lib/src/animation/curves.dart @@ -318,7 +318,7 @@ class Cubic extends Curve { /// part of the curve, or hardly at all in another part of the curve, depending /// on the definition of the curve. /// -/// {@tool snippet --template=stateless_widget_material} +/// {@tool sample --template=stateless_widget_material} /// This example shows how to use a [Curve2D] to modify the position of a widget /// so that it can follow an arbitrary path. /// diff --git a/packages/flutter/lib/src/animation/tween.dart b/packages/flutter/lib/src/animation/tween.dart index 4be58be11d..8b31868428 100644 --- a/packages/flutter/lib/src/animation/tween.dart +++ b/packages/flutter/lib/src/animation/tween.dart @@ -128,7 +128,7 @@ class _ChainedEvaluation extends Animatable { /// which results in two separate [Animation] objects, each configured with a /// single [Tween]. /// -/// {@tool sample} +/// {@tool snippet} /// /// Suppose `_controller` is an [AnimationController], and we want to create an /// [Animation] that is controlled by that controller, and save it in @@ -143,7 +143,7 @@ class _ChainedEvaluation extends Animatable { /// ); /// ``` /// {@end-tool} -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// _animation = Tween( @@ -413,7 +413,7 @@ class ConstantTween extends Tween { /// curves when the animation is going forward vs when it is going backward, /// which can be useful in some scenarios.) /// -/// {@tool sample} +/// {@tool snippet} /// /// The following code snippet shows how you can apply a curve to a linear /// animation produced by an [AnimationController] `controller`: diff --git a/packages/flutter/lib/src/animation/tween_sequence.dart b/packages/flutter/lib/src/animation/tween_sequence.dart index 3d1712a239..30b81b0f28 100644 --- a/packages/flutter/lib/src/animation/tween_sequence.dart +++ b/packages/flutter/lib/src/animation/tween_sequence.dart @@ -17,7 +17,7 @@ import 'tween.dart'; /// animation's duration. Each tween defines the animation's value during the /// interval indicated by its weight. /// -/// {@tool sample} +/// {@tool snippet} /// This example defines an animation that uses an easing curve to interpolate /// between 5.0 and 10.0 during the first 40% of the animation, remains at 10.0 /// for the next 20%, and then returns to 5.0 for the final 40%. @@ -136,7 +136,7 @@ class TweenSequenceItem { /// animation's duration indicated by [weight] and this item's position /// in the list of items. /// - /// {@tool sample} + /// {@tool snippet} /// /// The value of this item can be "curved" by chaining it to a [CurveTween]. /// For example to create a tween that eases from 0.0 to 10.0: diff --git a/packages/flutter/lib/src/cupertino/app.dart b/packages/flutter/lib/src/cupertino/app.dart index 0aa5dbc771..063cc0087c 100644 --- a/packages/flutter/lib/src/cupertino/app.dart +++ b/packages/flutter/lib/src/cupertino/app.dart @@ -195,7 +195,7 @@ class CupertinoApp extends StatefulWidget { final bool debugShowCheckedModeBanner; /// {@macro flutter.widgets.widgetsApp.shortcuts} - /// {@tool sample} + /// {@tool snippet} /// This example shows how to add a single shortcut for /// [LogicalKeyboardKey.select] to the default shortcuts without needing to /// add your own [Shortcuts] widget. @@ -223,7 +223,7 @@ class CupertinoApp extends StatefulWidget { final Map shortcuts; /// {@macro flutter.widgets.widgetsApp.actions} - /// {@tool sample} + /// {@tool snippet} /// This example shows how to add a single action handling an /// [ActivateAction] to the default actions without needing to /// add your own [Actions] widget. diff --git a/packages/flutter/lib/src/cupertino/colors.dart b/packages/flutter/lib/src/cupertino/colors.dart index fe2f3fa46d..44cf7ad20d 100644 --- a/packages/flutter/lib/src/cupertino/colors.dart +++ b/packages/flutter/lib/src/cupertino/colors.dart @@ -592,7 +592,7 @@ class CupertinoColors { /// [CupertinoDynamicColor.resolve] against its own [BuildContext], on a best-effort /// basis. /// -/// {@tool sample} +/// {@tool snippet} /// By default a [CupertinoButton] has no background color. The following sample /// code shows how to build a [CupertinoButton] that appears white in light mode, /// and changes automatically to black in dark mode. @@ -617,7 +617,7 @@ class CupertinoColors { /// implicitly resolves all the colors used in the retrieved [CupertinoThemeData], /// before returning it. /// -/// {@tool sample} +/// {@tool snippet} /// The following code sample creates a [Container] with the `primaryColor` of the /// current theme. If `primaryColor` is a [CupertinoDynamicColor], the container /// will be adaptive, thanks to [CupertinoTheme.of]: it will switch to `primaryColor`'s @@ -643,7 +643,7 @@ class CupertinoColors { /// the colors used in the [Border] have to be resolved manually before being passed /// to [CupertinoNavigationBar]'s constructor. /// -/// {@tool sample} +/// {@tool snippet} /// /// The following code samples demonstrate two cases where you have to manually /// resolve a [CupertinoDynamicColor]. diff --git a/packages/flutter/lib/src/cupertino/context_menu.dart b/packages/flutter/lib/src/cupertino/context_menu.dart index b790a39c4d..4a0409a33d 100644 --- a/packages/flutter/lib/src/cupertino/context_menu.dart +++ b/packages/flutter/lib/src/cupertino/context_menu.dart @@ -172,7 +172,7 @@ class CupertinoContextMenu extends StatefulWidget { /// child parameter provides access to the child displayed when the /// CupertinoContextMenu is closed. /// - /// {@tool sample} + /// {@tool snippet} /// /// Below is an example of using `previewBuilder` to show an image tile that's /// similar to each tile in the iOS iPhoto app's context menu. Several of diff --git a/packages/flutter/lib/src/cupertino/scrollbar.dart b/packages/flutter/lib/src/cupertino/scrollbar.dart index 633715a5ef..3395d248ad 100644 --- a/packages/flutter/lib/src/cupertino/scrollbar.dart +++ b/packages/flutter/lib/src/cupertino/scrollbar.dart @@ -86,7 +86,7 @@ class CupertinoScrollbar extends StatefulWidget { /// Here is an example of using the `controller` parameter to enable /// scrollbar dragging for multiple independent ListViews: /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// final ScrollController _controllerOne = ScrollController(); diff --git a/packages/flutter/lib/src/cupertino/segmented_control.dart b/packages/flutter/lib/src/cupertino/segmented_control.dart index fa72139173..04c276b0f0 100644 --- a/packages/flutter/lib/src/cupertino/segmented_control.dart +++ b/packages/flutter/lib/src/cupertino/segmented_control.dart @@ -122,7 +122,7 @@ class CupertinoSegmentedControl extends StatefulWidget { /// the parent [StatefulWidget] using the [State.setState] method, so that /// the parent gets rebuilt; for example: /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// class SegmentedControlExample extends StatefulWidget { diff --git a/packages/flutter/lib/src/cupertino/slider.dart b/packages/flutter/lib/src/cupertino/slider.dart index a8bb502bf8..e1327a9b9f 100644 --- a/packages/flutter/lib/src/cupertino/slider.dart +++ b/packages/flutter/lib/src/cupertino/slider.dart @@ -117,7 +117,7 @@ class CupertinoSlider extends StatefulWidget { /// The value passed will be the last [value] that the slider had before the /// change began. /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// CupertinoSlider( @@ -149,7 +149,7 @@ class CupertinoSlider extends StatefulWidget { /// [onChanged] for that), but rather to know when the user has completed /// selecting a new [value] by ending a drag. /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// CupertinoSlider( diff --git a/packages/flutter/lib/src/cupertino/sliding_segmented_control.dart b/packages/flutter/lib/src/cupertino/sliding_segmented_control.dart index 78f68c637e..d923851df3 100644 --- a/packages/flutter/lib/src/cupertino/sliding_segmented_control.dart +++ b/packages/flutter/lib/src/cupertino/sliding_segmented_control.dart @@ -178,7 +178,7 @@ class CupertinoSlidingSegmentedControl extends StatefulWidget { /// the parent [StatefulWidget] using the [State.setState] method, so that /// the parent gets rebuilt; for example: /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// class SegmentedControlExample extends StatefulWidget { diff --git a/packages/flutter/lib/src/cupertino/switch.dart b/packages/flutter/lib/src/cupertino/switch.dart index 25ccb04802..ff3982e196 100644 --- a/packages/flutter/lib/src/cupertino/switch.dart +++ b/packages/flutter/lib/src/cupertino/switch.dart @@ -26,7 +26,7 @@ import 'thumb_painter.dart'; /// that use a switch will listen for the [onChanged] callback and rebuild the /// switch with a new [value] to update the visual appearance of the switch. /// -/// {@tool sample} +/// {@tool snippet} /// /// This sample shows how to use a [CupertinoSwitch] in a [ListTile]. The /// [MergeSemantics] is used to turn the entire [ListTile] into a single item diff --git a/packages/flutter/lib/src/cupertino/tab_scaffold.dart b/packages/flutter/lib/src/cupertino/tab_scaffold.dart index 96c9b75121..5b9e0d6874 100644 --- a/packages/flutter/lib/src/cupertino/tab_scaffold.dart +++ b/packages/flutter/lib/src/cupertino/tab_scaffold.dart @@ -15,7 +15,7 @@ import 'theme.dart'; /// [CupertinoTabController] controls, as well as the currently selected tab item of /// its [CupertinoTabBar]. /// -/// {@tool sample} +/// {@tool snippet} /// /// [CupertinoTabController] can be used to switch tabs: /// @@ -135,7 +135,7 @@ class CupertinoTabController extends ChangeNotifier { /// (via [State.setState], for instance) from its descendant rather than from /// its ancestor. /// -/// {@tool sample} +/// {@tool snippet} /// /// A sample code implementing a typical iOS information architecture with tabs. /// diff --git a/packages/flutter/lib/src/cupertino/text_field.dart b/packages/flutter/lib/src/cupertino/text_field.dart index 805f4a12f6..9969535c4c 100644 --- a/packages/flutter/lib/src/cupertino/text_field.dart +++ b/packages/flutter/lib/src/cupertino/text_field.dart @@ -133,7 +133,7 @@ class _CupertinoTextFieldSelectionGestureDetectorBuilder extends TextSelectionGe /// [controller]. For example, to set the initial value of the text field, use /// a [controller] that already contains some text such as: /// -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// class MyPrefilledText extends StatefulWidget { diff --git a/packages/flutter/lib/src/foundation/annotations.dart b/packages/flutter/lib/src/foundation/annotations.dart index 35b4331cfd..b57bfac68e 100644 --- a/packages/flutter/lib/src/foundation/annotations.dart +++ b/packages/flutter/lib/src/foundation/annotations.dart @@ -16,7 +16,7 @@ /// /// A class can have multiple categories. /// -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// /// A copper coffee pot, as desired by Ben Turpin. @@ -54,7 +54,7 @@ class Category { /// /// Each class should only have one [DocumentationIcon]. /// -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// /// Utility class for beginning a dream-sharing sequence. @@ -87,7 +87,7 @@ class DocumentationIcon { /// for this purpose, but on occasion the first paragraph is either too short /// or too long for use in isolation, without the remainder of the documentation. /// -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// /// A famous cat. diff --git a/packages/flutter/lib/src/foundation/binding.dart b/packages/flutter/lib/src/foundation/binding.dart index 9c8a2707a8..daa9ed62a3 100644 --- a/packages/flutter/lib/src/foundation/binding.dart +++ b/packages/flutter/lib/src/foundation/binding.dart @@ -453,7 +453,7 @@ abstract class BindingBase { /// not wrapped in a guard that allows the tree shaker to remove it (see /// sample code below). /// - /// {@tool sample} + /// {@tool snippet} /// The following code registers a service extension that is only included in /// debug builds. /// @@ -467,7 +467,7 @@ abstract class BindingBase { /// ``` /// {@end-tool} /// - /// {@tool sample} + /// {@tool snippet} /// A service extension registered with the following code snippet is /// available in debug and profile mode. /// diff --git a/packages/flutter/lib/src/foundation/diagnostics.dart b/packages/flutter/lib/src/foundation/diagnostics.dart index f6af1afa39..1a2243864c 100644 --- a/packages/flutter/lib/src/foundation/diagnostics.dart +++ b/packages/flutter/lib/src/foundation/diagnostics.dart @@ -1716,7 +1716,7 @@ abstract class DiagnosticsNode { /// Debugging message displayed like a property. /// -/// {@tool sample} +/// {@tool snippet} /// /// The following two properties are better expressed using this /// [MessageProperty] class, rather than [StringProperty], as the intent is to @@ -1728,7 +1728,7 @@ abstract class DiagnosticsNode { /// var usefulness = MessageProperty('usefulness ratio', 'no metrics collected yet (never painted)'); /// ``` /// {@end-tool} -/// {@tool sample} +/// {@tool snippet} /// /// On the other hand, [StringProperty] is better suited when the property has a /// concrete value that is a string: @@ -2055,7 +2055,7 @@ class PercentProperty extends DoubleProperty { /// when `visible` is false and nothing when visible is true, in contrast to /// `visible: true` or `visible: false`. /// -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// FlagProperty( @@ -2065,7 +2065,7 @@ class PercentProperty extends DoubleProperty { /// ) /// ``` /// {@end-tool} -/// {@tool sample} +/// {@tool snippet} /// /// [FlagProperty] should also be used instead of [DiagnosticsProperty] /// if showing the bool value would not clearly indicate the meaning of the @@ -2969,7 +2969,7 @@ String describeIdentity(Object object) => '${object.runtimeType}#${shortHash(obj /// /// Strips off the enum class name from the `enumEntry.toString()`. /// -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// enum Day { @@ -3189,7 +3189,7 @@ mixin DiagnosticableMixin { /// `toString` method implementation works fine using [DiagnosticsProperty] /// directly. /// - /// {@tool sample} + /// {@tool snippet} /// /// This example shows best practices for implementing [debugFillProperties] /// illustrating use of all common [DiagnosticsProperty] subclasses and all diff --git a/packages/flutter/lib/src/foundation/licenses.dart b/packages/flutter/lib/src/foundation/licenses.dart index 5c9cd802ad..82b4b4c41f 100644 --- a/packages/flutter/lib/src/foundation/licenses.dart +++ b/packages/flutter/lib/src/foundation/licenses.dart @@ -66,7 +66,7 @@ enum _LicenseEntryWithLineBreaksParserState { /// unless they start with the same number of spaces as the previous line, in /// which case it's assumed they are a continuation of an indented paragraph. /// -/// {@tool sample} +/// {@tool snippet} /// /// For example, the BSD license in this format could be encoded as follows: /// diff --git a/packages/flutter/lib/src/foundation/stack_frame.dart b/packages/flutter/lib/src/foundation/stack_frame.dart index 387be8f9b2..d0ffc93633 100644 --- a/packages/flutter/lib/src/foundation/stack_frame.dart +++ b/packages/flutter/lib/src/foundation/stack_frame.dart @@ -8,7 +8,7 @@ import 'package:meta/meta.dart'; /// A object representation of a frame from a stack trace. /// -/// {@tool sample} +/// {@tool snippet} /// /// This example creates a traversable list of parsed [StackFrame] objects from /// the current [StackTrace]. diff --git a/packages/flutter/lib/src/material/about.dart b/packages/flutter/lib/src/material/about.dart index 44fc5397f8..3fd501ea57 100644 --- a/packages/flutter/lib/src/material/about.dart +++ b/packages/flutter/lib/src/material/about.dart @@ -33,7 +33,7 @@ import 'theme.dart'; /// /// If your application does not have a [Drawer], you should provide an /// affordance to call [showAboutDialog] or (at least) [showLicensePage]. -/// {@tool snippet --template=stateless_widget_material} +/// {@tool sample --template=stateless_widget_material} /// /// This sample shows two ways to open [AboutDialog]. The first one /// uses an [AboutListTile], and the second uses the [showAboutDialog] function. diff --git a/packages/flutter/lib/src/material/animated_icons/animated_icons.dart b/packages/flutter/lib/src/material/animated_icons/animated_icons.dart index 97366e44cb..cf2d66656d 100644 --- a/packages/flutter/lib/src/material/animated_icons/animated_icons.dart +++ b/packages/flutter/lib/src/material/animated_icons/animated_icons.dart @@ -18,7 +18,7 @@ part of material_animated_icons; /// /// {@youtube 560 315 https://www.youtube.com/watch?v=pJcbh8pbvJs} /// -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// AnimatedIcon( diff --git a/packages/flutter/lib/src/material/app.dart b/packages/flutter/lib/src/material/app.dart index 1f7d105862..dff4a67a07 100644 --- a/packages/flutter/lib/src/material/app.dart +++ b/packages/flutter/lib/src/material/app.dart @@ -77,7 +77,7 @@ enum ThemeMode { /// If [home], [routes], [onGenerateRoute], and [onUnknownRoute] are all null, /// and [builder] is not null, then no [Navigator] is created. /// -/// {@tool sample} +/// {@tool snippet} /// This example shows how to create a [MaterialApp] that disables the "debug" /// banner with a [home] route that will be displayed when the app is launched. /// @@ -95,7 +95,7 @@ enum ThemeMode { /// ``` /// {@end-tool} /// -/// {@tool sample} +/// {@tool snippet} /// This example shows how to create a [MaterialApp] that uses the [routes] /// `Map` to define the "home" route and an "about" route. /// @@ -121,7 +121,7 @@ enum ThemeMode { /// ``` /// {@end-tool} /// -/// {@tool sample} +/// {@tool snippet} /// This example shows how to create a [MaterialApp] that defines a [theme] that /// will be used for material widgets in the app. /// @@ -458,7 +458,7 @@ class MaterialApp extends StatefulWidget { final bool debugShowCheckedModeBanner; /// {@macro flutter.widgets.widgetsApp.shortcuts} - /// {@tool sample} + /// {@tool snippet} /// This example shows how to add a single shortcut for /// [LogicalKeyboardKey.select] to the default shortcuts without needing to /// add your own [Shortcuts] widget. @@ -486,7 +486,7 @@ class MaterialApp extends StatefulWidget { final Map shortcuts; /// {@macro flutter.widgets.widgetsApp.actions} - /// {@tool sample} + /// {@tool snippet} /// This example shows how to add a single action handling an /// [ActivateAction] to the default actions without needing to /// add your own [Actions] widget. diff --git a/packages/flutter/lib/src/material/app_bar.dart b/packages/flutter/lib/src/material/app_bar.dart index 72b8f259fc..e76c45fe18 100644 --- a/packages/flutter/lib/src/material/app_bar.dart +++ b/packages/flutter/lib/src/material/app_bar.dart @@ -214,7 +214,7 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget { /// there's no [Drawer] and the parent [Navigator] can go back, the [AppBar] /// will use a [BackButton] that calls [Navigator.maybePop]. /// - /// {@tool sample} + /// {@tool snippet} /// /// The following code shows how the drawer button could be manually specified /// instead of relying on [automaticallyImplyLeading]: @@ -835,7 +835,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate { /// [actions], above the [bottom] (if any). If a [flexibleSpace] widget is /// specified then it is stacked behind the toolbar and the bottom widget. /// -/// {@tool sample} +/// {@tool snippet} /// /// This is an example that could be included in a [CustomScrollView]'s /// [CustomScrollView.slivers] list: @@ -966,7 +966,7 @@ class SliverAppBar extends StatefulWidget { /// For less common operations, consider using a [PopupMenuButton] as the /// last action. /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Scaffold( diff --git a/packages/flutter/lib/src/material/bottom_app_bar.dart b/packages/flutter/lib/src/material/bottom_app_bar.dart index bb53bac8d6..249a312831 100644 --- a/packages/flutter/lib/src/material/bottom_app_bar.dart +++ b/packages/flutter/lib/src/material/bottom_app_bar.dart @@ -21,7 +21,7 @@ import 'theme.dart'; /// /// Typically used with a [Scaffold] and a [FloatingActionButton]. /// -/// {@tool sample} +/// {@tool snippet} /// ```dart /// Scaffold( /// bottomNavigationBar: BottomAppBar( diff --git a/packages/flutter/lib/src/material/bottom_navigation_bar.dart b/packages/flutter/lib/src/material/bottom_navigation_bar.dart index 2b6856765e..d6bfd58f6d 100644 --- a/packages/flutter/lib/src/material/bottom_navigation_bar.dart +++ b/packages/flutter/lib/src/material/bottom_navigation_bar.dart @@ -62,7 +62,7 @@ enum BottomNavigationBarType { /// case it's assumed that each item will have a different background color /// and that background color will contrast well with white. /// -/// {@tool snippet --template=stateful_widget_material} +/// {@tool sample --template=stateful_widget_material} /// This example shows a [BottomNavigationBar] as it is used within a [Scaffold] /// widget. The [BottomNavigationBar] has three [BottomNavigationBarItem] /// widgets and the [currentIndex] is set to index 0. The selected item is diff --git a/packages/flutter/lib/src/material/bottom_sheet.dart b/packages/flutter/lib/src/material/bottom_sheet.dart index 8cdc948aeb..0ecb4955b8 100644 --- a/packages/flutter/lib/src/material/bottom_sheet.dart +++ b/packages/flutter/lib/src/material/bottom_sheet.dart @@ -457,7 +457,7 @@ class _ModalBottomSheetRoute extends PopupRoute { /// /// {@animation 350 622 https://flutter.github.io/assets-for-api-docs/assets/material/show_modal_bottom_sheet.mp4} /// -/// {@tool snippet --template=stateless_widget_scaffold} +/// {@tool sample --template=stateless_widget_scaffold} /// /// This example demonstrates how to use `showModalBottomSheet` to display a /// bottom sheet that obscures the content behind it when a user taps a button. diff --git a/packages/flutter/lib/src/material/card.dart b/packages/flutter/lib/src/material/card.dart index 9cb8be9e03..785db00eb1 100644 --- a/packages/flutter/lib/src/material/card.dart +++ b/packages/flutter/lib/src/material/card.dart @@ -19,7 +19,7 @@ import 'theme.dart'; /// some text describing a musical, and the other with buttons for buying /// tickets or listening to the show.](https://flutter.github.io/assets-for-api-docs/assets/material/card.png) /// -/// {@tool snippet --template=stateless_widget_scaffold} +/// {@tool sample --template=stateless_widget_scaffold} /// /// This sample shows creation of a [Card] widget that shows album information /// and two actions. @@ -59,7 +59,7 @@ import 'theme.dart'; /// Sometimes the primary action area of a card is the card itself. Cards can be /// one large touch target that shows a detail screen when tapped. /// -/// {@tool snippet --template=stateless_widget_scaffold} +/// {@tool sample --template=stateless_widget_scaffold} /// /// This sample shows creation of a [Card] widget that can be tapped. When /// tapped this [Card]'s [InkWell] displays an "ink splash" that fills the diff --git a/packages/flutter/lib/src/material/checkbox_list_tile.dart b/packages/flutter/lib/src/material/checkbox_list_tile.dart index e2b76f796f..d1e21c471e 100644 --- a/packages/flutter/lib/src/material/checkbox_list_tile.dart +++ b/packages/flutter/lib/src/material/checkbox_list_tile.dart @@ -37,7 +37,7 @@ import 'theme_data.dart'; /// To show the [CheckboxListTile] as disabled, pass null as the [onChanged] /// callback. /// -/// {@tool snippet --template=stateful_widget_scaffold_center} +/// {@tool sample --template=stateful_widget_scaffold_center} /// /// ![CheckboxListTile sample](https://flutter.github.io/assets-for-api-docs/assets/material/checkbox_list_tile.png) /// @@ -82,7 +82,7 @@ import 'theme_data.dart'; /// into one. Therefore, it may be necessary to create a custom radio tile /// widget to accommodate similar use cases. /// -/// {@tool snippet --template=stateful_widget_scaffold_center} +/// {@tool sample --template=stateful_widget_scaffold_center} /// /// ![Checkbox list tile semantics sample](https://flutter.github.io/assets-for-api-docs/assets/material/checkbox_list_tile_semantics.png) /// @@ -166,7 +166,7 @@ import 'theme_data.dart'; /// combining [Checkbox] with other widgets, such as [Text], [Padding] and /// [InkWell]. /// -/// {@tool snippet --template=stateful_widget_scaffold_center} +/// {@tool sample --template=stateful_widget_scaffold_center} /// /// ![Custom checkbox list tile sample](https://flutter.github.io/assets-for-api-docs/assets/material/checkbox_list_tile_custom.png) /// diff --git a/packages/flutter/lib/src/material/chip.dart b/packages/flutter/lib/src/material/chip.dart index cce2ee213d..16206ff9d7 100644 --- a/packages/flutter/lib/src/material/chip.dart +++ b/packages/flutter/lib/src/material/chip.dart @@ -192,7 +192,7 @@ abstract class DeletableChipAttributes { /// that the user tapped the delete button. In order to delete the chip, you /// have to do something similar to the following sample: /// - /// {@tool snippet --template=stateful_widget_scaffold_center} + /// {@tool sample --template=stateful_widget_scaffold_center} /// /// This sample shows how to use [onDeleted] to remove an entry when the /// delete button is tapped. @@ -341,7 +341,7 @@ abstract class SelectableChipAttributes { /// The [onSelected] and [TappableChipAttributes.onPressed] callbacks must not /// both be specified at the same time. /// - /// {@tool sample} + /// {@tool snippet} /// /// A [StatefulWidget] that illustrates use of onSelected in an [InputChip]. /// @@ -479,7 +479,7 @@ abstract class TappableChipAttributes { /// taps on the label or avatar parts of the chip. If [onPressed] is null, /// then the chip will be disabled. /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// class Blacksmith extends StatelessWidget { @@ -525,7 +525,7 @@ abstract class TappableChipAttributes { /// [MaterialApp] and [Scaffold]. The [label] and [clipBehavior] arguments must /// not be null. /// -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// Chip( @@ -665,7 +665,7 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri /// * In a horizontally scrollable list, like a [ListView] whose /// scrollDirection is [Axis.horizontal]. /// -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// InputChip( @@ -858,7 +858,7 @@ class InputChip extends StatelessWidget /// Requires one of its ancestors to be a [Material] widget. The [selected] and /// [label] arguments must not be null. /// -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// class MyThreeOptions extends StatefulWidget { @@ -1038,7 +1038,7 @@ class ChoiceChip extends StatelessWidget /// /// Requires one of its ancestors to be a [Material] widget. /// -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// class ActorFilterEntry { @@ -1263,7 +1263,7 @@ class FilterChip extends StatelessWidget /// /// Requires one of its ancestors to be a [Material] widget. /// -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// ActionChip( diff --git a/packages/flutter/lib/src/material/chip_theme.dart b/packages/flutter/lib/src/material/chip_theme.dart index 27ece6b7ba..7fa1217a8d 100644 --- a/packages/flutter/lib/src/material/chip_theme.dart +++ b/packages/flutter/lib/src/material/chip_theme.dart @@ -62,7 +62,7 @@ class ChipTheme extends InheritedTheme { /// Defaults to the ambient [ThemeData.chipTheme] if there is no /// [ChipTheme] in the given build context. /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// class Spaceship extends StatelessWidget { @@ -120,7 +120,7 @@ class ChipTheme extends InheritedTheme { /// you get from [ChipTheme.of], or create an entirely new one with /// [ChipThemeData..fromDefaults]. /// -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// class CarColor extends StatefulWidget { diff --git a/packages/flutter/lib/src/material/circle_avatar.dart b/packages/flutter/lib/src/material/circle_avatar.dart index 5fe9b600c4..7d5cb992b9 100644 --- a/packages/flutter/lib/src/material/circle_avatar.dart +++ b/packages/flutter/lib/src/material/circle_avatar.dart @@ -17,7 +17,7 @@ import 'theme_data.dart'; /// such an image, the user's initials. A given user's initials should /// always be paired with the same background color, for consistency. /// -/// {@tool sample} +/// {@tool snippet} /// /// If the avatar is to have an image, the image should be specified in the /// [backgroundImage] property: @@ -31,7 +31,7 @@ import 'theme_data.dart'; /// /// The image will be cropped to have a circle shape. /// -/// {@tool sample} +/// {@tool snippet} /// /// If the avatar is to just have the user's initials, they are typically /// provided using a [Text] widget as the [child] and a [backgroundColor]: diff --git a/packages/flutter/lib/src/material/colors.dart b/packages/flutter/lib/src/material/colors.dart index bd141a2737..d23ebc2dc4 100644 --- a/packages/flutter/lib/src/material/colors.dart +++ b/packages/flutter/lib/src/material/colors.dart @@ -104,7 +104,7 @@ class MaterialAccentColor extends ColorSwatch { /// In addition, a series of blacks and whites with common opacities are /// available. For example, [black54] is a pure black with 54% opacity. /// -/// {@tool sample} +/// {@tool snippet} /// /// To select a specific color from one of the swatches, index into the swatch /// using an integer for the specific color desired, as follows: @@ -113,7 +113,7 @@ class MaterialAccentColor extends ColorSwatch { /// Color selection = Colors.green[400]; // Selects a mid-range green. /// ``` /// {@end-tool} -/// {@tool sample} +/// {@tool snippet} /// /// Each [ColorSwatch] constant is a color and can used directly. For example: /// @@ -428,7 +428,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.pink.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.pinkAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -472,7 +472,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.pink.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.pinkAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -510,7 +510,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.purple.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.purpleAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -554,7 +554,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.purple.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.purpleAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -592,7 +592,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.pink.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.pinkAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -636,7 +636,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.pink.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.pinkAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -674,7 +674,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.indigo.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.indigoAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -718,7 +718,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.indigo.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.indigoAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -756,7 +756,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.deepPurple.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.deepPurpleAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -800,7 +800,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.deepPurple.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.deepPurpleAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -840,7 +840,7 @@ class Colors { /// /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.blueGrey.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -884,7 +884,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.lightBlue.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.lightBlueAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -922,7 +922,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.cyan.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.cyanAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -966,7 +966,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.cyan.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.cyanAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -1006,7 +1006,7 @@ class Colors { /// /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.blueGrey.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -1050,7 +1050,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.teal.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.tealAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -1088,7 +1088,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.cyan.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.cyanAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -1132,7 +1132,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.cyan.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.cyanAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -1173,7 +1173,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.lime.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.limeAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -1220,7 +1220,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.lime.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.limeAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -1258,7 +1258,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.lime.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.limeAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -1302,7 +1302,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.lime.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.limeAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -1340,7 +1340,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.yellow.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.yellowAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -1384,7 +1384,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.yellow.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.yellowAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -1422,7 +1422,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.amber.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.amberAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -1466,7 +1466,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.amber.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.amberAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -1504,7 +1504,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.orange.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.orangeAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -1548,7 +1548,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.orange.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.orangeAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -1588,7 +1588,7 @@ class Colors { /// /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.brown.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -1632,7 +1632,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.deepOrange.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.deepOrangeAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -1672,7 +1672,7 @@ class Colors { /// /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.brown.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -1716,7 +1716,7 @@ class Colors { /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.red.png) /// ![](https://flutter.github.io/assets-for-api-docs/assets/material/Colors.redAccent.png) /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -1753,7 +1753,7 @@ class Colors { /// /// This swatch has no corresponding accent color and swatch. /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -1800,7 +1800,7 @@ class Colors { /// used for raised button while pressed in light themes, and 850 is used for /// the background color of the dark theme. See [ThemeData.brightness]. /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( @@ -1848,7 +1848,7 @@ class Colors { /// /// This swatch has no corresponding accent swatch. /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Icon( diff --git a/packages/flutter/lib/src/material/data_table.dart b/packages/flutter/lib/src/material/data_table.dart index b224aa121c..8451aeb294 100644 --- a/packages/flutter/lib/src/material/data_table.dart +++ b/packages/flutter/lib/src/material/data_table.dart @@ -225,7 +225,7 @@ class DataCell { /// [PaginatedDataTable] which automatically splits the data into /// multiple pages. /// -/// {@tool snippet --template=stateless_widget_scaffold} +/// {@tool sample --template=stateless_widget_scaffold} /// /// This sample shows how to display a [DataTable] with three columns: name, age, and /// role. The columns are defined by three [DataColumn] objects. The table diff --git a/packages/flutter/lib/src/material/date_picker.dart b/packages/flutter/lib/src/material/date_picker.dart index ca22129ccf..8a17d2db7e 100644 --- a/packages/flutter/lib/src/material/date_picker.dart +++ b/packages/flutter/lib/src/material/date_picker.dart @@ -1094,7 +1094,7 @@ typedef SelectableDayPredicate = bool Function(DateTime day); /// /// {@animation 350 622 https://flutter.github.io/assets-for-api-docs/assets/material/show_date_picker.mp4} /// -/// {@tool sample} +/// {@tool snippet} /// Show a date picker with the dark theme. /// /// ```dart diff --git a/packages/flutter/lib/src/material/dialog.dart b/packages/flutter/lib/src/material/dialog.dart index d5ecf21644..077c0a72ac 100644 --- a/packages/flutter/lib/src/material/dialog.dart +++ b/packages/flutter/lib/src/material/dialog.dart @@ -161,7 +161,7 @@ class Dialog extends StatelessWidget { /// /// {@animation 350 622 https://flutter.github.io/assets-for-api-docs/assets/material/alert_dialog.mp4} /// -/// {@tool sample} +/// {@tool snippet} /// /// This snippet shows a method in a [State] which, when called, displays a dialog box /// and returns a [Future] that completes when the dialog is dismissed. @@ -301,7 +301,7 @@ class AlertDialog extends StatelessWidget { /// [buttonPadding] may contribute to the padding on the edges of [actions] as /// well. /// - /// {@tool sample} + /// {@tool snippet} /// This is an example of a set of actions aligned with the content widget. /// ```dart /// AlertDialog( @@ -488,7 +488,7 @@ class AlertDialog extends StatelessWidget { /// title and the first option, and 24 pixels of spacing between the last option /// and the bottom of the dialog. /// -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// SimpleDialogOption( @@ -555,7 +555,7 @@ class SimpleDialogOption extends StatelessWidget { /// /// {@animation 350 622 https://flutter.github.io/assets-for-api-docs/assets/material/simple_dialog.mp4} /// -/// {@tool sample} +/// {@tool snippet} /// /// In this example, the user is asked to select between two options. These /// options are represented as an enum. The [showDialog] method here returns diff --git a/packages/flutter/lib/src/material/divider.dart b/packages/flutter/lib/src/material/divider.dart index be829a79bd..3879e29436 100644 --- a/packages/flutter/lib/src/material/divider.dart +++ b/packages/flutter/lib/src/material/divider.dart @@ -22,7 +22,7 @@ import 'theme.dart'; /// The box's total height is controlled by [height]. The appropriate /// padding is automatically computed from the height. /// -/// {@tool snippet --template=stateless_widget_scaffold} +/// {@tool sample --template=stateless_widget_scaffold} /// /// This sample shows how to display a Divider between an orange and blue box /// inside a column. The Divider is 20 logical pixels in height and contains a @@ -124,7 +124,7 @@ class Divider extends StatelessWidget { /// If this is null, then the [DividerThemeData.color] is used. If that is /// also null, then [ThemeData.dividerColor] is used. /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Divider( @@ -145,7 +145,7 @@ class Divider extends StatelessWidget { /// If [context] is null, the default color of [BorderSide] is used and the /// default width of 0.0 is used. /// - /// {@tool sample} + /// {@tool snippet} /// /// This example uses this method to create a box that has a divider above and /// below it. This is sometimes useful with lists, for instance, to separate a @@ -274,7 +274,7 @@ class VerticalDivider extends StatelessWidget { /// If this is null, then the [DividerThemeData.color] is used. If that is /// also null, then [ThemeData.dividerColor] is used. /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Divider( diff --git a/packages/flutter/lib/src/material/drawer.dart b/packages/flutter/lib/src/material/drawer.dart index ff292d8a9a..046feed189 100644 --- a/packages/flutter/lib/src/material/drawer.dart +++ b/packages/flutter/lib/src/material/drawer.dart @@ -61,7 +61,7 @@ const Duration _kBaseSettleDuration = Duration(milliseconds: 246); /// /// {@animation 350 622 https://flutter.github.io/assets-for-api-docs/assets/material/drawer.mp4} /// -/// {@tool sample} +/// {@tool snippet} /// This example shows how to create a [Scaffold] that contains an [AppBar] and /// a [Drawer]. A user taps the "menu" icon in the [AppBar] to open the /// [Drawer]. The [Drawer] displays four items: A header and three menu items. diff --git a/packages/flutter/lib/src/material/dropdown.dart b/packages/flutter/lib/src/material/dropdown.dart index 9b23a687f1..293d3a7bb9 100644 --- a/packages/flutter/lib/src/material/dropdown.dart +++ b/packages/flutter/lib/src/material/dropdown.dart @@ -707,7 +707,7 @@ class DropdownButtonHideUnderline extends InheritedWidget { /// dropdown's value. It should also call [State.setState] to rebuild the /// dropdown with the new value. /// -/// {@tool snippet --template=stateful_widget_scaffold_center} +/// {@tool sample --template=stateful_widget_scaffold_center} /// /// This sample shows a `DropdownButton` with a large arrow icon, /// purple text style, and bold purple underline, whose value is one of "One", @@ -865,7 +865,7 @@ class DropdownButton extends StatefulWidget { /// from the list corresponds to the [DropdownMenuItem] of the same index /// in [items]. /// - /// {@tool snippet --template=stateful_widget_scaffold} + /// {@tool sample --template=stateful_widget_scaffold} /// /// This sample shows a `DropdownButton` with a button with [Text] that /// corresponds to but is unique from [DropdownMenuItem]. @@ -916,7 +916,7 @@ class DropdownButton extends StatefulWidget { /// To use a separate text style for selected item when it's displayed within /// the dropdown button,, consider using [selectedItemBuilder]. /// - /// {@tool snippet --template=stateful_widget_scaffold} + /// {@tool sample --template=stateful_widget_scaffold} /// /// This sample shows a `DropdownButton` with a dropdown button text style /// that is different than its menu items. diff --git a/packages/flutter/lib/src/material/expansion_panel.dart b/packages/flutter/lib/src/material/expansion_panel.dart index 8236c6e263..c9e794e349 100644 --- a/packages/flutter/lib/src/material/expansion_panel.dart +++ b/packages/flutter/lib/src/material/expansion_panel.dart @@ -140,7 +140,7 @@ class ExpansionPanelRadio extends ExpansionPanel { /// Note that [expansionCallback] behaves differently for [ExpansionPanelList] /// and [ExpansionPanelList.radio]. /// -/// {@tool snippet --template=stateful_widget_scaffold} +/// {@tool sample --template=stateful_widget_scaffold} /// /// Here is a simple example of how to implement ExpansionPanelList. /// @@ -242,7 +242,7 @@ class ExpansionPanelList extends StatefulWidget { /// arguments must not be null. The [children] objects must be instances /// of [ExpansionPanelRadio]. /// - /// {@tool snippet --template=stateful_widget_scaffold} + /// {@tool sample --template=stateful_widget_scaffold} /// /// Here is a simple example of how to implement ExpansionPanelList.radio. /// diff --git a/packages/flutter/lib/src/material/feedback.dart b/packages/flutter/lib/src/material/feedback.dart index c1891a627a..61f74e9766 100644 --- a/packages/flutter/lib/src/material/feedback.dart +++ b/packages/flutter/lib/src/material/feedback.dart @@ -28,7 +28,7 @@ import 'theme.dart'; /// [StatelessWidget.build] method or from a [State]'s methods as you have to /// provide a [BuildContext]. /// -/// {@tool sample} +/// {@tool snippet} /// /// To trigger platform-specific feedback before executing the actual callback: /// @@ -53,7 +53,7 @@ import 'theme.dart'; /// } /// ``` /// {@end-tool} -/// {@tool sample} +/// {@tool snippet} /// /// Alternatively, you can also call [forTap] or [forLongPress] directly within /// your tap or long press handler: diff --git a/packages/flutter/lib/src/material/flat_button.dart b/packages/flutter/lib/src/material/flat_button.dart index 40b5d2b86b..2c580d4a0e 100644 --- a/packages/flutter/lib/src/material/flat_button.dart +++ b/packages/flutter/lib/src/material/flat_button.dart @@ -40,7 +40,7 @@ import 'theme_data.dart'; /// /// The [clipBehavior] argument must not be null. /// -/// {@tool sample} +/// {@tool snippet} /// /// This example shows a simple [FlatButton]. /// @@ -58,7 +58,7 @@ import 'theme_data.dart'; /// ``` /// {@end-tool} /// -/// {@tool sample} +/// {@tool snippet} /// /// This example shows a [FlatButton] that is normally white-on-blue, /// with splashes rendered in a different shade of blue. diff --git a/packages/flutter/lib/src/material/flexible_space_bar.dart b/packages/flutter/lib/src/material/flexible_space_bar.dart index 9ac1ed9977..a53890bf9e 100644 --- a/packages/flutter/lib/src/material/flexible_space_bar.dart +++ b/packages/flutter/lib/src/material/flexible_space_bar.dart @@ -50,7 +50,7 @@ enum StretchMode { /// [FlexibleSpaceBar.createSettings], to convey sizing information down to the /// [FlexibleSpaceBar]. /// -/// {@tool snippet --template=freeform} +/// {@tool sample --template=freeform} /// This sample application demonstrates the different features of the /// [FlexibleSpaceBar] when used in a [SliverAppBar]. This app bar is configured /// to stretch into the overscroll space, and uses the diff --git a/packages/flutter/lib/src/material/floating_action_button.dart b/packages/flutter/lib/src/material/floating_action_button.dart index 1a9e40ae49..e128992095 100644 --- a/packages/flutter/lib/src/material/floating_action_button.dart +++ b/packages/flutter/lib/src/material/floating_action_button.dart @@ -57,7 +57,7 @@ class _DefaultHeroTag { /// disabled. Consider changing the [backgroundColor] if disabling the floating /// action button. /// -/// {@tool snippet --template=stateless_widget_material} +/// {@tool sample --template=stateless_widget_material} /// This example shows how to display a [FloatingActionButton] in a /// [Scaffold], with a pink [backgroundColor] and a thumbs up [Icon]. /// @@ -84,7 +84,7 @@ class _DefaultHeroTag { /// ``` /// {@end-tool} /// -/// {@tool snippet --template=stateless_widget_material} +/// {@tool sample --template=stateless_widget_material} /// This example shows how to make an extended [FloatingActionButton] in a /// [Scaffold], with a pink [backgroundColor], a thumbs up [Icon] and a /// [Text] label that reads "Approve". diff --git a/packages/flutter/lib/src/material/icon_button.dart b/packages/flutter/lib/src/material/icon_button.dart index fc7a4e88c2..6b3ce2fa69 100644 --- a/packages/flutter/lib/src/material/icon_button.dart +++ b/packages/flutter/lib/src/material/icon_button.dart @@ -39,7 +39,7 @@ const double _kMinButtonSize = kMinInteractiveDimension; /// requirements in the Material Design specification. The [alignment] controls /// how the icon itself is positioned within the hit region. /// -/// {@tool snippet --template=stateful_widget_scaffold_center} +/// {@tool sample --template=stateful_widget_scaffold_center} /// /// This sample shows an `IconButton` that uses the Material icon "volume_up" to /// increase the volume. @@ -83,7 +83,7 @@ const double _kMinButtonSize = kMinInteractiveDimension; /// the underlying [Material] along with the splash and highlight /// [InkResponse] contributed by descendant widgets. /// -/// {@tool snippet --template=stateless_widget_scaffold} +/// {@tool sample --template=stateless_widget_scaffold} /// /// In this sample the icon button's background color is defined with an [Ink] /// widget whose child is an [IconButton]. The icon button's filled background diff --git a/packages/flutter/lib/src/material/icons.dart b/packages/flutter/lib/src/material/icons.dart index a943d44c51..b857c6be46 100644 --- a/packages/flutter/lib/src/material/icons.dart +++ b/packages/flutter/lib/src/material/icons.dart @@ -21,7 +21,7 @@ import 'package:flutter/widgets.dart'; /// uses-material-design: true /// ``` /// -/// {@tool sample} +/// {@tool snippet} /// This example shows how to create a [Row] of [Icon]s in different colors and /// sizes. The first [Icon] uses a [Icon.semanticLabel] to announce in accessibility /// modes like TalkBack and VoiceOver. diff --git a/packages/flutter/lib/src/material/ink_decoration.dart b/packages/flutter/lib/src/material/ink_decoration.dart index 57c58609f7..cf4d6412db 100644 --- a/packages/flutter/lib/src/material/ink_decoration.dart +++ b/packages/flutter/lib/src/material/ink_decoration.dart @@ -44,7 +44,7 @@ import 'material.dart'; /// generally speaking will match the order they are given in the widget tree, /// but this order may appear to be somewhat random in more dynamic situations. /// -/// {@tool sample} +/// {@tool snippet} /// /// This example shows how a [Material] widget can have a yellow rectangle drawn /// on it using [Ink], while still having ink effects over the yellow rectangle: @@ -68,7 +68,7 @@ import 'material.dart'; /// ) /// ``` /// {@end-tool} -/// {@tool sample} +/// {@tool snippet} /// /// The following example shows how an image can be printed on a [Material] /// widget with an [InkWell] above it: diff --git a/packages/flutter/lib/src/material/ink_well.dart b/packages/flutter/lib/src/material/ink_well.dart index 4fb38dbbac..551e6c1e5d 100644 --- a/packages/flutter/lib/src/material/ink_well.dart +++ b/packages/flutter/lib/src/material/ink_well.dart @@ -847,7 +847,7 @@ class _InkResponseState extends State with AutomaticKe /// /// An example of this situation is as follows: /// -/// {@tool snippet --template=stateful_widget_scaffold_center} +/// {@tool sample --template=stateful_widget_scaffold_center} /// /// Tap the container to cause it to grow. Then, tap it again and hold before /// the widget reaches its maximum size to observe the clipped ink splash. diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index e868c6a69e..f9627d41be 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -2305,7 +2305,7 @@ class _InputDecoratorState extends State with TickerProviderStat /// to describe their decoration. (In fact, this class is merely the /// configuration of an [InputDecorator], which does all the heavy lifting.) /// -/// {@tool snippet --template=stateless_widget_scaffold} +/// {@tool sample --template=stateless_widget_scaffold} /// /// This sample shows how to style a `TextField` using an `InputDecorator`. The /// TextField displays a "send message" icon to the left of the input area, @@ -2330,7 +2330,7 @@ class _InputDecoratorState extends State with TickerProviderStat /// ``` /// {@end-tool} /// -/// {@tool snippet --template=stateless_widget_scaffold} +/// {@tool sample --template=stateless_widget_scaffold} /// /// This sample shows how to style a "collapsed" `TextField` using an /// `InputDecorator`. The collapsed `TextField` surrounds the hint text and @@ -2350,7 +2350,7 @@ class _InputDecoratorState extends State with TickerProviderStat /// ``` /// {@end-tool} /// -/// {@tool snippet --template=stateless_widget_scaffold} +/// {@tool sample --template=stateless_widget_scaffold} /// /// This sample shows how to create a `TextField` with hint text, a red border /// on all sides, and an error message. To display a red border and error @@ -2371,7 +2371,7 @@ class _InputDecoratorState extends State with TickerProviderStat /// ``` /// {@end-tool} /// -/// {@tool snippet --template=stateless_widget_scaffold} +/// {@tool sample --template=stateless_widget_scaffold} /// /// This sample shows how to style a `TextField` with a round border and /// additional text before and after the input area. It displays "Prefix" before diff --git a/packages/flutter/lib/src/material/list_tile.dart b/packages/flutter/lib/src/material/list_tile.dart index 80eadc38d6..13bb1e6a41 100644 --- a/packages/flutter/lib/src/material/list_tile.dart +++ b/packages/flutter/lib/src/material/list_tile.dart @@ -195,7 +195,7 @@ enum ListTileControlAffinity { /// /// Requires one of its ancestors to be a [Material] widget. /// -/// {@tool sample} +/// {@tool snippet} /// /// This example uses a [ListView] to demonstrate different configurations of /// [ListTile]s in [Card]s. @@ -254,7 +254,7 @@ enum ListTileControlAffinity { /// ) /// ``` /// {@end-tool} -/// {@tool sample} +/// {@tool snippet} /// /// Tiles can be much more elaborate. Here is a tile which can be tapped, but /// which is disabled when the `_act` variable is not 2. When the tile is @@ -285,7 +285,7 @@ enum ListTileControlAffinity { /// that are large enough, but it is up to the developer to ensure that /// their widgets follow the Material spec. /// -/// {@tool sample} +/// {@tool snippet} /// /// Here is an example of a one-line, non-[dense] ListTile with a /// tappable leading widget that adheres to accessibility requirements and @@ -317,7 +317,7 @@ enum ListTileControlAffinity { /// you're looking for, it's easy to create custom list items with a /// combination of other widgets, such as [Row]s and [Column]s. /// -/// {@tool snippet --template=stateless_widget_scaffold} +/// {@tool sample --template=stateless_widget_scaffold} /// /// Here is an example of a custom list item that resembles a Youtube related /// video list item created with [Expanded] and [Container] widgets. @@ -438,7 +438,7 @@ enum ListTileControlAffinity { /// ``` /// {@end-tool} /// -/// {@tool snippet --template=stateless_widget_scaffold} +/// {@tool sample --template=stateless_widget_scaffold} /// /// Here is an example of an article list item with multiline titles and /// subtitles. It utilizes [Row]s and [Column]s, as well as [Expanded] and diff --git a/packages/flutter/lib/src/material/material_state.dart b/packages/flutter/lib/src/material/material_state.dart index ec29930ce4..9bc53c5e2d 100644 --- a/packages/flutter/lib/src/material/material_state.dart +++ b/packages/flutter/lib/src/material/material_state.dart @@ -85,7 +85,7 @@ typedef MaterialPropertyResolver = T Function(Set states); /// This should only be used as parameters when they are documented to take /// [MaterialStateColor], otherwise only the default state will be used. /// -/// {@tool sample} +/// {@tool snippet} /// /// This example shows how you could pass a `MaterialStateColor` to `FlatButton.textColor`. /// Here, the text color will be `Colors.blue[900]` when the button is being @@ -119,7 +119,7 @@ abstract class MaterialStateColor extends Color implements MaterialStateProperty /// to provide a `defaultValue` to the super constructor, so that we can know /// at compile-time what the value of the default [Color] is. /// - /// {@tool sample} + /// {@tool snippet} /// /// In this next example, we see how you can create a `MaterialStateColor` by /// extending the abstract class and overriding the `resolve` method. diff --git a/packages/flutter/lib/src/material/popup_menu.dart b/packages/flutter/lib/src/material/popup_menu.dart index a04a8ebc32..1b61e3925f 100644 --- a/packages/flutter/lib/src/material/popup_menu.dart +++ b/packages/flutter/lib/src/material/popup_menu.dart @@ -178,7 +178,7 @@ class _RenderMenuItem extends RenderShiftedBox { /// [PopupMenuItem] is kMinInteractiveDimension pixels high. If you use a widget /// with a different height, it must be specified in the [height] property. /// -/// {@tool sample} +/// {@tool snippet} /// /// Here, a [Text] widget is used with a popup menu item. The `WhyFarther` type /// is an enum, not shown here. @@ -339,7 +339,7 @@ class PopupMenuItemState> extends State { /// layout uses [ListTile]; the checkmark is an [Icons.done] icon, shown in the /// [ListTile.leading] position. /// -/// {@tool sample} +/// {@tool snippet} /// /// Suppose a `Commands` enum exists that lists the possible commands from a /// particular popup menu, including `Commands.heroAndScholar` and @@ -885,7 +885,7 @@ typedef PopupMenuItemBuilder = List> Function(BuildContext /// If both are null, then a standard overflow icon is created (depending on the /// platform). /// -/// {@tool sample} +/// {@tool snippet} /// /// This example shows a menu with four items, selecting between an enum's /// values and setting a `_selection` field based on the selection. diff --git a/packages/flutter/lib/src/material/radio.dart b/packages/flutter/lib/src/material/radio.dart index 5dfb5215e1..64845d0737 100644 --- a/packages/flutter/lib/src/material/radio.dart +++ b/packages/flutter/lib/src/material/radio.dart @@ -29,7 +29,7 @@ const double _kInnerRadius = 4.5; /// will respond to [onChanged] by calling [State.setState] to update the /// radio button's [groupValue]. /// -/// {@tool snippet --template=stateful_widget_scaffold_center} +/// {@tool sample --template=stateful_widget_scaffold_center} /// /// Here is an example of Radio widgets wrapped in ListTiles, which is similar /// to what you could get with the RadioListTile widget. diff --git a/packages/flutter/lib/src/material/radio_list_tile.dart b/packages/flutter/lib/src/material/radio_list_tile.dart index c096321c0a..cfc01247ef 100644 --- a/packages/flutter/lib/src/material/radio_list_tile.dart +++ b/packages/flutter/lib/src/material/radio_list_tile.dart @@ -40,7 +40,7 @@ import 'theme_data.dart'; /// To show the [RadioListTile] as disabled, pass null as the [onChanged] /// callback. /// -/// {@tool snippet --template=stateful_widget_scaffold} +/// {@tool sample --template=stateful_widget_scaffold} /// /// ![RadioListTile sample](https://flutter.github.io/assets-for-api-docs/assets/material/radio_list_tile.png) /// @@ -92,7 +92,7 @@ import 'theme_data.dart'; /// into one. Therefore, it may be necessary to create a custom radio tile /// widget to accommodate similar use cases. /// -/// {@tool snippet --template=stateful_widget_scaffold} +/// {@tool sample --template=stateful_widget_scaffold} /// /// ![Radio list tile semantics sample](https://flutter.github.io/assets-for-api-docs/assets/material/radio_list_tile_semantics.png) /// @@ -196,7 +196,7 @@ import 'theme_data.dart'; /// combining [Radio] with other widgets, such as [Text], [Padding] and /// [InkWell]. /// -/// {@tool snippet --template=stateful_widget_scaffold} +/// {@tool sample --template=stateful_widget_scaffold} /// /// ![Custom radio list tile sample](https://flutter.github.io/assets-for-api-docs/assets/material/radio_list_tile_custom.png) /// diff --git a/packages/flutter/lib/src/material/raised_button.dart b/packages/flutter/lib/src/material/raised_button.dart index 24dc533a42..2e2f4debd9 100644 --- a/packages/flutter/lib/src/material/raised_button.dart +++ b/packages/flutter/lib/src/material/raised_button.dart @@ -31,7 +31,7 @@ import 'theme_data.dart'; /// Raised buttons have a minimum size of 88.0 by 36.0 which can be overridden /// with [ButtonTheme]. /// -/// {@tool snippet --template=stateless_widget_scaffold} +/// {@tool sample --template=stateless_widget_scaffold} /// /// This sample shows how to render a disabled RaisedButton, an enabled RaisedButton /// and lastly a RaisedButton with gradient background. diff --git a/packages/flutter/lib/src/material/range_slider.dart b/packages/flutter/lib/src/material/range_slider.dart index cc4589e336..58113ec73d 100644 --- a/packages/flutter/lib/src/material/range_slider.dart +++ b/packages/flutter/lib/src/material/range_slider.dart @@ -155,7 +155,7 @@ class RangeSlider extends StatefulWidget { /// [StatefulWidget] using the [State.setState] method, so that the parent /// gets rebuilt; for example: /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// RangeSlider( @@ -187,7 +187,7 @@ class RangeSlider extends StatefulWidget { /// The values passed will be the last [values] that the slider had before the /// change began. /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// RangeSlider( @@ -222,7 +222,7 @@ class RangeSlider extends StatefulWidget { /// [onChanged] for that). Rather, it should be used to know when the user has /// completed selecting a new [values] by ending a drag or a click. /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// RangeSlider( @@ -310,7 +310,7 @@ class RangeSlider extends StatefulWidget { /// This is used by accessibility frameworks like TalkBack on Android to /// inform users what the currently selected value is with more context. /// - /// {@tool sample} + /// {@tool snippet} /// /// In the example below, a slider for currency values is configured to /// announce a value with a currency label. diff --git a/packages/flutter/lib/src/material/reorderable_list.dart b/packages/flutter/lib/src/material/reorderable_list.dart index 663644eb32..2944b1adc0 100644 --- a/packages/flutter/lib/src/material/reorderable_list.dart +++ b/packages/flutter/lib/src/material/reorderable_list.dart @@ -27,7 +27,7 @@ import 'material_localizations.dart'; /// /// {@youtube 560 315 https://www.youtube.com/watch?v=3fB1mxOsqJE} /// -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// final List backingList = [/* ... */]; diff --git a/packages/flutter/lib/src/material/scaffold.dart b/packages/flutter/lib/src/material/scaffold.dart index e1b86781f3..48ca12dcbb 100644 --- a/packages/flutter/lib/src/material/scaffold.dart +++ b/packages/flutter/lib/src/material/scaffold.dart @@ -803,7 +803,7 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr /// [ScaffoldState] for the current [BuildContext] via [Scaffold.of] and use the /// [ScaffoldState.showSnackBar] and [ScaffoldState.showBottomSheet] functions. /// -/// {@tool snippet --template=stateful_widget_material} +/// {@tool sample --template=stateful_widget_material} /// This example shows a [Scaffold] with a [body] and [FloatingActionButton]. /// The [body] is a [Text] placed in a [Center] in order to center the text /// within the [Scaffold]. The [FloatingActionButton] is connected to a @@ -832,7 +832,7 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr /// ``` /// {@end-tool} /// -/// {@tool snippet --template=stateful_widget_material} +/// {@tool sample --template=stateful_widget_material} /// This example shows a [Scaffold] with a blueGrey [backgroundColor], [body] /// and [FloatingActionButton]. The [body] is a [Text] placed in a [Center] in /// order to center the text within the [Scaffold]. The [FloatingActionButton] @@ -862,7 +862,7 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr /// ``` /// {@end-tool} /// -/// {@tool snippet --template=stateful_widget_material} +/// {@tool sample --template=stateful_widget_material} /// This example shows a [Scaffold] with an [AppBar], a [BottomAppBar] and a /// [FloatingActionButton]. The [body] is a [Text] placed in a [Center] in order /// to center the text within the [Scaffold]. The [FloatingActionButton] is @@ -932,7 +932,7 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr /// scaffold with a differently titled AppBar. It would be better to add a /// listener to the [TabController] that updates the AppBar. /// -/// {@tool sample} +/// {@tool snippet} /// Add a listener to the app's tab controller so that the [AppBar] title of the /// app's one and only scaffold is reset each time a new tab is selected. /// @@ -1097,7 +1097,7 @@ class Scaffold extends StatefulWidget { /// To open the drawer programmatically, use the [ScaffoldState.openDrawer] /// function. /// - /// {@tool snippet --template=stateful_widget_material} + /// {@tool sample --template=stateful_widget_material} /// To disable the drawer edge swipe, set the [Scaffold.drawerEdgeWidth] /// to 0. Then, use [ScaffoldState.openDrawer] to open the drawer. /// @@ -1138,7 +1138,7 @@ class Scaffold extends StatefulWidget { /// To open the drawer programmatically, use the [ScaffoldState.openEndDrawer] /// function. /// - /// {@tool snippet --template=stateful_widget_material} + /// {@tool sample --template=stateful_widget_material} /// To disable the drawer edge swipe, set the [Scaffold.drawerEdgeWidth] /// to 0. Then, use [ScaffoldState.openEndDrawer] to open the drawer. /// @@ -1267,7 +1267,7 @@ class Scaffold extends StatefulWidget { /// The state from the closest instance of this class that encloses the given context. /// - /// {@tool snippet --template=freeform} + /// {@tool sample --template=freeform} /// Typical usage of the [Scaffold.of] function is to call it from within the /// `build` method of a child of a [Scaffold]. /// @@ -1320,7 +1320,7 @@ class Scaffold extends StatefulWidget { /// ``` /// {@end-tool} /// - /// {@tool snippet --template=stateless_widget_material} + /// {@tool sample --template=stateless_widget_material} /// When the [Scaffold] is actually created in the same `build` function, the /// `context` argument to the `build` function can't be used to find the /// [Scaffold] (since it's "above" the widget being returned in the widget @@ -1877,7 +1877,7 @@ class ScaffoldState extends State with TickerProviderStateMixin { /// /// {@animation 350 622 https://flutter.github.io/assets-for-api-docs/assets/material/show_bottom_sheet.mp4} /// - /// {@tool snippet --template=stateless_widget_scaffold} + /// {@tool sample --template=stateless_widget_scaffold} /// /// This example demonstrates how to use `showBottomSheet` to display a /// bottom sheet when a user taps a button. It also demonstrates how to diff --git a/packages/flutter/lib/src/material/search.dart b/packages/flutter/lib/src/material/search.dart index b234ce85d3..9ddf0ae220 100644 --- a/packages/flutter/lib/src/material/search.dart +++ b/packages/flutter/lib/src/material/search.dart @@ -92,7 +92,7 @@ abstract class SearchDelegate { /// Constructor to be called by subclasses which may specify [searchFieldLabel], [keyboardType] and/or /// [textInputAction]. /// - /// {@tool sample} + /// {@tool snippet} /// ```dart /// class CustomSearchHintDelegate extends SearchDelegate { /// CustomSearchHintDelegate({ diff --git a/packages/flutter/lib/src/material/selectable_text.dart b/packages/flutter/lib/src/material/selectable_text.dart index 44253c554c..0549207d29 100644 --- a/packages/flutter/lib/src/material/selectable_text.dart +++ b/packages/flutter/lib/src/material/selectable_text.dart @@ -143,7 +143,7 @@ class _SelectableTextSelectionGestureDetectorBuilder extends TextSelectionGestur /// behavior is useful, for example, to make the text bold while using the /// default font family and size. /// -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// SelectableText( @@ -159,7 +159,7 @@ class _SelectableTextSelectionGestureDetectorBuilder extends TextSelectionGestur /// that follows displays "Hello beautiful world" with different styles /// for each word. /// -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// const SelectableText.rich( diff --git a/packages/flutter/lib/src/material/slider.dart b/packages/flutter/lib/src/material/slider.dart index 17ec4a85db..d1f158180f 100644 --- a/packages/flutter/lib/src/material/slider.dart +++ b/packages/flutter/lib/src/material/slider.dart @@ -180,7 +180,7 @@ class Slider extends StatefulWidget { /// [StatefulWidget] using the [State.setState] method, so that the parent /// gets rebuilt; for example: /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Slider( @@ -215,7 +215,7 @@ class Slider extends StatefulWidget { /// The value passed will be the last [value] that the slider had before the /// change began. /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Slider( @@ -248,7 +248,7 @@ class Slider extends StatefulWidget { /// [onChanged] for that), but rather to know when the user has completed /// selecting a new [value] by ending a drag or a click. /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// Slider( @@ -348,7 +348,7 @@ class Slider extends StatefulWidget { /// This is used by accessibility frameworks like TalkBack on Android to /// inform users what the currently selected value is with more context. /// - /// {@tool sample} + /// {@tool snippet} /// /// In the example below, a slider for currency values is configured to /// announce a value with a currency label. diff --git a/packages/flutter/lib/src/material/slider_theme.dart b/packages/flutter/lib/src/material/slider_theme.dart index a933dc4347..6f7e3dcd53 100644 --- a/packages/flutter/lib/src/material/slider_theme.dart +++ b/packages/flutter/lib/src/material/slider_theme.dart @@ -155,7 +155,7 @@ class SliderTheme extends InheritedTheme { /// Defaults to the ambient [ThemeData.sliderTheme] if there is no /// [SliderTheme] in the given build context. /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// class Launch extends StatefulWidget { @@ -316,7 +316,7 @@ class SliderThemeData extends Diagnosticable { /// [copyWith] on the one you get from [SliderTheme.of], or create an /// entirely new one with [SliderThemeData.fromPrimaryColors]. /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// class Blissful extends StatefulWidget { diff --git a/packages/flutter/lib/src/material/stepper.dart b/packages/flutter/lib/src/material/stepper.dart index db9875ea70..8e9013d3a2 100644 --- a/packages/flutter/lib/src/material/stepper.dart +++ b/packages/flutter/lib/src/material/stepper.dart @@ -192,7 +192,7 @@ class Stepper extends StatefulWidget { /// This callback which takes in a context and two functions,[onStepContinue] /// and [onStepCancel]. These can be used to control the stepper. /// - /// {@tool snippet --template=stateless_widget_scaffold} + /// {@tool sample --template=stateless_widget_scaffold} /// Creates a stepper control with custom buttons. /// /// ```dart diff --git a/packages/flutter/lib/src/material/switch_list_tile.dart b/packages/flutter/lib/src/material/switch_list_tile.dart index 7be5dc3a15..9f8215bd06 100644 --- a/packages/flutter/lib/src/material/switch_list_tile.dart +++ b/packages/flutter/lib/src/material/switch_list_tile.dart @@ -46,7 +46,7 @@ enum _SwitchListTileType { material, adaptive } /// To show the [SwitchListTile] as disabled, pass null as the [onChanged] /// callback. /// -/// {@tool snippet --template=stateful_widget_scaffold_center} +/// {@tool sample --template=stateful_widget_scaffold_center} /// /// ![SwitchListTile sample](https://flutter.github.io/assets-for-api-docs/assets/material/switch_list_tile.png) /// @@ -85,7 +85,7 @@ enum _SwitchListTileType { material, adaptive } /// into one. Therefore, it may be necessary to create a custom radio tile /// widget to accommodate similar use cases. /// -/// {@tool snippet --template=stateful_widget_scaffold_center} +/// {@tool sample --template=stateful_widget_scaffold_center} /// /// ![Switch list tile semantics sample](https://flutter.github.io/assets-for-api-docs/assets/material/switch_list_tile_semantics.png) /// @@ -169,7 +169,7 @@ enum _SwitchListTileType { material, adaptive } /// combining [Switch] with other widgets, such as [Text], [Padding] and /// [InkWell]. /// -/// {@tool snippet --template=stateful_widget_scaffold_center} +/// {@tool sample --template=stateful_widget_scaffold_center} /// /// ![Custom switch list tile sample](https://flutter.github.io/assets-for-api-docs/assets/material/switch_list_tile_custom.png) /// diff --git a/packages/flutter/lib/src/material/tab_controller.dart b/packages/flutter/lib/src/material/tab_controller.dart index c1f6823015..23ec1b4194 100644 --- a/packages/flutter/lib/src/material/tab_controller.dart +++ b/packages/flutter/lib/src/material/tab_controller.dart @@ -26,7 +26,7 @@ import 'constants.dart'; /// /// {@animation 700 540 https://flutter.github.io/assets-for-api-docs/assets/material/tabs.mp4} /// -/// {@tool sample} +/// {@tool snippet} /// /// This widget introduces a [Scaffold] with an [AppBar] and a [TabBar]. /// @@ -339,7 +339,7 @@ class DefaultTabController extends StatefulWidget { /// The closest instance of this class that encloses the given context. /// - /// {@tool sample} + /// {@tool snippet} /// Typical usage is as follows: /// /// ```dart diff --git a/packages/flutter/lib/src/material/text_field.dart b/packages/flutter/lib/src/material/text_field.dart index 45e14d4b67..36643f9e41 100644 --- a/packages/flutter/lib/src/material/text_field.dart +++ b/packages/flutter/lib/src/material/text_field.dart @@ -149,7 +149,7 @@ class _TextFieldSelectionGestureDetectorBuilder extends TextSelectionGestureDete /// Remember to [dispose] of the [TextEditingController] when it is no longer needed. /// This will ensure we discard any resources used by the object. /// -/// {@tool sample} +/// {@tool snippet} /// This example shows how to create a [TextField] that will obscure input. The /// [InputDecoration] surrounds the field in a border using [OutlineInputBorder] /// and adds a label. @@ -654,7 +654,7 @@ class TextField extends StatefulWidget { /// accessibility, but it also needs to be accessible itself. For example, /// if returning a Text widget, set the [semanticsLabel] property. /// - /// {@tool sample} + /// {@tool snippet} /// ```dart /// Widget counter( /// BuildContext context, diff --git a/packages/flutter/lib/src/material/text_form_field.dart b/packages/flutter/lib/src/material/text_form_field.dart index d4ea4bc058..1c9c411a29 100644 --- a/packages/flutter/lib/src/material/text_form_field.dart +++ b/packages/flutter/lib/src/material/text_form_field.dart @@ -36,7 +36,7 @@ export 'package:flutter/services.dart' show SmartQuotesType, SmartDashesType; /// /// For a documentation about the various parameters, see [TextField]. /// -/// {@tool sample} +/// {@tool snippet} /// /// Creates a [TextFormField] with an [InputDecoration] and validator function. /// diff --git a/packages/flutter/lib/src/material/text_theme.dart b/packages/flutter/lib/src/material/text_theme.dart index afa92bf432..13a4e89f78 100644 --- a/packages/flutter/lib/src/material/text_theme.dart +++ b/packages/flutter/lib/src/material/text_theme.dart @@ -176,7 +176,7 @@ class TextTheme extends Diagnosticable { /// the typography styles in the material design specification, as a starting /// point. /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// /// A Widget that sets the ambient theme's title text color for its @@ -260,7 +260,7 @@ class TextTheme extends Diagnosticable { /// [TextTheme] has only some fields defined, and you want to define the rest /// by merging it with a default theme. /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// /// A Widget that sets the ambient theme's title text color for its diff --git a/packages/flutter/lib/src/material/theme_data.dart b/packages/flutter/lib/src/material/theme_data.dart index e151810bc7..087a183ccc 100644 --- a/packages/flutter/lib/src/material/theme_data.dart +++ b/packages/flutter/lib/src/material/theme_data.dart @@ -96,7 +96,7 @@ enum MaterialTapTargetSize { /// /// To obtain the current theme, use [Theme.of]. /// -/// {@tool sample} +/// {@tool snippet} /// /// This sample creates a [Theme] widget that stores the `ThemeData`. The /// `ThemeData` can be accessed by descendant Widgets that use the correct @@ -128,7 +128,7 @@ enum MaterialTapTargetSize { /// [MaterialApp]. The `ThemeData` will be used throughout the app to style /// material design widgets. /// -/// {@tool sample} +/// {@tool snippet} /// /// This sample creates a [MaterialApp] widget that stores `ThemeData` and /// passes the `ThemeData` to descendant widgets. The [AppBar] widget uses the @@ -588,7 +588,7 @@ class ThemeData extends Diagnosticable { /// forward we will be converting all the widget implementations to only use /// colors or colors derived from those in [ColorScheme]. /// - /// {@tool sample} + /// {@tool snippet} /// This example will set up an application to use the baseline Material /// Design light and dark themes. /// diff --git a/packages/flutter/lib/src/material/time.dart b/packages/flutter/lib/src/material/time.dart index 011895beb8..c7e7243182 100644 --- a/packages/flutter/lib/src/material/time.dart +++ b/packages/flutter/lib/src/material/time.dart @@ -29,7 +29,7 @@ enum DayPeriod { /// minute or using [DateTime] object. /// Hours are specified between 0 and 23, as in a 24-hour clock. /// -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// TimeOfDay now = TimeOfDay.now(); diff --git a/packages/flutter/lib/src/material/time_picker.dart b/packages/flutter/lib/src/material/time_picker.dart index d6ddd70303..24ab9c9931 100644 --- a/packages/flutter/lib/src/material/time_picker.dart +++ b/packages/flutter/lib/src/material/time_picker.dart @@ -1723,7 +1723,7 @@ class _TimePickerDialogState extends State<_TimePickerDialog> { /// The returned Future resolves to the time selected by the user when the user /// closes the dialog. If the user cancels the dialog, null is returned. /// -/// {@tool sample} +/// {@tool snippet} /// Show a dialog with [initialTime] equal to the current time. /// /// ```dart @@ -1741,7 +1741,7 @@ class _TimePickerDialogState extends State<_TimePickerDialog> { /// to add inherited widgets like [Localizations.override], /// [Directionality], or [MediaQuery]. /// -/// {@tool sample} +/// {@tool snippet} /// Show a dialog with the text direction overridden to be [TextDirection.rtl]. /// /// ```dart @@ -1758,7 +1758,7 @@ class _TimePickerDialogState extends State<_TimePickerDialog> { /// ``` /// {@end-tool} /// -/// {@tool sample} +/// {@tool snippet} /// Show a dialog with time unconditionally displayed in 24 hour format. /// /// ```dart diff --git a/packages/flutter/lib/src/material/tooltip_theme.dart b/packages/flutter/lib/src/material/tooltip_theme.dart index 51ac275737..1719ccd09f 100644 --- a/packages/flutter/lib/src/material/tooltip_theme.dart +++ b/packages/flutter/lib/src/material/tooltip_theme.dart @@ -189,7 +189,7 @@ class TooltipThemeData extends Diagnosticable { /// Values specified here are used for [Tooltip] properties that are not /// given an explicit non-null value. /// -/// {@tool sample} +/// {@tool snippet} /// /// Here is an example of a tooltip theme that applies a blue foreground /// with non-rounded corners. diff --git a/packages/flutter/lib/src/painting/borders.dart b/packages/flutter/lib/src/painting/borders.dart index f5517c89a8..79341b09c9 100644 --- a/packages/flutter/lib/src/painting/borders.dart +++ b/packages/flutter/lib/src/painting/borders.dart @@ -29,7 +29,7 @@ enum BorderStyle { /// Note that setting [BorderSide.width] to 0.0 will result in hairline /// rendering. A more involved explanation is present in [BorderSide.width]. /// -/// {@tool sample} +/// {@tool snippet} /// /// This sample shows how [BorderSide] objects can be used in a [Container], via /// a [BoxDecoration] and a [Border], to decorate some [Text]. In this example, diff --git a/packages/flutter/lib/src/painting/box_border.dart b/packages/flutter/lib/src/painting/box_border.dart index d2de9dfbc0..30b425b642 100644 --- a/packages/flutter/lib/src/painting/box_border.dart +++ b/packages/flutter/lib/src/painting/box_border.dart @@ -243,7 +243,7 @@ abstract class BoxBorder extends ShapeBorder { /// /// The sides are represented by [BorderSide] objects. /// -/// {@tool sample} +/// {@tool snippet} /// /// All four borders the same, two-pixel wide solid white: /// @@ -251,7 +251,7 @@ abstract class BoxBorder extends ShapeBorder { /// Border.all(width: 2.0, color: const Color(0xFFFFFFFF)) /// ``` /// {@end-tool} -/// {@tool sample} +/// {@tool snippet} /// /// The border for a material design divider: /// @@ -259,7 +259,7 @@ abstract class BoxBorder extends ShapeBorder { /// Border(bottom: BorderSide(color: Theme.of(context).dividerColor)) /// ``` /// {@end-tool} -/// {@tool sample} +/// {@tool snippet} /// /// A 1990s-era "OK" button: /// diff --git a/packages/flutter/lib/src/painting/box_decoration.dart b/packages/flutter/lib/src/painting/box_decoration.dart index 95ec70f3f4..afbd20c5bf 100644 --- a/packages/flutter/lib/src/painting/box_decoration.dart +++ b/packages/flutter/lib/src/painting/box_decoration.dart @@ -33,7 +33,7 @@ import 'image_provider.dart'; /// /// The [border] paints over the body; the [boxShadow], naturally, paints below it. /// -/// {@tool sample} +/// {@tool snippet} /// /// The following applies a [BoxDecoration] to a [Container] widget to draw an /// [image] of an owl with a thick black [border] and rounded corners. diff --git a/packages/flutter/lib/src/painting/box_fit.dart b/packages/flutter/lib/src/painting/box_fit.dart index fa83839fa3..05035e8e64 100644 --- a/packages/flutter/lib/src/painting/box_fit.dart +++ b/packages/flutter/lib/src/painting/box_fit.dart @@ -104,7 +104,7 @@ class FittedSizes { /// convenience function, [Alignment.inscribe], for resolving the sizes to /// rects, as shown in the example below. /// -/// {@tool sample} +/// {@tool snippet} /// /// This function paints a [dart:ui.Image] `image` onto the [Rect] `outputRect` on a /// [Canvas] `canvas`, using a [Paint] `paint`, applying the [BoxFit] algorithm diff --git a/packages/flutter/lib/src/painting/continuous_rectangle_border.dart b/packages/flutter/lib/src/painting/continuous_rectangle_border.dart index 8b85deaf9b..20ba150551 100644 --- a/packages/flutter/lib/src/painting/continuous_rectangle_border.dart +++ b/packages/flutter/lib/src/painting/continuous_rectangle_border.dart @@ -12,7 +12,7 @@ import 'edge_insets.dart'; /// A rectangular border with smooth continuous transitions between the straight /// sides and the rounded corners. /// -/// {@tool sample} +/// {@tool snippet} /// ```dart /// Widget build(BuildContext context) { /// return Material( diff --git a/packages/flutter/lib/src/painting/edge_insets.dart b/packages/flutter/lib/src/painting/edge_insets.dart index 63504c863e..ac331a3038 100644 --- a/packages/flutter/lib/src/painting/edge_insets.dart +++ b/packages/flutter/lib/src/painting/edge_insets.dart @@ -305,7 +305,7 @@ abstract class EdgeInsetsGeometry { /// _start_, top, _end_, and bottom, where start and end are resolved in terms /// of a [TextDirection] (typically obtained from the ambient [Directionality]). /// -/// {@tool sample} +/// {@tool snippet} /// /// Here are some examples of how to create [EdgeInsets] instances: /// @@ -315,7 +315,7 @@ abstract class EdgeInsetsGeometry { /// const EdgeInsets.all(8.0) /// ``` /// {@end-tool} -/// {@tool sample} +/// {@tool snippet} /// /// Eight pixel margin above and below, no horizontal margins: /// @@ -323,7 +323,7 @@ abstract class EdgeInsetsGeometry { /// const EdgeInsets.symmetric(vertical: 8.0) /// ``` /// {@end-tool} -/// {@tool sample} +/// {@tool snippet} /// /// Left margin indent of 40 pixels: /// @@ -344,7 +344,7 @@ class EdgeInsets extends EdgeInsetsGeometry { /// Creates insets where all the offsets are `value`. /// - /// {@tool sample} + /// {@tool snippet} /// /// Typical eight-pixel margin on all sides: /// @@ -360,7 +360,7 @@ class EdgeInsets extends EdgeInsetsGeometry { /// Creates insets with only the given values non-zero. /// - /// {@tool sample} + /// {@tool snippet} /// /// Left margin indent of 40 pixels: /// @@ -377,7 +377,7 @@ class EdgeInsets extends EdgeInsetsGeometry { /// Creates insets with symmetrical vertical and horizontal offsets. /// - /// {@tool sample} + /// {@tool snippet} /// /// Eight pixel margin above and below, no horizontal margins: /// @@ -638,7 +638,7 @@ class EdgeInsetsDirectional extends EdgeInsetsGeometry { /// Creates insets with only the given values non-zero. /// - /// {@tool sample} + /// {@tool snippet} /// /// A margin indent of 40 pixels on the leading side: /// diff --git a/packages/flutter/lib/src/painting/gradient.dart b/packages/flutter/lib/src/painting/gradient.dart index 3ff92e05f7..db5c2815cd 100644 --- a/packages/flutter/lib/src/painting/gradient.dart +++ b/packages/flutter/lib/src/painting/gradient.dart @@ -82,7 +82,7 @@ abstract class GradientTransform { /// A [GradientTransform] that rotates the gradient around the center-point of /// its bounding box. /// -/// {@tool sample} +/// {@tool snippet} /// /// This sample would rotate a sweep gradient by a quarter turn clockwise: /// @@ -327,7 +327,7 @@ abstract class Gradient { /// Typically this class is used with [BoxDecoration], which does the painting. /// To use a [LinearGradient] to paint on a canvas directly, see [createShader]. /// -/// {@tool sample} +/// {@tool snippet} /// /// This sample draws a picture that looks like vertical window shades by having /// a [Container] display a [BoxDecoration] with a [LinearGradient]. @@ -551,7 +551,7 @@ class LinearGradient extends Gradient { /// Typically this class is used with [BoxDecoration], which does the painting. /// To use a [RadialGradient] to paint on a canvas directly, see [createShader]. /// -/// {@tool sample} +/// {@tool snippet} /// /// This function draws a gradient that looks like a sun in a blue sky. /// @@ -799,7 +799,7 @@ class RadialGradient extends Gradient { /// Typically this class is used with [BoxDecoration], which does the painting. /// To use a [SweepGradient] to paint on a canvas directly, see [createShader]. /// -/// {@tool sample} +/// {@tool snippet} /// /// This sample draws a different color in each quadrant. /// @@ -824,7 +824,7 @@ class RadialGradient extends Gradient { /// ``` /// {@end-tool} /// -/// {@tool sample} +/// {@tool snippet} /// /// This sample takes the above gradient and rotates it by `math.pi/4` radians, /// i.e. 45 degrees. diff --git a/packages/flutter/lib/src/painting/image_cache.dart b/packages/flutter/lib/src/painting/image_cache.dart index eb9c85704a..a16e3eba3c 100644 --- a/packages/flutter/lib/src/painting/image_cache.dart +++ b/packages/flutter/lib/src/painting/image_cache.dart @@ -29,7 +29,7 @@ const int _kDefaultSizeBytes = 100 << 20; // 100 MiB /// A shared instance of this cache is retained by [PaintingBinding] and can be /// obtained via the [imageCache] top-level property in the [painting] library. /// -/// {@tool sample} +/// {@tool snippet} /// /// This sample shows how to supply your own caching logic and replace the /// global [imageCache] varible. diff --git a/packages/flutter/lib/src/painting/image_provider.dart b/packages/flutter/lib/src/painting/image_provider.dart index cf0f137fa2..1c51cc4236 100644 --- a/packages/flutter/lib/src/painting/image_provider.dart +++ b/packages/flutter/lib/src/painting/image_provider.dart @@ -182,7 +182,7 @@ typedef DecoderCallback = Future Function(Uint8List bytes, {int cacheW /// /// The following image formats are supported: {@macro flutter.dart:ui.imageFormats} /// -/// {@tool sample} +/// {@tool snippet} /// /// The following shows the code required to write a widget that fully conforms /// to the [ImageProvider] and [Widget] protocols. (It is essentially a @@ -349,7 +349,7 @@ abstract class ImageProvider { /// The [configuration] is optional and defaults to /// [ImageConfiguration.empty]. /// - /// {@tool sample} + /// {@tool snippet} /// /// The following sample code shows how an image loaded using the [Image] /// widget can be evicted using a [NetworkImage] with a matching URL. diff --git a/packages/flutter/lib/src/painting/inline_span.dart b/packages/flutter/lib/src/painting/inline_span.dart index 8160a6afdc..90cd399954 100644 --- a/packages/flutter/lib/src/painting/inline_span.dart +++ b/packages/flutter/lib/src/painting/inline_span.dart @@ -108,7 +108,7 @@ class InlineSpanSemanticsInformation { /// this is the [WidgetSpan] class in the widgets library. /// * The subclass [WidgetSpan] specifies embedded inline widgets. /// -/// {@tool sample} +/// {@tool snippet} /// /// This example shows a tree of [InlineSpan]s that make a query asking for a /// name with a [TextField] embedded inline. diff --git a/packages/flutter/lib/src/painting/shape_decoration.dart b/packages/flutter/lib/src/painting/shape_decoration.dart index 06cfd2e05f..5e0fcac3dd 100644 --- a/packages/flutter/lib/src/painting/shape_decoration.dart +++ b/packages/flutter/lib/src/painting/shape_decoration.dart @@ -24,7 +24,7 @@ import 'rounded_rectangle_border.dart'; /// optionally filling it with a color or a gradient, optionally painting an /// image into it, and optionally casting a shadow. /// -/// {@tool sample} +/// {@tool snippet} /// /// The following example uses the [Container] widget from the widgets layer to /// draw a white rectangle with a 24-pixel multicolor outline, with the text diff --git a/packages/flutter/lib/src/painting/strut_style.dart b/packages/flutter/lib/src/painting/strut_style.dart index fa163dc444..eb085bb1a3 100644 --- a/packages/flutter/lib/src/painting/strut_style.dart +++ b/packages/flutter/lib/src/painting/strut_style.dart @@ -122,7 +122,7 @@ import 'text_style.dart'; /// /// ### Examples /// -/// {@tool sample} +/// {@tool snippet} /// In this simple case, the text will be rendered at font size 10, however, /// the vertical height of each line will be the strut height (Roboto in /// font size 30 * 1.5) as the text itself is shorter than the strut. @@ -143,7 +143,7 @@ import 'text_style.dart'; /// ``` /// {@end-tool} /// -/// {@tool sample} +/// {@tool snippet} /// Here, strut is used to absorb the additional line height in the second line. /// The strut [height] was defined as 1.5 (the default font size is 14), which /// caused all lines to be laid out taller than without strut. This extra space @@ -184,7 +184,7 @@ import 'text_style.dart'; /// ``` /// {@end-tool} /// -/// {@tool sample} +/// {@tool snippet} /// Here, strut is used to enable strange and overlapping text to achieve unique /// effects. The `M`s in lines 2 and 3 are able to extend above their lines and /// fill empty space in lines above. The [forceStrutHeight] is enabled and functions @@ -227,7 +227,7 @@ import 'text_style.dart'; /// ``` /// {@end-tool} /// -/// {@tool sample} +/// {@tool snippet} /// This example uses forceStrutHeight to create a 'drop cap' for the 'T' in 'The'. /// By locking the line heights to the metrics of the 14pt serif font, we are able /// to lay out a large 37pt 'T' on the second line to take up space on both the first diff --git a/packages/flutter/lib/src/painting/text_span.dart b/packages/flutter/lib/src/painting/text_span.dart index d4ea24918a..5bd5e3f097 100644 --- a/packages/flutter/lib/src/painting/text_span.dart +++ b/packages/flutter/lib/src/painting/text_span.dart @@ -30,7 +30,7 @@ import 'text_style.dart'; /// span in a widget, use a [RichText]. For text with a single style, consider /// using the [Text] widget. /// -/// {@tool sample} +/// {@tool snippet} /// /// The text "Hello world!", in black: /// @@ -110,7 +110,7 @@ class TextSpan extends InlineSpan { /// [GestureRecognizer.dispose] when the [InlineSpan] object is no longer /// used. /// - /// {@tool sample} + /// {@tool snippet} /// /// This example shows how to manage the lifetime of a gesture recognizer /// provided to an [InlineSpan] object. It defines a `BuzzingText` widget diff --git a/packages/flutter/lib/src/painting/text_style.dart b/packages/flutter/lib/src/painting/text_style.dart index 3e9bc2cd4a..19dd904442 100644 --- a/packages/flutter/lib/src/painting/text_style.dart +++ b/packages/flutter/lib/src/painting/text_style.dart @@ -25,7 +25,7 @@ const String _kColorBackgroundWarning = 'Cannot provide both a backgroundColor a /// /// ### Bold /// -/// {@tool sample} +/// {@tool snippet} /// Here, a single line of text in a [Text] widget is given a specific style /// override. The style is mixed with the ambient [DefaultTextStyle] by the /// [Text] widget. @@ -42,7 +42,7 @@ const String _kColorBackgroundWarning = 'Cannot provide both a backgroundColor a /// /// ### Italics /// -/// {@tool sample} +/// {@tool snippet} /// As in the previous example, the [Text] widget is given a specific style /// override which is implicitly mixed with the ambient [DefaultTextStyle]. /// @@ -98,7 +98,7 @@ const String _kColorBackgroundWarning = 'Cannot provide both a backgroundColor a /// /// ### Size /// -/// {@tool sample} +/// {@tool snippet} /// In this example, the ambient [DefaultTextStyle] is explicitly manipulated to /// obtain a [TextStyle] that doubles the default font size. /// @@ -124,7 +124,7 @@ const String _kColorBackgroundWarning = 'Cannot provide both a backgroundColor a /// /// ![Text height diagram](https://flutter.github.io/assets-for-api-docs/assets/painting/text_height_diagram.png) /// -/// {@tool sample} +/// {@tool snippet} /// The [height] property can be used to change the line height. Here, the line /// height is set to 5 times the font size, so that the text is very spaced out. /// Since the `fontSize` is set to 10, the final height of the line is @@ -146,7 +146,7 @@ const String _kColorBackgroundWarning = 'Cannot provide both a backgroundColor a /// /// ### Wavy red underline with black text /// -/// {@tool sample} +/// {@tool snippet} /// Styles can be combined. In this example, the misspelled word is drawn in /// black text and underlined with a wavy red line to indicate a spelling error. /// (The remainder is styled according to the Flutter default text styles, not @@ -180,7 +180,7 @@ const String _kColorBackgroundWarning = 'Cannot provide both a backgroundColor a /// /// ### Borders and stroke (Foreground) /// -/// {@tool sample} +/// {@tool snippet} /// To create bordered text, a [Paint] with [Paint.style] set to [PaintingStyle.stroke] /// should be provided as a [foreground] paint. The following example uses a [Stack] /// to produce a stroke and fill effect. @@ -216,7 +216,7 @@ const String _kColorBackgroundWarning = 'Cannot provide both a backgroundColor a /// /// ### Gradients (Foreground) /// -/// {@tool sample} +/// {@tool snippet} /// The [foreground] property also allows effects such as gradients to be /// applied to the text. Here we provide a [Paint] with a [ui.Gradient] /// shader. @@ -275,7 +275,7 @@ const String _kColorBackgroundWarning = 'Cannot provide both a backgroundColor a /// To select a custom font, create [TextStyle] using the [fontFamily] /// argument as shown in the example below: /// -/// {@tool sample} +/// {@tool snippet} /// ![](https://flutter.github.io/assets-for-api-docs/assets/painting/text_style_custom_fonts.png) /// /// ```dart @@ -322,7 +322,7 @@ const String _kColorBackgroundWarning = 'Cannot provide both a backgroundColor a /// In this case, since the app locally defines the font, the TextStyle is /// created without the `package` argument: /// -/// {@tool sample} +/// {@tool snippet} /// ```dart /// const TextStyle(fontFamily: 'Raleway') /// ``` @@ -348,7 +348,7 @@ const String _kColorBackgroundWarning = 'Cannot provide both a backgroundColor a /// families for multilingual text spans as well as separate fonts for glyphs such /// as emojis. /// -/// {@tool sample} +/// {@tool snippet} /// In the following example, any glyphs not present in the font `Raleway` will be attempted /// to be resolved with `Noto Sans CJK SC`, and then with `Noto Color Emoji`: /// @@ -618,7 +618,7 @@ class TextStyle extends Diagnosticable { /// a [decorationThickness] of 2.0 will draw a decoration twice as thick as /// the font defined decoration thickness. /// - /// {@tool sample} + /// {@tool snippet} /// To achieve a bolded strike-through, we can apply a thicker stroke for the /// decoration. /// @@ -633,7 +633,7 @@ class TextStyle extends Diagnosticable { /// ``` /// {@end-tool} /// - /// {@tool sample} + /// {@tool snippet} /// We can apply a very thin and subtle wavy underline (perhaps, when words /// are misspelled) by using a [decorationThickness] < 1.0. /// diff --git a/packages/flutter/lib/src/physics/gravity_simulation.dart b/packages/flutter/lib/src/physics/gravity_simulation.dart index 2f356b06bb..4f3bdf2f21 100644 --- a/packages/flutter/lib/src/physics/gravity_simulation.dart +++ b/packages/flutter/lib/src/physics/gravity_simulation.dart @@ -12,7 +12,7 @@ import 'simulation.dart'; /// Models a particle that follows Newton's second law of motion. The simulation /// ends when the position reaches a defined point. /// -/// {@tool sample} +/// {@tool snippet} /// /// This method triggers an [AnimationController] (a previously constructed /// `_controller` field) to simulate a fall of 300 pixels. diff --git a/packages/flutter/lib/src/rendering/binding.dart b/packages/flutter/lib/src/rendering/binding.dart index ee0efc76a4..2d1babbb21 100644 --- a/packages/flutter/lib/src/rendering/binding.dart +++ b/packages/flutter/lib/src/rendering/binding.dart @@ -189,7 +189,7 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture /// it causes the widget to be automatically rebuilt when the brightness /// changes. /// - /// {@tool sample} + /// {@tool snippet} /// Querying [Window.platformBrightness]. /// /// ```dart @@ -197,7 +197,7 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture /// ``` /// {@end-tool} /// - /// {@tool sample} + /// {@tool snippet} /// Querying [MediaQuery] directly. Preferred. /// /// ```dart @@ -205,7 +205,7 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture /// ``` /// {@end-tool} /// - /// {@tool sample} + /// {@tool snippet} /// Querying [MediaQueryData]. /// /// ```dart diff --git a/packages/flutter/lib/src/rendering/box.dart b/packages/flutter/lib/src/rendering/box.dart index 82b7f6d0c5..47d6fd18c6 100644 --- a/packages/flutter/lib/src/rendering/box.dart +++ b/packages/flutter/lib/src/rendering/box.dart @@ -683,7 +683,7 @@ class BoxHitTestResult extends HitTestResult { /// the child speaks a different hit test protocol then the parent and the /// position is not required to do the actual hit testing in that protocol. /// - /// {@tool sample} + /// {@tool snippet} /// This method is used in [RenderBox.hitTestChildren] when the child and /// parent don't share the same origin. /// diff --git a/packages/flutter/lib/src/rendering/custom_layout.dart b/packages/flutter/lib/src/rendering/custom_layout.dart index 3262ee09a1..779beae375 100644 --- a/packages/flutter/lib/src/rendering/custom_layout.dart +++ b/packages/flutter/lib/src/rendering/custom_layout.dart @@ -51,7 +51,7 @@ class MultiChildLayoutParentData extends ContainerBoxParentData { /// identifies it to the delegate. The [LayoutId.id] needs to be unique among /// the children that the [CustomMultiChildLayout] manages. /// -/// {@tool sample} +/// {@tool snippet} /// /// Below is an example implementation of [performLayout] that causes one widget /// (the follower) to be the same size as another (the leader): diff --git a/packages/flutter/lib/src/rendering/custom_paint.dart b/packages/flutter/lib/src/rendering/custom_paint.dart index e3cc975a91..4ba6dd5b1a 100644 --- a/packages/flutter/lib/src/rendering/custom_paint.dart +++ b/packages/flutter/lib/src/rendering/custom_paint.dart @@ -64,7 +64,7 @@ typedef SemanticsBuilderCallback = List Function(Size si /// class is provided, to check if the new instance contains different /// information that affects the semantics tree. /// -/// {@tool sample} +/// {@tool snippet} /// /// This sample extends the same code shown for [RadialGradient] to create a /// custom painter that paints a sky. diff --git a/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart b/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart index 8ec25e1304..c013347865 100644 --- a/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart +++ b/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart @@ -49,7 +49,7 @@ class _OverflowRegionData { /// overflows. It will print on the first occurrence, and once after each time that /// [reassemble] is called. /// -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// class MyRenderObject extends RenderAligningShiftedBox with DebugOverflowIndicatorMixin { diff --git a/packages/flutter/lib/src/rendering/object.dart b/packages/flutter/lib/src/rendering/object.dart index 3476119123..c9fa78f07f 100644 --- a/packages/flutter/lib/src/rendering/object.dart +++ b/packages/flutter/lib/src/rendering/object.dart @@ -2410,7 +2410,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im /// asynchronous computation) will at best have no useful effect and at worse /// will cause crashes as the data will be in an inconsistent state. /// - /// {@tool sample} + /// {@tool snippet} /// /// The following snippet will describe the node as a button that responds to /// tap actions. diff --git a/packages/flutter/lib/src/rendering/proxy_box.dart b/packages/flutter/lib/src/rendering/proxy_box.dart index 3b834c6223..b17180e332 100644 --- a/packages/flutter/lib/src/rendering/proxy_box.dart +++ b/packages/flutter/lib/src/rendering/proxy_box.dart @@ -2907,7 +2907,7 @@ class RenderRepaintBoundary extends RenderProxyBox { /// will give you a 1:1 mapping between logical pixels and the output pixels /// in the image. /// - /// {@tool sample} + /// {@tool snippet} /// /// The following is an example of how to go from a `GlobalKey` on a /// `RepaintBoundary` to a PNG: diff --git a/packages/flutter/lib/src/semantics/semantics.dart b/packages/flutter/lib/src/semantics/semantics.dart index 5831864fad..6447128af2 100644 --- a/packages/flutter/lib/src/semantics/semantics.dart +++ b/packages/flutter/lib/src/semantics/semantics.dart @@ -1665,7 +1665,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { /// describes how high the box is that this [SemanticsNode] occupies in three /// dimensional space. The two other dimensions are defined by [rect]. /// - /// {@tool sample} + /// {@tool snippet} /// The following code stacks three [PhysicalModel]s on top of each other /// separated by non-zero elevations. /// diff --git a/packages/flutter/lib/src/services/keyboard_key.dart b/packages/flutter/lib/src/services/keyboard_key.dart index 3c8e0b3897..f70d9d3b09 100644 --- a/packages/flutter/lib/src/services/keyboard_key.dart +++ b/packages/flutter/lib/src/services/keyboard_key.dart @@ -45,7 +45,7 @@ abstract class KeyboardKey extends Diagnosticable { /// look at the physical key to make sure that regardless of the character the /// key produces, you got the key that is in that location on the keyboard. /// -/// {@tool snippet --template=stateful_widget_scaffold} +/// {@tool sample --template=stateful_widget_scaffold} /// This example shows how to detect if the user has selected the logical "Q" /// key. /// @@ -127,7 +127,7 @@ class LogicalKeyboardKey extends KeyboardKey { /// /// [keyId] must not be null. /// - /// {@tool sample} + /// {@tool snippet} /// To save executable size, it is recommended that the [debugName] be null in /// release mode. You can do this by using the [kReleaseMode] constant. /// @@ -1960,7 +1960,7 @@ class LogicalKeyboardKey extends KeyboardKey { /// looking for "the key next next to the TAB key", since on a French keyboard, /// the key next to the TAB key has an "A" on it. /// -/// {@tool snippet --template=stateful_widget_scaffold} +/// {@tool sample --template=stateful_widget_scaffold} /// This example shows how to detect if the user has selected the physical key /// to the right of the CAPS LOCK key. /// @@ -2036,7 +2036,7 @@ class PhysicalKeyboardKey extends KeyboardKey { /// /// The [usbHidUsage] must not be null. /// - /// {@tool sample} + /// {@tool snippet} /// To save executable size, it is recommended that the [debugName] be null in /// release mode. You can do this using the [kReleaseMode] constant. /// diff --git a/packages/flutter/lib/src/services/platform_channel.dart b/packages/flutter/lib/src/services/platform_channel.dart index 3a32f36eec..47e914199a 100644 --- a/packages/flutter/lib/src/services/platform_channel.dart +++ b/packages/flutter/lib/src/services/platform_channel.dart @@ -180,7 +180,7 @@ class MethodChannel { /// in Dart using a MethodChannel and how to implement those methods in Java /// (for Android) and Objective-C (for iOS). /// - /// {@tool sample} + /// {@tool snippet} /// /// The code might be packaged up as a musical plugin, see /// : @@ -233,7 +233,7 @@ class MethodChannel { /// ``` /// {@end-tool} /// - /// {@tool sample} + /// {@tool snippet} /// /// Java (for Android): /// @@ -273,7 +273,7 @@ class MethodChannel { /// ``` /// {@end-tool} /// - /// {@tool sample} + /// {@tool snippet} /// /// Objective-C (for iOS): /// diff --git a/packages/flutter/lib/src/services/system_chrome.dart b/packages/flutter/lib/src/services/system_chrome.dart index 85b6bdebad..2cef6cd2d6 100644 --- a/packages/flutter/lib/src/services/system_chrome.dart +++ b/packages/flutter/lib/src/services/system_chrome.dart @@ -322,7 +322,7 @@ class SystemChrome { /// If a particular style is not supported on the platform, selecting it will /// have no effect. /// - /// {@tool sample} + /// {@tool snippet} /// ```dart /// @override /// Widget build(BuildContext context) { @@ -340,7 +340,7 @@ class SystemChrome { /// navigation bar and synthesize them into a single style. This can be used /// to configure the system styles when an app bar is not used. /// - /// {@tool snippet --template=stateful_widget_material} + /// {@tool sample --template=stateful_widget_material} /// The following example creates a widget that changes the status bar color /// to a random value on Android. /// diff --git a/packages/flutter/lib/src/widgets/actions.dart b/packages/flutter/lib/src/widgets/actions.dart index ded1ef867b..265850c773 100644 --- a/packages/flutter/lib/src/widgets/actions.dart +++ b/packages/flutter/lib/src/widgets/actions.dart @@ -371,7 +371,7 @@ class Actions extends InheritedWidget { /// widget, and the new control should be enabled for keyboard traversal and /// activation. /// -/// {@tool snippet --template=stateful_widget_material} +/// {@tool sample --template=stateful_widget_material} /// This example shows how keyboard interaction can be added to a custom control /// that changes color when hovered and focused, and can toggle a light when /// activated, either by touch or by hitting the `X` key on the keyboard. diff --git a/packages/flutter/lib/src/widgets/animated_cross_fade.dart b/packages/flutter/lib/src/widgets/animated_cross_fade.dart index 4e073067a7..f23dd52672 100644 --- a/packages/flutter/lib/src/widgets/animated_cross_fade.dart +++ b/packages/flutter/lib/src/widgets/animated_cross_fade.dart @@ -38,7 +38,7 @@ enum CrossFadeState { /// top child and the bottom child should be keyed using the provided /// `topChildKey` and `bottomChildKey` keys respectively. /// -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// Widget defaultLayoutBuilder(Widget topChild, Key topChildKey, Widget bottomChild, Key bottomChildKey) { @@ -84,7 +84,7 @@ typedef AnimatedCrossFadeBuilder = Widget Function(Widget topChild, Key topChild /// [AnimatedCrossFade] is rebuilt with a different value for the /// [crossFadeState] property. /// -/// {@tool sample} +/// {@tool snippet} /// /// This code fades between two representations of the Flutter logo. It depends /// on a boolean field `_first`; when `_first` is true, the first logo is shown, diff --git a/packages/flutter/lib/src/widgets/animated_list.dart b/packages/flutter/lib/src/widgets/animated_list.dart index 6298411c47..1db9baf589 100644 --- a/packages/flutter/lib/src/widgets/animated_list.dart +++ b/packages/flutter/lib/src/widgets/animated_list.dart @@ -48,7 +48,7 @@ class _ActiveItem implements Comparable<_ActiveItem> { /// /// {@youtube 560 315 https://www.youtube.com/watch?v=ZtfItHwFlZ8} /// -/// {@tool snippet --template=freeform} +/// {@tool sample --template=freeform} /// This sample application uses an [AnimatedList] to create an effect when /// items are removed or added to the list. /// @@ -490,7 +490,7 @@ class AnimatedListState extends State with TickerProviderStateMixi /// [GlobalKey] or use the static [SliverAnimatedList.of] method from an item's /// input callback. /// -/// {@tool snippet --template=freeform} +/// {@tool sample --template=freeform} /// This sample application uses a [SliverAnimatedList] to create an animated /// effect when items are removed or added to the list. /// diff --git a/packages/flutter/lib/src/widgets/animated_switcher.dart b/packages/flutter/lib/src/widgets/animated_switcher.dart index 10d1c5037c..abb009fb86 100644 --- a/packages/flutter/lib/src/widgets/animated_switcher.dart +++ b/packages/flutter/lib/src/widgets/animated_switcher.dart @@ -87,7 +87,7 @@ typedef AnimatedSwitcherLayoutBuilder = Widget Function(Widget currentChild, Lis /// progress indicator and the image will be fading out while a new progress /// indicator is fading in.) /// -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// class ClickCounter extends StatefulWidget { diff --git a/packages/flutter/lib/src/widgets/app.dart b/packages/flutter/lib/src/widgets/app.dart index 7c29768f7c..71f4dbd124 100644 --- a/packages/flutter/lib/src/widgets/app.dart +++ b/packages/flutter/lib/src/widgets/app.dart @@ -707,7 +707,7 @@ class WidgetsApp extends StatefulWidget { /// By default, this is set to [WidgetsApp.defaultShortcuts]. /// {@endtemplate} /// - /// {@tool sample} + /// {@tool snippet} /// This example shows how to add a single shortcut for /// [LogicalKeyboardKey.select] to the default shortcuts without needing to /// add your own [Shortcuts] widget. @@ -756,7 +756,7 @@ class WidgetsApp extends StatefulWidget { /// widget. /// {@endtemplate} /// - /// {@tool sample} + /// {@tool snippet} /// This example shows how to add a single action handling an /// [ActivateAction] to the default actions without needing to /// add your own [Actions] widget. diff --git a/packages/flutter/lib/src/widgets/async.dart b/packages/flutter/lib/src/widgets/async.dart index 8cd5ed9e56..71454b180b 100644 --- a/packages/flutter/lib/src/widgets/async.dart +++ b/packages/flutter/lib/src/widgets/async.dart @@ -341,7 +341,7 @@ typedef AsyncWidgetBuilder = Widget Function(BuildContext context, AsyncSnaps /// /// {@animation 200 150 https://flutter.github.io/assets-for-api-docs/assets/widgets/stream_builder_error.mp4} /// -/// {@tool snippet --template=stateful_widget_material} +/// {@tool sample --template=stateful_widget_material} /// /// This sample shows a [StreamBuilder] that listens to a Stream that emits bids /// for an auction. Every time the StreamBuilder receives a bid from the Stream, @@ -576,7 +576,7 @@ class StreamBuilder extends StreamBuilderBase> { /// /// {@animation 200 150 https://flutter.github.io/assets-for-api-docs/assets/widgets/future_builder_error.mp4} /// -/// {@tool snippet --template=stateful_widget_material} +/// {@tool sample --template=stateful_widget_material} /// /// This sample shows a [FutureBuilder] that displays a loading spinner while it /// loads data. It displays a success icon and text if the [Future] completes diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index eb236eb0ca..1d29dbc821 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -136,7 +136,7 @@ class Directionality extends InheritedWidget { /// /// {@youtube 560 315 https://www.youtube.com/watch?v=9hltevOHQBw} /// -/// {@tool sample} +/// {@tool snippet} /// /// This example shows some [Text] when the `_visible` member field is true, and /// hides it when it is false: @@ -167,7 +167,7 @@ class Directionality extends InheritedWidget { /// For example, `Container(color: Color.fromRGBO(255, 0, 0, 0.5))` is much /// faster than `Opacity(opacity: 0.5, child: Container(color: Colors.red))`. /// -/// {@tool sample} +/// {@tool snippet} /// /// The following example draws an [Image] with 0.5 opacity without using /// [Opacity]: @@ -266,7 +266,7 @@ class Opacity extends SingleChildRenderObjectWidget { /// For example, [ShaderMask] can be used to gradually fade out the edge /// of a child by using a [new ui.Gradient.linear] mask. /// -/// {@tool sample} +/// {@tool snippet} /// /// This example makes the text look like it is on fire: /// @@ -345,7 +345,7 @@ class ShaderMask extends SingleChildRenderObjectWidget { /// /// {@youtube 560 315 https://www.youtube.com/watch?v=dYRs7Q1vfYI} /// -/// {@tool sample} +/// {@tool snippet} /// If the [BackdropFilter] needs to be applied to an area that exactly matches /// its child, wraps the [BackdropFilter] with a clip widget that clips exactly /// to that child. @@ -439,7 +439,7 @@ class BackdropFilter extends SingleChildRenderObjectWidget { /// [isComplex] and [willChange] are hints to the compositor's raster cache /// and must not be null. /// -/// {@tool sample} +/// {@tool snippet} /// /// This example shows how the sample custom painter shown at [CustomPainter] /// could be used in a [CustomPaint] widget to display a background to some @@ -555,7 +555,7 @@ class CustomPaint extends SingleChildRenderObjectWidget { /// * [OverflowBox] /// * [SizedOverflowBox] /// -/// {@tool sample} +/// {@tool snippet} /// /// For example, by combining a [ClipRect] with an [Align], one can show just /// the top half of an [Image]: @@ -1056,7 +1056,7 @@ class PhysicalShape extends SingleChildRenderObjectWidget { /// /// {@youtube 560 315 https://www.youtube.com/watch?v=9z_YNlRlWfA} /// -/// {@tool sample} +/// {@tool snippet} /// /// This example rotates and skews an orange box containing text, keeping the /// top right corner pinned to its original position. @@ -1105,7 +1105,7 @@ class Transform extends SingleChildRenderObjectWidget { /// The `angle` argument must not be null. It gives the rotation in clockwise /// radians. /// - /// {@tool sample} + /// {@tool snippet} /// /// This example rotates an orange box containing text around its center by /// fifteen degrees. @@ -1140,7 +1140,7 @@ class Transform extends SingleChildRenderObjectWidget { /// /// The `offset` argument must not be null. It specifies the translation. /// - /// {@tool sample} + /// {@tool snippet} /// /// This example shifts the silver-colored child down by fifteen pixels. /// @@ -1173,7 +1173,7 @@ class Transform extends SingleChildRenderObjectWidget { /// The [alignment] controls the origin of the scale; by default, this is /// the center of the box. /// - /// {@tool sample} + /// {@tool snippet} /// /// This example shrinks an orange box containing text such that each dimension /// is half the size it would otherwise be. @@ -1512,7 +1512,7 @@ class FractionalTranslation extends SingleChildRenderObjectWidget { /// this object applies its rotation prior to layout, which means the entire /// rotated box consumes only as much space as required by the rotated child. /// -/// {@tool sample} +/// {@tool snippet} /// /// This snippet rotates the child (some [Text]) so that it renders from bottom /// to top, like an axis label on a graph: @@ -1561,7 +1561,7 @@ class RotatedBox extends SingleChildRenderObjectWidget { /// size. Padding then sizes itself to its child's size, inflated by the /// padding, effectively creating empty space around the child. /// -/// {@tool sample} +/// {@tool snippet} /// /// This snippet creates "Hello World!" [Text] inside a [Card] that is indented /// by sixteen pixels in each direction. @@ -1664,7 +1664,7 @@ class Padding extends SingleChildRenderObjectWidget { /// widget positions the `child` such that both points are lined up on top of /// each other. /// -/// {@tool sample} +/// {@tool snippet} /// The [Align] widget in this example uses one of the defined constants from /// [Alignment], [topRight]. This places the [FlutterLogo] in the top right corner /// of the parent blue [Container]. @@ -1688,7 +1688,7 @@ class Padding extends SingleChildRenderObjectWidget { /// ``` /// {@end-tool} /// -/// {@tool sample} +/// {@tool snippet} /// The [Alignment] used in the following example defines a single point: /// /// * (0.2 * width of [FlutterLogo]/2 + width of [FlutterLogo]/2, 0.6 * height @@ -1719,7 +1719,7 @@ class Padding extends SingleChildRenderObjectWidget { /// ``` /// {@end-tool} /// -/// {@tool sample} +/// {@tool snippet} /// The [FractionalOffset] used in the following example defines two points: /// /// * (0.2 * width of [FlutterLogo], 0.6 * height of [FlutterLogo]) = (12.0, 36.0) @@ -2014,7 +2014,7 @@ class CustomMultiChildLayout extends MultiChildRenderObjectWidget { /// /// {@youtube 560 315 https://www.youtube.com/watch?v=EHPu_DzRfqA} /// -/// {@tool sample} +/// {@tool snippet} /// /// This snippet makes the child widget (a [Card] with some [Text]) have the /// exact size 200x300, parental constraints permitting: @@ -2124,7 +2124,7 @@ class SizedBox extends SingleChildRenderObjectWidget { /// /// {@youtube 560 315 https://www.youtube.com/watch?v=o2KveVr7adg} /// -/// {@tool sample} +/// {@tool snippet} /// /// This snippet makes the child widget (a [Card] with some [Text]) fill the /// parent, by applying [BoxConstraints.expand] constraints: @@ -3105,7 +3105,7 @@ class ListBody extends MultiChildRenderObjectWidget { /// [CustomMultiChildLayout] instead. In particular, when using a [Stack] you /// can't position children relative to their size or the stack's own size. /// -/// {@tool sample} +/// {@tool snippet} /// /// Using a [Stack] you can position widgets over one another. /// @@ -3134,7 +3134,7 @@ class ListBody extends MultiChildRenderObjectWidget { /// ``` /// {@end-tool} /// -/// {@tool sample} +/// {@tool snippet} /// /// This example shows how [Stack] can be used to enhance text visibility /// by adding gradient backdrops. @@ -3968,7 +3968,7 @@ class Flex extends MultiChildRenderObjectWidget { /// If you only have one child, then consider using [Align] or [Center] to /// position the child. /// -/// {@tool sample} +/// {@tool snippet} /// /// This example divides the available space into three (horizontally), and /// places text centered in the first two cells and the Flutter logo centered in @@ -4158,7 +4158,7 @@ class Row extends Flex { /// If you only have one child, then consider using [Align] or [Center] to /// position the child. /// -/// {@tool sample} +/// {@tool snippet} /// /// This example uses a [Column] to arrange three widgets vertically, the last /// being made to fill all the remaining space. @@ -4180,7 +4180,7 @@ class Row extends Flex { /// ) /// ``` /// {@end-tool} -/// {@tool sample} +/// {@tool snippet} /// /// In the sample above, the text and the logo are centered on each line. In the /// following example, the [crossAxisAlignment] is set to @@ -4435,7 +4435,7 @@ class Flexible extends ParentDataWidget { /// /// {@youtube 560 315 https://www.youtube.com/watch?v=_rnZaagadyo} /// -/// {@tool snippet --template=stateless_widget_material} +/// {@tool sample --template=stateless_widget_material} /// This example shows how to use an [Expanded] widget in a [Column] so that /// it's middle child, a [Container] here, expands to fill the space. /// @@ -4474,7 +4474,7 @@ class Flexible extends ParentDataWidget { /// ``` /// {@end-tool} /// -/// {@tool snippet --template=stateless_widget_material} +/// {@tool sample --template=stateless_widget_material} /// This example shows how to use an [Expanded] widget in a [Row] with multiple /// children expanded, utilizing the [flex] factor to prioritize available space. /// @@ -4548,7 +4548,7 @@ class Expanded extends Flexible { /// /// {@youtube 560 315 https://www.youtube.com/watch?v=z5iw2SeFx2M} /// -/// {@tool sample} +/// {@tool snippet} /// /// This example renders some [Chip]s representing four contacts in a [Wrap] so /// that they flow across lines as necessary. @@ -4819,7 +4819,7 @@ class Wrap extends MultiChildRenderObjectWidget { /// /// {@animation 450 100 https://flutter.github.io/assets-for-api-docs/assets/widgets/flow_menu.mp4} /// -/// {@tool snippet --template=freeform} +/// {@tool sample --template=freeform} /// /// This example uses the [Flow] widget to create a menu that opens and closes /// as it is interacted with, shown above. The color of the button in the menu @@ -5001,7 +5001,7 @@ class Flow extends MultiChildRenderObjectWidget { /// spans with the default text style while still allowing specified styles per /// span. /// -/// {@tool sample} +/// {@tool snippet} /// /// This sample demonstrates how to mix and match text with different text /// styles using the [RichText] Widget. It displays the text "Hello bold world," @@ -5389,7 +5389,7 @@ class RawImage extends LeafRenderObjectWidget { /// For example, used by [Image] to determine which bundle to use for /// [AssetImage]s if no bundle is specified explicitly. /// -/// {@tool sample} +/// {@tool snippet} /// /// This can be used in tests to override what the current asset bundle is, thus /// allowing specific resources to be injected into the widget under test. @@ -5407,7 +5407,7 @@ class RawImage extends LeafRenderObjectWidget { /// } /// ``` /// {@end-tool} -/// {@tool sample} +/// {@tool snippet} /// /// ...then wrap the widget under test with a [DefaultAssetBundle] using this /// bundle implementation: @@ -5527,7 +5527,7 @@ class WidgetToRenderBoxAdapter extends LeafRenderObjectWidget { /// If it has a child, this widget defers to the child for sizing behavior. If /// it does not have a child, it grows to fit the parent instead. /// -/// {@tool snippet --template=stateful_widget_scaffold_center} +/// {@tool sample --template=stateful_widget_scaffold_center} /// This example makes a [Container] react to being touched, showing a count of /// the number of pointer downs and ups. /// @@ -5780,7 +5780,7 @@ class _PointerListener extends SingleChildRenderObjectWidget { /// If it has a child, this widget defers to the child for sizing behavior. If /// it does not have a child, it grows to fit the parent instead. /// -/// {@tool snippet --template=stateful_widget_scaffold_center} +/// {@tool sample --template=stateful_widget_scaffold_center} /// This example makes a [Container] react to being entered by a mouse /// pointer, showing a count of the number of entries and exits. /// @@ -6702,7 +6702,7 @@ class ExcludeSemantics extends SingleChildRenderObjectWidget { /// to manually provide semantic indexes if not all child of the scrollable /// contribute semantics. /// -/// {@tool sample} +/// {@tool snippet} /// /// The example below handles spacers in a scrollable that don't contribute /// semantics. The automatic indexes would give the spaces a semantic index, @@ -6838,7 +6838,7 @@ typedef StatefulWidgetBuilder = Widget Function(BuildContext context, StateSette /// Since the [builder] is re-invoked when the [StateSetter] is called, any /// variables that represents state should be kept outside the [builder] function. /// -/// {@tool sample} +/// {@tool snippet} /// /// This example shows using an inline StatefulBuilder that rebuilds and that /// also has state. diff --git a/packages/flutter/lib/src/widgets/binding.dart b/packages/flutter/lib/src/widgets/binding.dart index 995cb3ea89..291e7ba0f8 100644 --- a/packages/flutter/lib/src/widgets/binding.dart +++ b/packages/flutter/lib/src/widgets/binding.dart @@ -31,7 +31,7 @@ export 'dart:ui' show AppLifecycleState, Locale; /// handlers must be implemented (and the analyzer will list those that have /// been omitted). /// -/// {@tool sample} +/// {@tool snippet} /// /// This [StatefulWidget] implements the parts of the [State] and /// [WidgetsBindingObserver] protocols necessary to react to application @@ -109,7 +109,7 @@ abstract class WidgetsBindingObserver { /// /// This method exposes notifications from [Window.onMetricsChanged]. /// - /// {@tool sample} + /// {@tool snippet} /// /// This [StatefulWidget] implements the parts of the [State] and /// [WidgetsBindingObserver] protocols necessary to react when the device is @@ -170,7 +170,7 @@ abstract class WidgetsBindingObserver { /// /// This method exposes notifications from [Window.onTextScaleFactorChanged]. /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// class TextScaleFactorReactor extends StatefulWidget { diff --git a/packages/flutter/lib/src/widgets/container.dart b/packages/flutter/lib/src/widgets/container.dart index 2800c61815..472a092d70 100644 --- a/packages/flutter/lib/src/widgets/container.dart +++ b/packages/flutter/lib/src/widgets/container.dart @@ -23,7 +23,7 @@ import 'image.dart'; /// The [child] is not clipped. To clip a child to the shape of a particular /// [ShapeDecoration], consider using a [ClipPath] widget. /// -/// {@tool sample} +/// {@tool snippet} /// /// This sample shows a radial gradient that draws a moon on a night sky: /// @@ -230,7 +230,7 @@ class DecoratedBox extends SingleChildRenderObjectWidget { /// /// ## Example /// -/// {@tool sample} +/// {@tool snippet} /// This example shows a 48x48 amber square (placed inside a [Center] widget in /// case the parent widget has its own opinions regarding the size that the /// [Container] should take), with a margin so that it stays away from @@ -250,7 +250,7 @@ class DecoratedBox extends SingleChildRenderObjectWidget { /// ``` /// {@end-tool} /// -/// {@tool sample} +/// {@tool snippet} /// /// This example shows how to use many of the features of [Container] at once. /// The [constraints] are set to fit the font size plus ample headroom diff --git a/packages/flutter/lib/src/widgets/draggable_scrollable_sheet.dart b/packages/flutter/lib/src/widgets/draggable_scrollable_sheet.dart index 73d4222c6a..5694ae8830 100644 --- a/packages/flutter/lib/src/widgets/draggable_scrollable_sheet.dart +++ b/packages/flutter/lib/src/widgets/draggable_scrollable_sheet.dart @@ -54,7 +54,7 @@ typedef ScrollableWidgetBuilder = Widget Function( /// to position sheet based on the space it is taking, the [expand] property /// may be set to false. /// -/// {@tool sample} +/// {@tool snippet} /// /// This is a sample widget which shows a [ListView] that has 25 [ListTile]s. /// It starts out as taking up half the body of the [Scaffold], and can be diff --git a/packages/flutter/lib/src/widgets/editable_text.dart b/packages/flutter/lib/src/widgets/editable_text.dart index 8188fb6293..2586a170e7 100644 --- a/packages/flutter/lib/src/widgets/editable_text.dart +++ b/packages/flutter/lib/src/widgets/editable_text.dart @@ -70,7 +70,7 @@ const int _kObscureShowLatestCharCursorTicks = 3; /// /// Remember to [dispose] of the [TextEditingController] when it is no longer needed. /// This will ensure we discard any resources used by the object. -/// {@tool snippet --template=stateful_widget_material} +/// {@tool sample --template=stateful_widget_material} /// This example creates a [TextField] with a [TextEditingController] whose /// change listener forces the entered text to be lower case and keeps the /// cursor at the end of the input. @@ -868,7 +868,7 @@ class EditableText extends StatefulWidget { /// field. /// {@endtemplate} /// - /// {@tool snippet --template=stateful_widget_material} + /// {@tool sample --template=stateful_widget_material} /// When a non-completion action is pressed, such as "next" or "previous", it /// is often desirable to move the focus to the next or previous field. To do /// this, handle it as in this example, by calling [FocusNode.focusNext] in diff --git a/packages/flutter/lib/src/widgets/fade_in_image.dart b/packages/flutter/lib/src/widgets/fade_in_image.dart index 810dc0a656..5cbc0b23c7 100644 --- a/packages/flutter/lib/src/widgets/fade_in_image.dart +++ b/packages/flutter/lib/src/widgets/fade_in_image.dart @@ -52,7 +52,7 @@ import 'transitions.dart'; /// different image. This is known as "gapless playback" (see also /// [Image.gaplessPlayback]). /// -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// FadeInImage( diff --git a/packages/flutter/lib/src/widgets/focus_manager.dart b/packages/flutter/lib/src/widgets/focus_manager.dart index 2942c7c4fd..5ba3129b03 100644 --- a/packages/flutter/lib/src/widgets/focus_manager.dart +++ b/packages/flutter/lib/src/widgets/focus_manager.dart @@ -239,7 +239,7 @@ class FocusAttachment { /// [ReadingOrderTraversalPolicy], and [DirectionalFocusTraversalPolicyMixin], /// but custom policies can be built based upon these policies. /// -/// {@tool snippet --template=stateless_widget_scaffold} +/// {@tool sample --template=stateless_widget_scaffold} /// This example shows how a FocusNode should be managed if not using the /// [Focus] or [FocusScope] widgets. See the [Focus] widget for a similar /// example using [Focus] and [FocusScope] widgets. diff --git a/packages/flutter/lib/src/widgets/focus_scope.dart b/packages/flutter/lib/src/widgets/focus_scope.dart index 03a79372f6..e73787e5bb 100644 --- a/packages/flutter/lib/src/widgets/focus_scope.dart +++ b/packages/flutter/lib/src/widgets/focus_scope.dart @@ -38,7 +38,7 @@ import 'inherited_notifier.dart'; /// /// To collect a sub-tree of nodes into a group, use a [FocusScope]. /// -/// {@tool snippet --template=stateful_widget_scaffold} +/// {@tool sample --template=stateful_widget_scaffold} /// This example shows how to manage focus using the [Focus] and [FocusScope] /// widgets. See [FocusNode] for a similar example that doesn't use [Focus] or /// [FocusScope]. diff --git a/packages/flutter/lib/src/widgets/form.dart b/packages/flutter/lib/src/widgets/form.dart index 9b71f4b99a..cea394b146 100644 --- a/packages/flutter/lib/src/widgets/form.dart +++ b/packages/flutter/lib/src/widgets/form.dart @@ -16,7 +16,7 @@ import 'will_pop_scope.dart'; /// with a context whose ancestor is the [Form], or pass a [GlobalKey] to the /// [Form] constructor and call [GlobalKey.currentState]. /// -/// {@tool snippet --template=stateful_widget_scaffold} +/// {@tool sample --template=stateful_widget_scaffold} /// This example shows a [Form] with one [TextFormField] to enter an email /// address and a [RaisedButton] to submit the form. A [GlobalKey] is used here /// to identify the [Form] and validate input. diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index 000a1ce1da..cf8eb5d3bc 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -532,7 +532,7 @@ abstract class Widget extends DiagnosticableTree { /// widget, so that only the inner-most widget needs to be rebuilt when the /// theme changes. /// -/// {@tool sample} +/// {@tool snippet} /// /// The following is a skeleton of a stateless widget subclass called `GreenFrog`. /// @@ -551,7 +551,7 @@ abstract class Widget extends DiagnosticableTree { /// ``` /// {@end-tool} /// -/// {@tool sample} +/// {@tool snippet} /// /// This next example shows the more generic widget `Frog` which can be given /// a color and a child: @@ -746,7 +746,7 @@ abstract class StatelessWidget extends Widget { /// [KeyedSubtree] widget may be useful for this purpose if no other widget /// can conveniently be assigned the key.) /// -/// {@tool sample} +/// {@tool snippet} /// /// This is a skeleton of a stateful widget subclass called `YellowBird`. /// @@ -770,7 +770,7 @@ abstract class StatelessWidget extends Widget { /// } /// ``` /// {@end-tool} -/// {@tool sample} +/// {@tool snippet} /// /// This example shows the more generic widget `Bird` which can be given a /// color and a child, and which has some internal state with a method that @@ -1423,7 +1423,7 @@ abstract class ProxyWidget extends Widget { /// thus also to a particular [RenderObjectWidget] class. That class is `T`, the /// [ParentDataWidget] type argument. /// -/// {@tool sample} +/// {@tool snippet} /// /// This example shows how you would build a [ParentDataWidget] to configure a /// `FrogJar` widget's children by specifying a [Size] for each one. @@ -1558,7 +1558,7 @@ abstract class ParentDataWidget extends ProxyWidge /// /// {@youtube 560 315 https://www.youtube.com/watch?v=Zbm3hjPjQMk} /// -/// {@tool sample} +/// {@tool snippet} /// /// The following is a skeleton of an inherited widget called `FrogColor`: /// @@ -2182,7 +2182,7 @@ abstract class BuildContext { /// an ancestor from one of those methods, save a reference to the ancestor /// by calling [findAncestorStateOfType] in [State.didChangeDependencies]. /// - /// {@tool sample} + /// {@tool snippet} /// /// ```dart /// ScrollableState scrollable = context.findAncestorStateOfType(); @@ -4085,7 +4085,7 @@ typedef ErrorWidgetBuilder = Widget Function(FlutterErrorDetails details); /// /// It is possible to override this widget. /// -/// {@tool snippet --template=freeform} +/// {@tool sample --template=freeform} /// ```dart /// import 'package:flutter/material.dart'; /// diff --git a/packages/flutter/lib/src/widgets/gesture_detector.dart b/packages/flutter/lib/src/widgets/gesture_detector.dart index 9febee15d2..7fe883ac4a 100644 --- a/packages/flutter/lib/src/widgets/gesture_detector.dart +++ b/packages/flutter/lib/src/widgets/gesture_detector.dart @@ -128,7 +128,7 @@ class GestureRecognizerFactoryWithHandlers extends /// /// {@animation 200 150 https://flutter.github.io/assets-for-api-docs/assets/widgets/gesture_detector.mp4} /// -/// {@tool sample} +/// {@tool snippet} /// /// This example turns the light bulb yellow when the "turn lights on" button is /// tapped by setting the `_lights` field: @@ -759,7 +759,7 @@ class GestureDetector extends StatelessWidget { /// Configuring the gesture recognizers requires a carefully constructed map, as /// described in [gestures] and as shown in the example below. /// -/// {@tool sample} +/// {@tool snippet} /// /// This example shows how to hook up a [TapGestureRecognizer]. It assumes that /// the code is being used inside a [State] object with a `_last` field that is @@ -853,7 +853,7 @@ class RawGestureDetector extends StatefulWidget { /// `onDown`, `onStart`, `onUpdate` and `onEnd`, then /// [PanGestureRecognizer]'s `onDown`, `onStart`, `onUpdate` and `onEnd`. /// - /// {@tool sample} + /// {@tool snippet} /// This custom gesture detector listens to force presses, while also allows /// the same callback to be triggered by semantic long presses. /// diff --git a/packages/flutter/lib/src/widgets/icon.dart b/packages/flutter/lib/src/widgets/icon.dart index 0774e93565..b2a261faa1 100644 --- a/packages/flutter/lib/src/widgets/icon.dart +++ b/packages/flutter/lib/src/widgets/icon.dart @@ -24,7 +24,7 @@ import 'icon_theme_data.dart'; /// This widget assumes that the rendered icon is squared. Non-squared icons may /// render incorrectly. /// -/// {@tool sample} +/// {@tool snippet} /// /// This example shows how to create a [Row] of [Icon]s in different colors and /// sizes. The first [Icon] uses a [semanticLabel] to announce in accessibility @@ -113,7 +113,7 @@ class Icon extends StatelessWidget { /// See [Theme] to set the current theme and [ThemeData.brightness] /// for setting the current theme's brightness. /// - /// {@tool sample} + /// {@tool snippet} /// Typically, a material design color will be used, as follows: /// /// ```dart diff --git a/packages/flutter/lib/src/widgets/image.dart b/packages/flutter/lib/src/widgets/image.dart index ac170ac401..edc5d274c7 100644 --- a/packages/flutter/lib/src/widgets/image.dart +++ b/packages/flutter/lib/src/widgets/image.dart @@ -207,7 +207,7 @@ typedef ImageLoadingBuilder = Widget Function( /// The image is painted using [paintImage], which describes the meanings of the /// various fields on this class in more detail. /// -/// {@tool sample} +/// {@tool snippet} /// The default constructor can be used with any [ImageProvider], such as a /// [NetworkImage], to display an image from the internet. /// @@ -220,7 +220,7 @@ typedef ImageLoadingBuilder = Widget Function( /// ``` /// {@end-tool} /// -/// {@tool sample} +/// {@tool snippet} /// The [Image] Widget also provides several constructors to display different /// types of images for convenience. In this example, use the [Image.network] /// constructor to display an image from the internet. @@ -460,7 +460,7 @@ class Image extends StatefulWidget { /// which corresponds to bilinear interpolation, rather than the default /// [FilterQuality.none] which corresponds to nearest-neighbor. /// - /// {@tool sample} + /// {@tool snippet} /// /// Suppose that the project's `pubspec.yaml` file contains the following: /// @@ -499,7 +499,7 @@ class Image extends StatefulWidget { /// must be provided. For instance, suppose a package called `my_icons` has /// `icons/heart.png` . /// - /// {@tool sample} + /// {@tool snippet} /// Then to display the image, use: /// /// ```dart @@ -682,7 +682,7 @@ class Image extends StatefulWidget { /// ``` /// {@endtemplate} /// - /// {@tool snippet --template=stateless_widget_material} + /// {@tool sample --template=stateless_widget_material} /// /// The following sample demonstrates how to use this builder to implement an /// image that fades in once it's been loaded. @@ -753,7 +753,7 @@ class Image extends StatefulWidget { /// /// {@macro flutter.widgets.image.chainedBuildersExample} /// - /// {@tool snippet --template=stateless_widget_material} + /// {@tool sample --template=stateless_widget_material} /// /// The following sample uses [loadingBuilder] to show a /// [CircularProgressIndicator] while an image loads over the network. diff --git a/packages/flutter/lib/src/widgets/implicit_animations.dart b/packages/flutter/lib/src/widgets/implicit_animations.dart index e74eddaa3b..cf5d3ee1f6 100644 --- a/packages/flutter/lib/src/widgets/implicit_animations.dart +++ b/packages/flutter/lib/src/widgets/implicit_animations.dart @@ -473,7 +473,7 @@ abstract class ImplicitlyAnimatedWidgetState /// properties. Dependent properties should not be updated within /// [forEachTween]. /// - /// {@tool sample} + /// {@tool snippet} /// /// This sample implements an implicitly animated widget's `State`. /// The widget animates between colors whenever `widget.targetColor` @@ -578,7 +578,7 @@ abstract class AnimatedWidgetBaseState exten /// like, using a [curve] of [Curves.fastOutSlowIn]. /// {@animation 250 266 https://flutter.github.io/assets-for-api-docs/assets/widgets/animated_container.mp4} /// -/// {@tool snippet --template=stateful_widget_scaffold} +/// {@tool sample --template=stateful_widget_scaffold} /// /// The following example (depicted above) transitions an AnimatedContainer /// between two states. It adjusts the [height], [width], [color], and @@ -1251,7 +1251,7 @@ class _AnimatedPositionedDirectionalState extends AnimatedWidgetBaseState with TickerProviderStateMixin { /// /// {@macro flutter.widgets.navigator.pushNamed.arguments} /// - /// {@tool sample} + /// {@tool snippet} /// /// Typical usage is as follows: /// @@ -1691,7 +1691,7 @@ class NavigatorState extends State with TickerProviderStateMixin { /// /// {@macro flutter.widgets.navigator.pushNamed.arguments} /// - /// {@tool sample} + /// {@tool snippet} /// /// Typical usage is as follows: /// @@ -1717,7 +1717,7 @@ class NavigatorState extends State with TickerProviderStateMixin { /// /// {@macro flutter.widgets.navigator.pushNamed.arguments} /// - /// {@tool sample} + /// {@tool snippet} /// /// Typical usage is as follows: /// @@ -1744,7 +1744,7 @@ class NavigatorState extends State with TickerProviderStateMixin { /// /// {@macro flutter.widgets.navigator.pushNamed.arguments} /// - /// {@tool sample} + /// {@tool snippet} /// /// Typical usage is as follows: /// @@ -1767,7 +1767,7 @@ class NavigatorState extends State with TickerProviderStateMixin { /// /// {@macro flutter.widgets.navigator.push} /// - /// {@tool sample} + /// {@tool snippet} /// /// Typical usage is as follows: /// @@ -1853,7 +1853,7 @@ class NavigatorState extends State with TickerProviderStateMixin { /// /// {@macro flutter.widgets.navigator.pushReplacement} /// - /// {@tool sample} + /// {@tool snippet} /// /// Typical usage is as follows: /// @@ -1912,7 +1912,7 @@ class NavigatorState extends State with TickerProviderStateMixin { /// /// {@macro flutter.widgets.navigator.pushAndRemoveUntil} /// - /// {@tool sample} + /// {@tool snippet} /// /// Typical usage is as follows: /// @@ -2088,7 +2088,7 @@ class NavigatorState extends State with TickerProviderStateMixin { /// /// {@macro flutter.widgets.navigator.pop} /// - /// {@tool sample} + /// {@tool snippet} /// /// Typical usage for closing a route is as follows: /// @@ -2098,7 +2098,7 @@ class NavigatorState extends State with TickerProviderStateMixin { /// } /// ``` /// {@end-tool} - /// {@tool sample} + /// {@tool snippet} /// /// A dialog box might be closed with a result: /// @@ -2157,7 +2157,7 @@ class NavigatorState extends State with TickerProviderStateMixin { /// /// {@macro flutter.widgets.navigator.popUntil} /// - /// {@tool sample} + /// {@tool snippet} /// /// Typical usage is as follows: /// diff --git a/packages/flutter/lib/src/widgets/nested_scroll_view.dart b/packages/flutter/lib/src/widgets/nested_scroll_view.dart index 529856a449..f729dc3b96 100644 --- a/packages/flutter/lib/src/widgets/nested_scroll_view.dart +++ b/packages/flutter/lib/src/widgets/nested_scroll_view.dart @@ -61,7 +61,7 @@ typedef NestedScrollViewHeaderSliversBuilder = List Function(BuildContex /// (those inside the [TabBarView], hooking them together so that they appear, /// to the user, as one coherent scroll view. /// -/// {@tool sample} +/// {@tool snippet} /// /// This example shows a [NestedScrollView] whose header is the combination of a /// [TabBar] in a [SliverAppBar] and whose body is a [TabBarView]. It uses a diff --git a/packages/flutter/lib/src/widgets/page_view.dart b/packages/flutter/lib/src/widgets/page_view.dart index 28548eacbe..ac8adfeb1c 100644 --- a/packages/flutter/lib/src/widgets/page_view.dart +++ b/packages/flutter/lib/src/widgets/page_view.dart @@ -39,7 +39,7 @@ import 'viewport.dart'; /// /// * [PageView], which is the widget this object controls. /// -/// {@tool sample} +/// {@tool snippet} /// /// This widget introduces a [MaterialApp], [Scaffold] and [PageView] with two pages /// using the default constructor. Both pages contain a [RaisedButton] allowing you @@ -610,7 +610,7 @@ class PageView extends StatefulWidget { /// Creates a scrollable list that works page by page with a custom child /// model. /// - /// {@tool sample} + /// {@tool snippet} /// /// This [PageView] uses a custom [SliverChildBuilderDelegate] to support child /// reordering. diff --git a/packages/flutter/lib/src/widgets/routes.dart b/packages/flutter/lib/src/widgets/routes.dart index 18ba06c750..b9041f7283 100644 --- a/packages/flutter/lib/src/widgets/routes.dart +++ b/packages/flutter/lib/src/widgets/routes.dart @@ -388,7 +388,7 @@ mixin LocalHistoryRoute on Route { /// The given local history entry must not already be part of another local /// history route. /// - /// {@tool sample} + /// {@tool snippet} /// /// The following example is an app with 2 pages: `HomePage` and `SecondPage`. /// The `HomePage` can navigate to the `SecondPage`. @@ -1373,7 +1373,7 @@ abstract class PopupRoute extends ModalRoute { /// than only specific subtypes. For example, to watch for all [PageRoute] /// variants, the `RouteObserver>` type may be used. /// -/// {@tool sample} +/// {@tool snippet} /// /// To make a [StatefulWidget] aware of its current [Route] state, implement /// [RouteAware] in its [State] and subscribe it to a [RouteObserver]: diff --git a/packages/flutter/lib/src/widgets/scroll_controller.dart b/packages/flutter/lib/src/widgets/scroll_controller.dart index 35c1b1f06e..6b3769e12d 100644 --- a/packages/flutter/lib/src/widgets/scroll_controller.dart +++ b/packages/flutter/lib/src/widgets/scroll_controller.dart @@ -284,7 +284,7 @@ class ScrollController extends ChangeNotifier { /// It tracks the most recently updated scroll position and reports it as its /// `initialScrollOffset`. /// -/// {@tool sample} +/// {@tool snippet} /// /// In this example each [PageView] page contains a [ListView] and all three /// [ListView]'s share a [TrackingScrollController]. The scroll offsets of all diff --git a/packages/flutter/lib/src/widgets/scroll_physics.dart b/packages/flutter/lib/src/widgets/scroll_physics.dart index 8501af508e..631d9028f8 100644 --- a/packages/flutter/lib/src/widgets/scroll_physics.dart +++ b/packages/flutter/lib/src/widgets/scroll_physics.dart @@ -80,7 +80,7 @@ class ScrollPhysics { /// The returned object will combine some of the behaviors from this /// [ScrollPhysics] instance and some of the behaviors from [ancestor]. /// - /// {@tool sample} + /// {@tool snippet} /// /// In the following example, the [applyTo] method is used to combine the /// scroll physics of two [ScrollPhysics] objects, the resulting [ScrollPhysics] diff --git a/packages/flutter/lib/src/widgets/scroll_view.dart b/packages/flutter/lib/src/widgets/scroll_view.dart index bb96c0f09c..402d820fd2 100644 --- a/packages/flutter/lib/src/widgets/scroll_view.dart +++ b/packages/flutter/lib/src/widgets/scroll_view.dart @@ -342,7 +342,7 @@ abstract class ScrollView extends StatelessWidget { /// /// {@animation 400 376 https://flutter.github.io/assets-for-api-docs/assets/widgets/custom_scroll_view.mp4} /// -/// {@tool sample} +/// {@tool snippet} /// /// This sample code shows a scroll view that contains a flexible pinned app /// bar, a grid, and an infinite list. @@ -608,7 +608,7 @@ abstract class BoxScrollView extends ScrollView { /// extremities to avoid partial obstructions indicated by [MediaQuery]'s /// padding. To avoid this behavior, override with a zero [padding] property. /// -/// {@tool sample} +/// {@tool snippet} /// This example uses the default constructor for [ListView] which takes an /// explicit [List] of children. This [ListView]'s children are made up /// of [Container]s with [Text]. @@ -639,7 +639,7 @@ abstract class BoxScrollView extends ScrollView { /// ``` /// {@end-tool} /// -/// {@tool sample} +/// {@tool snippet} /// This example mirrors the previous one, creating the same list using the /// [ListView.builder] constructor. Using the [IndexedWidgetBuilder], children /// are built lazily and can be infinite in number. @@ -664,7 +664,7 @@ abstract class BoxScrollView extends ScrollView { /// ``` /// {@end-tool} /// -/// {@tool sample} +/// {@tool snippet} /// This example continues to build from our the previous ones, creating a /// similar list using [ListView.separated]. Here, a [Divider] is used as a /// separator. @@ -786,7 +786,7 @@ abstract class BoxScrollView extends ScrollView { /// [SliverGrid] or [SliverAppBar], can be put in the [CustomScrollView.slivers] /// list. /// -/// {@tool sample} +/// {@tool snippet} /// /// Here are two brief snippets showing a [ListView] and its equivalent using /// [CustomScrollView]: @@ -804,7 +804,7 @@ abstract class BoxScrollView extends ScrollView { /// ) /// ``` /// {@end-tool} -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// CustomScrollView( @@ -989,7 +989,7 @@ class ListView extends BoxScrollView { /// advance, or all at once when the [ListView] itself is created, it is more /// efficient to use [new ListView]. /// - /// {@tool sample} + /// {@tool snippet} /// /// This example shows how to create [ListView] whose [ListTile] list items /// are separated by [Divider]s. @@ -1077,7 +1077,7 @@ class ListView extends BoxScrollView { /// For example, a custom child model can control the algorithm used to /// estimate the size of children that are not actually visible. /// - /// {@tool sample} + /// {@tool snippet} /// /// This [ListView] uses a custom [SliverChildBuilderDelegate] to support child /// reordering. @@ -1290,7 +1290,7 @@ class ListView extends BoxScrollView { /// [SliverList] or [SliverAppBar], can be put in the [CustomScrollView.slivers] /// list. /// -/// {@tool sample} +/// {@tool snippet} /// This example demonstrates how to create a [GridView] with two columns. The /// children are spaced apart using the [crossAxisSpacing] and [mainAxisSpacing] /// properties. @@ -1340,7 +1340,7 @@ class ListView extends BoxScrollView { /// ``` /// {@end-tool} /// -/// {@tool sample} +/// {@tool snippet} /// This example shows how to create the same grid as the previous example /// using a [CustomScrollView] and a [SliverGrid]. /// diff --git a/packages/flutter/lib/src/widgets/single_child_scroll_view.dart b/packages/flutter/lib/src/widgets/single_child_scroll_view.dart index 5eaf425ae7..7a9a4b2b3f 100644 --- a/packages/flutter/lib/src/widgets/single_child_scroll_view.dart +++ b/packages/flutter/lib/src/widgets/single_child_scroll_view.dart @@ -80,7 +80,7 @@ import 'scrollable.dart'; /// with some remaining space to allocate as specified by its /// [Column.mainAxisAlignment] argument. /// -/// {@tool snippet --template=stateless_widget} +/// {@tool sample --template=stateless_widget} /// In this example, the children are spaced out equally, unless there's no more /// room, in which case they stack vertically and scroll. /// @@ -149,7 +149,7 @@ import 'scrollable.dart'; /// so that the intrinsic sizing algorithm can short-circuit the computation when it /// reaches those parts of the subtree. /// -/// {@tool snippet --template=stateless_widget} +/// {@tool sample --template=stateless_widget} /// In this example, the column becomes either as big as viewport, or as big as /// the contents, whichever is biggest. /// diff --git a/packages/flutter/lib/src/widgets/sliver.dart b/packages/flutter/lib/src/widgets/sliver.dart index 70fa5d9cf9..5fedaf5ed4 100644 --- a/packages/flutter/lib/src/widgets/sliver.dart +++ b/packages/flutter/lib/src/widgets/sliver.dart @@ -237,7 +237,7 @@ typedef ChildIndexGetter = int Function(Key key); /// delegates where the first has 10 children contributing semantics, then the /// second delegate should offset its children by 10. /// -/// {@tool sample} +/// {@tool snippet} /// /// This sample code shows how to use `semanticIndexOffset` to handle multiple /// delegates in a single scroll view. @@ -276,7 +276,7 @@ typedef ChildIndexGetter = int Function(Key key); /// providing a `semanticIndexCallback` which returns null for separators /// indexes and rounds the non-separator indexes down by half. /// -/// {@tool sample} +/// {@tool snippet} /// /// This sample code shows how to use `semanticIndexCallback` to handle /// annotating a subset of child nodes with a semantic index. There is @@ -832,7 +832,7 @@ class SliverList extends SliverMultiBoxAdaptorWidget { /// [SliverFixedExtentList] does not need to perform layout on its children to /// obtain their extent in the main axis. /// -/// {@tool sample} +/// {@tool snippet} /// /// This example, which would be inserted into a [CustomScrollView.slivers] /// list, shows an infinite number of items in varying shades of blue: @@ -899,7 +899,7 @@ class SliverFixedExtentList extends SliverMultiBoxAdaptorWidget { /// /// {@youtube 560 315 https://www.youtube.com/watch?v=ORiTTaVY6mM} /// -/// {@tool sample} +/// {@tool snippet} /// /// This example, which would be inserted into a [CustomScrollView.slivers] /// list, shows twenty boxes in a pretty teal grid: @@ -1325,7 +1325,7 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render /// For the value 1.0, the sliver child is painted immediately without an /// intermediate buffer. /// -/// {@tool sample} +/// {@tool snippet} /// /// This example shows a [SliverList] when the `_visible` member field is true, /// and hides it when it is false: diff --git a/packages/flutter/lib/src/widgets/sliver_fill.dart b/packages/flutter/lib/src/widgets/sliver_fill.dart index 27d3c965af..be9c59b7e7 100644 --- a/packages/flutter/lib/src/widgets/sliver_fill.dart +++ b/packages/flutter/lib/src/widgets/sliver_fill.dart @@ -183,7 +183,7 @@ class _RenderSliverFractionalPadding extends RenderSliverEdgeInsetsPadding { /// /// {@animation 250 500 https://flutter.github.io/assets-for-api-docs/assets/widgets/sliver_fill_remaining_sizes_child.mp4} /// -/// {@tool snippet --template=stateless_widget_scaffold} +/// {@tool sample --template=stateless_widget_scaffold} /// /// In this sample the [SliverFillRemaining] sizes its [child] to fill the /// remaining extent of the viewport in both axes. The icon is centered in the @@ -221,7 +221,7 @@ class _RenderSliverFractionalPadding extends RenderSliverEdgeInsetsPadding { /// /// {@animation 250 500 https://flutter.github.io/assets-for-api-docs/assets/widgets/sliver_fill_remaining_defers_to_child.mp4} /// -/// {@tool snippet --template=stateless_widget_scaffold} +/// {@tool sample --template=stateless_widget_scaffold} /// /// In this sample the [SliverFillRemaining] defers to the size of its [child] /// because the child's extent exceeds that of the remaining extent of the @@ -265,7 +265,7 @@ class _RenderSliverFractionalPadding extends RenderSliverEdgeInsetsPadding { /// /// {@animation 250 500 https://flutter.github.io/assets-for-api-docs/assets/widgets/sliver_fill_remaining_scrolled_beyond.mp4} /// -/// {@tool snippet --template=stateless_widget_scaffold} +/// {@tool sample --template=stateless_widget_scaffold} /// /// In this sample the [SliverFillRemaining] defers to the size of its [child] /// because the [precedingScrollExtent] of the [SliverConstraints] has gone @@ -314,7 +314,7 @@ class _RenderSliverFractionalPadding extends RenderSliverEdgeInsetsPadding { /// /// {@animation 250 500 https://flutter.github.io/assets-for-api-docs/assets/widgets/sliver_fill_remaining_fill_overscroll.mp4} /// -/// {@tool snippet --template=stateless_widget_scaffold} +/// {@tool sample --template=stateless_widget_scaffold} /// /// In this sample the [SliverFillRemaining]'s child stretches to fill the /// overscroll area when [fillOverscroll] is true. This sample also features a diff --git a/packages/flutter/lib/src/widgets/spacer.dart b/packages/flutter/lib/src/widgets/spacer.dart index 65ec084457..f6b8ad80ec 100644 --- a/packages/flutter/lib/src/widgets/spacer.dart +++ b/packages/flutter/lib/src/widgets/spacer.dart @@ -17,7 +17,7 @@ import 'framework.dart'; /// [Spacer] has taken up all of the additional space, therefore there is none /// left to redistribute. /// -/// {@tool sample} +/// {@tool snippet} /// /// ```dart /// Row( diff --git a/packages/flutter/lib/src/widgets/text.dart b/packages/flutter/lib/src/widgets/text.dart index f97de8657b..ca2c3cec86 100644 --- a/packages/flutter/lib/src/widgets/text.dart +++ b/packages/flutter/lib/src/widgets/text.dart @@ -204,7 +204,7 @@ class DefaultTextStyle extends InheritedTheme { /// behavior is useful, for example, to make the text bold while using the /// default font family and size. /// -/// {@tool sample} +/// {@tool snippet} /// /// This example shows how to display text using the [Text] widget with the /// [overflow] set to [TextOverflow.ellipsis]. @@ -228,7 +228,7 @@ class DefaultTextStyle extends InheritedTheme { /// that follows displays "Hello beautiful world" with different styles /// for each word. /// -/// {@tool sample} +/// {@tool snippet} /// /// ![The word "Hello" is shown with the default text styles. The word "beautiful" is italicized. The word "world" is bold.](https://flutter.github.io/assets-for-api-docs/assets/widgets/text_rich.png) /// diff --git a/packages/flutter/lib/src/widgets/transitions.dart b/packages/flutter/lib/src/widgets/transitions.dart index 524a4298fd..cac6012278 100644 --- a/packages/flutter/lib/src/widgets/transitions.dart +++ b/packages/flutter/lib/src/widgets/transitions.dart @@ -23,7 +23,7 @@ export 'package:flutter/rendering.dart' show RelativeRect; /// [AnimatedWidget] is most useful for widgets that are otherwise stateless. To /// use [AnimatedWidget], simply subclass it and implement the build function. /// -///{@tool sample} +///{@tool snippet} /// /// This code defines a widget called `Spinner` that spins a green square /// continually. It is built with an [AnimatedWidget]. @@ -194,7 +194,7 @@ class _AnimatedState extends State { /// animated by a [CurvedAnimation] set to [Curves.elasticIn]: /// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/slide_transition.mp4} /// -/// {@tool snippet --template=stateful_widget_scaffold_center_freeform_state} +/// {@tool sample --template=stateful_widget_scaffold_center_freeform_state} /// The following code implements the [SlideTransition] as seen in the video /// above: /// @@ -583,7 +583,7 @@ class FadeTransition extends SingleChildRenderObjectWidget { /// Animates the opacity of a sliver widget. /// -/// {@tool snippet --template=stateful_widget_scaffold_center_freeform_state} +/// {@tool sample --template=stateful_widget_scaffold_center_freeform_state} /// Creates a [CustomScrollView] with a [SliverFixedExtentList] that uses a /// [SliverFadeTransition] to fade the list in and out. /// @@ -1035,7 +1035,7 @@ class DefaultTextStyleTransition extends AnimatedWidget { /// Using this pre-built child is entirely optional, but can improve /// performance significantly in some cases and is therefore a good practice. /// -/// {@tool sample} +/// {@tool snippet} /// /// This code defines a widget called `Spinner` that spins a green square /// continually. It is built with an [AnimatedBuilder] and makes use of the diff --git a/packages/flutter/lib/src/widgets/tween_animation_builder.dart b/packages/flutter/lib/src/widgets/tween_animation_builder.dart index d67597675c..c26cc15b93 100644 --- a/packages/flutter/lib/src/widgets/tween_animation_builder.dart +++ b/packages/flutter/lib/src/widgets/tween_animation_builder.dart @@ -59,7 +59,7 @@ import 'value_listenable_builder.dart'; /// /// ## Example Code /// -/// {@tool snippet --template=stateful_widget_scaffold_center} +/// {@tool sample --template=stateful_widget_scaffold_center} /// This example shows an [IconButton] that "zooms" in when the widget first /// builds (its size smoothly increases from 0 to 24) and whenever the button /// is pressed, it smoothly changes its size to the new target value of either diff --git a/packages/flutter/lib/src/widgets/value_listenable_builder.dart b/packages/flutter/lib/src/widgets/value_listenable_builder.dart index 08e9ced1f4..b82b5a3c7f 100644 --- a/packages/flutter/lib/src/widgets/value_listenable_builder.dart +++ b/packages/flutter/lib/src/widgets/value_listenable_builder.dart @@ -40,7 +40,7 @@ typedef ValueWidgetBuilder = Widget Function(BuildContext context, T value, W /// Using this pre-built child is entirely optional, but can improve /// performance significantly in some cases and is therefore a good practice. /// -/// {@tool sample} +/// {@tool snippet} /// /// This sample shows how you could use a [ValueListenableBuilder] instead of /// setting state on the whole [Scaffold] in the default `flutter create` app. diff --git a/packages/flutter/lib/src/widgets/widget_span.dart b/packages/flutter/lib/src/widgets/widget_span.dart index 65a283ef8f..ad3407611e 100644 --- a/packages/flutter/lib/src/widgets/widget_span.dart +++ b/packages/flutter/lib/src/widgets/widget_span.dart @@ -22,7 +22,7 @@ import 'framework.dart'; /// To properly layout and paint the [child] widget, [WidgetSpan] should be /// passed into a [Text.rich] widget. /// -/// {@tool sample} +/// {@tool snippet} /// /// A card with `Hello World!` embedded inline within a TextSpan tree. /// diff --git a/packages/flutter_test/lib/src/matchers.dart b/packages/flutter_test/lib/src/matchers.dart index 529774ba83..ec459395df 100644 --- a/packages/flutter_test/lib/src/matchers.dart +++ b/packages/flutter_test/lib/src/matchers.dart @@ -327,7 +327,7 @@ Matcher coversSameAreaAs(Path expectedPath, { @required Rect areaToCompare, int /// The master golden image files that are tested against can be created or /// updated by running `flutter test --update-goldens` on the test. /// -/// {@tool sample} +/// {@tool snippet} /// Sample invocations of [matchesGoldenFile]. /// /// ```dart diff --git a/packages/flutter_test/lib/src/widget_tester.dart b/packages/flutter_test/lib/src/widget_tester.dart index afac83bdb8..56fbf49fbb 100644 --- a/packages/flutter_test/lib/src/widget_tester.dart +++ b/packages/flutter_test/lib/src/widget_tester.dart @@ -419,7 +419,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker /// [expectLater] call to test that a widget throws an exception. Instead, use /// [TestWidgetsFlutterBinding.takeException]. /// - /// {@tool sample} + /// {@tool snippet} /// ```dart /// testWidgets('MyWidget asserts invalid bounds', (WidgetTester tester) async { /// await tester.pumpWidget(MyWidget(-1));