Update samples to use repo analysis options, Fix sample templates and a ton of analyzer issues (#77868)
This commit is contained in:
parent
d6f5767ec8
commit
a8d820a46e
@ -7,6 +7,7 @@
|
||||
// To run this, from the root of the Flutter repository:
|
||||
// bin/cache/dart-sdk/bin/dart dev/bots/analyze_sample_code.dart
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:args/args.dart';
|
||||
@ -41,7 +42,7 @@ void main(List<String> arguments) {
|
||||
argParser.addOption(
|
||||
'interactive',
|
||||
abbr: 'i',
|
||||
help: 'Analyzes the sample code in the specified file interactivly.',
|
||||
help: 'Analyzes the sample code in the specified file interactively.',
|
||||
);
|
||||
|
||||
final ArgResults parsedArguments = argParser.parse(arguments);
|
||||
@ -326,6 +327,8 @@ class SampleChecker {
|
||||
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>[];
|
||||
int dartpadCount = 0;
|
||||
int sampleCount = 0;
|
||||
|
||||
for (final File file in files) {
|
||||
final String relativeFilePath = path.relative(file.path, from: _flutterPackage.path);
|
||||
@ -430,6 +433,12 @@ class SampleChecker {
|
||||
} else if (sampleMatch != null) {
|
||||
inSnippet = sampleMatch != null && (sampleMatch[1] == 'sample' || sampleMatch[1] == 'dartpad');
|
||||
if (inSnippet) {
|
||||
if (sampleMatch[1] == 'sample') {
|
||||
sampleCount++;
|
||||
}
|
||||
if (sampleMatch[1] == 'dartpad') {
|
||||
dartpadCount++;
|
||||
}
|
||||
startLine = Line(
|
||||
'',
|
||||
filename: relativeFilePath,
|
||||
@ -455,7 +464,7 @@ class SampleChecker {
|
||||
}
|
||||
}
|
||||
if (!silent)
|
||||
print('Found ${sections.length} sample code sections.');
|
||||
print('Found ${sections.length} snippet code blocks, $sampleCount sample code sections, and $dartpadCount dartpad sections.');
|
||||
for (final Section section in sections) {
|
||||
final String path = _writeSection(section).path;
|
||||
if (sectionMap != null)
|
||||
@ -510,10 +519,10 @@ class SampleChecker {
|
||||
}
|
||||
|
||||
/// Creates the configuration files necessary for the analyzer to consider
|
||||
/// the temporary director a package, and sets which lint rules to enforce.
|
||||
/// the temporary directory a package, and sets which lint rules to enforce.
|
||||
void _createConfigurationFiles(Directory directory) {
|
||||
final File pubSpec = File(path.join(directory.path, 'pubspec.yaml'))..createSync(recursive: true);
|
||||
final File analysisOptions = File(path.join(directory.path, 'analysis_options.yaml'))..createSync(recursive: true);
|
||||
|
||||
pubSpec.writeAsStringSync('''
|
||||
name: analyze_sample_code
|
||||
environment:
|
||||
@ -524,12 +533,9 @@ dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
''');
|
||||
analysisOptions.writeAsStringSync('''
|
||||
linter:
|
||||
rules:
|
||||
- unnecessary_const
|
||||
- unnecessary_new
|
||||
''');
|
||||
|
||||
// Copy in the analysis options from the Flutter root.
|
||||
File(path.join(_flutterRoot,'analysis_options.yaml')).copySync(path.join(directory.path, 'analysis_options.yaml'));
|
||||
}
|
||||
|
||||
/// Writes out a sample section to the disk and returns the file.
|
||||
@ -606,107 +612,107 @@ linter:
|
||||
final String kBullet = Platform.isWindows ? ' - ' : ' • ';
|
||||
// RegExp to match an error output line of the analyzer.
|
||||
final RegExp errorPattern = RegExp(
|
||||
'^ +([a-z]+)$kBullet(.+)$kBullet(.+):([0-9]+):([0-9]+)$kBullet([-a-z_]+)\$',
|
||||
'^ +(?<type>[a-z]+)'
|
||||
'$kBullet(?<description>.+)'
|
||||
'$kBullet(?<file>.+):(?<line>[0-9]+):(?<column>[0-9]+)'
|
||||
'$kBullet(?<code>[-a-z_]+)\$',
|
||||
caseSensitive: false,
|
||||
);
|
||||
bool unknownAnalyzerErrors = false;
|
||||
final int headerLength = headers.length + 3;
|
||||
for (final String error in errors) {
|
||||
final Match parts = errorPattern.matchAsPrefix(error);
|
||||
if (parts != null) {
|
||||
final String message = parts[2];
|
||||
final File file = File(path.join(_tempDirectory.path, parts[3]));
|
||||
final List<String> fileContents = file.readAsLinesSync();
|
||||
final bool isSnippet = path.basename(file.path).startsWith('snippet.');
|
||||
final bool isSample = path.basename(file.path).startsWith('sample.');
|
||||
final String line = parts[4];
|
||||
final String column = parts[5];
|
||||
final String errorCode = parts[6];
|
||||
final int lineNumber = int.parse(line, radix: 10) - (isSnippet ? headerLength : 0);
|
||||
final int columnNumber = int.parse(column, radix: 10);
|
||||
final RegExpMatch match = errorPattern.firstMatch(error);
|
||||
if (match == null) {
|
||||
stderr.writeln('Analyzer output: $error');
|
||||
unknownAnalyzerErrors = true;
|
||||
continue;
|
||||
}
|
||||
final String type = match.namedGroup('type');
|
||||
final String message = match.namedGroup('description');
|
||||
final File file = File(path.join(_tempDirectory.path, match.namedGroup('file')));
|
||||
final List<String> fileContents = file.readAsLinesSync();
|
||||
final bool isSnippet = path.basename(file.path).startsWith('snippet.');
|
||||
final bool isSample = path.basename(file.path).startsWith('sample.');
|
||||
final String line = match.namedGroup('line');
|
||||
final String column = match.namedGroup('column');
|
||||
final String errorCode = match.namedGroup('code');
|
||||
final int lineNumber = int.parse(line, radix: 10) - (isSnippet ? headerLength : 0);
|
||||
final int columnNumber = int.parse(column, radix: 10);
|
||||
|
||||
// For when errors occur outside of the things we're trying to analyze.
|
||||
if (!isSnippet && !isSample) {
|
||||
// For when errors occur outside of the things we're trying to analyze.
|
||||
if (!isSnippet && !isSample) {
|
||||
addAnalysisError(
|
||||
file,
|
||||
AnalysisError(
|
||||
type,
|
||||
lineNumber,
|
||||
columnNumber,
|
||||
message,
|
||||
errorCode,
|
||||
Line(
|
||||
'',
|
||||
filename: file.path,
|
||||
line: lineNumber,
|
||||
),
|
||||
),
|
||||
);
|
||||
throw SampleCheckerException(
|
||||
'Cannot analyze dartdocs; analysis errors exist: $error',
|
||||
file: file.path,
|
||||
line: lineNumber,
|
||||
);
|
||||
}
|
||||
|
||||
if (isSample) {
|
||||
addAnalysisError(
|
||||
file,
|
||||
AnalysisError(
|
||||
type,
|
||||
lineNumber,
|
||||
columnNumber,
|
||||
message,
|
||||
errorCode,
|
||||
null,
|
||||
sample: samples[file.path],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
if (lineNumber < 1 || lineNumber > fileContents.length) {
|
||||
addAnalysisError(
|
||||
file,
|
||||
AnalysisError(
|
||||
type,
|
||||
lineNumber,
|
||||
columnNumber,
|
||||
message,
|
||||
errorCode,
|
||||
Line(
|
||||
'',
|
||||
filename: file.path,
|
||||
line: lineNumber,
|
||||
),
|
||||
Line('', filename: file.path, line: lineNumber),
|
||||
),
|
||||
);
|
||||
throw SampleCheckerException('Failed to parse error message: $error', file: file.path, line: lineNumber);
|
||||
}
|
||||
|
||||
final Section actualSection = sections[file.path];
|
||||
if (actualSection == null) {
|
||||
throw SampleCheckerException(
|
||||
'Cannot analyze dartdocs; analysis errors exist: $error',
|
||||
"Unknown section for ${file.path}. Maybe the temporary directory wasn't empty?",
|
||||
file: file.path,
|
||||
line: lineNumber,
|
||||
);
|
||||
}
|
||||
final Line actualLine = actualSection.code[lineNumber - 1];
|
||||
|
||||
if (isSample) {
|
||||
addAnalysisError(
|
||||
file,
|
||||
AnalysisError(
|
||||
lineNumber,
|
||||
columnNumber,
|
||||
message,
|
||||
errorCode,
|
||||
null,
|
||||
sample: samples[file.path],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
if (lineNumber < 1 || lineNumber > fileContents.length) {
|
||||
addAnalysisError(
|
||||
file,
|
||||
AnalysisError(
|
||||
lineNumber,
|
||||
columnNumber,
|
||||
message,
|
||||
errorCode,
|
||||
Line('', filename: file.path, line: lineNumber),
|
||||
),
|
||||
);
|
||||
throw SampleCheckerException('Failed to parse error message: $error', file: file.path, line: lineNumber);
|
||||
}
|
||||
|
||||
final Section actualSection = sections[file.path];
|
||||
if (actualSection == null) {
|
||||
throw SampleCheckerException(
|
||||
"Unknown section for ${file.path}. Maybe the temporary directory wasn't empty?",
|
||||
file: file.path,
|
||||
line: lineNumber,
|
||||
);
|
||||
}
|
||||
final Line actualLine = actualSection.code[lineNumber - 1];
|
||||
|
||||
if (actualLine?.filename == null) {
|
||||
if (errorCode == 'missing_identifier' && lineNumber > 1) {
|
||||
if (fileContents[lineNumber - 2].endsWith(',')) {
|
||||
final Line actualLine = sections[file.path].code[lineNumber - 2];
|
||||
addAnalysisError(
|
||||
file,
|
||||
AnalysisError(
|
||||
actualLine.line,
|
||||
actualLine.indent + fileContents[lineNumber - 2].length - 1,
|
||||
'Unexpected comma at end of sample code.',
|
||||
errorCode,
|
||||
actualLine,
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (actualLine?.filename == null) {
|
||||
if (errorCode == 'missing_identifier' && lineNumber > 1) {
|
||||
if (fileContents[lineNumber - 2].endsWith(',')) {
|
||||
final Line actualLine = sections[file.path].code[lineNumber - 2];
|
||||
addAnalysisError(
|
||||
file,
|
||||
AnalysisError(
|
||||
lineNumber - 1,
|
||||
columnNumber,
|
||||
message,
|
||||
type,
|
||||
actualLine.line,
|
||||
actualLine.indent + fileContents[lineNumber - 2].length - 1,
|
||||
'Unexpected comma at end of sample code.',
|
||||
errorCode,
|
||||
actualLine,
|
||||
),
|
||||
@ -716,18 +722,28 @@ linter:
|
||||
addAnalysisError(
|
||||
file,
|
||||
AnalysisError(
|
||||
actualLine.line,
|
||||
actualLine.indent + columnNumber,
|
||||
type,
|
||||
lineNumber - 1,
|
||||
columnNumber,
|
||||
message,
|
||||
errorCode,
|
||||
actualLine,
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
addAnalysisError(
|
||||
file,
|
||||
AnalysisError(
|
||||
type,
|
||||
actualLine.line,
|
||||
actualLine.indent + columnNumber,
|
||||
message,
|
||||
errorCode,
|
||||
actualLine,
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
stderr.writeln('Analyzer output: $error');
|
||||
unknownAnalyzerErrors = true;
|
||||
}
|
||||
}
|
||||
if (_exitCode == 1 && analysisErrors.isEmpty && !unknownAnalyzerErrors) {
|
||||
@ -906,6 +922,7 @@ class Sample {
|
||||
/// Changes how it converts to a string based on the source of the error.
|
||||
class AnalysisError {
|
||||
const AnalysisError(
|
||||
this.type,
|
||||
this.line,
|
||||
this.column,
|
||||
this.message,
|
||||
@ -914,6 +931,7 @@ class AnalysisError {
|
||||
this.sample,
|
||||
});
|
||||
|
||||
final String type;
|
||||
final int line;
|
||||
final int column;
|
||||
final String message;
|
||||
@ -924,19 +942,18 @@ class AnalysisError {
|
||||
@override
|
||||
String toString() {
|
||||
if (source != null) {
|
||||
return '${source.toStringWithColumn(column)}\n>>> $message ($errorCode)';
|
||||
return '${source.toStringWithColumn(column)}\n>>> $type: $message ($errorCode)';
|
||||
} else if (sample != null) {
|
||||
return 'In sample starting at '
|
||||
'${sample.start.filename}:${sample.start.line}:${sample.contents[line - 1]}\n'
|
||||
'>>> $message ($errorCode)';
|
||||
'>>> $type: $message ($errorCode)';
|
||||
} else {
|
||||
return '<source unknown>:$line:$column\n>>> $message ($errorCode)';
|
||||
return '<source unknown>:$line:$column\n>>> $type: $message ($errorCode)';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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()) {
|
||||
@ -955,6 +972,7 @@ Future<void> _runInteractive(Directory tempDir, Directory flutterPackage, String
|
||||
});
|
||||
print('Using temp dir ${tempDir.path}');
|
||||
}
|
||||
print('Starting up in interactive mode on ${path.relative(filePath, from: _flutterRoot)} ...');
|
||||
|
||||
void analyze(SampleChecker checker, File file) {
|
||||
final Map<String, Section> sections = <String, Section>{};
|
||||
@ -976,8 +994,32 @@ Future<void> _runInteractive(Directory tempDir, Directory flutterPackage, String
|
||||
.._createConfigurationFiles(tempDir);
|
||||
analyze(checker, file);
|
||||
|
||||
Watcher(file.absolute.path).events.listen((_) {
|
||||
print('Type "q" to quit, or "r" to delete temp dir and manually reload.');
|
||||
|
||||
void rerun() {
|
||||
print('\n\nRerunning...');
|
||||
analyze(checker, file);
|
||||
try {
|
||||
analyze(checker, file);
|
||||
} on SampleCheckerException catch (e) {
|
||||
print('Caught Exception (${e.runtimeType}), press "r" to retry:\n$e');
|
||||
}
|
||||
}
|
||||
|
||||
stdin.lineMode = false;
|
||||
stdin.echoMode = false;
|
||||
stdin.transform(utf8.decoder).listen((String input) {
|
||||
switch (input) {
|
||||
case 'q':
|
||||
print('Exiting...');
|
||||
exit(0);
|
||||
break;
|
||||
case 'r':
|
||||
print('Deleting temp files...');
|
||||
tempDir.deleteSync(recursive: true);
|
||||
rerun();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
Watcher(file.absolute.path).events.listen((_) => rerun());
|
||||
}
|
||||
|
@ -17,20 +17,32 @@ void main() {
|
||||
..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:bool? _visible = true;',
|
||||
'>>> info: Use late for private members with non-nullable type (use_late_for_private_fields_and_variables)',
|
||||
'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)',
|
||||
'>>> error: 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)',
|
||||
'>>> info: Unnecessary new keyword (unnecessary_new)',
|
||||
'known_broken_documentation.dart:62:9: new Opacity(',
|
||||
'>>> Unnecessary new keyword (unnecessary_new)',
|
||||
'>>> info: Unnecessary new keyword (unnecessary_new)',
|
||||
'known_broken_documentation.dart:95:9: const text0 = Text(\'Poor wandering ones!\');',
|
||||
'>>> info: Specify type annotations (always_specify_types)',
|
||||
'known_broken_documentation.dart:103:9: const text1 = _Text(\'Poor wandering ones!\');',
|
||||
'>>> info: Specify type annotations (always_specify_types)',
|
||||
'known_broken_documentation.dart:111:9: final String? bar = \'Hello\';',
|
||||
'>>> info: Prefer const over final for declarations (prefer_const_declarations)',
|
||||
'known_broken_documentation.dart:111:23: final String? bar = \'Hello\';',
|
||||
'>>> info: Use a non-nullable type for a final variable initialized with a non-nullable value (unnecessary_nullable_for_final_variable_declarations)',
|
||||
'known_broken_documentation.dart:112:9: final int foo = null;',
|
||||
'>>> info: Prefer const over final for declarations (prefer_const_declarations)',
|
||||
'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)',
|
||||
'>>> error: 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.',
|
||||
'Found 8 snippet code blocks, 0 sample code sections, and 2 dartpad sections.',
|
||||
'Starting analysis of code samples.',
|
||||
'',
|
||||
]);
|
||||
|
@ -28,7 +28,12 @@ Future<String> capture(AsyncVoidCallback callback, { int exitCode = 0 }) async {
|
||||
} finally {
|
||||
print = oldPrint;
|
||||
}
|
||||
return buffer.toString();
|
||||
if (stdout.supportsAnsiEscapes) {
|
||||
// Remove ANSI escapes when this test is running on a terminal.
|
||||
return buffer.toString().replaceAll(RegExp(r'(\x9B|\x1B\[)[0-?]{1,3}[ -/]*[@-~]'), '');
|
||||
} else {
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
{{description}}
|
||||
|
||||
{{code-dartImports}}
|
||||
{{code-imports}}
|
||||
|
||||
{{code-main}}
|
||||
|
@ -2,20 +2,23 @@
|
||||
|
||||
{{description}}
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
{{code-dartImports}}
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
{{code-imports}}
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
void main() => runApp(const MyApp());
|
||||
|
||||
/// This is the main application widget.
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WidgetsApp(
|
||||
return const WidgetsApp(
|
||||
title: 'Flutter Code Sample',
|
||||
home: MyStatefulWidget(),
|
||||
color: const Color(0xffffffff),
|
||||
color: Color(0xffffffff),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -24,7 +27,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);
|
||||
const MyStatefulWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
|
||||
|
@ -2,19 +2,22 @@
|
||||
|
||||
{{description}}
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
{{code-dartImports}}
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
{{code-imports}}
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
void main() => runApp(const MyApp());
|
||||
|
||||
/// This is the main application widget.
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoApp(
|
||||
return const CupertinoApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
);
|
||||
@ -25,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);
|
||||
const MyStatefulWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
|
||||
|
@ -2,19 +2,22 @@
|
||||
|
||||
{{description}}
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
{{code-dartImports}}
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
{{code-imports}}
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
void main() => runApp(const MyApp());
|
||||
|
||||
/// This is the main application widget.
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoApp(
|
||||
return const CupertinoApp(
|
||||
title: _title,
|
||||
home: CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(middle: const Text(_title)),
|
||||
@ -28,7 +31,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);
|
||||
const MyStatefulWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
|
||||
|
@ -2,19 +2,22 @@
|
||||
|
||||
{{description}}
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
{{code-dartImports}}
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
{{code-imports}}
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
void main() => runApp(const MyApp());
|
||||
|
||||
/// This is the main application widget.
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoApp(
|
||||
return const CupertinoApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
);
|
||||
@ -25,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);
|
||||
const MyStatefulWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
|
||||
|
@ -2,19 +2,22 @@
|
||||
|
||||
{{description}}
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
{{code-dartImports}}
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
{{code-imports}}
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
void main() => runApp(const MyApp());
|
||||
|
||||
/// This is the main application widget.
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
);
|
||||
@ -25,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);
|
||||
const MyStatefulWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
|
||||
|
@ -2,19 +2,22 @@
|
||||
|
||||
{{description}}
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
{{code-dartImports}}
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
{{code-imports}}
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
void main() => runApp(const MyApp());
|
||||
|
||||
/// This is the main application widget.
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatefulWidget(),
|
||||
);
|
||||
@ -25,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);
|
||||
const MyStatefulWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
|
||||
|
@ -2,19 +2,22 @@
|
||||
|
||||
{{description}}
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
{{code-dartImports}}
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
{{code-imports}}
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
void main() => runApp(const MyApp());
|
||||
|
||||
/// This is the main application widget.
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WidgetsApp(
|
||||
title: 'Flutter Code Sample',
|
||||
home: Center(
|
||||
home: const Center(
|
||||
child: MyStatefulWidget(restorationId: 'main'),
|
||||
),
|
||||
color: const Color(0xffffffff),
|
||||
@ -26,7 +29,7 @@ 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);
|
||||
const MyStatefulWidget({Key? key, this.restorationId}) : super(key: key);
|
||||
|
||||
final String? restorationId;
|
||||
|
||||
|
@ -2,14 +2,17 @@
|
||||
|
||||
{{description}}
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
{{code-dartImports}}
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
{{code-imports}}
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
void main() => runApp(const MyApp());
|
||||
|
||||
/// This is the main application widget.
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
|
||||
@override
|
||||
@ -18,7 +21,7 @@ class MyApp extends StatelessWidget {
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
body: MyStatefulWidget(),
|
||||
body: const MyStatefulWidget(),
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -28,7 +31,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);
|
||||
const MyStatefulWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
|
||||
|
@ -2,14 +2,17 @@
|
||||
|
||||
{{description}}
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
{{code-dartImports}}
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
{{code-imports}}
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
void main() => runApp(const MyApp());
|
||||
|
||||
/// This is the main application widget.
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
|
||||
@override
|
||||
@ -18,7 +21,7 @@ class MyApp extends StatelessWidget {
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
body: Center(
|
||||
body: const Center(
|
||||
child: MyStatefulWidget(),
|
||||
),
|
||||
),
|
||||
@ -30,7 +33,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);
|
||||
const MyStatefulWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
|
||||
|
@ -2,14 +2,17 @@
|
||||
|
||||
{{description}}
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
{{code-dartImports}}
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
{{code-imports}}
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
void main() => runApp(const MyApp());
|
||||
|
||||
/// This is the main application widget.
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
|
||||
@override
|
||||
@ -18,7 +21,7 @@ class MyApp extends StatelessWidget {
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
body: Center(
|
||||
body: const Center(
|
||||
child: MyStatefulWidget(),
|
||||
),
|
||||
),
|
||||
@ -30,7 +33,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);
|
||||
const MyStatefulWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
|
||||
|
@ -2,20 +2,23 @@
|
||||
|
||||
{{description}}
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
{{code-dartImports}}
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
{{code-imports}}
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
void main() => runApp(const MyApp());
|
||||
|
||||
/// This is the main application widget.
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WidgetsApp(
|
||||
return const WidgetsApp(
|
||||
title: 'Flutter Code Sample',
|
||||
home: MyStatefulWidget(),
|
||||
color: const Color(0xffffffff),
|
||||
color: Color(0xffffffff),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -24,7 +27,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);
|
||||
const MyStatefulWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
|
||||
|
@ -2,21 +2,22 @@
|
||||
|
||||
{{description}}
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
{{code-dartImports}}
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
{{code-imports}}
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
void main() => runApp(const MyApp());
|
||||
|
||||
/// This is the main application widget.
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WidgetsApp(
|
||||
title: 'Flutter Code Sample',
|
||||
builder: (BuildContext context, Widget navigator) {
|
||||
return MyStatelessWidget();
|
||||
},
|
||||
builder: (BuildContext context, Widget? navigator) => const MyStatelessWidget(),
|
||||
color: const Color(0xffffffff),
|
||||
);
|
||||
}
|
||||
@ -26,7 +27,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);
|
||||
const MyStatelessWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
{{code}}
|
||||
|
@ -2,19 +2,22 @@
|
||||
|
||||
{{description}}
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
{{code-dartImports}}
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
{{code-imports}}
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
void main() => runApp(const MyApp());
|
||||
|
||||
/// This is the main application widget.
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoApp(
|
||||
return const CupertinoApp(
|
||||
title: _title,
|
||||
home: MyStatelessWidget(),
|
||||
);
|
||||
@ -26,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);
|
||||
const MyStatelessWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
{{code}}
|
||||
|
@ -2,19 +2,22 @@
|
||||
|
||||
{{description}}
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
{{code-dartImports}}
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
{{code-imports}}
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
void main() => runApp(const MyApp());
|
||||
|
||||
/// This is the main application widget.
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoApp(
|
||||
return const CupertinoApp(
|
||||
title: _title,
|
||||
home: CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(middle: const Text(_title)),
|
||||
@ -29,7 +32,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);
|
||||
const MyStatelessWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
{{code}}
|
||||
|
@ -2,19 +2,22 @@
|
||||
|
||||
{{description}}
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
{{code-dartImports}}
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
{{code-imports}}
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
void main() => runApp(const MyApp());
|
||||
|
||||
/// This is the main application widget.
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
return const MaterialApp(
|
||||
title: _title,
|
||||
home: MyStatelessWidget(),
|
||||
);
|
||||
@ -26,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);
|
||||
const MyStatelessWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
{{code}}
|
||||
|
@ -2,14 +2,17 @@
|
||||
|
||||
{{description}}
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
{{code-dartImports}}
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
{{code-imports}}
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
void main() => runApp(const MyApp());
|
||||
|
||||
/// This is the main application widget.
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
|
||||
@override
|
||||
@ -18,7 +21,7 @@ class MyApp extends StatelessWidget {
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
body: MyStatelessWidget(),
|
||||
body: const MyStatelessWidget(),
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -29,7 +32,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);
|
||||
const MyStatelessWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
{{code}}
|
||||
|
@ -2,14 +2,17 @@
|
||||
|
||||
{{description}}
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
{{code-dartImports}}
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
{{code-imports}}
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
void main() => runApp(const MyApp());
|
||||
|
||||
/// This is the main application widget.
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
static const String _title = 'Flutter Code Sample';
|
||||
|
||||
@override
|
||||
@ -18,7 +21,7 @@ class MyApp extends StatelessWidget {
|
||||
title: _title,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text(_title)),
|
||||
body: Center(
|
||||
body: const Center(
|
||||
child: MyStatelessWidget(),
|
||||
),
|
||||
),
|
||||
@ -31,7 +34,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);
|
||||
const MyStatelessWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
{{code}}
|
||||
|
@ -138,7 +138,7 @@ abstract class Animation<T> extends Listenable implements ValueListenable<T> {
|
||||
/// final Animatable<Alignment> _tween = AlignmentTween(begin: Alignment.topLeft, end: Alignment.topRight)
|
||||
/// .chain(CurveTween(curve: Curves.easeIn));
|
||||
/// // ...
|
||||
/// Animation<Alignment> _alignment2 = _controller.drive(_tween);
|
||||
/// final Animation<Alignment> _alignment2 = _controller.drive(_tween);
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
/// {@tool snippet}
|
||||
|
@ -136,7 +136,7 @@ enum AnimationBehavior {
|
||||
///
|
||||
/// ```dart
|
||||
/// class Foo extends StatefulWidget {
|
||||
/// Foo({ Key? key, required this.duration }) : super(key: key);
|
||||
/// const Foo({ Key? key, required this.duration }) : super(key: key);
|
||||
///
|
||||
/// final Duration duration;
|
||||
///
|
||||
|
@ -339,8 +339,8 @@ class Cubic extends Curve {
|
||||
/// Offset(0.93, 0.93),
|
||||
/// Offset(0.05, 0.75),
|
||||
/// ],
|
||||
/// startHandle: Offset(0.93, 0.93),
|
||||
/// endHandle: Offset(0.18, 0.23),
|
||||
/// startHandle: const Offset(0.93, 0.93),
|
||||
/// endHandle: const Offset(0.18, 0.23),
|
||||
/// tension: 0.0,
|
||||
/// );
|
||||
///
|
||||
@ -389,7 +389,7 @@ class Cubic extends Curve {
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// // Scale the path values to match the -1.0 to 1.0 domain of the Alignment widget.
|
||||
/// final Offset position = widget.path.transform(animation.value) * 2.0 - Offset(1.0, 1.0);
|
||||
/// final Offset position = widget.path.transform(animation.value) * 2.0 - const Offset(1.0, 1.0);
|
||||
/// return Align(
|
||||
/// alignment: Alignment(position.dx, position.dy),
|
||||
/// child: widget.child,
|
||||
@ -411,7 +411,7 @@ class Cubic extends Curve {
|
||||
/// backgroundColor: Colors.yellow,
|
||||
/// child: DefaultTextStyle(
|
||||
/// style: Theme.of(context).textTheme.headline6!,
|
||||
/// child: Text("B"), // Buzz, buzz!
|
||||
/// child: const Text('B'), // Buzz, buzz!
|
||||
/// ),
|
||||
/// ),
|
||||
/// ),
|
||||
|
@ -22,7 +22,7 @@ import 'tween.dart';
|
||||
/// for the next 20%, and then returns to 5.0 for the final 40%.
|
||||
///
|
||||
/// ```dart
|
||||
/// final Animation<double> animation = TweenSequence(
|
||||
/// final Animation<double> animation = TweenSequence<double>(
|
||||
/// <TweenSequenceItem<double>>[
|
||||
/// TweenSequenceItem<double>(
|
||||
/// tween: Tween<double>(begin: 5.0, end: 10.0)
|
||||
|
@ -105,6 +105,8 @@ const double _kDividerThickness = 1.0;
|
||||
///
|
||||
/// ```dart
|
||||
/// class MyStatefulWidget extends StatefulWidget {
|
||||
/// const MyStatefulWidget({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// _MyStatefulWidgetState createState() => _MyStatefulWidgetState();
|
||||
/// }
|
||||
@ -116,12 +118,12 @@ const double _kDividerThickness = 1.0;
|
||||
/// child: Center(
|
||||
/// child: CupertinoButton(
|
||||
/// onPressed: () {
|
||||
/// showCupertinoModalPopup(
|
||||
/// showCupertinoModalPopup<void>(
|
||||
/// context: context,
|
||||
/// builder: (BuildContext context) => CupertinoActionSheet(
|
||||
/// title: const Text('Title'),
|
||||
/// message: const Text('Message'),
|
||||
/// actions: [
|
||||
/// actions: <CupertinoActionSheetAction>[
|
||||
/// CupertinoActionSheetAction(
|
||||
/// child: const Text('Action One'),
|
||||
/// onPressed: () {
|
||||
@ -138,7 +140,7 @@ const double _kDividerThickness = 1.0;
|
||||
/// ),
|
||||
/// );
|
||||
/// },
|
||||
/// child: Text('CupertinoActionSheet'),
|
||||
/// child: const Text('CupertinoActionSheet'),
|
||||
/// ),
|
||||
/// ),
|
||||
/// );
|
||||
|
@ -57,10 +57,10 @@ import 'theme.dart';
|
||||
/// 
|
||||
///
|
||||
/// ```dart
|
||||
/// CupertinoApp(
|
||||
/// const CupertinoApp(
|
||||
/// home: CupertinoPageScaffold(
|
||||
/// navigationBar: CupertinoNavigationBar(
|
||||
/// middle: const Text('Home'),
|
||||
/// middle: Text('Home'),
|
||||
/// ),
|
||||
/// child: Center(child: Icon(CupertinoIcons.share)),
|
||||
/// ),
|
||||
@ -77,17 +77,17 @@ import 'theme.dart';
|
||||
/// CupertinoApp(
|
||||
/// routes: <String, WidgetBuilder>{
|
||||
/// '/': (BuildContext context) {
|
||||
/// return CupertinoPageScaffold(
|
||||
/// return const CupertinoPageScaffold(
|
||||
/// navigationBar: CupertinoNavigationBar(
|
||||
/// middle: const Text('Home Route'),
|
||||
/// middle: Text('Home Route'),
|
||||
/// ),
|
||||
/// child: Center(child: Icon(CupertinoIcons.share)),
|
||||
/// );
|
||||
/// },
|
||||
/// '/about': (BuildContext context) {
|
||||
/// return CupertinoPageScaffold(
|
||||
/// return const CupertinoPageScaffold(
|
||||
/// navigationBar: CupertinoNavigationBar(
|
||||
/// middle: const Text('About Route'),
|
||||
/// middle: Text('About Route'),
|
||||
/// ),
|
||||
/// child: Center(child: Icon(CupertinoIcons.share)),
|
||||
/// );
|
||||
@ -104,14 +104,14 @@ import 'theme.dart';
|
||||
/// 
|
||||
///
|
||||
/// ```dart
|
||||
/// CupertinoApp(
|
||||
/// const CupertinoApp(
|
||||
/// theme: CupertinoThemeData(
|
||||
/// brightness: Brightness.dark,
|
||||
/// primaryColor: CupertinoColors.systemOrange,
|
||||
/// ),
|
||||
/// home: CupertinoPageScaffold(
|
||||
/// navigationBar: CupertinoNavigationBar(
|
||||
/// middle: const Text('CupertinoApp Theme'),
|
||||
/// middle: Text('CupertinoApp Theme'),
|
||||
/// ),
|
||||
/// child: Center(child: Icon(CupertinoIcons.share)),
|
||||
/// ),
|
||||
@ -374,7 +374,7 @@ class CupertinoApp extends StatefulWidget {
|
||||
/// return WidgetsApp(
|
||||
/// actions: <Type, Action<Intent>>{
|
||||
/// ... WidgetsApp.defaultActions,
|
||||
/// ActivateAction: CallbackAction(
|
||||
/// ActivateAction: CallbackAction<Intent>(
|
||||
/// onInvoke: (Intent intent) {
|
||||
/// // Do something here...
|
||||
/// return null;
|
||||
|
@ -601,7 +601,7 @@ class CupertinoColors {
|
||||
/// CupertinoButton(
|
||||
/// child: child,
|
||||
/// // CupertinoDynamicColor works out of box in a CupertinoButton.
|
||||
/// color: CupertinoDynamicColor.withBrightness(
|
||||
/// color: const CupertinoDynamicColor.withBrightness(
|
||||
/// color: CupertinoColors.white,
|
||||
/// darkColor: CupertinoColors.black,
|
||||
/// ),
|
||||
|
@ -86,7 +86,7 @@ enum _ContextMenuLocation {
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Scaffold(
|
||||
/// body: Center(
|
||||
/// child: Container(
|
||||
/// child: SizedBox(
|
||||
/// width: 100,
|
||||
/// height: 100,
|
||||
/// child: CupertinoContextMenu(
|
||||
|
@ -41,7 +41,7 @@ const EdgeInsetsGeometry _kDefaultPadding =
|
||||
///
|
||||
/// ```dart
|
||||
/// class FlutterDemo extends StatefulWidget {
|
||||
/// FlutterDemo({Key? key}) : super(key: key);
|
||||
/// const FlutterDemo({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// _FlutterDemoState createState() => _FlutterDemoState();
|
||||
@ -55,20 +55,20 @@ const EdgeInsetsGeometry _kDefaultPadding =
|
||||
/// return CupertinoPageScaffold(
|
||||
/// child: Center(
|
||||
/// child: CupertinoFormSection(
|
||||
/// header: Text('SECTION 1'),
|
||||
/// header: const Text('SECTION 1'),
|
||||
/// children: <Widget>[
|
||||
/// CupertinoFormRow(
|
||||
/// child: CupertinoSwitch(
|
||||
/// value: this.toggleValue,
|
||||
/// onChanged: (value) {
|
||||
/// value: toggleValue,
|
||||
/// onChanged: (bool value) {
|
||||
/// setState(() {
|
||||
/// this.toggleValue = value;
|
||||
/// toggleValue = value;
|
||||
/// });
|
||||
/// },
|
||||
/// ),
|
||||
/// prefix: Text('Toggle'),
|
||||
/// helper: Text('Use your instincts'),
|
||||
/// error: toggleValue ? Text('Cannot be true') : null,
|
||||
/// prefix: const Text('Toggle'),
|
||||
/// helper: const Text('Use your instincts'),
|
||||
/// error: toggleValue ? const Text('Cannot be true') : null,
|
||||
/// ),
|
||||
/// ],
|
||||
/// ),
|
||||
|
@ -189,6 +189,7 @@ bool _isTransitionable(BuildContext context) {
|
||||
///
|
||||
///
|
||||
/// ```dart
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return CupertinoPageScaffold(
|
||||
/// navigationBar: CupertinoNavigationBar(
|
||||
@ -197,7 +198,7 @@ bool _isTransitionable(BuildContext context) {
|
||||
/// middle: const Text('Sample Code'),
|
||||
/// ),
|
||||
/// child: Column(
|
||||
/// children: [
|
||||
/// children: <Widget>[
|
||||
/// Container(height: 50, color: CupertinoColors.systemRed),
|
||||
/// Container(height: 50, color: CupertinoColors.systemGreen),
|
||||
/// Container(height: 50, color: CupertinoColors.systemBlue),
|
||||
|
@ -26,15 +26,16 @@ import 'theme.dart';
|
||||
/// ```dart
|
||||
/// int _count = 0;
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return CupertinoPageScaffold(
|
||||
/// // Uncomment to change the background color
|
||||
/// // backgroundColor: CupertinoColors.systemPink,
|
||||
/// navigationBar: CupertinoNavigationBar(
|
||||
/// navigationBar: const CupertinoNavigationBar(
|
||||
/// middle: const Text('Sample Code'),
|
||||
/// ),
|
||||
/// child: ListView(
|
||||
/// children: [
|
||||
/// children: <Widget>[
|
||||
/// CupertinoButton(
|
||||
/// onPressed: () => setState(() => _count++),
|
||||
/// child: const Icon(CupertinoIcons.add),
|
||||
|
@ -273,12 +273,12 @@ typedef RefreshCallback = Future<void> Function();
|
||||
/// adds a new item to the top of the list view.
|
||||
///
|
||||
/// ```dart
|
||||
/// List<Color> colors = [
|
||||
/// List<Color> colors = <Color>[
|
||||
/// CupertinoColors.systemYellow,
|
||||
/// CupertinoColors.systemOrange,
|
||||
/// CupertinoColors.systemPink
|
||||
/// ];
|
||||
/// List<Widget> items = [
|
||||
/// List<Widget> items = <Widget>[
|
||||
/// Container(color: CupertinoColors.systemPink, height: 100.0),
|
||||
/// Container(color: CupertinoColors.systemOrange, height: 100.0),
|
||||
/// Container(color: CupertinoColors.systemYellow, height: 100.0),
|
||||
@ -296,7 +296,7 @@ typedef RefreshCallback = Future<void> Function();
|
||||
/// refreshTriggerPullDistance: 100.0,
|
||||
/// refreshIndicatorExtent: 60.0,
|
||||
/// onRefresh: () async {
|
||||
/// await Future.delayed(Duration(milliseconds: 1000));
|
||||
/// await Future<void>.delayed(const Duration(milliseconds: 1000));
|
||||
/// setState(() {
|
||||
/// items.insert(0, Container(color: colors[items.length % 3], height: 100.0));
|
||||
/// });
|
||||
|
@ -1144,13 +1144,15 @@ class CupertinoModalPopupRoute<T> extends PopupRoute<T> {
|
||||
///
|
||||
/// ```dart
|
||||
/// void main() {
|
||||
/// runApp(MyApp());
|
||||
/// runApp(const MyApp());
|
||||
/// }
|
||||
///
|
||||
/// class MyApp extends StatelessWidget {
|
||||
/// const MyApp({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return CupertinoApp(
|
||||
/// return const CupertinoApp(
|
||||
/// restorationScopeId: 'app',
|
||||
/// home: MyHomePage(),
|
||||
/// );
|
||||
@ -1158,13 +1160,15 @@ class CupertinoModalPopupRoute<T> extends PopupRoute<T> {
|
||||
/// }
|
||||
///
|
||||
/// class MyHomePage extends StatelessWidget {
|
||||
/// static Route _modalBuilder(BuildContext context, Object? arguments) {
|
||||
/// return CupertinoModalPopupRoute(
|
||||
/// const MyHomePage({Key? key}) : super(key: key);
|
||||
///
|
||||
/// static Route<void> _modalBuilder(BuildContext context, Object? arguments) {
|
||||
/// return CupertinoModalPopupRoute<void>(
|
||||
/// builder: (BuildContext context) {
|
||||
/// return CupertinoActionSheet(
|
||||
/// title: const Text('Title'),
|
||||
/// message: const Text('Message'),
|
||||
/// actions: [
|
||||
/// actions: <CupertinoActionSheetAction>[
|
||||
/// CupertinoActionSheetAction(
|
||||
/// child: const Text('Action One'),
|
||||
/// onPressed: () {
|
||||
@ -1306,13 +1310,15 @@ Widget _buildCupertinoDialogTransitions(BuildContext context, Animation<double>
|
||||
///
|
||||
/// ```dart
|
||||
/// void main() {
|
||||
/// runApp(MyApp());
|
||||
/// runApp(const MyApp());
|
||||
/// }
|
||||
///
|
||||
/// class MyApp extends StatelessWidget {
|
||||
/// const MyApp({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return CupertinoApp(
|
||||
/// return const CupertinoApp(
|
||||
/// restorationScopeId: 'app',
|
||||
/// home: MyHomePage(),
|
||||
/// );
|
||||
@ -1320,6 +1326,8 @@ Widget _buildCupertinoDialogTransitions(BuildContext context, Animation<double>
|
||||
/// }
|
||||
///
|
||||
/// class MyHomePage extends StatelessWidget {
|
||||
/// const MyHomePage({Key? key}) : super(key: key);
|
||||
///
|
||||
/// static Route<Object?> _dialogBuilder(BuildContext context, Object? arguments) {
|
||||
/// return CupertinoDialogRoute<void>(
|
||||
/// context: context,
|
||||
|
@ -25,6 +25,8 @@ import 'text_field.dart';
|
||||
///
|
||||
/// ```dart
|
||||
/// class MyPrefilledSearch extends StatefulWidget {
|
||||
/// const MyPrefilledSearch({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// _MyPrefilledSearchState createState() => _MyPrefilledSearchState();
|
||||
/// }
|
||||
@ -54,6 +56,8 @@ import 'text_field.dart';
|
||||
///
|
||||
/// ```dart
|
||||
/// class MyPrefilledSearch extends StatefulWidget {
|
||||
/// const MyPrefilledSearch({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// _MyPrefilledSearchState createState() => _MyPrefilledSearchState();
|
||||
/// }
|
||||
@ -62,11 +66,11 @@ import 'text_field.dart';
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return CupertinoSearchTextField(
|
||||
/// onChanged: (value) {
|
||||
/// print("The text has changed to: " + value);
|
||||
/// onChanged: (String value) {
|
||||
/// print('The text has changed to: $value');
|
||||
/// },
|
||||
/// onSubmitted: (value) {
|
||||
/// print("Submitted text: " + value);
|
||||
/// onSubmitted: (String value) {
|
||||
/// print('Submitted text: $value');
|
||||
/// },
|
||||
/// );
|
||||
/// }
|
||||
|
@ -127,12 +127,14 @@ class CupertinoSegmentedControl<T extends Object> extends StatefulWidget {
|
||||
///
|
||||
/// ```dart
|
||||
/// class SegmentedControlExample extends StatefulWidget {
|
||||
/// const SegmentedControlExample({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// State createState() => SegmentedControlExampleState();
|
||||
/// }
|
||||
///
|
||||
/// class SegmentedControlExampleState extends State<SegmentedControlExample> {
|
||||
/// final Map<int, Widget> children = const {
|
||||
/// final Map<int, Widget> children = const <int, Widget>{
|
||||
/// 0: Text('Child 1'),
|
||||
/// 1: Text('Child 2'),
|
||||
/// };
|
||||
@ -141,16 +143,14 @@ class CupertinoSegmentedControl<T extends Object> extends StatefulWidget {
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Container(
|
||||
/// child: CupertinoSegmentedControl<int>(
|
||||
/// children: children,
|
||||
/// onValueChanged: (int newValue) {
|
||||
/// setState(() {
|
||||
/// currentValue = newValue;
|
||||
/// });
|
||||
/// },
|
||||
/// groupValue: currentValue,
|
||||
/// ),
|
||||
/// return CupertinoSegmentedControl<int>(
|
||||
/// children: children,
|
||||
/// onValueChanged: (int newValue) {
|
||||
/// setState(() {
|
||||
/// currentValue = newValue;
|
||||
/// });
|
||||
/// },
|
||||
/// groupValue: currentValue,
|
||||
/// );
|
||||
/// }
|
||||
/// }
|
||||
|
@ -352,12 +352,14 @@ class CupertinoSlidingSegmentedControl<T> extends StatefulWidget {
|
||||
///
|
||||
/// ```dart
|
||||
/// class SegmentedControlExample extends StatefulWidget {
|
||||
/// const SegmentedControlExample({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// State createState() => SegmentedControlExampleState();
|
||||
/// }
|
||||
///
|
||||
/// class SegmentedControlExampleState extends State<SegmentedControlExample> {
|
||||
/// final Map<int, Widget> children = const {
|
||||
/// final Map<int, Widget> children = const <int, Widget>{
|
||||
/// 0: Text('Child 1'),
|
||||
/// 1: Text('Child 2'),
|
||||
/// };
|
||||
@ -366,16 +368,14 @@ class CupertinoSlidingSegmentedControl<T> extends StatefulWidget {
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Container(
|
||||
/// child: CupertinoSlidingSegmentedControl<int>(
|
||||
/// children: children,
|
||||
/// onValueChanged: (int? newValue) {
|
||||
/// setState(() {
|
||||
/// currentValue = newValue;
|
||||
/// });
|
||||
/// },
|
||||
/// groupValue: currentValue,
|
||||
/// ),
|
||||
/// return CupertinoSlidingSegmentedControl<int>(
|
||||
/// children: children,
|
||||
/// onValueChanged: (int? newValue) {
|
||||
/// setState(() {
|
||||
/// currentValue = newValue;
|
||||
/// });
|
||||
/// },
|
||||
/// groupValue: currentValue,
|
||||
/// );
|
||||
/// }
|
||||
/// }
|
||||
|
@ -35,7 +35,7 @@ import 'thumb_painter.dart';
|
||||
/// ```dart
|
||||
/// MergeSemantics(
|
||||
/// child: ListTile(
|
||||
/// title: Text('Lights'),
|
||||
/// title: const Text('Lights'),
|
||||
/// trailing: CupertinoSwitch(
|
||||
/// value: _lights,
|
||||
/// onChanged: (bool value) { setState(() { _lights = value; }); },
|
||||
|
@ -20,6 +20,8 @@ import 'theme.dart';
|
||||
///
|
||||
/// ```dart
|
||||
/// class MyCupertinoTabScaffoldPage extends StatefulWidget {
|
||||
/// const MyCupertinoTabScaffoldPage({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// _CupertinoTabScaffoldPageState createState() => _CupertinoTabScaffoldPageState();
|
||||
/// }
|
||||
@ -31,7 +33,7 @@ import 'theme.dart';
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return CupertinoTabScaffold(
|
||||
/// tabBar: CupertinoTabBar(
|
||||
/// items: <BottomNavigationBarItem> [
|
||||
/// items: const <BottomNavigationBarItem> [
|
||||
/// // ...
|
||||
/// ],
|
||||
/// ),
|
||||
@ -143,7 +145,7 @@ class CupertinoTabController extends ChangeNotifier {
|
||||
/// ```dart
|
||||
/// CupertinoTabScaffold(
|
||||
/// tabBar: CupertinoTabBar(
|
||||
/// items: <BottomNavigationBarItem> [
|
||||
/// items: const <BottomNavigationBarItem> [
|
||||
/// // ...
|
||||
/// ],
|
||||
/// ),
|
||||
|
@ -149,6 +149,8 @@ class _CupertinoTextFieldSelectionGestureDetectorBuilder extends TextSelectionGe
|
||||
///
|
||||
/// ```dart
|
||||
/// class MyPrefilledText extends StatefulWidget {
|
||||
/// const MyPrefilledText({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// _MyPrefilledTextState createState() => _MyPrefilledTextState();
|
||||
/// }
|
||||
|
@ -58,7 +58,7 @@ import 'text_field.dart';
|
||||
///
|
||||
/// ```dart
|
||||
/// CupertinoTextFormFieldRow(
|
||||
/// prefix: Text('Username'),
|
||||
/// prefix: const Text('Username'),
|
||||
/// onSaved: (String? value) {
|
||||
/// // This optional block of code can be used to run
|
||||
/// // code when the user saves the form.
|
||||
@ -79,6 +79,7 @@ import 'text_field.dart';
|
||||
/// ```
|
||||
///
|
||||
/// ```dart
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return CupertinoPageScaffold(
|
||||
/// child: Center(
|
||||
@ -88,12 +89,12 @@ import 'text_field.dart';
|
||||
/// Form.of(primaryFocus!.context!)?.save();
|
||||
/// },
|
||||
/// child: CupertinoFormSection.insetGrouped(
|
||||
/// header: Text('SECTION 1'),
|
||||
/// header: const Text('SECTION 1'),
|
||||
/// children: List<Widget>.generate(5, (int index) {
|
||||
/// return CupertinoTextFormFieldRow(
|
||||
/// prefix: Text('Enter text'),
|
||||
/// prefix: const Text('Enter text'),
|
||||
/// placeholder: 'Enter text',
|
||||
/// validator: (value) {
|
||||
/// validator: (String? value) {
|
||||
/// if (value == null || value.isEmpty) {
|
||||
/// return 'Please enter a value';
|
||||
/// }
|
||||
|
@ -1763,8 +1763,8 @@ abstract class DiagnosticsNode {
|
||||
/// of an actual property of the object:
|
||||
///
|
||||
/// ```dart
|
||||
/// var table = MessageProperty('table size', '$columns\u00D7$rows');
|
||||
/// var usefulness = MessageProperty('usefulness ratio', 'no metrics collected yet (never painted)');
|
||||
/// MessageProperty table = MessageProperty('table size', '$columns\u00D7$rows');
|
||||
/// MessageProperty usefulness = MessageProperty('usefulness ratio', 'no metrics collected yet (never painted)');
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
/// {@tool snippet}
|
||||
@ -1773,7 +1773,7 @@ abstract class DiagnosticsNode {
|
||||
/// concrete value that is a string:
|
||||
///
|
||||
/// ```dart
|
||||
/// var name = StringProperty('name', _name);
|
||||
/// StringProperty name = StringProperty('name', _name);
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
///
|
||||
@ -3068,7 +3068,7 @@ class DiagnosticPropertiesBuilder {
|
||||
}
|
||||
|
||||
// Examples can assume:
|
||||
// class ExampleSuperclass with Diagnosticable { late String message; late double stepWidth; late double scale; late double paintExtent; late double hitTestExtent; late double paintExtend; late double maxWidth; late bool primary; late double progress; late int maxLines; late Duration duration; late int depth; late dynamic boxShadow; late dynamic style; late bool hasSize; late Matrix4 transform; Map<Listenable, VoidCallback>? handles; late Color color; late bool obscureText; late ImageRepeat repeat; late Size size; late Widget widget; late bool isCurrent; late bool keepAlive; late TextAlign textAlign; }
|
||||
// class ExampleSuperclass with Diagnosticable { late String message; late double stepWidth; late double scale; late double paintExtent; late double hitTestExtent; late double paintExtend; late double maxWidth; late bool primary; late double progress; late int maxLines; late Duration duration; late int depth; Iterable<BoxShadow>? boxShadow; late DiagnosticsTreeStyle style; late bool hasSize; late Matrix4 transform; Map<Listenable, VoidCallback>? handles; late Color color; late bool obscureText; late ImageRepeat repeat; late Size size; late Widget widget; late bool isCurrent; late bool keepAlive; late TextAlign textAlign; }
|
||||
|
||||
/// A mixin class for providing string and [DiagnosticsNode] debug
|
||||
/// representations describing the properties of an object.
|
||||
|
@ -71,7 +71,7 @@ enum _LicenseEntryWithLineBreaksParserState {
|
||||
/// ```dart
|
||||
/// void initMyLibrary() {
|
||||
/// LicenseRegistry.addLicense(() async* {
|
||||
/// yield LicenseEntryWithLineBreaks(<String>['my_library'], '''
|
||||
/// yield const LicenseEntryWithLineBreaks(<String>['my_library'], '''
|
||||
/// Copyright 2016 The Sample Authors. All rights reserved.
|
||||
///
|
||||
/// Redistribution and use in source and binary forms, with or without
|
||||
|
@ -52,7 +52,7 @@ import 'theme.dart';
|
||||
/// Widget build(BuildContext context) {
|
||||
/// final TextStyle textStyle = Theme.of(context).textTheme.bodyText2!;
|
||||
/// final List<Widget> aboutBoxChildren = <Widget>[
|
||||
/// SizedBox(height: 24),
|
||||
/// const SizedBox(height: 24),
|
||||
/// RichText(
|
||||
/// text: TextSpan(
|
||||
/// children: <TextSpan>[
|
||||
@ -77,14 +77,14 @@ import 'theme.dart';
|
||||
///
|
||||
/// return Scaffold(
|
||||
/// appBar: AppBar(
|
||||
/// title: Text('Show About Example'),
|
||||
/// title: const Text('Show About Example'),
|
||||
/// ),
|
||||
/// drawer: Drawer(
|
||||
/// child: SingleChildScrollView(
|
||||
/// child: SafeArea(
|
||||
/// child: AboutListTile(
|
||||
/// icon: Icon(Icons.info),
|
||||
/// applicationIcon: FlutterLogo(),
|
||||
/// icon: const Icon(Icons.info),
|
||||
/// applicationIcon: const FlutterLogo(),
|
||||
/// applicationName: 'Show About Example',
|
||||
/// applicationVersion: 'August 2019',
|
||||
/// applicationLegalese: '\u{a9} 2014 The Flutter Authors',
|
||||
@ -95,11 +95,11 @@ import 'theme.dart';
|
||||
/// ),
|
||||
/// body: Center(
|
||||
/// child: ElevatedButton(
|
||||
/// child: Text('Show About Example'),
|
||||
/// child: const Text('Show About Example'),
|
||||
/// onPressed: () {
|
||||
/// showAboutDialog(
|
||||
/// context: context,
|
||||
/// applicationIcon: FlutterLogo(),
|
||||
/// applicationIcon: const FlutterLogo(),
|
||||
/// applicationName: 'Show About Example',
|
||||
/// applicationVersion: 'August 2019',
|
||||
/// applicationLegalese: '\u{a9} 2014 The Flutter Authors',
|
||||
|
@ -613,7 +613,7 @@ class MaterialApp extends StatefulWidget {
|
||||
/// return WidgetsApp(
|
||||
/// actions: <Type, Action<Intent>>{
|
||||
/// ... WidgetsApp.defaultActions,
|
||||
/// ActivateAction: CallbackAction(
|
||||
/// ActivateAction: CallbackAction<Intent>(
|
||||
/// onInvoke: (Intent intent) {
|
||||
/// // Do something here...
|
||||
/// return null;
|
||||
|
@ -115,7 +115,7 @@ class _ToolbarContainerLayout extends SingleChildLayoutDelegate {
|
||||
/// icon: const Icon(Icons.navigate_next),
|
||||
/// tooltip: 'Go to the next page',
|
||||
/// onPressed: () {
|
||||
/// Navigator.push(context, MaterialPageRoute(
|
||||
/// Navigator.push(context, MaterialPageRoute<void>(
|
||||
/// builder: (BuildContext context) {
|
||||
/// return Scaffold(
|
||||
/// appBar: AppBar(
|
||||
@ -317,10 +317,10 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
|
||||
/// primary: true,
|
||||
/// slivers: <Widget>[
|
||||
/// SliverAppBar(
|
||||
/// title: Text('Hello World'),
|
||||
/// title: const Text('Hello World'),
|
||||
/// actions: <Widget>[
|
||||
/// IconButton(
|
||||
/// icon: Icon(Icons.shopping_cart),
|
||||
/// icon: const Icon(Icons.shopping_cart),
|
||||
/// tooltip: 'Open shopping cart',
|
||||
/// onPressed: () {
|
||||
/// // handle the press
|
||||
@ -1273,7 +1273,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
|
||||
/// ```
|
||||
///
|
||||
/// ```dart
|
||||
/// void main() => runApp(MyApp());
|
||||
/// void main() => runApp(const MyApp());
|
||||
///
|
||||
/// class MyApp extends StatefulWidget {
|
||||
/// const MyApp({Key? key}) : super(key: key);
|
||||
@ -1296,20 +1296,20 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
|
||||
/// body: CustomScrollView(
|
||||
/// slivers: <Widget>[
|
||||
/// SliverAppBar(
|
||||
/// pinned: this._pinned,
|
||||
/// snap: this._snap,
|
||||
/// floating: this._floating,
|
||||
/// pinned: _pinned,
|
||||
/// snap: _snap,
|
||||
/// floating: _floating,
|
||||
/// expandedHeight: 160.0,
|
||||
/// flexibleSpace: FlexibleSpaceBar(
|
||||
/// title: const Text("SliverAppBar"),
|
||||
/// flexibleSpace: const FlexibleSpaceBar(
|
||||
/// title: Text('SliverAppBar'),
|
||||
/// background: FlutterLogo(),
|
||||
/// ),
|
||||
/// ),
|
||||
/// SliverToBoxAdapter(
|
||||
/// const SliverToBoxAdapter(
|
||||
/// child: Center(
|
||||
/// child: Container(
|
||||
/// child: SizedBox(
|
||||
/// height: 2000,
|
||||
/// child: const Text("Scroll to see SliverAppBar in effect ."),
|
||||
/// child: const Text('Scroll to see SliverAppBar in effect .'),
|
||||
/// ),
|
||||
/// ),
|
||||
/// ),
|
||||
@ -1325,10 +1325,10 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
|
||||
/// Switch(
|
||||
/// onChanged: (bool val) {
|
||||
/// setState(() {
|
||||
/// this._pinned = val;
|
||||
/// _pinned = val;
|
||||
/// });
|
||||
/// },
|
||||
/// value: this._pinned,
|
||||
/// value: _pinned,
|
||||
/// ),
|
||||
/// ],
|
||||
/// ),
|
||||
@ -1338,12 +1338,12 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
|
||||
/// Switch(
|
||||
/// onChanged: (bool val) {
|
||||
/// setState(() {
|
||||
/// this._snap = val;
|
||||
/// _snap = val;
|
||||
/// //Snapping only applies when the app bar is floating.
|
||||
/// this._floating = this._floating || val;
|
||||
/// _floating = _floating || val;
|
||||
/// });
|
||||
/// },
|
||||
/// value: this._snap,
|
||||
/// value: _snap,
|
||||
/// ),
|
||||
/// ],
|
||||
/// ),
|
||||
@ -1353,15 +1353,15 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
|
||||
/// Switch(
|
||||
/// onChanged: (bool val) {
|
||||
/// setState(() {
|
||||
/// this._floating = val;
|
||||
/// if (this._snap == true) {
|
||||
/// if (this._floating != true) {
|
||||
/// this._snap = false;
|
||||
/// _floating = val;
|
||||
/// if (_snap == true) {
|
||||
/// if (_floating != true) {
|
||||
/// _snap = false;
|
||||
/// }
|
||||
/// }
|
||||
/// });
|
||||
/// },
|
||||
/// value: this._floating,
|
||||
/// value: _floating,
|
||||
/// ),
|
||||
/// ],
|
||||
/// ),
|
||||
|
@ -57,6 +57,7 @@ import 'text_form_field.dart';
|
||||
/// ```
|
||||
///
|
||||
/// ```dart
|
||||
/// @immutable
|
||||
/// class User {
|
||||
/// const User({
|
||||
/// required this.email,
|
||||
@ -73,8 +74,9 @@ import 'text_form_field.dart';
|
||||
///
|
||||
/// @override
|
||||
/// bool operator ==(Object other) {
|
||||
/// if (other.runtimeType != runtimeType)
|
||||
/// if (other.runtimeType != runtimeType) {
|
||||
/// return false;
|
||||
/// }
|
||||
/// return other is User
|
||||
/// && other.name == name
|
||||
/// && other.email == email;
|
||||
@ -85,9 +87,9 @@ import 'text_form_field.dart';
|
||||
/// }
|
||||
///
|
||||
/// class AutocompleteBasicUserExample extends StatelessWidget {
|
||||
/// AutocompleteBasicUserExample({Key? key}) : super(key: key);
|
||||
/// const AutocompleteBasicUserExample({Key? key}) : super(key: key);
|
||||
///
|
||||
/// static final List<User> _userOptions = <User>[
|
||||
/// static const List<User> _userOptions = <User>[
|
||||
/// User(name: 'Alice', email: 'alice@example.com'),
|
||||
/// User(name: 'Bob', email: 'bob@example.com'),
|
||||
/// User(name: 'Charlie', email: 'charlie123@gmail.com'),
|
||||
|
@ -27,7 +27,7 @@ import 'theme.dart';
|
||||
/// color: Colors.white,
|
||||
/// child: bottomAppBarContents,
|
||||
/// ),
|
||||
/// floatingActionButton: FloatingActionButton(onPressed: null),
|
||||
/// floatingActionButton: const FloatingActionButton(onPressed: null),
|
||||
/// )
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
@ -42,20 +42,20 @@ import 'theme.dart';
|
||||
///
|
||||
/// ```dart
|
||||
/// void main() {
|
||||
/// runApp(BottomAppBarDemo());
|
||||
/// runApp(const BottomAppBarDemo());
|
||||
/// }
|
||||
///
|
||||
/// class BottomAppBarDemo extends StatefulWidget {
|
||||
/// const BottomAppBarDemo();
|
||||
/// const BottomAppBarDemo({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// State createState() => _BottomAppBarDemoState();
|
||||
/// }
|
||||
///
|
||||
/// class _BottomAppBarDemoState extends State<BottomAppBarDemo> {
|
||||
/// var _showFab = true;
|
||||
/// var _showNotch = true;
|
||||
/// var _fabLocation = FloatingActionButtonLocation.endDocked;
|
||||
/// bool _showFab = true;
|
||||
/// bool _showNotch = true;
|
||||
/// FloatingActionButtonLocation _fabLocation = FloatingActionButtonLocation.endDocked;
|
||||
///
|
||||
/// void _onShowNotchChanged(bool value) {
|
||||
/// setState(() {
|
||||
@ -69,9 +69,9 @@ import 'theme.dart';
|
||||
/// });
|
||||
/// }
|
||||
///
|
||||
/// void _onFabLocationChanged(dynamic value) {
|
||||
/// void _onFabLocationChanged(FloatingActionButtonLocation? value) {
|
||||
/// setState(() {
|
||||
/// _fabLocation = value;
|
||||
/// _fabLocation = value ?? FloatingActionButtonLocation.endDocked;
|
||||
/// });
|
||||
/// }
|
||||
///
|
||||
@ -81,55 +81,47 @@ import 'theme.dart';
|
||||
/// home: Scaffold(
|
||||
/// appBar: AppBar(
|
||||
/// automaticallyImplyLeading: false,
|
||||
/// title: Text("Bottom App Bar Demo"),
|
||||
/// title: const Text('Bottom App Bar Demo'),
|
||||
/// ),
|
||||
/// body: ListView(
|
||||
/// padding: const EdgeInsets.only(bottom: 88),
|
||||
/// children: [
|
||||
/// children: <Widget>[
|
||||
/// SwitchListTile(
|
||||
/// title: Text(
|
||||
/// "Floating Action Button",
|
||||
/// title: const Text(
|
||||
/// 'Floating Action Button',
|
||||
/// ),
|
||||
/// value: _showFab,
|
||||
/// onChanged: _onShowFabChanged,
|
||||
/// ),
|
||||
/// SwitchListTile(
|
||||
/// title: Text("Notch"),
|
||||
/// title: const Text('Notch'),
|
||||
/// value: _showNotch,
|
||||
/// onChanged: _onShowNotchChanged,
|
||||
/// ),
|
||||
/// Padding(
|
||||
/// padding: const EdgeInsets.all(16),
|
||||
/// child: Text("Floating action button position"),
|
||||
/// const Padding(
|
||||
/// padding: EdgeInsets.all(16),
|
||||
/// child: Text('Floating action button position'),
|
||||
/// ),
|
||||
/// RadioListTile<FloatingActionButtonLocation>(
|
||||
/// title: Text(
|
||||
/// "Docked - End",
|
||||
/// ),
|
||||
/// title: const Text('Docked - End'),
|
||||
/// value: FloatingActionButtonLocation.endDocked,
|
||||
/// groupValue: _fabLocation,
|
||||
/// onChanged: _onFabLocationChanged,
|
||||
/// ),
|
||||
/// RadioListTile<FloatingActionButtonLocation>(
|
||||
/// title: Text(
|
||||
/// "Docked - Center",
|
||||
/// ),
|
||||
/// title: const Text('Docked - Center'),
|
||||
/// value: FloatingActionButtonLocation.centerDocked,
|
||||
/// groupValue: _fabLocation,
|
||||
/// onChanged: _onFabLocationChanged,
|
||||
/// ),
|
||||
/// RadioListTile<FloatingActionButtonLocation>(
|
||||
/// title: Text(
|
||||
/// "Floating - End",
|
||||
/// ),
|
||||
/// title: const Text('Floating - End'),
|
||||
/// value: FloatingActionButtonLocation.endFloat,
|
||||
/// groupValue: _fabLocation,
|
||||
/// onChanged: _onFabLocationChanged,
|
||||
/// ),
|
||||
/// RadioListTile<FloatingActionButtonLocation>(
|
||||
/// title: Text(
|
||||
/// "Floating - Center",
|
||||
/// ),
|
||||
/// title: const Text('Floating - Center'),
|
||||
/// value: FloatingActionButtonLocation.centerFloat,
|
||||
/// groupValue: _fabLocation,
|
||||
/// onChanged: _onFabLocationChanged,
|
||||
@ -140,7 +132,7 @@ import 'theme.dart';
|
||||
/// ? FloatingActionButton(
|
||||
/// onPressed: () {},
|
||||
/// child: const Icon(Icons.add),
|
||||
/// tooltip: "Create",
|
||||
/// tooltip: 'Create',
|
||||
/// )
|
||||
/// : null,
|
||||
/// floatingActionButtonLocation: _fabLocation,
|
||||
@ -160,9 +152,9 @@ import 'theme.dart';
|
||||
/// });
|
||||
///
|
||||
/// final FloatingActionButtonLocation fabLocation;
|
||||
/// final dynamic shape;
|
||||
/// final NotchedShape? shape;
|
||||
///
|
||||
/// static final centerLocations = <FloatingActionButtonLocation>[
|
||||
/// static final List<FloatingActionButtonLocation> centerLocations = <FloatingActionButtonLocation>[
|
||||
/// FloatingActionButtonLocation.centerDocked,
|
||||
/// FloatingActionButtonLocation.centerFloat,
|
||||
/// ];
|
||||
@ -175,7 +167,7 @@ import 'theme.dart';
|
||||
/// child: IconTheme(
|
||||
/// data: IconThemeData(color: Theme.of(context).colorScheme.onPrimary),
|
||||
/// child: Row(
|
||||
/// children: [
|
||||
/// children: <Widget>[
|
||||
/// IconButton(
|
||||
/// tooltip: 'Open navigation menu',
|
||||
/// icon: const Icon(Icons.menu),
|
||||
@ -183,12 +175,12 @@ import 'theme.dart';
|
||||
/// ),
|
||||
/// if (centerLocations.contains(fabLocation)) const Spacer(),
|
||||
/// IconButton(
|
||||
/// tooltip: "Search",
|
||||
/// tooltip: 'Search',
|
||||
/// icon: const Icon(Icons.search),
|
||||
/// onPressed: () {},
|
||||
/// ),
|
||||
/// IconButton(
|
||||
/// tooltip: "Favorite",
|
||||
/// tooltip: 'Favorite',
|
||||
/// icon: const Icon(Icons.favorite),
|
||||
/// onPressed: () {},
|
||||
/// ),
|
||||
|
@ -78,7 +78,7 @@ import 'theme.dart';
|
||||
/// onTap: () {
|
||||
/// print('Card tapped.');
|
||||
/// },
|
||||
/// child: Container(
|
||||
/// child: const SizedBox(
|
||||
/// width: 300,
|
||||
/// height: 100,
|
||||
/// child: Text('A card that can be tapped'),
|
||||
|
@ -39,6 +39,8 @@ import 'toggleable.dart';
|
||||
///
|
||||
/// ```dart
|
||||
/// bool isChecked = false;
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// Color getColor(Set<MaterialState> states) {
|
||||
/// const Set<MaterialState> interactiveStates = <MaterialState>{
|
||||
@ -55,9 +57,9 @@ import 'toggleable.dart';
|
||||
/// checkColor: Colors.white,
|
||||
/// fillColor: MaterialStateProperty.resolveWith(getColor),
|
||||
/// value: isChecked,
|
||||
/// onChanged: (val) {
|
||||
/// onChanged: (bool? value) {
|
||||
/// setState(() {
|
||||
/// isChecked = !isChecked;
|
||||
/// isChecked = value!;
|
||||
/// });
|
||||
/// },
|
||||
/// );
|
||||
|
@ -99,11 +99,12 @@ import 'theme_data.dart';
|
||||
/// ```dart preamble
|
||||
/// class LinkedLabelCheckbox extends StatelessWidget {
|
||||
/// const LinkedLabelCheckbox({
|
||||
/// Key? key,
|
||||
/// required this.label,
|
||||
/// required this.padding,
|
||||
/// required this.value,
|
||||
/// required this.onChanged,
|
||||
/// });
|
||||
/// }) : super(key: key);
|
||||
///
|
||||
/// final String label;
|
||||
/// final EdgeInsets padding;
|
||||
@ -120,7 +121,7 @@ import 'theme_data.dart';
|
||||
/// child: RichText(
|
||||
/// text: TextSpan(
|
||||
/// text: label,
|
||||
/// style: TextStyle(
|
||||
/// style: const TextStyle(
|
||||
/// color: Colors.blueAccent,
|
||||
/// decoration: TextDecoration.underline,
|
||||
/// ),
|
||||
@ -179,11 +180,12 @@ import 'theme_data.dart';
|
||||
/// ```dart preamble
|
||||
/// class LabeledCheckbox extends StatelessWidget {
|
||||
/// const LabeledCheckbox({
|
||||
/// Key? key,
|
||||
/// required this.label,
|
||||
/// required this.padding,
|
||||
/// required this.value,
|
||||
/// required this.onChanged,
|
||||
/// });
|
||||
/// }) : super(key: key);
|
||||
///
|
||||
/// final String label;
|
||||
/// final EdgeInsets padding;
|
||||
|
@ -232,6 +232,8 @@ abstract class DeletableChipAttributes {
|
||||
/// }
|
||||
///
|
||||
/// class CastList extends StatefulWidget {
|
||||
/// const CastList({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// State createState() => CastListState();
|
||||
/// }
|
||||
@ -275,7 +277,7 @@ abstract class DeletableChipAttributes {
|
||||
/// ```dart
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return CastList();
|
||||
/// return const CastList();
|
||||
/// }
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
@ -383,6 +385,8 @@ abstract class SelectableChipAttributes {
|
||||
///
|
||||
/// ```dart
|
||||
/// class Wood extends StatefulWidget {
|
||||
/// const Wood({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// State<StatefulWidget> createState() => WoodState();
|
||||
/// }
|
||||
@ -519,6 +523,8 @@ abstract class TappableChipAttributes {
|
||||
///
|
||||
/// ```dart
|
||||
/// class Blacksmith extends StatelessWidget {
|
||||
/// const Blacksmith({Key? key}) : super(key: key);
|
||||
///
|
||||
/// void startHammering() {
|
||||
/// print('bang bang bang');
|
||||
/// }
|
||||
@ -567,9 +573,9 @@ abstract class TappableChipAttributes {
|
||||
/// Chip(
|
||||
/// avatar: CircleAvatar(
|
||||
/// backgroundColor: Colors.grey.shade800,
|
||||
/// child: Text('AB'),
|
||||
/// child: const Text('AB'),
|
||||
/// ),
|
||||
/// label: Text('Aaron Burr'),
|
||||
/// label: const Text('Aaron Burr'),
|
||||
/// )
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
@ -716,9 +722,9 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri
|
||||
/// InputChip(
|
||||
/// avatar: CircleAvatar(
|
||||
/// backgroundColor: Colors.grey.shade800,
|
||||
/// child: Text('AB'),
|
||||
/// child: const Text('AB'),
|
||||
/// ),
|
||||
/// label: Text('Aaron Burr'),
|
||||
/// label: const Text('Aaron Burr'),
|
||||
/// onPressed: () {
|
||||
/// print('I am the one thing in life.');
|
||||
/// }
|
||||
@ -916,6 +922,8 @@ class InputChip extends StatelessWidget
|
||||
///
|
||||
/// ```dart
|
||||
/// class MyThreeOptions extends StatefulWidget {
|
||||
/// const MyThreeOptions({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// _MyThreeOptionsState createState() => _MyThreeOptionsState();
|
||||
/// }
|
||||
@ -1106,6 +1114,8 @@ class ChoiceChip extends StatelessWidget
|
||||
/// }
|
||||
///
|
||||
/// class CastFilter extends StatefulWidget {
|
||||
/// const CastFilter({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// State createState() => CastFilterState();
|
||||
/// }
|
||||
@ -1117,7 +1127,7 @@ class ChoiceChip extends StatelessWidget
|
||||
/// const ActorFilterEntry('Eliza Hamilton', 'EH'),
|
||||
/// const ActorFilterEntry('James Madison', 'JM'),
|
||||
/// ];
|
||||
/// List<String> _filters = <String>[];
|
||||
/// final List<String> _filters = <String>[];
|
||||
///
|
||||
/// Iterable<Widget> get actorWidgets sync* {
|
||||
/// for (final ActorFilterEntry actor in _cast) {
|
||||
@ -1331,11 +1341,11 @@ class FilterChip extends StatelessWidget
|
||||
/// ActionChip(
|
||||
/// avatar: CircleAvatar(
|
||||
/// backgroundColor: Colors.grey.shade800,
|
||||
/// child: Text('AB'),
|
||||
/// child: const Text('AB'),
|
||||
/// ),
|
||||
/// label: Text('Aaron Burr'),
|
||||
/// label: const Text('Aaron Burr'),
|
||||
/// onPressed: () {
|
||||
/// print("If you stand for nothing, Burr, what’ll you fall for?");
|
||||
/// print('If you stand for nothing, Burr, what’ll you fall for?');
|
||||
/// }
|
||||
/// )
|
||||
/// ```
|
||||
|
@ -65,6 +65,8 @@ class ChipTheme extends InheritedTheme {
|
||||
///
|
||||
/// ```dart
|
||||
/// class Spaceship extends StatelessWidget {
|
||||
/// const Spaceship({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return ChipTheme(
|
||||
@ -122,6 +124,8 @@ class ChipTheme extends InheritedTheme {
|
||||
///
|
||||
/// ```dart
|
||||
/// class CarColor extends StatefulWidget {
|
||||
/// const CarColor({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// State createState() => _CarColorState();
|
||||
/// }
|
||||
@ -134,7 +138,7 @@ class ChipTheme extends InheritedTheme {
|
||||
/// return ChipTheme(
|
||||
/// data: ChipTheme.of(context).copyWith(backgroundColor: Colors.lightBlue),
|
||||
/// child: ChoiceChip(
|
||||
/// label: Text('Light Blue'),
|
||||
/// label: const Text('Light Blue'),
|
||||
/// onSelected: (bool value) {
|
||||
/// setState(() {
|
||||
/// _color = value ? Colors.lightBlue : Colors.red;
|
||||
|
@ -46,7 +46,7 @@ import 'theme.dart';
|
||||
/// ```dart
|
||||
/// CircleAvatar(
|
||||
/// backgroundColor: Colors.brown.shade800,
|
||||
/// child: Text('AH'),
|
||||
/// child: const Text('AH'),
|
||||
/// )
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
|
@ -373,7 +373,7 @@ class DataCell {
|
||||
///
|
||||
/// ```dart
|
||||
/// static const int numItems = 10;
|
||||
/// List<bool> selected = List<bool>.generate(numItems, (index) => false);
|
||||
/// List<bool> selected = List<bool>.generate(numItems, (int index) => false);
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
@ -387,17 +387,18 @@ class DataCell {
|
||||
/// ],
|
||||
/// rows: List<DataRow>.generate(
|
||||
/// numItems,
|
||||
/// (index) => DataRow(
|
||||
/// (int index) => DataRow(
|
||||
/// color: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
/// // All rows will have the same selected color.
|
||||
/// if (states.contains(MaterialState.selected))
|
||||
/// return Theme.of(context).colorScheme.primary.withOpacity(0.08);
|
||||
/// // Even rows will have a grey color.
|
||||
/// if (index % 2 == 0)
|
||||
/// if (index.isEven) {
|
||||
/// return Colors.grey.withOpacity(0.3);
|
||||
/// }
|
||||
/// return null; // Use default value for other states and odd rows.
|
||||
/// }),
|
||||
/// cells: [DataCell(Text('Row $index'))],
|
||||
/// cells: <DataCell>[ DataCell(Text('Row $index')) ],
|
||||
/// selected: selected[index],
|
||||
/// onSelectChanged: (bool? value) {
|
||||
/// setState(() {
|
||||
|
@ -194,10 +194,10 @@ class Dialog extends StatelessWidget {
|
||||
/// barrierDismissible: false, // user must tap button!
|
||||
/// builder: (BuildContext context) {
|
||||
/// return AlertDialog(
|
||||
/// title: Text('AlertDialog Title'),
|
||||
/// title: const Text('AlertDialog Title'),
|
||||
/// content: SingleChildScrollView(
|
||||
/// child: ListBody(
|
||||
/// children: <Widget>[
|
||||
/// children: const <Widget>[
|
||||
/// Text('This is a demo alert dialog.'),
|
||||
/// Text('Would you like to approve of this message?'),
|
||||
/// ],
|
||||
@ -205,7 +205,7 @@ class Dialog extends StatelessWidget {
|
||||
/// ),
|
||||
/// actions: <Widget>[
|
||||
/// TextButton(
|
||||
/// child: Text('Approve'),
|
||||
/// child: const Text('Approve'),
|
||||
/// onPressed: () {
|
||||
/// Navigator.of(context).pop();
|
||||
/// },
|
||||
@ -232,7 +232,7 @@ class Dialog extends StatelessWidget {
|
||||
/// builder: (BuildContext context) => AlertDialog(
|
||||
/// title: const Text('AlertDialog Tilte'),
|
||||
/// content: const Text('AlertDialog description'),
|
||||
/// actions: [
|
||||
/// actions: <Widget>[
|
||||
/// TextButton(
|
||||
/// onPressed: () => Navigator.pop(context, 'Cancel'),
|
||||
/// child: const Text('Cancel'),
|
||||
@ -244,7 +244,7 @@ class Dialog extends StatelessWidget {
|
||||
/// ],
|
||||
/// ),
|
||||
/// ),
|
||||
/// child: Text('Show Dialog'),
|
||||
/// child: const Text('Show Dialog'),
|
||||
/// );
|
||||
/// }
|
||||
///
|
||||
@ -367,13 +367,13 @@ class AlertDialog extends StatelessWidget {
|
||||
/// This is an example of a set of actions aligned with the content widget.
|
||||
/// ```dart
|
||||
/// AlertDialog(
|
||||
/// title: Text('Title'),
|
||||
/// title: const Text('Title'),
|
||||
/// content: Container(width: 200, height: 200, color: Colors.green),
|
||||
/// actions: <Widget>[
|
||||
/// ElevatedButton(onPressed: () {}, child: Text('Button 1')),
|
||||
/// ElevatedButton(onPressed: () {}, child: Text('Button 2')),
|
||||
/// ElevatedButton(onPressed: () {}, child: const Text('Button 1')),
|
||||
/// ElevatedButton(onPressed: () {}, child: const Text('Button 2')),
|
||||
/// ],
|
||||
/// actionsPadding: EdgeInsets.symmetric(horizontal: 8.0),
|
||||
/// actionsPadding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
/// )
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
@ -1009,13 +1009,15 @@ Widget _buildMaterialDialogTransitions(BuildContext context, Animation<double> a
|
||||
///
|
||||
/// ```dart
|
||||
/// void main() {
|
||||
/// runApp(MyApp());
|
||||
/// runApp(const MyApp());
|
||||
/// }
|
||||
///
|
||||
/// class MyApp extends StatelessWidget {
|
||||
/// const MyApp({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return MaterialApp(
|
||||
/// return const MaterialApp(
|
||||
/// restorationScopeId: 'app',
|
||||
/// title: 'Restorable Routes Demo',
|
||||
/// home: MyHomePage(),
|
||||
@ -1024,6 +1026,8 @@ Widget _buildMaterialDialogTransitions(BuildContext context, Animation<double> a
|
||||
/// }
|
||||
///
|
||||
/// class MyHomePage extends StatelessWidget {
|
||||
/// const MyHomePage({Key? key}) : super(key: key);
|
||||
///
|
||||
/// static Route<Object?> _dialogBuilder(BuildContext context, Object? arguments) {
|
||||
/// return DialogRoute<void>(
|
||||
/// context: context,
|
||||
|
@ -140,7 +140,7 @@ class Divider extends StatelessWidget {
|
||||
/// {@tool snippet}
|
||||
///
|
||||
/// ```dart
|
||||
/// Divider(
|
||||
/// const Divider(
|
||||
/// color: Colors.deepOrange,
|
||||
/// )
|
||||
/// ```
|
||||
@ -332,7 +332,7 @@ class VerticalDivider extends StatelessWidget {
|
||||
/// {@tool snippet}
|
||||
///
|
||||
/// ```dart
|
||||
/// Divider(
|
||||
/// const Divider(
|
||||
/// color: Colors.deepOrange,
|
||||
/// )
|
||||
/// ```
|
||||
|
@ -760,10 +760,10 @@ class DropdownButtonHideUnderline extends InheritedWidget {
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return DropdownButton<String>(
|
||||
/// value: dropdownValue,
|
||||
/// icon: Icon(Icons.arrow_downward),
|
||||
/// icon: const Icon(Icons.arrow_downward),
|
||||
/// iconSize: 24,
|
||||
/// elevation: 16,
|
||||
/// style: TextStyle(
|
||||
/// style: const TextStyle(
|
||||
/// color: Colors.deepPurple
|
||||
/// ),
|
||||
/// underline: Container(
|
||||
@ -1002,12 +1002,12 @@ class DropdownButton<T> extends StatefulWidget {
|
||||
/// dropdownValue = newValue!;
|
||||
/// });
|
||||
/// },
|
||||
/// style: TextStyle(color: Colors.blue),
|
||||
/// style: const TextStyle(color: Colors.blue),
|
||||
/// selectedItemBuilder: (BuildContext context) {
|
||||
/// return options.map((String value) {
|
||||
/// return Text(
|
||||
/// dropdownValue,
|
||||
/// style: TextStyle(color: Colors.white),
|
||||
/// style: const TextStyle(color: Colors.white),
|
||||
/// );
|
||||
/// }).toList();
|
||||
/// },
|
||||
|
@ -52,9 +52,10 @@ import 'theme_data.dart';
|
||||
/// This sample produces an enabled and a disabled ElevatedButton.
|
||||
///
|
||||
/// ```dart
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// final ButtonStyle style =
|
||||
/// ElevatedButton.styleFrom(textStyle: TextStyle(fontSize: 20));
|
||||
/// ElevatedButton.styleFrom(textStyle: const TextStyle(fontSize: 20));
|
||||
///
|
||||
/// return Center(
|
||||
/// child: Column(
|
||||
|
@ -166,7 +166,7 @@ class ExpansionPanelRadio extends ExpansionPanel {
|
||||
/// }
|
||||
///
|
||||
/// List<Item> generateItems(int numberOfItems) {
|
||||
/// return List.generate(numberOfItems, (int index) {
|
||||
/// return List<Item>.generate(numberOfItems, (int index) {
|
||||
/// return Item(
|
||||
/// headerValue: 'Panel $index',
|
||||
/// expandedValue: 'This is item number $index',
|
||||
@ -176,7 +176,7 @@ class ExpansionPanelRadio extends ExpansionPanel {
|
||||
/// ```
|
||||
///
|
||||
/// ```dart
|
||||
/// List<Item> _data = generateItems(8);
|
||||
/// final List<Item> _data = generateItems(8);
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
@ -203,11 +203,11 @@ class ExpansionPanelRadio extends ExpansionPanel {
|
||||
/// },
|
||||
/// body: ListTile(
|
||||
/// title: Text(item.expandedValue),
|
||||
/// subtitle: Text('To delete this panel, tap the trash can icon'),
|
||||
/// trailing: Icon(Icons.delete),
|
||||
/// subtitle: const Text('To delete this panel, tap the trash can icon'),
|
||||
/// trailing: const Icon(Icons.delete),
|
||||
/// onTap: () {
|
||||
/// setState(() {
|
||||
/// _data.removeWhere((currentItem) => item == currentItem);
|
||||
/// _data.removeWhere((Item currentItem) => item == currentItem);
|
||||
/// });
|
||||
/// }
|
||||
/// ),
|
||||
@ -270,7 +270,7 @@ class ExpansionPanelList extends StatefulWidget {
|
||||
/// }
|
||||
///
|
||||
/// List<Item> generateItems(int numberOfItems) {
|
||||
/// return List.generate(numberOfItems, (int index) {
|
||||
/// return List<Item>.generate(numberOfItems, (int index) {
|
||||
/// return Item(
|
||||
/// id: index,
|
||||
/// headerValue: 'Panel $index',
|
||||
@ -281,7 +281,7 @@ class ExpansionPanelList extends StatefulWidget {
|
||||
/// ```
|
||||
///
|
||||
/// ```dart
|
||||
/// List<Item> _data = generateItems(8);
|
||||
/// final List<Item> _data = generateItems(8);
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
@ -305,11 +305,11 @@ class ExpansionPanelList extends StatefulWidget {
|
||||
/// },
|
||||
/// body: ListTile(
|
||||
/// title: Text(item.expandedValue),
|
||||
/// subtitle: Text('To delete this panel, tap the trash can icon'),
|
||||
/// trailing: Icon(Icons.delete),
|
||||
/// subtitle: const Text('To delete this panel, tap the trash can icon'),
|
||||
/// trailing: const Icon(Icons.delete),
|
||||
/// onTap: () {
|
||||
/// setState(() {
|
||||
/// _data.removeWhere((currentItem) => item == currentItem);
|
||||
/// _data.removeWhere((Item currentItem) => item == currentItem);
|
||||
/// });
|
||||
/// }
|
||||
/// )
|
||||
|
@ -32,6 +32,8 @@ import 'theme.dart';
|
||||
///
|
||||
/// ```dart
|
||||
/// class WidgetWithWrappedHandler extends StatelessWidget {
|
||||
/// const WidgetWithWrappedHandler({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return GestureDetector(
|
||||
@ -58,6 +60,8 @@ import 'theme.dart';
|
||||
///
|
||||
/// ```dart
|
||||
/// class WidgetWithExplicitCall extends StatelessWidget {
|
||||
/// const WidgetWithExplicitCall({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return GestureDetector(
|
||||
|
@ -66,9 +66,11 @@ enum StretchMode {
|
||||
/// import 'package:flutter/material.dart';
|
||||
/// ```
|
||||
/// ```dart
|
||||
/// void main() => runApp(MaterialApp(home: MyApp()));
|
||||
/// void main() => runApp(const MaterialApp(home: MyApp()));
|
||||
///
|
||||
/// class MyApp extends StatelessWidget {
|
||||
/// const MyApp({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Scaffold(
|
||||
@ -79,11 +81,11 @@ enum StretchMode {
|
||||
/// stretch: true,
|
||||
/// onStretchTrigger: () {
|
||||
/// // Function callback for stretch
|
||||
/// return Future.value();
|
||||
/// return Future<void>.value();
|
||||
/// },
|
||||
/// expandedHeight: 300.0,
|
||||
/// flexibleSpace: FlexibleSpaceBar(
|
||||
/// stretchModes: <StretchMode>[
|
||||
/// stretchModes: const <StretchMode>[
|
||||
/// StretchMode.zoomBackground,
|
||||
/// StretchMode.blurBackground,
|
||||
/// StretchMode.fadeTitle,
|
||||
@ -92,7 +94,7 @@ enum StretchMode {
|
||||
/// title: const Text('Flight Report'),
|
||||
/// background: Stack(
|
||||
/// fit: StackFit.expand,
|
||||
/// children: [
|
||||
/// children: <Widget>[
|
||||
/// Image.network(
|
||||
/// 'https://flutter.github.io/assets-for-api-docs/assets/widgets/owl-2.jpg',
|
||||
/// fit: BoxFit.cover,
|
||||
@ -114,19 +116,21 @@ enum StretchMode {
|
||||
/// ),
|
||||
/// ),
|
||||
/// SliverList(
|
||||
/// delegate: SliverChildListDelegate([
|
||||
/// ListTile(
|
||||
/// leading: Icon(Icons.wb_sunny),
|
||||
/// title: Text('Sunday'),
|
||||
/// subtitle: Text('sunny, h: 80, l: 65'),
|
||||
/// ),
|
||||
/// ListTile(
|
||||
/// leading: Icon(Icons.wb_sunny),
|
||||
/// title: Text('Monday'),
|
||||
/// subtitle: Text('sunny, h: 80, l: 65'),
|
||||
/// ),
|
||||
/// // ListTiles++
|
||||
/// ]),
|
||||
/// delegate: SliverChildListDelegate(
|
||||
/// const <Widget>[
|
||||
/// ListTile(
|
||||
/// leading: Icon(Icons.wb_sunny),
|
||||
/// title: Text('Sunday'),
|
||||
/// subtitle: Text('sunny, h: 80, l: 65'),
|
||||
/// ),
|
||||
/// ListTile(
|
||||
/// leading: Icon(Icons.wb_sunny),
|
||||
/// title: Text('Monday'),
|
||||
/// subtitle: Text('sunny, h: 80, l: 65'),
|
||||
/// ),
|
||||
/// // ListTiles++
|
||||
/// ],
|
||||
/// ),
|
||||
/// ),
|
||||
/// ],
|
||||
/// ),
|
||||
|
@ -69,14 +69,14 @@ class _DefaultHeroTag {
|
||||
/// appBar: AppBar(
|
||||
/// title: const Text('Floating Action Button'),
|
||||
/// ),
|
||||
/// body: Center(
|
||||
/// child: const Text('Press the button below!')
|
||||
/// body: const Center(
|
||||
/// child: Text('Press the button below!')
|
||||
/// ),
|
||||
/// floatingActionButton: FloatingActionButton(
|
||||
/// onPressed: () {
|
||||
/// // Add your onPressed code here!
|
||||
/// },
|
||||
/// child: Icon(Icons.navigation),
|
||||
/// child: const Icon(Icons.navigation),
|
||||
/// backgroundColor: Colors.green,
|
||||
/// ),
|
||||
/// );
|
||||
@ -97,15 +97,15 @@ class _DefaultHeroTag {
|
||||
/// appBar: AppBar(
|
||||
/// title: const Text('Floating Action Button Label'),
|
||||
/// ),
|
||||
/// body: Center(
|
||||
/// child: const Text('Press the button with a label below!'),
|
||||
/// body: const Center(
|
||||
/// child: Text('Press the button with a label below!'),
|
||||
/// ),
|
||||
/// floatingActionButton: FloatingActionButton.extended(
|
||||
/// onPressed: () {
|
||||
/// // Add your onPressed code here!
|
||||
/// },
|
||||
/// label: Text('Approve'),
|
||||
/// icon: Icon(Icons.thumb_up),
|
||||
/// label: const Text('Approve'),
|
||||
/// icon: const Icon(Icons.thumb_up),
|
||||
/// backgroundColor: Colors.pink,
|
||||
/// ),
|
||||
/// );
|
||||
|
@ -461,12 +461,12 @@ abstract class FloatingActionButtonLocation {
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Scaffold(
|
||||
/// appBar: AppBar(
|
||||
/// title: Text('Home page'),
|
||||
/// title: const Text('Home page'),
|
||||
/// ),
|
||||
/// floatingActionButton: FloatingActionButton(
|
||||
/// onPressed: () { print('FAB pressed.'); },
|
||||
/// tooltip: 'Increment',
|
||||
/// child: Icon(Icons.add),
|
||||
/// child: const Icon(Icons.add),
|
||||
/// ),
|
||||
/// floatingActionButtonLocation: AlmostEndFloatFabLocation(),
|
||||
/// );
|
||||
|
@ -52,12 +52,13 @@ const double _kMinButtonSize = kMinInteractiveDimension;
|
||||
/// ```
|
||||
///
|
||||
/// ```dart
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Column(
|
||||
/// mainAxisSize: MainAxisSize.min,
|
||||
/// children: <Widget>[
|
||||
/// IconButton(
|
||||
/// icon: Icon(Icons.volume_up),
|
||||
/// icon: const Icon(Icons.volume_up),
|
||||
/// tooltip: 'Increase volume by 10',
|
||||
/// onPressed: () {
|
||||
/// setState(() {
|
||||
@ -94,6 +95,7 @@ const double _kMinButtonSize = kMinInteractiveDimension;
|
||||
/// 
|
||||
///
|
||||
/// ```dart
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Material(
|
||||
/// color: Colors.white,
|
||||
@ -104,7 +106,7 @@ const double _kMinButtonSize = kMinInteractiveDimension;
|
||||
/// shape: CircleBorder(),
|
||||
/// ),
|
||||
/// child: IconButton(
|
||||
/// icon: Icon(Icons.android),
|
||||
/// icon: const Icon(Icons.android),
|
||||
/// color: Colors.white,
|
||||
/// onPressed: () {},
|
||||
/// ),
|
||||
|
@ -59,7 +59,7 @@ import 'material.dart';
|
||||
/// height: 100.0,
|
||||
/// child: InkWell(
|
||||
/// onTap: () { /* ... */ },
|
||||
/// child: Center(
|
||||
/// child: const Center(
|
||||
/// child: Text('YELLOW'),
|
||||
/// )
|
||||
/// ),
|
||||
@ -78,17 +78,23 @@ import 'material.dart';
|
||||
/// color: Colors.grey[800],
|
||||
/// child: Center(
|
||||
/// child: Ink.image(
|
||||
/// image: AssetImage('cat.jpeg'),
|
||||
/// image: const AssetImage('cat.jpeg'),
|
||||
/// fit: BoxFit.cover,
|
||||
/// width: 300.0,
|
||||
/// height: 200.0,
|
||||
/// child: InkWell(
|
||||
/// onTap: () { /* ... */ },
|
||||
/// child: Align(
|
||||
/// child: const Align(
|
||||
/// alignment: Alignment.topLeft,
|
||||
/// child: Padding(
|
||||
/// padding: const EdgeInsets.all(10.0),
|
||||
/// child: Text('KITTEN', style: TextStyle(fontWeight: FontWeight.w900, color: Colors.white)),
|
||||
/// padding: EdgeInsets.all(10.0),
|
||||
/// child: Text(
|
||||
/// 'KITTEN',
|
||||
/// style: TextStyle(
|
||||
/// fontWeight: FontWeight.w900,
|
||||
/// color: Colors.white,
|
||||
/// ),
|
||||
/// ),
|
||||
/// ),
|
||||
/// )
|
||||
/// ),
|
||||
|
@ -1182,11 +1182,12 @@ class _InkResponseState extends State<_InkResponseStateWidget>
|
||||
/// ```dart
|
||||
/// double sideLength = 50;
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return AnimatedContainer(
|
||||
/// height: sideLength,
|
||||
/// width: sideLength,
|
||||
/// duration: Duration(seconds: 2),
|
||||
/// duration: const Duration(seconds: 2),
|
||||
/// curve: Curves.easeIn,
|
||||
/// child: Material(
|
||||
/// color: Colors.yellow,
|
||||
|
@ -2415,7 +2415,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
|
||||
///
|
||||
/// ```dart
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return TextField(
|
||||
/// return const TextField(
|
||||
/// decoration: InputDecoration(
|
||||
/// icon: Icon(Icons.send),
|
||||
/// hintText: 'Hint Text',
|
||||
@ -2438,7 +2438,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
|
||||
///
|
||||
/// ```dart
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return TextField(
|
||||
/// return const TextField(
|
||||
/// decoration: InputDecoration.collapsed(
|
||||
/// hintText: 'Hint Text',
|
||||
/// border: OutlineInputBorder(),
|
||||
@ -2458,7 +2458,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
|
||||
///
|
||||
/// ```dart
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return TextField(
|
||||
/// return const TextField(
|
||||
/// decoration: InputDecoration(
|
||||
/// hintText: 'Hint Text',
|
||||
/// errorText: 'Error Text',
|
||||
@ -2875,7 +2875,7 @@ class InputDecoration {
|
||||
/// padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
/// child: Column(
|
||||
/// mainAxisAlignment: MainAxisAlignment.center,
|
||||
/// children: <Widget>[
|
||||
/// children: const <Widget>[
|
||||
/// TextField(
|
||||
/// decoration: InputDecoration(
|
||||
/// hintText: 'Normal Icon Constraints',
|
||||
@ -3043,7 +3043,7 @@ class InputDecoration {
|
||||
/// padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
/// child: Column(
|
||||
/// mainAxisAlignment: MainAxisAlignment.center,
|
||||
/// children: <Widget>[
|
||||
/// children: const <Widget>[
|
||||
/// TextField(
|
||||
/// decoration: InputDecoration(
|
||||
/// hintText: 'Normal Icon Constraints',
|
||||
|
@ -399,12 +399,12 @@ enum ListTileControlAffinity {
|
||||
/// child: Container(
|
||||
/// width: 48,
|
||||
/// height: 48,
|
||||
/// padding: EdgeInsets.symmetric(vertical: 4.0),
|
||||
/// padding: const EdgeInsets.symmetric(vertical: 4.0),
|
||||
/// alignment: Alignment.center,
|
||||
/// child: CircleAvatar(),
|
||||
/// child: const CircleAvatar(),
|
||||
/// ),
|
||||
/// ),
|
||||
/// title: Text('title'),
|
||||
/// title: const Text('title'),
|
||||
/// dense: false,
|
||||
/// ),
|
||||
/// ```
|
||||
@ -426,11 +426,12 @@ enum ListTileControlAffinity {
|
||||
/// ```dart preamble
|
||||
/// class CustomListItem extends StatelessWidget {
|
||||
/// const CustomListItem({
|
||||
/// Key? key,
|
||||
/// required this.thumbnail,
|
||||
/// required this.title,
|
||||
/// required this.user,
|
||||
/// required this.viewCount,
|
||||
/// });
|
||||
/// }) : super(key: key);
|
||||
///
|
||||
/// final Widget thumbnail;
|
||||
/// final String title;
|
||||
@ -547,7 +548,7 @@ enum ListTileControlAffinity {
|
||||
///
|
||||
/// ```dart preamble
|
||||
/// class _ArticleDescription extends StatelessWidget {
|
||||
/// _ArticleDescription({
|
||||
/// const _ArticleDescription({
|
||||
/// Key? key,
|
||||
/// required this.title,
|
||||
/// required this.subtitle,
|
||||
@ -573,7 +574,7 @@ enum ListTileControlAffinity {
|
||||
/// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
/// children: <Widget>[
|
||||
/// Text(
|
||||
/// '$title',
|
||||
/// title,
|
||||
/// maxLines: 2,
|
||||
/// overflow: TextOverflow.ellipsis,
|
||||
/// style: const TextStyle(
|
||||
@ -582,7 +583,7 @@ enum ListTileControlAffinity {
|
||||
/// ),
|
||||
/// const Padding(padding: EdgeInsets.only(bottom: 2.0)),
|
||||
/// Text(
|
||||
/// '$subtitle',
|
||||
/// subtitle,
|
||||
/// maxLines: 2,
|
||||
/// overflow: TextOverflow.ellipsis,
|
||||
/// style: const TextStyle(
|
||||
@ -600,7 +601,7 @@ enum ListTileControlAffinity {
|
||||
/// mainAxisAlignment: MainAxisAlignment.end,
|
||||
/// children: <Widget>[
|
||||
/// Text(
|
||||
/// '$author',
|
||||
/// author,
|
||||
/// style: const TextStyle(
|
||||
/// fontSize: 12.0,
|
||||
/// color: Colors.black87,
|
||||
@ -622,7 +623,7 @@ enum ListTileControlAffinity {
|
||||
/// }
|
||||
///
|
||||
/// class CustomListItemTwo extends StatelessWidget {
|
||||
/// CustomListItemTwo({
|
||||
/// const CustomListItemTwo({
|
||||
/// Key? key,
|
||||
/// required this.thumbnail,
|
||||
/// required this.title,
|
||||
@ -683,7 +684,7 @@ enum ListTileControlAffinity {
|
||||
/// ),
|
||||
/// title: 'Flutter 1.0 Launch',
|
||||
/// subtitle:
|
||||
/// 'Flutter continues to improve and expand its horizons.'
|
||||
/// 'Flutter continues to improve and expand its horizons. '
|
||||
/// 'This text should max out at two lines and clip',
|
||||
/// author: 'Dash',
|
||||
/// publishDate: 'Dec 28',
|
||||
|
@ -109,11 +109,11 @@ typedef MaterialPropertyResolver<T> = T Function(Set<MaterialState> states);
|
||||
///
|
||||
/// ```dart
|
||||
/// class MyColor extends MaterialStateColor {
|
||||
/// const MyColor() : super(_defaultColor);
|
||||
///
|
||||
/// static const int _defaultColor = 0xcafefeed;
|
||||
/// static const int _pressedColor = 0xdeadbeef;
|
||||
///
|
||||
/// const MyColor() : super(_defaultColor);
|
||||
///
|
||||
/// @override
|
||||
/// Color resolve(Set<MaterialState> states) {
|
||||
/// if (states.contains(MaterialState.pressed)) {
|
||||
@ -204,7 +204,7 @@ class _MaterialStateColor extends MaterialStateColor {
|
||||
/// ```dart
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return ListTile(
|
||||
/// title: Text('Disabled ListTile'),
|
||||
/// title: const Text('Disabled ListTile'),
|
||||
/// enabled: false,
|
||||
/// mouseCursor: ListTileCursor(),
|
||||
/// );
|
||||
@ -304,7 +304,7 @@ class _EnabledAndDisabledMouseCursor extends MaterialStateMouseCursor {
|
||||
/// @override
|
||||
/// BorderSide? resolve(Set<MaterialState> states) {
|
||||
/// if (states.contains(MaterialState.selected)) {
|
||||
/// return BorderSide(
|
||||
/// return const BorderSide(
|
||||
/// width: 1,
|
||||
/// color: Colors.red,
|
||||
/// );
|
||||
@ -317,9 +317,10 @@ class _EnabledAndDisabledMouseCursor extends MaterialStateMouseCursor {
|
||||
/// ```dart
|
||||
/// bool isSelected = true;
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return FilterChip(
|
||||
/// label: Text('Select chip'),
|
||||
/// label: const Text('Select chip'),
|
||||
/// selected: isSelected,
|
||||
/// onSelected: (bool value) {
|
||||
/// setState(() {
|
||||
@ -364,7 +365,7 @@ abstract class MaterialStateBorderSide extends BorderSide implements MaterialSta
|
||||
/// @override
|
||||
/// OutlinedBorder? resolve(Set<MaterialState> states) {
|
||||
/// if (states.contains(MaterialState.selected)) {
|
||||
/// return RoundedRectangleBorder();
|
||||
/// return const RoundedRectangleBorder();
|
||||
/// }
|
||||
/// return null; // Defer to default value on the theme or widget.
|
||||
/// }
|
||||
@ -374,9 +375,10 @@ abstract class MaterialStateBorderSide extends BorderSide implements MaterialSta
|
||||
/// ```dart
|
||||
/// bool isSelected = true;
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return FilterChip(
|
||||
/// label: Text('Select chip'),
|
||||
/// label: const Text('Select chip'),
|
||||
/// selected: isSelected,
|
||||
/// onSelected: (bool value) {
|
||||
/// setState(() {
|
||||
@ -451,7 +453,7 @@ abstract class MaterialStateOutlinedBorder extends OutlinedBorder implements Mat
|
||||
/// foregroundColor: MaterialStateProperty.resolveWith(getColor),
|
||||
/// ),
|
||||
/// onPressed: () {},
|
||||
/// child: Text('TextButton'),
|
||||
/// child: const Text('TextButton'),
|
||||
/// );
|
||||
/// }
|
||||
/// ```
|
||||
|
@ -58,7 +58,7 @@ import 'theme.dart';
|
||||
/// });
|
||||
/// },
|
||||
/// labelType: NavigationRailLabelType.selected,
|
||||
/// destinations: [
|
||||
/// destinations: const <NavigationRailDestination>[
|
||||
/// NavigationRailDestination(
|
||||
/// icon: Icon(Icons.favorite_border),
|
||||
/// selectedIcon: Icon(Icons.favorite),
|
||||
@ -76,7 +76,7 @@ import 'theme.dart';
|
||||
/// ),
|
||||
/// ],
|
||||
/// ),
|
||||
/// VerticalDivider(thickness: 1, width: 1),
|
||||
/// const VerticalDivider(thickness: 1, width: 1),
|
||||
/// // This is the main content.
|
||||
/// Expanded(
|
||||
/// child: Center(
|
||||
@ -329,7 +329,7 @@ class NavigationRail extends StatefulWidget {
|
||||
/// This can be used to synchronize animations in the [leading] or [trailing]
|
||||
/// widget, such as an animated menu or a [FloatingActionButton] animation.
|
||||
///
|
||||
/// {@tool snippet}
|
||||
/// {@tool dartpad --template=stateless_widget_material}
|
||||
///
|
||||
/// This example shows how to use this animation to create a
|
||||
/// [FloatingActionButton] that animates itself between the normal and
|
||||
@ -338,10 +338,11 @@ class NavigationRail extends StatefulWidget {
|
||||
/// An instance of `ExtendableFab` would be created for
|
||||
/// [NavigationRail.leading].
|
||||
///
|
||||
/// ```dart
|
||||
/// ```dart dartImports
|
||||
/// import 'dart:ui';
|
||||
/// ```
|
||||
///
|
||||
/// @override
|
||||
/// ```dart
|
||||
/// Widget build(BuildContext context) {
|
||||
/// final Animation<double> animation = NavigationRail.extendedAnimation(context);
|
||||
/// return AnimatedBuilder(
|
||||
@ -355,7 +356,7 @@ class NavigationRail extends StatefulWidget {
|
||||
/// ),
|
||||
/// child: animation.value == 0
|
||||
/// ? FloatingActionButton(
|
||||
/// child: Icon(Icons.add),
|
||||
/// child: const Icon(Icons.add),
|
||||
/// onPressed: () {},
|
||||
/// )
|
||||
/// : Align(
|
||||
@ -364,8 +365,8 @@ class NavigationRail extends StatefulWidget {
|
||||
/// child: Padding(
|
||||
/// padding: const EdgeInsetsDirectional.only(start: 8),
|
||||
/// child: FloatingActionButton.extended(
|
||||
/// icon: Icon(Icons.add),
|
||||
/// label: Text('CREATE'),
|
||||
/// icon: const Icon(Icons.add),
|
||||
/// label: const Text('CREATE'),
|
||||
/// onPressed: () {},
|
||||
/// ),
|
||||
/// ),
|
||||
|
@ -22,8 +22,8 @@ import 'tooltip.dart';
|
||||
|
||||
// Examples can assume:
|
||||
// enum Commands { heroAndScholar, hurricaneCame }
|
||||
// dynamic _heroAndScholar;
|
||||
// dynamic _selection;
|
||||
// late bool _heroAndScholar;
|
||||
// late dynamic _selection;
|
||||
// late BuildContext context;
|
||||
// void setState(VoidCallback fn) { }
|
||||
|
||||
|
@ -267,14 +267,15 @@ class _LinearProgressIndicatorPainter extends CustomPainter {
|
||||
/// super.dispose();
|
||||
/// }
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Scaffold(
|
||||
/// body: Padding(
|
||||
/// padding: const EdgeInsets.all(20.0),
|
||||
/// child: Column(
|
||||
/// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
/// children: [
|
||||
/// Text(
|
||||
/// children: <Widget>[
|
||||
/// const Text(
|
||||
/// 'Linear progress indicator with a fixed color',
|
||||
/// style: const TextStyle(fontSize: 20),
|
||||
/// ),
|
||||
@ -505,13 +506,14 @@ class _CircularProgressIndicatorPainter extends CustomPainter {
|
||||
/// super.dispose();
|
||||
/// }
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Scaffold(
|
||||
/// body: Padding(
|
||||
/// padding: const EdgeInsets.all(20.0),
|
||||
/// child: Column(
|
||||
/// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
/// children: [
|
||||
/// children: <Widget>[
|
||||
/// Text(
|
||||
/// 'Linear progress indicator with a fixed color',
|
||||
/// style: Theme.of(context).textTheme.headline6,
|
||||
|
@ -52,12 +52,13 @@ const double _kInnerRadius = 4.5;
|
||||
/// ```dart
|
||||
/// SingingCharacter? _character = SingingCharacter.lafayette;
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Column(
|
||||
/// children: <Widget>[
|
||||
/// ListTile(
|
||||
/// title: const Text('Lafayette'),
|
||||
/// leading: Radio(
|
||||
/// leading: Radio<SingingCharacter>(
|
||||
/// value: SingingCharacter.lafayette,
|
||||
/// groupValue: _character,
|
||||
/// onChanged: (SingingCharacter? value) {
|
||||
@ -67,7 +68,7 @@ const double _kInnerRadius = 4.5;
|
||||
/// ),
|
||||
/// ListTile(
|
||||
/// title: const Text('Thomas Jefferson'),
|
||||
/// leading: Radio(
|
||||
/// leading: Radio<SingingCharacter>(
|
||||
/// value: SingingCharacter.jefferson,
|
||||
/// groupValue: _character,
|
||||
/// onChanged: (SingingCharacter? value) {
|
||||
@ -218,7 +219,7 @@ class Radio<T> extends StatefulWidget {
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Scaffold(
|
||||
/// body: ListView.builder(
|
||||
/// itemBuilder: (context, index) {
|
||||
/// itemBuilder: (BuildContext context, int index) {
|
||||
/// return Row(
|
||||
/// mainAxisSize: MainAxisSize.min,
|
||||
/// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
|
@ -108,12 +108,13 @@ import 'theme_data.dart';
|
||||
/// ```dart preamble
|
||||
/// class LinkedLabelRadio extends StatelessWidget {
|
||||
/// const LinkedLabelRadio({
|
||||
/// Key? key,
|
||||
/// required this.label,
|
||||
/// required this.padding,
|
||||
/// required this.groupValue,
|
||||
/// required this.value,
|
||||
/// required this.onChanged,
|
||||
/// });
|
||||
/// }) :super(key: key);
|
||||
///
|
||||
/// final String label;
|
||||
/// final EdgeInsets padding;
|
||||
@ -137,7 +138,7 @@ import 'theme_data.dart';
|
||||
/// RichText(
|
||||
/// text: TextSpan(
|
||||
/// text: label,
|
||||
/// style: TextStyle(
|
||||
/// style: const TextStyle(
|
||||
/// color: Colors.blueAccent,
|
||||
/// decoration: TextDecoration.underline,
|
||||
/// ),
|
||||
@ -164,7 +165,7 @@ import 'theme_data.dart';
|
||||
/// children: <Widget>[
|
||||
/// LinkedLabelRadio(
|
||||
/// label: 'First tappable label text',
|
||||
/// padding: EdgeInsets.symmetric(horizontal: 5.0),
|
||||
/// padding: const EdgeInsets.symmetric(horizontal: 5.0),
|
||||
/// value: true,
|
||||
/// groupValue: _isRadioSelected,
|
||||
/// onChanged: (bool newValue) {
|
||||
@ -175,7 +176,7 @@ import 'theme_data.dart';
|
||||
/// ),
|
||||
/// LinkedLabelRadio(
|
||||
/// label: 'Second tappable label text',
|
||||
/// padding: EdgeInsets.symmetric(horizontal: 5.0),
|
||||
/// padding: const EdgeInsets.symmetric(horizontal: 5.0),
|
||||
/// value: false,
|
||||
/// groupValue: _isRadioSelected,
|
||||
/// onChanged: (bool newValue) {
|
||||
@ -208,12 +209,13 @@ import 'theme_data.dart';
|
||||
/// ```dart preamble
|
||||
/// class LabeledRadio extends StatelessWidget {
|
||||
/// const LabeledRadio({
|
||||
/// Key? key,
|
||||
/// required this.label,
|
||||
/// required this.padding,
|
||||
/// required this.groupValue,
|
||||
/// required this.value,
|
||||
/// required this.onChanged,
|
||||
/// });
|
||||
/// }) : super(key: key);
|
||||
///
|
||||
/// final String label;
|
||||
/// final EdgeInsets padding;
|
||||
@ -225,8 +227,9 @@ import 'theme_data.dart';
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return InkWell(
|
||||
/// onTap: () {
|
||||
/// if (value != groupValue)
|
||||
/// if (value != groupValue) {
|
||||
/// onChanged(value);
|
||||
/// }
|
||||
/// },
|
||||
/// child: Padding(
|
||||
/// padding: padding,
|
||||
@ -406,7 +409,7 @@ class RadioListTile<T> extends StatelessWidget {
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Scaffold(
|
||||
/// body: ListView.builder(
|
||||
/// itemBuilder: (context, index) {
|
||||
/// itemBuilder: (BuildContext context, int index) {
|
||||
/// return RadioListTile<int>(
|
||||
/// value: index,
|
||||
/// groupValue: groupValue,
|
||||
|
@ -18,8 +18,8 @@ import 'slider_theme.dart';
|
||||
import 'theme.dart';
|
||||
|
||||
// Examples can assume:
|
||||
// RangeValues _rangeValues = RangeValues(0.3, 0.7);
|
||||
// RangeValues _dollarsRange = RangeValues(50, 100);
|
||||
// RangeValues _rangeValues = const RangeValues(0.3, 0.7);
|
||||
// RangeValues _dollarsRange = const RangeValues(50, 100);
|
||||
// void setState(VoidCallback fn) { }
|
||||
|
||||
/// [RangeSlider] uses this callback to paint the value indicator on the overlay.
|
||||
|
@ -34,10 +34,11 @@ import 'theme.dart';
|
||||
/// ```dart
|
||||
/// final List<int> _items = List<int>.generate(50, (int index) => index);
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context){
|
||||
/// final ColorScheme colorScheme = Theme.of(context).colorScheme;
|
||||
/// final oddItemColor = colorScheme.primary.withOpacity(0.05);
|
||||
/// final evenItemColor = colorScheme.primary.withOpacity(0.15);
|
||||
/// final Color oddItemColor = colorScheme.primary.withOpacity(0.05);
|
||||
/// final Color evenItemColor = colorScheme.primary.withOpacity(0.15);
|
||||
///
|
||||
/// return ReorderableListView(
|
||||
/// padding: const EdgeInsets.symmetric(horizontal: 40),
|
||||
@ -186,10 +187,11 @@ class ReorderableListView extends StatefulWidget {
|
||||
/// ```dart
|
||||
/// final List<int> _items = List<int>.generate(50, (int index) => index);
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context){
|
||||
/// final ColorScheme colorScheme = Theme.of(context).colorScheme;
|
||||
/// final oddItemColor = colorScheme.primary.withOpacity(0.05);
|
||||
/// final evenItemColor = colorScheme.primary.withOpacity(0.15);
|
||||
/// final Color oddItemColor = colorScheme.primary.withOpacity(0.05);
|
||||
/// final Color evenItemColor = colorScheme.primary.withOpacity(0.15);
|
||||
///
|
||||
/// return ReorderableListView(
|
||||
/// buildDefaultDragHandles: false,
|
||||
@ -217,7 +219,7 @@ class ReorderableListView extends StatefulWidget {
|
||||
/// ),
|
||||
/// ),
|
||||
/// ],
|
||||
/// onReorder: (oldIndex, newIndex) {
|
||||
/// onReorder: (int oldIndex, int newIndex) {
|
||||
/// setState(() {
|
||||
/// if (oldIndex < newIndex) {
|
||||
/// newIndex -= 1;
|
||||
|
@ -152,9 +152,11 @@ class ScaffoldMessenger extends StatefulWidget {
|
||||
/// import 'package:flutter/material.dart';
|
||||
/// ```
|
||||
/// ```dart
|
||||
/// void main() => runApp(MyApp());
|
||||
/// void main() => runApp(const MyApp());
|
||||
///
|
||||
/// class MyApp extends StatefulWidget {
|
||||
/// const MyApp({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// _MyAppState createState() => _MyAppState();
|
||||
/// }
|
||||
@ -179,12 +181,12 @@ class ScaffoldMessenger extends StatefulWidget {
|
||||
/// return MaterialApp(
|
||||
/// scaffoldMessengerKey: _scaffoldMessengerKey,
|
||||
/// home: Scaffold(
|
||||
/// appBar: AppBar(title: Text('ScaffoldMessenger Demo')),
|
||||
/// appBar: AppBar(title: const Text('ScaffoldMessenger Demo')),
|
||||
/// body: Center(
|
||||
/// child: Column(
|
||||
/// mainAxisAlignment: MainAxisAlignment.center,
|
||||
/// children: <Widget>[
|
||||
/// Text(
|
||||
/// const Text(
|
||||
/// 'You have pushed the button this many times:',
|
||||
/// ),
|
||||
/// Text(
|
||||
@ -197,7 +199,7 @@ class ScaffoldMessenger extends StatefulWidget {
|
||||
/// floatingActionButton: FloatingActionButton(
|
||||
/// onPressed: _incrementCounter,
|
||||
/// tooltip: 'Increment',
|
||||
/// child: Icon(Icons.add),
|
||||
/// child: const Icon(Icons.add),
|
||||
/// ),
|
||||
/// ),
|
||||
/// );
|
||||
@ -1291,6 +1293,7 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr
|
||||
/// ```dart
|
||||
/// int _count = 0;
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Scaffold(
|
||||
/// appBar: AppBar(
|
||||
@ -1320,6 +1323,7 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr
|
||||
/// ```dart
|
||||
/// int _count = 0;
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Scaffold(
|
||||
/// appBar: AppBar(
|
||||
@ -1352,6 +1356,7 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr
|
||||
/// ```dart
|
||||
/// int _count = 0;
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Scaffold(
|
||||
/// appBar: AppBar(
|
||||
@ -1369,7 +1374,7 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr
|
||||
/// _count++;
|
||||
/// }),
|
||||
/// tooltip: 'Increment Counter',
|
||||
/// child: Icon(Icons.add),
|
||||
/// child: const Icon(Icons.add),
|
||||
/// ),
|
||||
/// floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||
/// );
|
||||
@ -1665,11 +1670,11 @@ class Scaffold extends StatefulWidget {
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Scaffold(
|
||||
/// key: _scaffoldKey,
|
||||
/// appBar: AppBar(title: Text('Drawer Demo')),
|
||||
/// appBar: AppBar(title: const Text('Drawer Demo')),
|
||||
/// body: Center(
|
||||
/// child: ElevatedButton(
|
||||
/// onPressed: _openEndDrawer,
|
||||
/// child: Text('Open End Drawer'),
|
||||
/// child: const Text('Open End Drawer'),
|
||||
/// ),
|
||||
/// ),
|
||||
/// endDrawer: Drawer(
|
||||
@ -1822,11 +1827,13 @@ class Scaffold extends StatefulWidget {
|
||||
/// ```
|
||||
///
|
||||
/// ```dart main
|
||||
/// void main() => runApp(MyApp());
|
||||
/// void main() => runApp(const MyApp());
|
||||
/// ```
|
||||
///
|
||||
/// ```dart preamble
|
||||
/// class MyApp extends StatelessWidget {
|
||||
/// const MyApp({Key? key}) : super(key: key);
|
||||
///
|
||||
/// // This widget is the root of your application.
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
@ -1836,7 +1843,7 @@ class Scaffold extends StatefulWidget {
|
||||
/// primarySwatch: Colors.blue,
|
||||
/// ),
|
||||
/// home: Scaffold(
|
||||
/// body: MyScaffoldBody(),
|
||||
/// body: const MyScaffoldBody(),
|
||||
/// appBar: AppBar(title: const Text('Scaffold.of Example')),
|
||||
/// ),
|
||||
/// color: Colors.white,
|
||||
@ -1847,6 +1854,8 @@ class Scaffold extends StatefulWidget {
|
||||
///
|
||||
/// ```dart
|
||||
/// class MyScaffoldBody extends StatelessWidget {
|
||||
/// const MyScaffoldBody({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Center(
|
||||
@ -2213,8 +2222,8 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
||||
/// return OutlinedButton(
|
||||
/// onPressed: () {
|
||||
/// ScaffoldMessenger.of(context).showSnackBar(
|
||||
/// SnackBar(
|
||||
/// content: const Text('A SnackBar has been shown.'),
|
||||
/// const SnackBar(
|
||||
/// content: Text('A SnackBar has been shown.'),
|
||||
/// ),
|
||||
/// );
|
||||
/// },
|
||||
|
@ -101,7 +101,7 @@ abstract class SearchDelegate<T> {
|
||||
///
|
||||
/// {@tool snippet}
|
||||
/// ```dart
|
||||
/// class CustomSearchHintDelegate extends SearchDelegate {
|
||||
/// class CustomSearchHintDelegate extends SearchDelegate<String> {
|
||||
/// CustomSearchHintDelegate({
|
||||
/// required String hintText,
|
||||
/// }) : super(
|
||||
@ -111,22 +111,23 @@ abstract class SearchDelegate<T> {
|
||||
/// );
|
||||
///
|
||||
/// @override
|
||||
/// Widget buildLeading(BuildContext context) => Text("leading");
|
||||
/// Widget buildLeading(BuildContext context) => const Text('leading');
|
||||
///
|
||||
/// @override
|
||||
/// PreferredSizeWidget buildBottom(BuildContext context) {
|
||||
/// return PreferredSize(
|
||||
/// return const PreferredSize(
|
||||
/// preferredSize: Size.fromHeight(56.0),
|
||||
/// child: Text("bottom"));
|
||||
/// child: Text('bottom'));
|
||||
/// }
|
||||
///
|
||||
/// @override
|
||||
/// Widget buildSuggestions(BuildContext context) => Text("suggestions");
|
||||
/// Widget buildSuggestions(BuildContext context) => const Text('suggestions');
|
||||
///
|
||||
/// @override
|
||||
/// Widget buildResults(BuildContext context) => Text('results');
|
||||
/// Widget buildResults(BuildContext context) => const Text('results');
|
||||
///
|
||||
/// @override
|
||||
/// List<Widget> buildActions(BuildContext context) => [];
|
||||
/// List<Widget> buildActions(BuildContext context) => <Widget>[];
|
||||
/// }
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
|
@ -125,7 +125,7 @@ class _SelectableTextSelectionGestureDetectorBuilder extends TextSelectionGestur
|
||||
/// {@tool snippet}
|
||||
///
|
||||
/// ```dart
|
||||
/// SelectableText(
|
||||
/// const SelectableText(
|
||||
/// 'Hello! How are you?',
|
||||
/// textAlign: TextAlign.center,
|
||||
/// style: TextStyle(fontWeight: FontWeight.bold),
|
||||
|
@ -84,6 +84,8 @@ class SliderTheme extends InheritedTheme {
|
||||
///
|
||||
/// ```dart
|
||||
/// class Launch extends StatefulWidget {
|
||||
/// const Launch({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// State createState() => LaunchState();
|
||||
/// }
|
||||
@ -244,6 +246,8 @@ class SliderThemeData with Diagnosticable {
|
||||
///
|
||||
/// ```dart
|
||||
/// class Blissful extends StatefulWidget {
|
||||
/// const Blissful({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// State createState() => BlissfulState();
|
||||
/// }
|
||||
|
@ -165,13 +165,13 @@ class _SnackBarActionState extends State<SnackBarAction> {
|
||||
/// ```dart
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return ElevatedButton(
|
||||
/// child: Text("Show Snackbar"),
|
||||
/// child: const Text('Show Snackbar'),
|
||||
/// onPressed: () {
|
||||
/// ScaffoldMessenger.of(context).showSnackBar(
|
||||
/// SnackBar(
|
||||
/// content: Text("Awesome Snackbar!"),
|
||||
/// content: const Text('Awesome Snackbar!'),
|
||||
/// action: SnackBarAction(
|
||||
/// label: "Action",
|
||||
/// label: 'Action',
|
||||
/// onPressed: () {
|
||||
/// // Code to execute.
|
||||
/// },
|
||||
@ -193,21 +193,22 @@ class _SnackBarActionState extends State<SnackBarAction> {
|
||||
/// ```dart
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return ElevatedButton(
|
||||
/// child: Text("Show Snackbar"),
|
||||
/// child: const Text('Show Snackbar'),
|
||||
/// onPressed: () {
|
||||
/// ScaffoldMessenger.of(context).showSnackBar(
|
||||
/// SnackBar(
|
||||
/// action: SnackBarAction(
|
||||
/// label: "Action",
|
||||
/// label: 'Action',
|
||||
/// onPressed: () {
|
||||
/// // Code to execute.
|
||||
/// },
|
||||
/// ),
|
||||
/// content: Text("Awesome SnackBar!"),
|
||||
/// duration: Duration(milliseconds: 1500),
|
||||
/// content: const Text('Awesome SnackBar!'),
|
||||
/// duration: const Duration(milliseconds: 1500),
|
||||
/// width: 280.0, // Width of the SnackBar.
|
||||
/// padding: EdgeInsets.symmetric(
|
||||
/// horizontal: 8.0), // Inner padding for SnackBar content.
|
||||
/// padding: const EdgeInsets.symmetric(
|
||||
/// horizontal: 8.0, // Inner padding for SnackBar content.
|
||||
/// ),
|
||||
/// behavior: SnackBarBehavior.floating,
|
||||
/// shape: RoundedRectangleBorder(
|
||||
/// borderRadius: BorderRadius.circular(10.0),
|
||||
|
@ -126,29 +126,33 @@ class Step {
|
||||
///
|
||||
/// ```dart
|
||||
/// int _index = 0;
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Stepper(
|
||||
/// currentStep: _index,
|
||||
/// onStepCancel: () {
|
||||
/// if (_index > 0)
|
||||
/// if (_index > 0) {
|
||||
/// setState(() { _index -= 1; });
|
||||
/// }
|
||||
/// },
|
||||
/// onStepContinue: () {
|
||||
/// if (_index <= 0)
|
||||
/// if (_index <= 0) {
|
||||
/// setState(() { _index += 1; });
|
||||
/// }
|
||||
/// },
|
||||
/// onStepTapped: (index) {
|
||||
/// onStepTapped: (int index) {
|
||||
/// setState(() { _index = index; });
|
||||
/// },
|
||||
/// steps: <Step>[
|
||||
/// Step(
|
||||
/// title: Text('Step 1 title'),
|
||||
/// title: const Text('Step 1 title'),
|
||||
/// content: Container(
|
||||
/// alignment: Alignment.centerLeft,
|
||||
/// child: Text('Content for Step 1')
|
||||
/// child: const Text('Content for Step 1')
|
||||
/// ),
|
||||
/// ),
|
||||
/// Step(
|
||||
/// const Step(
|
||||
/// title: Text('Step 2 title'),
|
||||
/// content: Text('Content for Step 2'),
|
||||
/// ),
|
||||
|
@ -102,11 +102,12 @@ enum _SwitchListTileType { material, adaptive }
|
||||
/// ```dart preamble
|
||||
/// class LinkedLabelSwitch extends StatelessWidget {
|
||||
/// const LinkedLabelSwitch({
|
||||
/// Key? key,
|
||||
/// required this.label,
|
||||
/// required this.padding,
|
||||
/// required this.value,
|
||||
/// required this.onChanged,
|
||||
/// });
|
||||
/// }) : super(key: key);
|
||||
///
|
||||
/// final String label;
|
||||
/// final EdgeInsets padding;
|
||||
@ -123,7 +124,7 @@ enum _SwitchListTileType { material, adaptive }
|
||||
/// child: RichText(
|
||||
/// text: TextSpan(
|
||||
/// text: label,
|
||||
/// style: TextStyle(
|
||||
/// style: const TextStyle(
|
||||
/// color: Colors.blueAccent,
|
||||
/// decoration: TextDecoration.underline,
|
||||
/// ),
|
||||
@ -182,11 +183,12 @@ enum _SwitchListTileType { material, adaptive }
|
||||
/// ```dart preamble
|
||||
/// class LabeledSwitch extends StatelessWidget {
|
||||
/// const LabeledSwitch({
|
||||
/// Key? key,
|
||||
/// required this.label,
|
||||
/// required this.padding,
|
||||
/// required this.value,
|
||||
/// required this.onChanged,
|
||||
/// });
|
||||
/// }) : super(key: key);
|
||||
///
|
||||
/// final String label;
|
||||
/// final EdgeInsets padding;
|
||||
|
@ -38,7 +38,7 @@ import 'constants.dart';
|
||||
/// }
|
||||
///
|
||||
/// class _MyTabbedPageState extends State<MyTabbedPage> with SingleTickerProviderStateMixin {
|
||||
/// final List<Tab> myTabs = <Tab>[
|
||||
/// static const List<Tab> myTabs = <Tab>[
|
||||
/// Tab(text: 'LEFT'),
|
||||
/// Tab(text: 'RIGHT'),
|
||||
/// ];
|
||||
@ -90,7 +90,7 @@ import 'constants.dart';
|
||||
/// when using [DefaultTabController].
|
||||
///
|
||||
/// ```dart preamble
|
||||
/// final List<Tab> tabs = <Tab>[
|
||||
/// const List<Tab> tabs = <Tab>[
|
||||
/// Tab(text: 'Zeroth'),
|
||||
/// Tab(text: 'First'),
|
||||
/// Tab(text: 'Second'),
|
||||
@ -114,7 +114,7 @@ import 'constants.dart';
|
||||
/// });
|
||||
/// return Scaffold(
|
||||
/// appBar: AppBar(
|
||||
/// bottom: TabBar(
|
||||
/// bottom: const TabBar(
|
||||
/// tabs: tabs,
|
||||
/// ),
|
||||
/// ),
|
||||
|
@ -579,8 +579,8 @@ class _TabBarScrollController extends ScrollController {
|
||||
/// length: 3,
|
||||
/// child: Scaffold(
|
||||
/// appBar: AppBar(
|
||||
/// title: Text('TabBar Widget'),
|
||||
/// bottom: TabBar(
|
||||
/// title: const Text('TabBar Widget'),
|
||||
/// bottom: const TabBar(
|
||||
/// tabs: <Widget>[
|
||||
/// Tab(
|
||||
/// icon: Icon(Icons.cloud_outlined),
|
||||
@ -594,7 +594,7 @@ class _TabBarScrollController extends ScrollController {
|
||||
/// ],
|
||||
/// ),
|
||||
/// ),
|
||||
/// body: TabBarView(
|
||||
/// body: const TabBarView(
|
||||
/// children: <Widget>[
|
||||
/// Center(
|
||||
/// child: Text('It\'s cloudy here'),
|
||||
@ -628,13 +628,14 @@ class _TabBarScrollController extends ScrollController {
|
||||
/// _tabController = TabController(length: 3, vsync: this);
|
||||
/// }
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Scaffold(
|
||||
/// appBar: AppBar(
|
||||
/// title: Text('TabBar Widget'),
|
||||
/// title: const Text('TabBar Widget'),
|
||||
/// bottom: TabBar(
|
||||
/// controller: _tabController,
|
||||
/// tabs: <Widget>[
|
||||
/// tabs: const <Widget>[
|
||||
/// Tab(
|
||||
/// icon: Icon(Icons.cloud_outlined),
|
||||
/// ),
|
||||
@ -649,7 +650,7 @@ class _TabBarScrollController extends ScrollController {
|
||||
/// ),
|
||||
/// body: TabBarView(
|
||||
/// controller: _tabController,
|
||||
/// children: <Widget>[
|
||||
/// children: const <Widget>[
|
||||
/// Center(
|
||||
/// child: Text('It\'s cloudy here'),
|
||||
/// ),
|
||||
|
@ -64,7 +64,7 @@ import 'theme_data.dart';
|
||||
/// children: <Widget>[
|
||||
/// TextButton(
|
||||
/// style: TextButton.styleFrom(
|
||||
/// textStyle: TextStyle(fontSize: 20),
|
||||
/// textStyle: const TextStyle(fontSize: 20),
|
||||
/// ),
|
||||
/// onPressed: null,
|
||||
/// child: const Text('Disabled'),
|
||||
@ -72,7 +72,7 @@ import 'theme_data.dart';
|
||||
/// const SizedBox(height: 30),
|
||||
/// TextButton(
|
||||
/// style: TextButton.styleFrom(
|
||||
/// textStyle: TextStyle(fontSize: 20),
|
||||
/// textStyle: const TextStyle(fontSize: 20),
|
||||
/// ),
|
||||
/// onPressed: () {},
|
||||
/// child: const Text('Enabled'),
|
||||
@ -99,7 +99,7 @@ import 'theme_data.dart';
|
||||
/// style: TextButton.styleFrom(
|
||||
/// padding: const EdgeInsets.all(16.0),
|
||||
/// primary: Colors.white,
|
||||
/// textStyle: TextStyle(fontSize: 20),
|
||||
/// textStyle: const TextStyle(fontSize: 20),
|
||||
/// ),
|
||||
/// onPressed: () {},
|
||||
/// child: const Text('Gradient'),
|
||||
|
@ -181,7 +181,7 @@ class _TextFieldSelectionGestureDetectorBuilder extends TextSelectionGestureDete
|
||||
/// 
|
||||
///
|
||||
/// ```dart
|
||||
/// TextField(
|
||||
/// const TextField(
|
||||
/// obscureText: true,
|
||||
/// decoration: InputDecoration(
|
||||
/// border: OutlineInputBorder(),
|
||||
@ -205,16 +205,19 @@ class _TextFieldSelectionGestureDetectorBuilder extends TextSelectionGestureDete
|
||||
/// ```dart
|
||||
/// late TextEditingController _controller;
|
||||
///
|
||||
/// @override
|
||||
/// void initState() {
|
||||
/// super.initState();
|
||||
/// _controller = TextEditingController();
|
||||
/// }
|
||||
///
|
||||
/// @override
|
||||
/// void dispose() {
|
||||
/// _controller.dispose();
|
||||
/// super.dispose();
|
||||
/// }
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Scaffold(
|
||||
/// body: Center(
|
||||
|
@ -76,6 +76,7 @@ export 'package:flutter/services.dart' show SmartQuotesType, SmartDashesType;
|
||||
/// ```
|
||||
///
|
||||
/// ```dart
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Material(
|
||||
/// child: Center(
|
||||
|
@ -118,7 +118,7 @@ class TextSelectionThemeData with Diagnosticable {
|
||||
/// color with light blue selection handles to the child text field.
|
||||
///
|
||||
/// ```dart
|
||||
/// TextSelectionTheme(
|
||||
/// const TextSelectionTheme(
|
||||
/// data: TextSelectionThemeData(
|
||||
/// cursorColor: Colors.blue,
|
||||
/// selectionHandleColor: Colors.lightBlue,
|
||||
|
@ -353,7 +353,7 @@ class TextTheme with Diagnosticable {
|
||||
/// /// A Widget that sets the ambient theme's title text color for its
|
||||
/// /// descendants, while leaving other ambient theme attributes alone.
|
||||
/// class TitleColorThemeCopy extends StatelessWidget {
|
||||
/// TitleColorThemeCopy({Key? key, required this.child, required this.titleColor}) : super(key: key);
|
||||
/// const TitleColorThemeCopy({Key? key, required this.child, required this.titleColor}) : super(key: key);
|
||||
///
|
||||
/// final Color titleColor;
|
||||
/// final Widget child;
|
||||
@ -494,7 +494,7 @@ class TextTheme with Diagnosticable {
|
||||
/// /// A Widget that sets the ambient theme's title text color for its
|
||||
/// /// descendants, while leaving other ambient theme attributes alone.
|
||||
/// class TitleColorTheme extends StatelessWidget {
|
||||
/// TitleColorTheme({Key? key, required this.child, required this.titleColor}) : super(key: key);
|
||||
/// const TitleColorTheme({Key? key, required this.child, required this.titleColor}) : super(key: key);
|
||||
///
|
||||
/// final Color titleColor;
|
||||
/// final Widget child;
|
||||
@ -507,7 +507,7 @@ class TextTheme with Diagnosticable {
|
||||
/// // set the title, but everything else would be null. This isn't very
|
||||
/// // useful, so merge it with the existing theme to keep all of the
|
||||
/// // preexisting definitions for the other styles.
|
||||
/// TextTheme partialTheme = TextTheme(headline6: TextStyle(color: titleColor));
|
||||
/// final TextTheme partialTheme = TextTheme(headline6: TextStyle(color: titleColor));
|
||||
/// theme = theme.copyWith(textTheme: theme.textTheme.merge(partialTheme));
|
||||
/// return Theme(data: theme, child: child);
|
||||
/// }
|
||||
|
@ -164,7 +164,7 @@ enum MaterialTapTargetSize {
|
||||
/// theme: ThemeData(
|
||||
/// primaryColor: Colors.blue,
|
||||
/// accentColor: Colors.green,
|
||||
/// textTheme: TextTheme(bodyText2: TextStyle(color: Colors.purple)),
|
||||
/// textTheme: const TextTheme(bodyText2: TextStyle(color: Colors.purple)),
|
||||
/// ),
|
||||
/// home: Scaffold(
|
||||
/// appBar: AppBar(
|
||||
@ -174,10 +174,8 @@ enum MaterialTapTargetSize {
|
||||
/// child: const Icon(Icons.add),
|
||||
/// onPressed: () {},
|
||||
/// ),
|
||||
/// body: Center(
|
||||
/// child: Text(
|
||||
/// 'Button pressed 0 times',
|
||||
/// ),
|
||||
/// body: const Center(
|
||||
/// child: Text('Button pressed 0 times'),
|
||||
/// ),
|
||||
/// ),
|
||||
/// )
|
||||
@ -722,8 +720,8 @@ class ThemeData with Diagnosticable {
|
||||
///
|
||||
/// ```dart
|
||||
/// MaterialApp(
|
||||
/// theme: ThemeData.from(colorScheme: ColorScheme.light()),
|
||||
/// darkTheme: ThemeData.from(colorScheme: ColorScheme.dark()),
|
||||
/// theme: ThemeData.from(colorScheme: const ColorScheme.light()),
|
||||
/// darkTheme: ThemeData.from(colorScheme: const ColorScheme.dark()),
|
||||
/// )
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
|
@ -31,7 +31,7 @@ enum DayPeriod {
|
||||
///
|
||||
/// ```dart
|
||||
/// TimeOfDay now = TimeOfDay.now();
|
||||
/// TimeOfDay releaseTime = TimeOfDay(hour: 15, minute: 0); // 3:00pm
|
||||
/// const TimeOfDay releaseTime = TimeOfDay(hour: 15, minute: 0); // 3:00pm
|
||||
/// TimeOfDay roomBooked = TimeOfDay.fromDateTime(DateTime.parse('2018-10-20 16:30:04Z')); // 4:30pm
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
|
@ -2174,7 +2174,7 @@ class _TimePickerDialogState extends State<_TimePickerDialog> {
|
||||
/// ```dart
|
||||
/// Future<TimeOfDay?> selectedTime24Hour = showTimePicker(
|
||||
/// context: context,
|
||||
/// initialTime: TimeOfDay(hour: 10, minute: 47),
|
||||
/// initialTime: const TimeOfDay(hour: 10, minute: 47),
|
||||
/// builder: (BuildContext context, Widget? child) {
|
||||
/// return MediaQuery(
|
||||
/// data: MediaQuery.of(context).copyWith(alwaysUse24HourFormat: true),
|
||||
|
@ -38,9 +38,9 @@ import 'tooltip_theme.dart';
|
||||
///
|
||||
/// ```dart
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Tooltip(
|
||||
/// message: "I am a Tooltip",
|
||||
/// child: Text("Hover over the text to show a tooltip."),
|
||||
/// return const Tooltip(
|
||||
/// message: 'I am a Tooltip',
|
||||
/// child: Text('Hover over the text to show a tooltip.'),
|
||||
/// );
|
||||
/// }
|
||||
/// ```
|
||||
@ -63,20 +63,20 @@ import 'tooltip_theme.dart';
|
||||
/// ```dart
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Tooltip(
|
||||
/// message: "I am a Tooltip",
|
||||
/// child: Text("Tap this text and hold down to show a tooltip."),
|
||||
/// message: 'I am a Tooltip',
|
||||
/// child: const Text('Tap this text and hold down to show a tooltip.'),
|
||||
/// decoration: BoxDecoration(
|
||||
/// borderRadius: BorderRadius.circular(25),
|
||||
/// gradient: LinearGradient(colors: [Colors.amber, Colors.red]),
|
||||
/// gradient: const LinearGradient(colors: <Color>[Colors.amber, Colors.red]),
|
||||
/// ),
|
||||
/// height: 50,
|
||||
/// padding: EdgeInsets.all(8.0),
|
||||
/// padding: const EdgeInsets.all(8.0),
|
||||
/// preferBelow: false,
|
||||
/// textStyle: TextStyle(
|
||||
/// textStyle: const TextStyle(
|
||||
/// fontSize: 24,
|
||||
/// ),
|
||||
/// showDuration: Duration(seconds: 2),
|
||||
/// waitDuration: Duration(seconds: 1),
|
||||
/// showDuration: const Duration(seconds: 2),
|
||||
/// waitDuration: const Duration(seconds: 1),
|
||||
/// );
|
||||
/// }
|
||||
/// ```
|
||||
|
@ -207,7 +207,7 @@ class TooltipThemeData with Diagnosticable {
|
||||
/// message: 'Example tooltip',
|
||||
/// child: IconButton(
|
||||
/// iconSize: 36.0,
|
||||
/// icon: Icon(Icons.touch_app),
|
||||
/// icon: const Icon(Icons.touch_app),
|
||||
/// onPressed: () {},
|
||||
/// ),
|
||||
/// ),
|
||||
|
@ -38,14 +38,14 @@ enum BorderStyle {
|
||||
///
|
||||
/// ```dart
|
||||
/// Container(
|
||||
/// padding: EdgeInsets.all(8.0),
|
||||
/// padding: const EdgeInsets.all(8.0),
|
||||
/// decoration: BoxDecoration(
|
||||
/// border: Border(
|
||||
/// top: BorderSide(width: 16.0, color: Colors.lightBlue.shade50),
|
||||
/// bottom: BorderSide(width: 16.0, color: Colors.lightBlue.shade900),
|
||||
/// ),
|
||||
/// ),
|
||||
/// child: Text('Flutter in the sky', textAlign: TextAlign.center),
|
||||
/// child: const Text('Flutter in the sky', textAlign: TextAlign.center),
|
||||
/// )
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
|
@ -267,20 +267,20 @@ abstract class BoxBorder extends ShapeBorder {
|
||||
/// Container(
|
||||
/// decoration: const BoxDecoration(
|
||||
/// border: Border(
|
||||
/// top: BorderSide(width: 1.0, color: Color(0xFFFFFFFFFF)),
|
||||
/// left: BorderSide(width: 1.0, color: Color(0xFFFFFFFFFF)),
|
||||
/// right: BorderSide(width: 1.0, color: Color(0xFFFF000000)),
|
||||
/// bottom: BorderSide(width: 1.0, color: Color(0xFFFF000000)),
|
||||
/// top: BorderSide(width: 1.0, color: Color(0xFFFFFFFF)),
|
||||
/// left: BorderSide(width: 1.0, color: Color(0xFFFFFFFF)),
|
||||
/// right: BorderSide(width: 1.0, color: Color(0xFF000000)),
|
||||
/// bottom: BorderSide(width: 1.0, color: Color(0xFF000000)),
|
||||
/// ),
|
||||
/// ),
|
||||
/// child: Container(
|
||||
/// padding: const EdgeInsets.symmetric(horizontal: 20.0, vertical: 2.0),
|
||||
/// decoration: const BoxDecoration(
|
||||
/// border: Border(
|
||||
/// top: BorderSide(width: 1.0, color: Color(0xFFFFDFDFDF)),
|
||||
/// left: BorderSide(width: 1.0, color: Color(0xFFFFDFDFDF)),
|
||||
/// right: BorderSide(width: 1.0, color: Color(0xFFFF7F7F7F)),
|
||||
/// bottom: BorderSide(width: 1.0, color: Color(0xFFFF7F7F7F)),
|
||||
/// top: BorderSide(width: 1.0, color: Color(0xFFDFDFDF)),
|
||||
/// left: BorderSide(width: 1.0, color: Color(0xFFDFDFDF)),
|
||||
/// right: BorderSide(width: 1.0, color: Color(0xFF7F7F7F)),
|
||||
/// bottom: BorderSide(width: 1.0, color: Color(0xFF7F7F7F)),
|
||||
/// ),
|
||||
/// color: Color(0xFFBFBFBF),
|
||||
/// ),
|
||||
|
@ -338,11 +338,11 @@ abstract class Gradient {
|
||||
/// ```dart
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Container(
|
||||
/// decoration: BoxDecoration(
|
||||
/// gradient: LinearGradient(
|
||||
/// decoration: const BoxDecoration(
|
||||
/// gradient: const LinearGradient(
|
||||
/// begin: Alignment.topLeft,
|
||||
/// end: Alignment(0.8, 0.0), // 10% of the width, so there are ten blinds.
|
||||
/// colors: [const Color(0xffee0000), const Color(0xffeeee00)], // red to yellow
|
||||
/// colors: const <Color>[Color(0xffee0000), Color(0xffeeee00)], // red to yellow
|
||||
/// tileMode: TileMode.repeated, // repeats the gradient over the canvas
|
||||
/// ),
|
||||
/// ),
|
||||
@ -562,17 +562,17 @@ class LinearGradient extends Gradient {
|
||||
///
|
||||
/// ```dart
|
||||
/// void paintSky(Canvas canvas, Rect rect) {
|
||||
/// var gradient = RadialGradient(
|
||||
/// center: const Alignment(0.7, -0.6), // near the top right
|
||||
/// const RadialGradient gradient = RadialGradient(
|
||||
/// center: Alignment(0.7, -0.6), // near the top right
|
||||
/// radius: 0.2,
|
||||
/// colors: [
|
||||
/// const Color(0xFFFFFF00), // yellow sun
|
||||
/// const Color(0xFF0099FF), // blue sky
|
||||
/// colors: <Color>[
|
||||
/// Color(0xFFFFFF00), // yellow sun
|
||||
/// Color(0xFF0099FF), // blue sky
|
||||
/// ],
|
||||
/// stops: [0.4, 1.0],
|
||||
/// stops: <double>[0.4, 1.0],
|
||||
/// );
|
||||
/// // rect is the area we are painting over
|
||||
/// var paint = Paint()
|
||||
/// final Paint paint = Paint()
|
||||
/// ..shader = gradient.createShader(rect);
|
||||
/// canvas.drawRect(rect, paint);
|
||||
/// }
|
||||
@ -810,19 +810,19 @@ class RadialGradient extends Gradient {
|
||||
///
|
||||
/// ```dart
|
||||
/// Container(
|
||||
/// decoration: BoxDecoration(
|
||||
/// decoration: const BoxDecoration(
|
||||
/// gradient: SweepGradient(
|
||||
/// center: FractionalOffset.center,
|
||||
/// startAngle: 0.0,
|
||||
/// endAngle: math.pi * 2,
|
||||
/// colors: const <Color>[
|
||||
/// colors: <Color>[
|
||||
/// Color(0xFF4285F4), // blue
|
||||
/// Color(0xFF34A853), // green
|
||||
/// Color(0xFFFBBC05), // yellow
|
||||
/// Color(0xFFEA4335), // red
|
||||
/// Color(0xFF4285F4), // blue again to seamlessly transition to the start
|
||||
/// ],
|
||||
/// stops: const <double>[0.0, 0.25, 0.5, 0.75, 1.0],
|
||||
/// stops: <double>[0.0, 0.25, 0.5, 0.75, 1.0],
|
||||
/// ),
|
||||
/// )
|
||||
/// )
|
||||
@ -836,19 +836,19 @@ class RadialGradient extends Gradient {
|
||||
///
|
||||
/// ```dart
|
||||
/// Container(
|
||||
/// decoration: BoxDecoration(
|
||||
/// decoration: const BoxDecoration(
|
||||
/// gradient: SweepGradient(
|
||||
/// center: FractionalOffset.center,
|
||||
/// startAngle: 0.0,
|
||||
/// endAngle: math.pi * 2,
|
||||
/// colors: const <Color>[
|
||||
/// colors: <Color>[
|
||||
/// Color(0xFF4285F4), // blue
|
||||
/// Color(0xFF34A853), // green
|
||||
/// Color(0xFFFBBC05), // yellow
|
||||
/// Color(0xFFEA4335), // red
|
||||
/// Color(0xFF4285F4), // blue again to seamlessly transition to the start
|
||||
/// ],
|
||||
/// stops: const <double>[0.0, 0.25, 0.5, 0.75, 1.0],
|
||||
/// stops: <double>[0.0, 0.25, 0.5, 0.75, 1.0],
|
||||
/// transform: GradientRotation(math.pi/4),
|
||||
/// ),
|
||||
/// ),
|
||||
|
@ -19,7 +19,7 @@ const int _kDefaultSizeBytes = 100 << 20; // 100 MiB
|
||||
/// MB. The maximum size can be adjusted using [maximumSize] and
|
||||
/// [maximumSizeBytes].
|
||||
///
|
||||
/// The cache also holds a list of "live" references. An image is considered
|
||||
/// The cache also holds a list of 'live' references. An image is considered
|
||||
/// live if its [ImageStreamCompleter]'s listener count has never dropped to
|
||||
/// zero after adding at least one listener. The cache uses
|
||||
/// [ImageStreamCompleter.addOnLastListenerRemovedCallback] to determine when
|
||||
@ -28,7 +28,7 @@ const int _kDefaultSizeBytes = 100 << 20; // 100 MiB
|
||||
/// The [putIfAbsent] method is the main entry-point to the cache API. It
|
||||
/// returns the previously cached [ImageStreamCompleter] for the given key, if
|
||||
/// available; if not, it calls the given callback to obtain it first. In either
|
||||
/// case, the key is moved to the "most recently used" position.
|
||||
/// case, the key is moved to the 'most recently used' position.
|
||||
///
|
||||
/// A caller can determine whether an image is already in the cache by using
|
||||
/// [containsKey], which will return true if the image is tracked by the cache
|
||||
@ -52,7 +52,7 @@ const int _kDefaultSizeBytes = 100 << 20; // 100 MiB
|
||||
/// class MyImageCache extends ImageCache {
|
||||
/// @override
|
||||
/// void clear() {
|
||||
/// print("Clearing cache!");
|
||||
/// print('Clearing cache!');
|
||||
/// super.clear();
|
||||
/// }
|
||||
/// }
|
||||
@ -65,10 +65,12 @@ const int _kDefaultSizeBytes = 100 << 20; // 100 MiB
|
||||
/// void main() {
|
||||
/// // The constructor sets global variables.
|
||||
/// MyWidgetsBinding();
|
||||
/// runApp(MyApp());
|
||||
/// runApp(const MyApp());
|
||||
/// }
|
||||
///
|
||||
/// class MyApp extends StatelessWidget {
|
||||
/// const MyApp({Key? key}) : super(key: key);
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Container();
|
||||
@ -309,7 +311,7 @@ class ImageCache {
|
||||
|
||||
/// Returns the previously cached [ImageStream] for the given key, if available;
|
||||
/// if not, calls the given callback to obtain it first. In either case, the
|
||||
/// key is moved to the "most recently used" position.
|
||||
/// key is moved to the 'most recently used' position.
|
||||
///
|
||||
/// The arguments must not be null. The `loader` cannot return null.
|
||||
///
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user