Prepare to migrate API doc samples and snippets to null safety (#72040)

This commit is contained in:
Michael Goderbauer 2020-12-11 13:39:36 -08:00 committed by GitHub
parent 74298a76e7
commit ff05ca2503
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
179 changed files with 1280 additions and 264 deletions

View File

@ -8,9 +8,11 @@
// bin/cache/dart-sdk/bin/dart dev/bots/analyze-sample-code.dart
import 'dart:io';
import 'dart:isolate';
import 'package:args/args.dart';
import 'package:path/path.dart' as path;
import 'package:watcher/watcher.dart';
final String _flutterRoot = path.dirname(path.dirname(path.dirname(path.fromUri(Platform.script))));
final String _defaultFlutterPackage = path.join(_flutterRoot, 'packages', 'flutter', 'lib');
@ -37,6 +39,11 @@ void main(List<String> arguments) {
negatable: false,
help: 'Print help for this command.',
);
argParser.addOption(
'interactive',
abbr: 'i',
help: 'Analyzes the sample code in the specified file interactivly.',
);
final ArgResults parsedArguments = argParser.parse(arguments);
@ -69,15 +76,20 @@ void main(List<String> arguments) {
}
tempDirectory.createSync();
}
try {
exitCode = SampleChecker(
flutterPackage,
tempDirectory: tempDirectory,
verbose: parsedArguments['verbose'] as bool,
).checkSamples();
} on SampleCheckerException catch (e) {
stderr.write(e);
exit(1);
if (parsedArguments['interactive'] != null) {
_runInteractive(tempDirectory, flutterPackage, parsedArguments['interactive'] as String);
} else {
try {
exitCode = SampleChecker(
flutterPackage,
tempDirectory: tempDirectory,
verbose: parsedArguments['verbose'] as bool,
).checkSamples();
} on SampleCheckerException catch (e) {
stderr.write(e);
exit(1);
}
}
}
@ -141,6 +153,9 @@ class SampleChecker {
/// A RegExp that matches a Dart constructor.
static final RegExp _constructorRegExp = RegExp(r'(const\s+)?_*[A-Z][a-zA-Z0-9<>._]*\(');
/// A RegExp that matches a dart version specification in an example preamble.
static final RegExp _dartVersionRegExp = RegExp(r'\/\/ \/\/ @dart = ([0-9]+\.[0-9]+)');
/// Whether or not to print verbose output.
final bool verbose;
@ -186,8 +201,8 @@ class SampleChecker {
/// Computes the headers needed for each sample file.
List<Line> get headers {
return _headers ??= <String>[
'// @dart = 2.9',
'// generated code',
'// ignore_for_file: unused_import',
"import 'dart:async';",
"import 'dart:convert';",
"import 'dart:math' as math;",
@ -211,7 +226,7 @@ class SampleChecker {
try {
final Map<String, Section> sections = <String, Section>{};
final Map<String, Sample> snippets = <String, Sample>{};
_extractSamples(sections, snippets);
_extractSamples(_listDartFiles(_flutterPackage, recursive: true), sectionMap: sections, sampleMap: snippets);
errors = _analyze(_tempDirectory, sections, snippets);
} finally {
if (errors.isNotEmpty) {
@ -305,13 +320,13 @@ class SampleChecker {
return outputFile;
}
/// Extracts the samples from the Dart files in [_flutterPackage], writes them
/// Extracts the samples from the Dart files in [files], writes them
/// to disk, and adds them to the appropriate [sectionMap] or [sampleMap].
void _extractSamples(Map<String, Section> sectionMap, Map<String, Sample> sampleMap) {
void _extractSamples(List<File> files, {Map<String, Section> sectionMap, Map<String, Sample> sampleMap, bool silent = false}) {
final List<Section> sections = <Section>[];
final List<Sample> samples = <Sample>[];
for (final File file in _listDartFiles(_flutterPackage, recursive: true)) {
for (final File file in files) {
final String relativeFilePath = path.relative(file.path, from: _flutterPackage.path);
final List<String> sampleLines = file.readAsLinesSync();
final List<Section> preambleSections = <Section>[];
@ -323,6 +338,7 @@ class SampleChecker {
bool inSnippet = false;
// Whether or not we're in a '```dart' segment.
bool inDart = false;
String dartVersionOverride;
int lineNumber = 0;
final List<String> block = <String>[];
List<String> snippetArgs = <String>[];
@ -353,10 +369,16 @@ class SampleChecker {
} else if (inPreamble) {
if (line.isEmpty) {
inPreamble = false;
preambleSections.add(_processBlock(startLine, block));
// If there's only a dartVersionOverride in the preamble, don't add
// it as a section. The dartVersionOverride was processed below.
if (dartVersionOverride == null || block.isNotEmpty) {
preambleSections.add(_processBlock(startLine, block));
}
block.clear();
} else if (!line.startsWith('// ')) {
throw SampleCheckerException('Unexpected content in sample code preamble.', file: relativeFilePath, line: lineNumber);
} else if (_dartVersionRegExp.hasMatch(line)) {
dartVersionOverride = line.substring(3);
} else {
block.add(line.substring(3));
}
@ -371,11 +393,8 @@ class SampleChecker {
if (_codeBlockEndRegex.hasMatch(trimmedLine)) {
inDart = false;
final Section processed = _processBlock(startLine, block);
if (preambleSections.isEmpty) {
sections.add(processed);
} else {
sections.add(Section.combine(preambleSections..add(processed)));
}
final Section combinedSection = preambleSections.isEmpty ? processed : Section.combine(preambleSections..add(processed));
sections.add(combinedSection.copyWith(dartVersionOverride: dartVersionOverride));
block.clear();
} else if (trimmedLine == _dartDocPrefix) {
block.add('');
@ -434,14 +453,19 @@ class SampleChecker {
}
}
}
print('Found ${sections.length} sample code sections.');
if (!silent)
print('Found ${sections.length} sample code sections.');
for (final Section section in sections) {
sectionMap[_writeSection(section).path] = section;
final String path = _writeSection(section).path;
if (sectionMap != null)
sectionMap[path] = section;
}
for (final Sample sample in samples) {
final File snippetFile = _writeSample(sample);
sample.contents = snippetFile.readAsLinesSync();
sampleMap[snippetFile.absolute.path] = sample;
if (sampleMap != null) {
sample.contents = snippetFile.readAsLinesSync();
sampleMap[snippetFile.absolute.path] = sample;
}
}
}
@ -492,7 +516,7 @@ class SampleChecker {
pubSpec.writeAsStringSync('''
name: analyze_sample_code
environment:
sdk: '>=2.10.0 <3.0.0'
sdk: ">=2.12.0-0 <3.0.0"
dependencies:
flutter:
sdk: flutter
@ -512,6 +536,7 @@ linter:
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<Line> mainContents = <Line>[
if (section.dartVersionOverride != null) Line(section.dartVersionOverride) else const Line(''),
...headers,
const Line(''),
Line('// From: ${section.start.filename}:${section.start.line}'),
@ -582,7 +607,7 @@ linter:
caseSensitive: false,
);
bool unknownAnalyzerErrors = false;
final int headerLength = headers.length + 2;
final int headerLength = headers.length + 3;
for (final String error in errors) {
final Match parts = errorPattern.matchAsPrefix(error);
if (parts != null) {
@ -803,7 +828,7 @@ class Line {
/// A class to represent a section of sample code, marked by "{@tool snippet}...{@end-tool}".
class Section {
const Section(this.code);
const Section(this.code, {this.dartVersionOverride});
factory Section.combine(List<Section> sections) {
final List<Line> code = sections
.expand((Section section) => section.code)
@ -846,6 +871,11 @@ class Section {
}
Line get start => code.firstWhere((Line line) => line.filename != null);
final List<Line> code;
final String dartVersionOverride;
Section copyWith({String dartVersionOverride}) {
return Section(code, dartVersionOverride: dartVersionOverride);
}
}
/// A class to represent a sample in the dartdoc comments, marked by
@ -908,3 +938,46 @@ class AnalysisError {
}
}
}
Future<void> _runInteractive(Directory tempDir, Directory flutterPackage, String filePath) async {
print('Starting up in interactive mode...');
filePath = path.isAbsolute(filePath) ? filePath : path.join(path.current, filePath);
final File file = File(filePath);
if (!file.existsSync()) {
throw 'Path ${file.absolute.path} does not exist.';
}
if (!path.isWithin(_flutterRoot, file.absolute.path)) {
throw 'Path ${file.absolute.path} is not within the flutter root: $_flutterRoot';
}
if (tempDir == null) {
tempDir = Directory.systemTemp.createTempSync('flutter_analyze_sample_code.');
ProcessSignal.sigint.watch().listen((_) {
print('Deleting temp files...');
tempDir.deleteSync(recursive: true);
exit(0);
});
print('Using temp dir ${tempDir.path}');
}
final SampleChecker checker = SampleChecker(flutterPackage, tempDirectory: tempDir)
.._createConfigurationFiles(tempDir)
.._extractSamples(<File>[file], silent: true);
await Isolate.spawn(_watcher, <dynamic>[checker, file]);
await Process.start(
_flutter,
<String>['--no-wrap', 'analyze', '--no-preamble', '--no-congratulate', '--watch', '.'],
workingDirectory: tempDir.absolute.path,
mode: ProcessStartMode.inheritStdio
);
}
void _watcher(List<dynamic> args) {
final File file = args.last as File;
final SampleChecker checker = args.first as SampleChecker;
Watcher(file.absolute.path).events.listen((_) {
checker._extractSamples(<File>[file], silent: true);
});
}

View File

@ -6,6 +6,7 @@
// precise contents (including especially the comments) of this file.
// Examples can assume:
// // @dart = 2.9
// bool _visible = true;
// class _Text extends Text {
// const _Text(String text) : super(text);
@ -34,7 +35,7 @@
/// ```
/// {@end-tool}
///
/// {@tool dartpad --template=stateless_widget_material}
/// {@tool dartpad --template=stateless_widget_material_no_null_safety}
/// Bla blabla blabla some [Text] when the `_blabla` blabla blabla is true, and
/// blabla it when it is blabla:
///

View File

@ -0,0 +1,134 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file is used by ../analyze-sample-code_test.dart, which depends on the
// precise contents (including especially the comments) of this file.
// Examples can assume:
// bool _visible = true;
// class _Text extends Text {
// const _Text(String text) : super(text);
// const _Text.__(String text) : super(text);
// }
/// A blabla that blabla its blabla blabla blabla.
///
/// Bla blabla blabla its blabla into an blabla blabla and then blabla the
/// blabla back into the blabla blabla blabla.
///
/// Bla blabla of blabla blabla than 0.0 and 1.0, this blabla is blabla blabla
/// blabla it blabla pirates blabla the blabla into of blabla blabla. Bla the
/// blabla 0.0, the penzance blabla is blabla not blabla at all. Bla the blabla
/// 1.0, the blabla is blabla blabla blabla an blabla blabla.
///
/// {@tool snippet}
/// Bla blabla blabla some [Text] when the `_blabla` blabla blabla is true, and
/// blabla it when it is blabla:
///
/// ```dart
/// new Opacity(
/// opacity: _visible ? 1.0 : 0.0,
/// child: const Text('Poor wandering ones!'),
/// )
/// ```
/// {@end-tool}
///
/// {@tool dartpad --template=stateless_widget_material}
/// Bla blabla blabla some [Text] when the `_blabla` blabla blabla is true, and
/// blabla it when it is blabla:
///
/// ```dart preamble
/// bool _visible = true;
/// final GlobalKey globalKey = GlobalKey();
/// ```
///
/// ```dart
/// Widget build(BuildContext context) {
/// return Opacity(
/// key: globalKey,
/// opacity: _visible ? 1.0 : 0.0,
/// child: const Text('Poor wandering ones!'),
/// );
/// }
/// ```
/// {@end-tool}
///
/// {@tool snippet}
/// Bla blabla blabla some [Text] when the `_blabla` blabla blabla is true, and
/// blabla finale blabla:
///
/// ```dart
/// new Opacity(
/// opacity: _visible ? 1.0 : 0.0,
/// child: const Text('Poor wandering ones!'),
/// )
/// ```
/// {@end-tool}
///
/// {@tool snippet}
/// regular const constructor
///
/// ```dart
/// const Text('Poor wandering ones!')
/// ```
/// {@end-tool}
///
/// {@tool snippet}
/// const private constructor
/// ```dart
/// const _Text('Poor wandering ones!')
/// ```
/// {@end-tool}
///
/// {@tool snippet}
/// yet another const private constructor
/// ```dart
/// const _Text.__('Poor wandering ones!')
/// ```
/// {@end-tool}
///
/// {@tool snippet}
/// const variable
///
/// ```dart
/// const text0 = Text('Poor wandering ones!');
/// ```
/// {@end-tool}
///
/// {@tool snippet}
/// more const variables
///
/// ```dart
/// const text1 = _Text('Poor wandering ones!');
/// ```
/// {@end-tool}
///
/// {@tool snippet}
/// Snippet with null-safe syntax
///
/// ```dart
/// final String? bar = 'Hello';
/// final int foo = null;
/// ```
/// {@end-tool}
///
/// {@tool dartpad --template=stateless_widget_material}
/// Dartpad with null-safe syntax
///
/// ```dart preamble
/// bool? _visible = true;
/// final GlobalKey globalKey = GlobalKey();
/// ```
///
/// ```dart
/// Widget build(BuildContext context) {
/// final String title;
/// return Opacity(
/// key: globalKey,
/// opacity: _visible! ? 1.0 : 0.0,
/// child: Text(title),
/// );
/// }
/// ```
/// {@end-tool}

View File

@ -17,9 +17,9 @@ void main() {
..removeWhere((String line) => line.startsWith('Analyzer output:') || line.startsWith('Building flutter tool...'));
expect(process.exitCode, isNot(equals(0)));
expect(stderrLines, <String>[
'known_broken_documentation.dart:30:9: new Opacity(',
'known_broken_documentation.dart:31:9: new Opacity(',
'>>> Unnecessary new keyword (unnecessary_new)',
'known_broken_documentation.dart:62:9: new Opacity(',
'known_broken_documentation.dart:63:9: new Opacity(',
'>>> Unnecessary new keyword (unnecessary_new)',
'',
'Found 1 sample code errors.',
@ -27,7 +27,36 @@ void main() {
]);
expect(stdoutLines, <String>[
'Found 7 sample code sections.',
'Starting analysis of code samples.',
'Starting analysis of code samples.',
'',
]);
}, skip: Platform.isWindows);
test('analyze-sample-code null-safe', () {
final ProcessResult process = Process.runSync(
'../../bin/cache/dart-sdk/bin/dart',
<String>['analyze-sample-code.dart', 'test/analyze-sample-code-test-null-safe-input'],
);
final List<String> stdoutLines = process.stdout.toString().split('\n');
final List<String> stderrLines = process.stderr.toString().split('\n')
..removeWhere((String line) => line.startsWith('Analyzer output:') || line.startsWith('Building flutter tool...'));
expect(process.exitCode, isNot(equals(0)));
expect(stderrLines, <String>[
'In sample starting at known_broken_documentation.dart:117: child: Text(title),',
'>>> The final variable \'title\' can\'t be read because it is potentially unassigned at this point (read_potentially_unassigned_final)',
'known_broken_documentation.dart:30:9: new Opacity(',
'>>> Unnecessary new keyword (unnecessary_new)',
'known_broken_documentation.dart:62:9: new Opacity(',
'>>> Unnecessary new keyword (unnecessary_new)',
'known_broken_documentation.dart:112:25: final int foo = null;',
'>>> A value of type \'Null\' can\'t be assigned to a variable of type \'int\' (invalid_assignment)',
'',
'Found 2 sample code errors.',
''
]);
expect(stdoutLines, <String>[
'Found 8 sample code sections.',
'Starting analysis of code samples.',
'',
]);
}, skip: Platform.isWindows);

View File

@ -23,7 +23,7 @@
<div class="snippet-container">
<div class="snippet" id="longSnippet{{serial}}">
{{description}}
<iframe class="snippet-dartpad" src="https://dartpad.dev/embed-flutter.html?split=60&run=true&sample_id={{id}}&sample_channel={{channel}}"></iframe>
<iframe class="snippet-dartpad" src="https://dartpad.dev/embed-flutter.html?split=60&run=true&null_safety=true&sample_id={{id}}&sample_channel={{channel}}"></iframe>
<div class="snippet-description">To create a local project with this code sample, run:<br/>
<span class="snippet-create-command">flutter create --sample={{id}} mysample</span>
</div>

View File

@ -1,5 +1,4 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}

View File

@ -0,0 +1,12 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
{{code-imports}}
{{code-main}}
{{code-preamble}}
{{code}}

View File

@ -1,5 +1,4 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
@ -25,7 +24,7 @@ class MyApp extends StatelessWidget {
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
MyStatefulWidget({Key? key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();

View File

@ -1,5 +1,4 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
@ -26,7 +25,7 @@ class MyApp extends StatelessWidget {
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
MyStatefulWidget({Key? key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();

View File

@ -0,0 +1,38 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
import 'package:flutter/cupertino.dart';
{{code-imports}}
void main() => runApp(new MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return CupertinoApp(
title: _title,
home: MyStatefulWidget(),
);
}
}
{{code-preamble}}
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
/// This is the private State class that goes with MyStatefulWidget.
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
{{code}}
}

View File

@ -1,5 +1,4 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
@ -29,7 +28,7 @@ class MyApp extends StatelessWidget {
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
MyStatefulWidget({Key? key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();

View File

@ -0,0 +1,41 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
import 'package:flutter/cupertino.dart';
{{code-imports}}
void main() => runApp(new MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return CupertinoApp(
title: _title,
home: CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(middle: const Text(_title)),
child: MyStatefulWidget(),
),
);
}
}
{{code-preamble}}
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
/// This is the private State class that goes with MyStatefulWidget.
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
{{code}}
}

View File

@ -1,5 +1,4 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
@ -26,7 +25,7 @@ class MyApp extends StatelessWidget {
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
MyStatefulWidget({Key? key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();

View File

@ -0,0 +1,39 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
import 'package:flutter/cupertino.dart';
{{code-imports}}
void main() => runApp(new MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return CupertinoApp(
title: _title,
home: MyStatefulWidget(),
);
}
}
{{code-preamble}}
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
/// This is the private State class that goes with MyStatefulWidget.
/// AnimationControllers can be created with `vsync: this` because of TickerProviderStateMixin.
class _MyStatefulWidgetState extends State<MyStatefulWidget> with TickerProviderStateMixin {
{{code}}
}

View File

@ -1,5 +1,4 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
@ -26,7 +25,7 @@ class MyApp extends StatelessWidget {
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
MyStatefulWidget({Key? key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();

View File

@ -0,0 +1,38 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
import 'package:flutter/material.dart';
{{code-imports}}
void main() => runApp(new MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: MyStatefulWidget(),
);
}
}
{{code-preamble}}
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
/// This is the private State class that goes with MyStatefulWidget.
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
{{code}}
}

View File

@ -1,5 +1,4 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
@ -26,7 +25,7 @@ class MyApp extends StatelessWidget {
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
MyStatefulWidget({Key? key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();

View File

@ -0,0 +1,39 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
import 'package:flutter/material.dart';
{{code-imports}}
void main() => runApp(new MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: MyStatefulWidget(),
);
}
}
{{code-preamble}}
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
/// This is the private State class that goes with MyStatefulWidget.
/// AnimationControllers can be created with `vsync: this` because of TickerProviderStateMixin.
class _MyStatefulWidgetState extends State<MyStatefulWidget> with TickerProviderStateMixin {
{{code}}
}

View File

@ -0,0 +1,37 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
import 'package:flutter/widgets.dart';
{{code-imports}}
void main() => runApp(new MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return WidgetsApp(
title: 'Flutter Code Sample',
home: MyStatefulWidget(),
color: const Color(0xffffffff),
);
}
}
{{code-preamble}}
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
/// This is the private State class that goes with MyStatefulWidget.
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
{{code}}
}

View File

@ -1,5 +1,4 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
@ -27,9 +26,9 @@ class MyApp extends StatelessWidget {
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key, this.restorationId}) : super(key: key);
MyStatefulWidget({Key? key, this.restorationId}) : super(key: key);
final String restorationId;
final String? restorationId;
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
@ -41,7 +40,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> with RestorationMix
// In this example, the restoration ID for the mixin is passed in through
// the [StatefulWidget]'s constructor.
@override
String get restorationId => widget.restorationId;
String? get restorationId => widget.restorationId;
{{code}}
}

View File

@ -0,0 +1,47 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
import 'package:flutter/material.dart';
{{code-imports}}
void main() => runApp(new MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return WidgetsApp(
title: 'Flutter Code Sample',
home: Center(
child: MyStatefulWidget(restorationId: 'main'),
),
color: const Color(0xffffffff),
);
}
}
{{code-preamble}}
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key, this.restorationId}) : super(key: key);
final String restorationId;
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
/// This is the private State class that goes with MyStatefulWidget.
/// RestorationProperty objects can be used because of RestorationMixin.
class _MyStatefulWidgetState extends State<MyStatefulWidget> with RestorationMixin {
// In this example, the restoration ID for the mixin is passed in through
// the [StatefulWidget]'s constructor.
@override
String get restorationId => widget.restorationId;
{{code}}
}

View File

@ -1,5 +1,4 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
@ -29,7 +28,7 @@ class MyApp extends StatelessWidget {
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
MyStatefulWidget({Key? key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();

View File

@ -1,5 +1,4 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
@ -31,7 +30,7 @@ class MyApp extends StatelessWidget {
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
MyStatefulWidget({Key? key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();

View File

@ -1,5 +1,4 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
@ -31,7 +30,7 @@ class MyApp extends StatelessWidget {
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
MyStatefulWidget({Key? key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();

View File

@ -0,0 +1,41 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
import 'package:flutter/material.dart';
{{code-imports}}
void main() => runApp(new MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: Center(
child: MyStatefulWidget(),
),
),
);
}
}
{{code-preamble}}
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
/// This is the private State class that goes with MyStatefulWidget.
{{code}}

View File

@ -0,0 +1,43 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
import 'package:flutter/material.dart';
{{code-imports}}
void main() => runApp(new MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: Center(
child: MyStatefulWidget(),
),
),
);
}
}
{{code-preamble}}
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
/// This is the private State class that goes with MyStatefulWidget.
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
{{code}}
}

View File

@ -0,0 +1,41 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
import 'package:flutter/material.dart';
{{code-imports}}
void main() => runApp(new MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: MyStatefulWidget(),
),
);
}
}
{{code-preamble}}
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
/// This is the private State class that goes with MyStatefulWidget.
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
{{code}}
}

View File

@ -1,5 +1,4 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
@ -25,7 +24,7 @@ class MyApp extends StatelessWidget {
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
MyStatefulWidget({Key? key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();

View File

@ -0,0 +1,38 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
import 'package:flutter/widgets.dart';
{{code-imports}}
void main() => runApp(new MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return WidgetsApp(
title: 'Flutter Code Sample',
home: MyStatefulWidget(),
color: const Color(0xffffffff),
);
}
}
{{code-preamble}}
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
/// This is the private State class that goes with MyStatefulWidget.
/// AnimationControllers can be created with `vsync: this` because of TickerProviderStateMixin.
class _MyStatefulWidgetState extends State<MyStatefulWidget> with TickerProviderStateMixin {
{{code}}
}

View File

@ -1,5 +1,4 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
@ -27,7 +26,7 @@ class MyApp extends StatelessWidget {
/// This is the stateless widget that the main application instantiates.
class MyStatelessWidget extends StatelessWidget {
MyStatelessWidget({Key key}) : super(key: key);
MyStatelessWidget({Key? key}) : super(key: key);
@override
{{code}}

View File

@ -1,5 +1,4 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
@ -27,7 +26,7 @@ class MyApp extends StatelessWidget {
/// This is the stateless widget that the main application instantiates.
class MyStatelessWidget extends StatelessWidget {
MyStatelessWidget({Key key}) : super(key: key);
MyStatelessWidget({Key? key}) : super(key: key);
@override
{{code}}

View File

@ -0,0 +1,34 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
import 'package:flutter/cupertino.dart';
{{code-imports}}
void main() => runApp(new MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return CupertinoApp(
title: _title,
home: MyStatelessWidget(),
);
}
}
{{code-preamble}}
/// This is the stateless widget that the main application instantiates.
class MyStatelessWidget extends StatelessWidget {
MyStatelessWidget({Key key}) : super(key: key);
@override
{{code}}
}

View File

@ -1,5 +1,4 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
@ -30,7 +29,7 @@ class MyApp extends StatelessWidget {
/// This is the stateless widget that the main application instantiates.
class MyStatelessWidget extends StatelessWidget {
MyStatelessWidget({Key key}) : super(key: key);
MyStatelessWidget({Key? key}) : super(key: key);
@override
{{code}}

View File

@ -0,0 +1,37 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
import 'package:flutter/cupertino.dart';
{{code-imports}}
void main() => runApp(new MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return CupertinoApp(
title: _title,
home: CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(middle: const Text(_title)),
body: MyStatelessWidget(),
),
);
}
}
{{code-preamble}}
/// This is the stateless widget that the main application instantiates.
class MyStatelessWidget extends StatelessWidget {
MyStatelessWidget({Key key}) : super(key: key);
@override
{{code}}
}

View File

@ -1,5 +1,4 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
@ -27,7 +26,7 @@ class MyApp extends StatelessWidget {
/// This is the stateless widget that the main application instantiates.
class MyStatelessWidget extends StatelessWidget {
MyStatelessWidget({Key key}) : super(key: key);
MyStatelessWidget({Key? key}) : super(key: key);
@override
{{code}}

View File

@ -0,0 +1,34 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
import 'package:flutter/material.dart';
{{code-imports}}
void main() => runApp(new MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: MyStatelessWidget(),
);
}
}
{{code-preamble}}
/// This is the stateless widget that the main application instantiates.
class MyStatelessWidget extends StatelessWidget {
MyStatelessWidget({Key key}) : super(key: key);
@override
{{code}}
}

View File

@ -0,0 +1,34 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
import 'package:flutter/widgets.dart';
{{code-imports}}
void main() => runApp(new MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return WidgetsApp(
title: 'Flutter Code Sample',
builder: (BuildContext context, Widget navigator) {
return MyStatelessWidget();
},
color: const Color(0xffffffff),
);
}
}
{{code-preamble}}
/// This is the stateless widget that the main application instantiates.
class MyStatelessWidget extends StatelessWidget {
MyStatelessWidget({Key key}) : super(key: key);
@override
{{code}}
}

View File

@ -1,5 +1,4 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
@ -30,7 +29,7 @@ class MyApp extends StatelessWidget {
/// This is the stateless widget that the main application instantiates.
class MyStatelessWidget extends StatelessWidget {
MyStatelessWidget({Key key}) : super(key: key);
MyStatelessWidget({Key? key}) : super(key: key);
@override
{{code}}

View File

@ -1,5 +1,4 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
@ -32,7 +31,7 @@ class MyApp extends StatelessWidget {
/// This is the stateless widget that the main application instantiates.
class MyStatelessWidget extends StatelessWidget {
MyStatelessWidget({Key key}) : super(key: key);
MyStatelessWidget({Key? key}) : super(key: key);
@override
{{code}}

View File

@ -0,0 +1,39 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
import 'package:flutter/material.dart';
{{code-imports}}
void main() => runApp(new MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: Center(
child: MyStatelessWidget(),
),
),
);
}
}
{{code-preamble}}
/// This is the stateless widget that the main application instantiates.
class MyStatelessWidget extends StatelessWidget {
MyStatelessWidget({Key key}) : super(key: key);
@override
{{code}}
}

View File

@ -0,0 +1,37 @@
/// Flutter code sample for {{element}}
// @dart = 2.9
{{description}}
import 'package:flutter/material.dart';
{{code-imports}}
void main() => runApp(new MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: MyStatelessWidget(),
),
);
}
}
{{code-preamble}}
/// This is the stateless widget that the main application instantiates.
class MyStatelessWidget extends StatelessWidget {
MyStatelessWidget({Key key}) : super(key: key);
@override
{{code}}
}

View File

@ -20,6 +20,7 @@ export 'package:meta/meta.dart' show
visibleForTesting;
// Examples can assume:
// // @dart = 2.9
// String _name;
// bool _first;
// bool _lights;

View File

@ -8,6 +8,7 @@ import 'package:flutter/foundation.dart';
import 'tween.dart';
// Examples can assume:
// // @dart = 2.9
// AnimationController _controller;
/// The status of an animation.

View File

@ -17,6 +17,7 @@ import 'listener_helpers.dart';
export 'package:flutter/scheduler.dart' show TickerFuture, TickerCanceled;
// Examples can assume:
// // @dart = 2.9
// AnimationController _controller, fadeAnimationController, sizeAnimationController;
// bool dismissed;
// void setState(VoidCallback fn) { }

View File

@ -12,6 +12,7 @@ import 'curves.dart';
import 'listener_helpers.dart';
// Examples can assume:
// // @dart = 2.9
// AnimationController controller;
class _AlwaysCompleteAnimation extends Animation<double> {

View File

@ -319,7 +319,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 dartpad --template=stateless_widget_material}
/// {@tool dartpad --template=stateless_widget_material_no_null_safety}
/// This example shows how to use a [Curve2D] to modify the position of a widget
/// so that it can follow an arbitrary path.
///

View File

@ -12,6 +12,7 @@ import 'animations.dart';
import 'curves.dart';
// Examples can assume:
// // @dart = 2.9
// Animation<Offset> _animation;
// AnimationController _controller;

View File

@ -7,6 +7,7 @@ import 'animation.dart';
import 'tween.dart';
// Examples can assume:
// // @dart = 2.9
// AnimationController myAnimationController;
/// Enables creating an [Animation] whose value is defined by a sequence of

View File

@ -13,6 +13,9 @@ import 'localizations.dart';
import 'route.dart';
import 'theme.dart';
// Examples can assume:
// // @dart = 2.9
/// An application that uses Cupertino design.
///
/// A convenience widget that wraps a number of widgets that are commonly

View File

@ -12,6 +12,7 @@ import 'interface_level.dart';
import 'theme.dart';
// Examples can assume:
// // @dart = 2.9
// Widget child;
// BuildContext context;

View File

@ -75,7 +75,7 @@ enum _ContextMenuLocation {
/// child's corners and allowing its aspect ratio to expand, similar to the
/// Photos app on iOS.
///
/// {@tool dartpad --template=stateless_widget_material}
/// {@tool dartpad --template=stateless_widget_material_no_null_safety}
///
/// This sample shows a very simple CupertinoContextMenu for an empty red
/// 100x100 Container. Simply long press on it to open.

View File

@ -8,6 +8,9 @@ import 'package:flutter/widgets.dart';
import 'colors.dart';
import 'theme.dart';
// Examples can assume:
// // @dart = 2.9
// Content padding determined via SwiftUI's `Form` view in the iOS 14.2 SDK.
const EdgeInsetsGeometry _kDefaultPadding =
EdgeInsetsDirectional.fromSTEB(20.0, 6.0, 6.0, 6.0);

View File

@ -267,7 +267,7 @@ typedef RefreshCallback = Future<void> Function();
/// sliver such as [CupertinoSliverNavigationBar] and your main scrollable
/// content's sliver.
///
/// {@tool dartpad --template=stateful_widget_material}
/// {@tool dartpad --template=stateful_widget_material_no_null_safety}
///
/// When the user scrolls past [refreshTriggerPullDistance],
/// this sample shows the default iOS pull to refresh indicator for 1 second and

View File

@ -12,6 +12,9 @@ import 'icons.dart';
import 'localizations.dart';
import 'text_field.dart';
// Examples can assume:
// // @dart = 2.9
/// A [CupertinoTextField] that mimics the look and behavior of UIKit's
/// `UISearchTextField`.
///

View File

@ -11,6 +11,9 @@ import 'package:flutter/widgets.dart';
import 'theme.dart';
// Examples can assume:
// // @dart = 2.9
// Minimum padding from edges of the segmented control to edges of
// encompassing widget.
const EdgeInsetsGeometry _kHorizontalItemPadding = EdgeInsets.symmetric(horizontal: 16.0);

View File

@ -14,6 +14,7 @@ import 'theme.dart';
import 'thumb_painter.dart';
// Examples can assume:
// // @dart = 2.9
// int _cupertinoSliderValue = 1;
// void setState(VoidCallback fn) { }

View File

@ -12,6 +12,9 @@ import 'package:flutter/widgets.dart';
import 'colors.dart';
// Examples can assume:
// // @dart = 2.9
// Extracted from https://developer.apple.com/design/resources/.
// Minimum padding from edges of the segmented control to edges of

View File

@ -14,6 +14,7 @@ import 'colors.dart';
import 'thumb_painter.dart';
// Examples can assume:
// // @dart = 2.9
// bool _lights;
// void setState(VoidCallback fn) { }

View File

@ -16,6 +16,9 @@ import 'theme.dart';
export 'package:flutter/services.dart' show TextInputType, TextInputAction, TextCapitalization, SmartQuotesType, SmartDashesType;
// Examples can assume:
// // @dart = 2.9
const TextStyle _kDefaultPlaceholderStyle = TextStyle(
fontWeight: FontWeight.w400,
color: CupertinoColors.placeholderText,

View File

@ -11,6 +11,9 @@ import 'form_row.dart';
import 'text_field.dart';
import 'theme.dart';
// Examples can assume:
// // @dart = 2.9
/// Creates a [CupertinoFormRow] containing a [FormField] that wraps
/// a [CupertinoTextField].
///
@ -72,7 +75,7 @@ import 'theme.dart';
/// ```
/// {@end-tool}
///
/// {@tool dartpad --template=stateful_widget_material}
/// {@tool dartpad --template=stateful_widget_material_no_null_safety}
/// This example shows how to move the focus to the next field when the user
/// presses the SPACE key.
///

View File

@ -3,6 +3,7 @@
// found in the LICENSE file.
// Examples can assume:
// // @dart = 2.9
// class Cat { }
/// A category with which to annotate a class, for documentation

View File

@ -11,6 +11,7 @@ import 'print.dart';
import 'stack_frame.dart';
// Examples can assume:
// // @dart = 2.9
// String runtimeType;
// bool draconisAlive;
// bool draconisAmulet;

View File

@ -12,6 +12,7 @@ import 'debug.dart';
import 'object.dart';
// Examples can assume:
// // @dart = 2.9
// int rows, columns;
// String _name;
// bool inherit;

View File

@ -43,13 +43,13 @@ import 'theme.dart';
///
/// If your application does not have a [Drawer], you should provide an
/// affordance to call [showAboutDialog] or (at least) [showLicensePage].
/// {@tool dartpad --template=stateless_widget_material}
///
/// {@tool dartpad --template=stateless_widget_material_no_null_safety}
///
/// This sample shows two ways to open [AboutDialog]. The first one
/// uses an [AboutListTile], and the second uses the [showAboutDialog] function.
///
/// ```dart
///
/// Widget build(BuildContext context) {
/// final TextStyle textStyle = Theme.of(context).textTheme.bodyText2;
/// final List<Widget> aboutBoxChildren = <Widget>[
@ -110,10 +110,9 @@ import 'theme.dart';
/// ),
/// ),
/// );
///}
/// }
/// ```
/// {@end-tool}
///
class AboutListTile extends StatelessWidget {
/// Creates a list tile for showing an about box.
///

View File

@ -10,6 +10,7 @@ part of material_animated_icons;
// generic vector graphics support in Flutter.
// Examples can assume:
// // @dart = 2.9
// AnimationController controller;
/// Shows an animated icon at a given animation [progress].

View File

@ -18,6 +18,9 @@ import 'page.dart';
import 'scaffold.dart' show ScaffoldMessenger, ScaffoldMessengerState;
import 'theme.dart';
// Examples can assume:
// // @dart = 2.9
/// [MaterialApp] uses this [TextStyle] as its [DefaultTextStyle] to encourage
/// developers to be intentional about their [DefaultTextStyle].
///

View File

@ -91,7 +91,7 @@ class _ToolbarContainerLayout extends SingleChildLayoutDelegate {
/// to false. In that case a null leading widget will result in the middle/title widget
/// stretching to start.
///
/// {@tool dartpad --template=stateless_widget_material}
/// {@tool dartpad --template=stateless_widget_material_no_null_safety}
///
/// This sample shows an [AppBar] with two simple actions. The first action
/// opens a [SnackBar], while the second action navigates to a new page.

View File

@ -18,7 +18,7 @@ import 'theme.dart';
/// They are persistent and non-modal, allowing the user to either ignore them or
/// interact with them at any time.
///
/// {@tool dartpad --template=stateless_widget_scaffold}
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
///
/// ```dart
/// Widget build(BuildContext context) {

View File

@ -13,6 +13,7 @@ import 'scaffold.dart';
import 'theme.dart';
// Examples can assume:
// // @dart = 2.9
// Widget bottomAppBarContents;
/// A container that is typically used with [Scaffold.bottomNavigationBar], and

View File

@ -63,7 +63,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 dartpad --template=stateful_widget_material}
/// {@tool dartpad --template=stateful_widget_material_no_null_safety}
/// 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

View File

@ -596,7 +596,7 @@ class _BottomSheetSuspendedCurve extends ParametricCurve<double> {
/// Returns a `Future` that resolves to the value (if any) that was passed to
/// [Navigator.pop] when the modal bottom sheet was closed.
///
/// {@tool dartpad --template=stateless_widget_scaffold}
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
///
/// This example demonstrates how to use `showModalBottomSheet` to display a
/// bottom sheet that obscures the content behind it when a user taps a button.

View File

@ -20,7 +20,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 dartpad --template=stateless_widget_scaffold}
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
///
/// This sample shows creation of a [Card] widget that shows album information
/// and two actions.
@ -63,7 +63,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 dartpad --template=stateless_widget_scaffold}
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
///
/// 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

View File

@ -10,6 +10,7 @@ import 'theme.dart';
import 'theme_data.dart';
// Examples can assume:
// // @dart = 2.9
// void setState(VoidCallback fn) { }
/// A [ListTile] with a [Checkbox]. In other words, a checkbox with a label.
@ -39,7 +40,7 @@ import 'theme_data.dart';
/// To show the [CheckboxListTile] as disabled, pass null as the [onChanged]
/// callback.
///
/// {@tool dartpad --template=stateful_widget_scaffold_center}
/// {@tool dartpad --template=stateful_widget_scaffold_center_no_null_safety}
///
/// ![CheckboxListTile sample](https://flutter.github.io/assets-for-api-docs/assets/material/checkbox_list_tile.png)
///
@ -84,7 +85,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 sample --template=stateful_widget_scaffold_center}
/// {@tool sample --template=stateful_widget_scaffold_center_no_null_safety}
///
/// ![Checkbox list tile semantics sample](https://flutter.github.io/assets-for-api-docs/assets/material/checkbox_list_tile_semantics.png)
///
@ -168,7 +169,7 @@ import 'theme_data.dart';
/// combining [Checkbox] with other widgets, such as [Text], [Padding] and
/// [InkWell].
///
/// {@tool dartpad --template=stateful_widget_scaffold_center}
/// {@tool dartpad --template=stateful_widget_scaffold_center_no_null_safety}
///
/// ![Custom checkbox list tile sample](https://flutter.github.io/assets-for-api-docs/assets/material/checkbox_list_tile_custom.png)
///

View File

@ -23,6 +23,9 @@ import 'theme.dart';
import 'theme_data.dart';
import 'tooltip.dart';
// Examples can assume:
// // @dart = 2.9
// Some design constants
const double _kChipHeight = 32.0;
const double _kDeleteIconSize = 18.0;
@ -221,7 +224,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 dartpad --template=stateful_widget_scaffold_center}
/// {@tool dartpad --template=stateful_widget_scaffold_center_no_null_safety}
///
/// This sample shows how to use [onDeleted] to remove an entry when the
/// delete button is tapped.

View File

@ -9,6 +9,7 @@ import 'theme.dart';
import 'theme_data.dart';
// Examples can assume:
// // @dart = 2.9
// String userAvatarUrl;
/// A circle that represents a user.

View File

@ -6,6 +6,9 @@ import 'dart:ui' show Color;
import 'package:flutter/painting.dart';
// Examples can assume:
// // @dart = 2.9
/// Defines a single color as well a color swatch with ten shades of the color.
///
/// The color's shades are referred to by index. The greater the index, the

View File

@ -260,7 +260,7 @@ class DataCell {
/// [PaginatedDataTable] which automatically splits the data into
/// multiple pages.
///
/// {@tool dartpad --template=stateless_widget_scaffold}
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
///
/// 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
@ -322,7 +322,7 @@ class DataCell {
/// {@end-tool}
///
///
/// {@tool dartpad --template=stateful_widget_scaffold}
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
///
/// This sample shows how to display a [DataTable] with alternate colors per
/// row, and a custom color for when the row is selected.

View File

@ -23,6 +23,7 @@ import 'theme.dart';
// Examples can assume:
// // @dart = 2.9
// BuildContext context;
const Duration _kMonthScrollDuration = Duration(milliseconds: 200);

View File

@ -18,6 +18,7 @@ import 'theme.dart';
import 'theme_data.dart';
// Examples can assume:
// // @dart = 2.9
// enum Department { treasury, state }
// BuildContext context;

View File

@ -9,6 +9,7 @@ import 'divider_theme.dart';
import 'theme.dart';
// Examples can assume:
// // @dart = 2.9
// BuildContext context;
/// A thin horizontal line, with padding on either side.
@ -24,7 +25,7 @@ import 'theme.dart';
/// The box's total height is controlled by [height]. The appropriate
/// padding is automatically computed from the height.
///
/// {@tool dartpad --template=stateless_widget_scaffold}
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
///
/// 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

View File

@ -728,7 +728,7 @@ class DropdownButtonHideUnderline extends InheritedWidget {
/// dropdown's value. It should also call [State.setState] to rebuild the
/// dropdown with the new value.
///
/// {@tool dartpad --template=stateful_widget_scaffold_center}
/// {@tool dartpad --template=stateful_widget_scaffold_center_no_null_safety}
///
/// This sample shows a `DropdownButton` with a large arrow icon,
/// purple text style, and bold purple underline, whose value is one of "One",
@ -912,7 +912,7 @@ class DropdownButton<T> extends StatefulWidget {
/// from the list corresponds to the [DropdownMenuItem] of the same index
/// in [items].
///
/// {@tool dartpad --template=stateful_widget_scaffold}
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
///
/// This sample shows a `DropdownButton` with a button with [Text] that
/// corresponds to but is unique from [DropdownMenuItem].
@ -963,7 +963,7 @@ class DropdownButton<T> extends StatefulWidget {
/// To use a separate text style for selected item when it's displayed within
/// the dropdown button, consider using [selectedItemBuilder].
///
/// {@tool dartpad --template=stateful_widget_scaffold}
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
///
/// This sample shows a `DropdownButton` with a dropdown button text style
/// that is different than its menu items.

View File

@ -148,7 +148,7 @@ class ExpansionPanelRadio extends ExpansionPanel {
/// Note that [expansionCallback] behaves differently for [ExpansionPanelList]
/// and [ExpansionPanelList.radio].
///
/// {@tool dartpad --template=stateful_widget_scaffold}
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
///
/// Here is a simple example of how to implement ExpansionPanelList.
///
@ -252,7 +252,7 @@ class ExpansionPanelList extends StatefulWidget {
/// arguments must not be null. The [children] objects must be instances
/// of [ExpansionPanelRadio].
///
/// {@tool dartpad --template=stateful_widget_scaffold}
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
///
/// Here is a simple example of how to implement ExpansionPanelList.radio.
///

View File

@ -53,7 +53,7 @@ enum StretchMode {
/// [FlexibleSpaceBar.createSettings], to convey sizing information down to the
/// [FlexibleSpaceBar].
///
/// {@tool dartpad --template=freeform}
/// {@tool dartpad --template=freeform_no_null_safety}
/// 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

View File

@ -58,7 +58,7 @@ class _DefaultHeroTag {
/// disabled. Consider changing the [backgroundColor] if disabling the floating
/// action button.
///
/// {@tool dartpad --template=stateless_widget_material}
/// {@tool dartpad --template=stateless_widget_material_no_null_safety}
/// This example shows how to display a [FloatingActionButton] in a
/// [Scaffold], with a pink [backgroundColor] and a thumbs up [Icon].
///
@ -85,7 +85,7 @@ class _DefaultHeroTag {
/// ```
/// {@end-tool}
///
/// {@tool dartpad --template=stateless_widget_material}
/// {@tool dartpad --template=stateless_widget_material_no_null_safety}
/// 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".

View File

@ -431,7 +431,7 @@ abstract class FloatingActionButtonLocation {
/// You can create your own subclass of [StandardFabLocation]
/// to implement a custom [FloatingActionButtonLocation].
///
/// {@tool dartpad --template=stateless_widget_material}
/// {@tool dartpad --template=stateless_widget_material_no_null_safety}
///
/// This is an example of a user-defined [FloatingActionButtonLocation].
///

View File

@ -40,7 +40,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 dartpad --template=stateful_widget_scaffold_center}
/// {@tool dartpad --template=stateful_widget_scaffold_center_no_null_safety}
///
/// This sample shows an `IconButton` that uses the Material icon "volume_up" to
/// increase the volume.
@ -84,7 +84,7 @@ const double _kMinButtonSize = kMinInteractiveDimension;
/// the underlying [Material] along with the splash and highlight
/// [InkResponse] contributed by descendant widgets.
///
/// {@tool dartpad --template=stateless_widget_scaffold}
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
///
/// 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

View File

@ -1170,7 +1170,7 @@ class _InkResponseState extends State<_InkResponseStateWidget>
///
/// An example of this situation is as follows:
///
/// {@tool dartpad --template=stateful_widget_scaffold_center}
/// {@tool dartpad --template=stateful_widget_scaffold_center_no_null_safety}
///
/// 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.

View File

@ -2389,7 +2389,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
/// to describe their decoration. (In fact, this class is merely the
/// configuration of an [InputDecorator], which does all the heavy lifting.)
///
/// {@tool dartpad --template=stateless_widget_scaffold}
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
///
/// 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,
@ -2414,7 +2414,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
/// ```
/// {@end-tool}
///
/// {@tool dartpad --template=stateless_widget_scaffold}
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
///
/// This sample shows how to style a "collapsed" `TextField` using an
/// `InputDecorator`. The collapsed `TextField` surrounds the hint text and
@ -2434,7 +2434,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
/// ```
/// {@end-tool}
///
/// {@tool dartpad --template=stateless_widget_scaffold}
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
///
/// 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
@ -2455,7 +2455,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
/// ```
/// {@end-tool}
///
/// {@tool dartpad --template=stateless_widget_scaffold}
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
///
/// 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
@ -2836,7 +2836,7 @@ class InputDecoration {
/// setting the constraints' minimum height and width to a value lower than
/// 48px.
///
/// {@tool dartpad --template=stateless_widget_scaffold}
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
/// This example shows the differences between two `TextField` widgets when
/// [prefixIconConstraints] is set to the default value and when one is not.
///
@ -3004,7 +3004,7 @@ class InputDecoration {
/// If null, a [BoxConstraints] with a minimum width and height of 48px is
/// used.
///
/// {@tool dartpad --template=stateless_widget_scaffold}
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
/// This example shows the differences between two `TextField` widgets when
/// [suffixIconConstraints] is set to the default value and when one is not.
///

View File

@ -416,7 +416,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 dartpad --template=stateless_widget_scaffold}
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
///
/// Here is an example of a custom list item that resembles a YouTube-related
/// video list item created with [Expanded] and [Container] widgets.
@ -537,7 +537,7 @@ enum ListTileControlAffinity {
/// ```
/// {@end-tool}
///
/// {@tool dartpad --template=stateless_widget_scaffold}
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
///
/// 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
@ -889,7 +889,7 @@ class ListTile extends StatelessWidget {
/// By default the selected color is the theme's primary color. The selected color
/// can be overridden with a [ListTileTheme].
///
/// {@tool dartpad --template=stateful_widget_scaffold}
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
///
/// Here is an example of using a [StatefulWidget] to keep track of the
/// selected index, and using that to set the `selected` property on the

View File

@ -179,7 +179,7 @@ class _MaterialStateColor extends MaterialStateColor {
/// To use a [MaterialStateMouseCursor], you should create a subclass of
/// [MaterialStateMouseCursor] and implement the abstract `resolve` method.
///
/// {@tool dartpad --template=stateless_widget_scaffold_center}
/// {@tool dartpad --template=stateless_widget_scaffold_center_no_null_safety}
///
/// This example defines a mouse cursor that resolves to
/// [SystemMouseCursors.forbidden] when its widget is disabled.
@ -294,7 +294,7 @@ class _EnabledAndDisabledMouseCursor extends MaterialStateMouseCursor {
/// To use a [MaterialStateBorderSide], you should create a subclass of a
/// [MaterialStateBorderSide] and override the abstract `resolve` method.
///
/// {@tool dartpad --template=stateful_widget_material}
/// {@tool dartpad --template=stateful_widget_material_no_null_safety}
///
/// This example defines a subclass of [MaterialStateBorderSide], that resolves
/// to a red border side when its widget is selected.
@ -352,7 +352,7 @@ abstract class MaterialStateBorderSide extends BorderSide implements MaterialSta
/// [OutlinedBorder] and implement [MaterialStateOutlinedBorder]'s abstract
/// `resolve` method.
///
/// {@tool dartpad --template=stateful_widget_material}
/// {@tool dartpad --template=stateful_widget_material_no_null_safety}
///
/// This example defines a subclass of [RoundedRectangleBorder] and an
/// implementation of [MaterialStateOutlinedBorder], that resolves to
@ -423,7 +423,7 @@ abstract class MaterialStateOutlinedBorder extends OutlinedBorder implements Mat
/// of their current material state and [resolve] the button style's
/// material state properties when their value is needed.
///
/// {@tool dartpad --template=stateless_widget_scaffold_center}
/// {@tool dartpad --template=stateless_widget_scaffold_center_no_null_safety}
///
/// This example shows how you can override the default text and icon
/// color (the "foreground color") of a [TextButton] with a

View File

@ -16,6 +16,9 @@ import 'navigation_rail_theme.dart';
import 'theme.dart';
import 'theme_data.dart';
// Examples can assume:
// // @dart = 2.9
/// A material widget that is meant to be displayed at the left or right of an
/// app to navigate between a small number of views, typically between three and
/// five.
@ -38,7 +41,7 @@ import 'theme_data.dart';
/// [https://github.com/flutter/samples/blob/master/experimental/web_dashboard/lib/src/widgets/third_party/adaptive_scaffold.dart]
/// for an example.
///
/// {@tool dartpad --template=stateful_widget_material}
/// {@tool dartpad --template=stateful_widget_material_no_null_safety}
///
/// This example shows a [NavigationRail] used within a Scaffold with 3
/// [NavigationRailDestination]s. The main content is separated by a divider

View File

@ -57,7 +57,7 @@ const Duration _kElevationDuration = Duration(milliseconds: 75);
/// Outline buttons have a minimum size of 88.0 by 36.0 which can be overridden
/// with [ButtonTheme].
///
/// {@tool dartpad --template=stateless_widget_scaffold_center}
/// {@tool dartpad --template=stateless_widget_scaffold_center_no_null_safety}
///
/// Here is an example of a basic [OutlineButton].
///

View File

@ -21,6 +21,7 @@ import 'theme.dart';
import 'tooltip.dart';
// Examples can assume:
// // @dart = 2.9
// enum Commands { heroAndScholar, hurricaneCame }
// dynamic _heroAndScholar;
// dynamic _selection;

View File

@ -243,7 +243,7 @@ class _LinearProgressIndicatorPainter extends CustomPainter {
/// The minimum height of the indicator can be specified using [minHeight].
/// The indicator can be made taller by wrapping the widget with a [SizedBox].
///
/// {@tool dartpad --template=stateful_widget_material_ticker}
/// {@tool dartpad --template=stateful_widget_material_ticker_no_null_safety}
///
/// This example shows a [LinearProgressIndicator] with a changing value.
///
@ -481,7 +481,7 @@ class _CircularProgressIndicatorPainter extends CustomPainter {
/// The indicator arc is displayed with [valueColor], an animated value. To
/// specify a constant color use: `AlwaysStoppedAnimation<Color>(color)`.
///
/// {@tool dartpad --template=stateful_widget_material_ticker}
/// {@tool dartpad --template=stateful_widget_material_ticker_no_null_safety}
///
/// This example shows a [CircularProgressIndicator] with a changing value.
///

View File

@ -30,7 +30,7 @@ const double _kInnerRadius = 4.5;
/// will respond to [onChanged] by calling [State.setState] to update the
/// radio button's [groupValue].
///
/// {@tool dartpad --template=stateful_widget_scaffold_center}
/// {@tool dartpad --template=stateful_widget_scaffold_center_no_null_safety}
///
/// Here is an example of Radio widgets wrapped in ListTiles, which is similar
/// to what you could get with the RadioListTile widget.
@ -202,7 +202,7 @@ class Radio<T> extends StatefulWidget {
///
/// The default is false.
///
/// {@tool dartpad --template=stateful_widget_scaffold}
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
/// This example shows how to enable deselecting a radio button by setting the
/// [toggleable] attribute.
///

View File

@ -10,6 +10,7 @@ import 'theme.dart';
import 'theme_data.dart';
// Examples can assume:
// // @dart = 2.9
// void setState(VoidCallback fn) { }
/// A [ListTile] with a [Radio]. In other words, a radio button with a label.
@ -40,7 +41,7 @@ import 'theme_data.dart';
/// To show the [RadioListTile] as disabled, pass null as the [onChanged]
/// callback.
///
/// {@tool dartpad --template=stateful_widget_scaffold}
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
///
/// ![RadioListTile sample](https://flutter.github.io/assets-for-api-docs/assets/material/radio_list_tile.png)
///
@ -92,7 +93,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 dartpad --template=stateful_widget_scaffold}
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
///
/// ![Radio list tile semantics sample](https://flutter.github.io/assets-for-api-docs/assets/material/radio_list_tile_semantics.png)
///
@ -196,7 +197,7 @@ import 'theme_data.dart';
/// combining [Radio] with other widgets, such as [Text], [Padding] and
/// [InkWell].
///
/// {@tool dartpad --template=stateful_widget_scaffold}
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
///
/// ![Custom radio list tile sample](https://flutter.github.io/assets-for-api-docs/assets/material/radio_list_tile_custom.png)
///
@ -386,7 +387,7 @@ class RadioListTile<T> extends StatelessWidget {
///
/// The default is false.
///
/// {@tool dartpad --template=stateful_widget_scaffold}
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
/// This example shows how to enable deselecting a radio button by setting the
/// [toggleable] attribute.
///

View File

@ -43,7 +43,7 @@ import 'theme_data.dart';
/// Raised buttons have a minimum size of 88.0 by 36.0 which can be overridden
/// with [ButtonTheme].
///
/// {@tool dartpad --template=stateless_widget_scaffold}
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
///
/// This sample shows how to render a disabled RaisedButton, an enabled RaisedButton
/// and lastly a RaisedButton with gradient background.

View File

@ -18,6 +18,7 @@ import 'slider_theme.dart';
import 'theme.dart';
// Examples can assume:
// // @dart = 2.9
// RangeValues _rangeValues = RangeValues(0.3, 0.7);
// RangeValues _dollarsRange = RangeValues(50, 100);
// void setState(VoidCallback fn) { }
@ -33,7 +34,7 @@ typedef PaintRangeValueIndicator = void Function(PaintingContext context, Offset
///
/// {@youtube 560 315 https://www.youtube.com/watch?v=ufb4gIPDmEs}
///
/// {@tool dartpad --template=stateful_widget_scaffold}
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
///
/// ![A range slider widget, consisting of 5 divisions and showing the default
/// value indicator.](https://flutter.github.io/assets-for-api-docs/assets/material/range_slider.png)

View File

@ -12,6 +12,7 @@ import 'material.dart';
import 'material_localizations.dart';
// Examples can assume:
// // @dart = 2.9
// class MyDataObject { }
/// The callback used by [ReorderableListView] to move an item to a new
@ -59,7 +60,7 @@ typedef ReorderCallback = void Function(int oldIndex, int newIndex);
/// The [onReorder] parameter is required and will be called when a child
/// widget is dragged to a new position.
///
/// {@tool dartpad --template=stateful_widget_scaffold}
/// {@tool dartpad --template=stateful_widget_scaffold_no_null_safety}
///
/// ```dart
/// List<String> _list = List.generate(5, (i) => "${i}");

View File

@ -30,6 +30,7 @@ import 'theme.dart';
import 'theme_data.dart';
// Examples can assume:
// // @dart = 2.9
// TabController tabController;
// void setState(VoidCallback fn) { }
// String appBarTitle;
@ -68,7 +69,7 @@ enum _ScaffoldSlot {
/// [BuildContext] via [ScaffoldMessenger.of] and use the
/// [ScaffoldMessengerState.showSnackBar] function.
///
/// {@tool dartpad --template=stateless_widget_scaffold_center}
/// {@tool dartpad --template=stateless_widget_scaffold_center_no_null_safety}
///
/// Here is an example of showing a [SnackBar] when the user presses a button.
///
@ -111,7 +112,7 @@ class ScaffoldMessenger extends StatefulWidget {
/// The state from the closest instance of this class that encloses the given
/// context.
///
/// {@tool dartpad --template=stateless_widget_scaffold_center}
/// {@tool dartpad --template=stateless_widget_scaffold_center_no_null_safety}
/// Typical usage of the [ScaffoldMessenger.of] function is to call it in
/// response to a user gesture or an application state change.
///
@ -137,7 +138,7 @@ class ScaffoldMessenger extends StatefulWidget {
/// function. The [MaterialApp.scaffoldMessengerKey] refers to the root
/// ScaffoldMessenger that is provided by default.
///
/// {@tool dartpad --template=freeform}
/// {@tool dartpad --template=freeform_no_null_safety}
/// Sometimes [SnackBar]s are produced by code that doesn't have ready access
/// to a valid [BuildContext]. One such example of this is when you show a
/// SnackBar from a method outside of the `build` function. In these
@ -303,7 +304,7 @@ class ScaffoldMessengerState extends State<ScaffoldMessenger> with TickerProvide
/// See [ScaffoldMessenger.of] for information about how to obtain the
/// [ScaffoldMessengerState].
///
/// {@tool dartpad --template=stateless_widget_scaffold_center}
/// {@tool dartpad --template=stateless_widget_scaffold_center_no_null_safety}
///
/// Here is an example of showing a [SnackBar] when the user presses a button.
///
@ -1258,7 +1259,7 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr
/// [ScaffoldState] for the current [BuildContext] via [Scaffold.of] and use the
/// [ScaffoldState.showBottomSheet] function.
///
/// {@tool dartpad --template=stateful_widget_material}
/// {@tool dartpad --template=stateful_widget_material_no_null_safety}
/// 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
@ -1287,7 +1288,7 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr
/// ```
/// {@end-tool}
///
/// {@tool dartpad --template=stateful_widget_material}
/// {@tool dartpad --template=stateful_widget_material_no_null_safety}
/// 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]
@ -1317,7 +1318,7 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr
/// ```
/// {@end-tool}
///
/// {@tool dartpad --template=stateful_widget_material}
/// {@tool dartpad --template=stateful_widget_material_no_null_safety}
/// 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
@ -1559,7 +1560,7 @@ class Scaffold extends StatefulWidget {
///
/// To close the drawer, use [Navigator.pop].
///
/// {@tool dartpad --template=stateful_widget_material}
/// {@tool dartpad --template=stateful_widget_material_no_null_safety}
/// To disable the drawer edge swipe, set the
/// [Scaffold.drawerEnableOpenDragGesture] to false. Then, use
/// [ScaffoldState.openDrawer] to open the drawer and [Navigator.pop] to close
@ -1622,7 +1623,7 @@ class Scaffold extends StatefulWidget {
///
/// To close the drawer, use [Navigator.pop].
///
/// {@tool dartpad --template=stateful_widget_material}
/// {@tool dartpad --template=stateful_widget_material_no_null_safety}
/// To disable the drawer edge swipe, set the
/// [Scaffold.endDrawerEnableOpenDragGesture] to false. Then, use
/// [ScaffoldState.openEndDrawer] to open the drawer and [Navigator.pop] to
@ -1789,7 +1790,7 @@ class Scaffold extends StatefulWidget {
/// If no instance of this class encloses the given context, will cause an
/// assert in debug mode, and throw an exception in release mode.
///
/// {@tool dartpad --template=freeform}
/// {@tool dartpad --template=freeform_no_null_safety}
/// Typical usage of the [Scaffold.of] function is to call it from within the
/// `build` method of a child of a [Scaffold].
///
@ -1860,7 +1861,7 @@ class Scaffold extends StatefulWidget {
/// ```
/// {@end-tool}
///
/// {@tool dartpad --template=stateless_widget_material}
/// {@tool dartpad --template=stateless_widget_material_no_null_safety}
/// 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
@ -2172,7 +2173,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
/// See [ScaffoldMessenger.of] for information about how to obtain the
/// [ScaffoldMessengerState].
///
/// {@tool dartpad --template=stateless_widget_scaffold_center}
/// {@tool dartpad --template=stateless_widget_scaffold_center_no_null_safety}
///
/// Here is an example of showing a [SnackBar] when the user presses a button.
///
@ -2546,7 +2547,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
/// of the app. Modal bottom sheets can be created and displayed with the
/// [showModalBottomSheet] function.
///
/// {@tool dartpad --template=stateless_widget_scaffold}
/// {@tool dartpad --template=stateless_widget_scaffold_no_null_safety}
///
/// This example demonstrates how to use `showBottomSheet` to display a
/// bottom sheet when a user taps a button. It also demonstrates how to

Some files were not shown because too many files have changed in this diff Show More