Prepare to migrate API doc samples and snippets to null safety (#72040)
This commit is contained in:
committed by
GitHub
parent
74298a76e7
commit
ff05ca2503
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
///
|
||||
|
||||
@@ -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}
|
||||
@@ -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);
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/// Flutter code sample for {{element}}
|
||||
// @dart = 2.9
|
||||
|
||||
{{description}}
|
||||
|
||||
|
||||
12
dev/snippets/config/templates/freeform_no_null_safety.tmpl
Normal file
12
dev/snippets/config/templates/freeform_no_null_safety.tmpl
Normal file
@@ -0,0 +1,12 @@
|
||||
/// Flutter code sample for {{element}}
|
||||
// @dart = 2.9
|
||||
|
||||
{{description}}
|
||||
|
||||
{{code-imports}}
|
||||
|
||||
{{code-main}}
|
||||
|
||||
{{code-preamble}}
|
||||
|
||||
{{code}}
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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}}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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}}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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}}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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}}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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}}
|
||||
}
|
||||
@@ -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}}
|
||||
}
|
||||
@@ -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}}
|
||||
}
|
||||
|
||||
@@ -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}}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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}}
|
||||
@@ -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}}
|
||||
}
|
||||
@@ -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}}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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}}
|
||||
}
|
||||
@@ -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}}
|
||||
|
||||
@@ -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}}
|
||||
|
||||
@@ -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}}
|
||||
}
|
||||
@@ -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}}
|
||||
|
||||
@@ -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}}
|
||||
}
|
||||
@@ -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}}
|
||||
|
||||
@@ -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}}
|
||||
}
|
||||
@@ -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}}
|
||||
}
|
||||
@@ -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}}
|
||||
|
||||
@@ -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}}
|
||||
|
||||
@@ -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}}
|
||||
}
|
||||
@@ -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}}
|
||||
}
|
||||
Reference in New Issue
Block a user