Unverified Commit 21e80274 authored by Emmanuel Garcia's avatar Emmanuel Garcia Committed by GitHub

Migrate Flutter Gallery test to null safety (#70116)

parent 43e1d159
...@@ -29,15 +29,13 @@ dependencies: ...@@ -29,15 +29,13 @@ dependencies:
coverage: 0.14.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" coverage: 0.14.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
crypto: 2.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
csslib: 0.16.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" csslib: 0.16.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
dart_style: 1.3.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
fake_async: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" fake_async: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
glob: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
html: 0.14.0+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" html: 0.14.0+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
http: 0.12.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http: 0.12.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
http_multi_server: 2.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 2.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
http_parser: 3.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
intl: 0.16.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" intl: 0.17.0-nullsafety.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
intl_translation: 0.17.10+1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
io: 0.3.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 0.3.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
isolate: 2.0.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" isolate: 2.0.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
js: 0.6.3-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" js: 0.6.3-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
...@@ -50,7 +48,6 @@ dependencies: ...@@ -50,7 +48,6 @@ dependencies:
package_config: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" package_config: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
path: 1.8.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.8.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
pedantic: 1.10.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.10.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
petitparser: 3.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
pool: 1.5.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.5.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
pub_semver: 1.4.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pub_semver: 1.4.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
shelf: 0.7.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf: 0.7.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
...@@ -77,4 +74,4 @@ dependencies: ...@@ -77,4 +74,4 @@ dependencies:
flutter: flutter:
uses-material-design: true uses-material-design: true
# PUBSPEC CHECKSUM: 77af # PUBSPEC CHECKSUM: 2c1c
...@@ -9,42 +9,23 @@ dependencies: ...@@ -9,42 +9,23 @@ dependencies:
sdk: flutter sdk: flutter
flutter_localizations: flutter_localizations:
sdk: flutter sdk: flutter
intl: 0.16.1 intl: 0.17.0-nullsafety.2
intl_translation: 0.17.10+1
http: 0.12.2 http: 0.12.2
isolate: 2.0.3 isolate: 2.0.3
_fe_analyzer_shared: 7.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
analyzer: 0.39.17 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
args: 1.6.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
async: 2.5.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
characters: 1.1.0-nullsafety.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" characters: 1.1.0-nullsafety.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
charcode: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
cli_util: 0.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" clock: 1.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
collection: 1.15.0-nullsafety.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.15.0-nullsafety.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
crypto: 2.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
csslib: 0.16.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
dart_style: 1.3.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
glob: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
html: 0.14.0+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
http_parser: 3.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
js: 0.6.3-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
meta: 1.3.0-nullsafety.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.3.0-nullsafety.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
node_interop: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
node_io: 1.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
package_config: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
path: 1.8.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.8.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
pedantic: 1.10.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pedantic: 1.10.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
petitparser: 3.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
pub_semver: 1.4.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
source_span: 1.8.0-nullsafety.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.8.0-nullsafety.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
string_scanner: 1.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" string_scanner: 1.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
term_glyph: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
typed_data: 1.3.0-nullsafety.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" typed_data: 1.3.0-nullsafety.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
vector_math: 2.1.0-nullsafety.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vector_math: 2.1.0-nullsafety.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
watcher: 0.9.7+15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
yaml: 2.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
...@@ -53,19 +34,33 @@ dev_dependencies: ...@@ -53,19 +34,33 @@ dev_dependencies:
sdk: flutter sdk: flutter
test: 1.16.0-nullsafety.9 test: 1.16.0-nullsafety.9
_fe_analyzer_shared: 7.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
analyzer: 0.39.17 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
archive: 2.0.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" archive: 2.0.13 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
args: 1.6.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
async: 2.5.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
boolean_selector: 2.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 2.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
clock: 1.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" cli_util: 0.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
coverage: 0.14.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" coverage: 0.14.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
crypto: 2.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
csslib: 0.16.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
fake_async: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" fake_async: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
file: 6.0.0-nullsafety.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" file: 6.0.0-nullsafety.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
glob: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
html: 0.14.0+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
http_multi_server: 2.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_multi_server: 2.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
io: 0.3.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" io: 0.3.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
js: 0.6.3-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
logging: 0.11.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" logging: 0.11.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
matcher: 0.12.10-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" matcher: 0.12.10-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
mime: 0.9.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" mime: 0.9.7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
node_interop: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
node_io: 1.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
node_preamble: 1.4.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" node_preamble: 1.4.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
package_config: 1.9.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
pool: 1.5.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" pool: 1.5.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
pub_semver: 1.4.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
shelf: 0.7.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf: 0.7.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
shelf_packages_handler: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_packages_handler: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
...@@ -78,11 +73,13 @@ dev_dependencies: ...@@ -78,11 +73,13 @@ dev_dependencies:
test_api: 0.2.19-nullsafety.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" test_api: 0.2.19-nullsafety.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
test_core: 0.3.12-nullsafety.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" test_core: 0.3.12-nullsafety.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
vm_service: 5.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" vm_service: 5.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
watcher: 0.9.7+15 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
web_socket_channel: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" web_socket_channel: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
webdriver: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" webdriver: 2.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
webkit_inspection_protocol: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" webkit_inspection_protocol: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
yaml: 2.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
flutter: flutter:
uses-material-design: true uses-material-design: true
# PUBSPEC CHECKSUM: b21f # PUBSPEC CHECKSUM: 4b8b
...@@ -32,10 +32,10 @@ const double _kAppBarMidHeight = 256.0; ...@@ -32,10 +32,10 @@ const double _kAppBarMidHeight = 256.0;
// TODO(hansmuller): it would be worth adding something like this to the framework. // TODO(hansmuller): it would be worth adding something like this to the framework.
class _RenderStatusBarPaddingSliver extends RenderSliver { class _RenderStatusBarPaddingSliver extends RenderSliver {
_RenderStatusBarPaddingSliver({ _RenderStatusBarPaddingSliver({
@required double maxHeight, required double maxHeight,
@required double scrollFactor, required double scrollFactor,
}) : assert(maxHeight != null && maxHeight >= 0.0), }) : assert(maxHeight >= 0.0),
assert(scrollFactor != null && scrollFactor >= 1.0), assert(scrollFactor >= 1.0),
_maxHeight = maxHeight, _maxHeight = maxHeight,
_scrollFactor = scrollFactor; _scrollFactor = scrollFactor;
...@@ -43,7 +43,7 @@ class _RenderStatusBarPaddingSliver extends RenderSliver { ...@@ -43,7 +43,7 @@ class _RenderStatusBarPaddingSliver extends RenderSliver {
double get maxHeight => _maxHeight; double get maxHeight => _maxHeight;
double _maxHeight; double _maxHeight;
set maxHeight(double value) { set maxHeight(double value) {
assert(maxHeight != null && maxHeight >= 0.0); assert(maxHeight >= 0.0);
if (_maxHeight == value) if (_maxHeight == value)
return; return;
_maxHeight = value; _maxHeight = value;
...@@ -55,7 +55,7 @@ class _RenderStatusBarPaddingSliver extends RenderSliver { ...@@ -55,7 +55,7 @@ class _RenderStatusBarPaddingSliver extends RenderSliver {
double get scrollFactor => _scrollFactor; double get scrollFactor => _scrollFactor;
double _scrollFactor; double _scrollFactor;
set scrollFactor(double value) { set scrollFactor(double value) {
assert(scrollFactor != null && scrollFactor >= 1.0); assert(scrollFactor >= 1.0);
if (_scrollFactor == value) if (_scrollFactor == value)
return; return;
_scrollFactor = value; _scrollFactor = value;
...@@ -64,7 +64,7 @@ class _RenderStatusBarPaddingSliver extends RenderSliver { ...@@ -64,7 +64,7 @@ class _RenderStatusBarPaddingSliver extends RenderSliver {
@override @override
void performLayout() { void performLayout() {
final double height = (maxHeight - constraints.scrollOffset / scrollFactor).clamp(0.0, maxHeight) as double; final double height = (maxHeight - constraints.scrollOffset / scrollFactor).clamp(0.0, maxHeight);
geometry = SliverGeometry( geometry = SliverGeometry(
paintExtent: math.min(height, constraints.remainingPaintExtent), paintExtent: math.min(height, constraints.remainingPaintExtent),
scrollExtent: maxHeight, scrollExtent: maxHeight,
...@@ -75,11 +75,11 @@ class _RenderStatusBarPaddingSliver extends RenderSliver { ...@@ -75,11 +75,11 @@ class _RenderStatusBarPaddingSliver extends RenderSliver {
class _StatusBarPaddingSliver extends SingleChildRenderObjectWidget { class _StatusBarPaddingSliver extends SingleChildRenderObjectWidget {
const _StatusBarPaddingSliver({ const _StatusBarPaddingSliver({
Key key, Key? key,
@required this.maxHeight, required this.maxHeight,
this.scrollFactor = 5.0, this.scrollFactor = 5.0,
}) : assert(maxHeight != null && maxHeight >= 0.0), }) : assert(maxHeight >= 0.0),
assert(scrollFactor != null && scrollFactor >= 1.0), assert(scrollFactor >= 1.0),
super(key: key); super(key: key);
final double maxHeight; final double maxHeight;
...@@ -110,9 +110,9 @@ class _StatusBarPaddingSliver extends SingleChildRenderObjectWidget { ...@@ -110,9 +110,9 @@ class _StatusBarPaddingSliver extends SingleChildRenderObjectWidget {
class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate { class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
_SliverAppBarDelegate({ _SliverAppBarDelegate({
@required this.minHeight, required this.minHeight,
@required this.maxHeight, required this.maxHeight,
@required this.child, required this.child,
}); });
final double minHeight; final double minHeight;
...@@ -170,51 +170,51 @@ class _AllSectionsLayout extends MultiChildLayoutDelegate { ...@@ -170,51 +170,51 @@ class _AllSectionsLayout extends MultiChildLayoutDelegate {
this.selectedIndex, this.selectedIndex,
}); });
final Alignment translation; final Alignment? translation;
final double tColumnToRow; final double? tColumnToRow;
final double tCollapsed; final double? tCollapsed;
final int cardCount; final int? cardCount;
final double selectedIndex; final double? selectedIndex;
Rect _interpolateRect(Rect begin, Rect end) { Rect? _interpolateRect(Rect begin, Rect end) {
return Rect.lerp(begin, end, tColumnToRow); return Rect.lerp(begin, end, tColumnToRow!);
} }
Offset _interpolatePoint(Offset begin, Offset end) { Offset? _interpolatePoint(Offset begin, Offset end) {
return Offset.lerp(begin, end, tColumnToRow); return Offset.lerp(begin, end, tColumnToRow!);
} }
@override @override
void performLayout(Size size) { void performLayout(Size size) {
final double columnCardX = size.width / 5.0; final double columnCardX = size.width / 5.0;
final double columnCardWidth = size.width - columnCardX; final double columnCardWidth = size.width - columnCardX;
final double columnCardHeight = size.height / cardCount; final double columnCardHeight = size.height / cardCount!;
final double rowCardWidth = size.width; final double rowCardWidth = size.width;
final Offset offset = translation.alongSize(size); final Offset offset = translation!.alongSize(size);
double columnCardY = 0.0; double columnCardY = 0.0;
double rowCardX = -(selectedIndex * rowCardWidth); double rowCardX = -(selectedIndex! * rowCardWidth);
// When tCollapsed > 0 the titles spread apart // When tCollapsed > 0 the titles spread apart
final double columnTitleX = size.width / 10.0; final double columnTitleX = size.width / 10.0;
final double rowTitleWidth = size.width * ((1 + tCollapsed) / 2.25); final double rowTitleWidth = size.width * ((1 + tCollapsed!) / 2.25);
double rowTitleX = (size.width - rowTitleWidth) / 2.0 - selectedIndex * rowTitleWidth; double rowTitleX = (size.width - rowTitleWidth) / 2.0 - selectedIndex! * rowTitleWidth;
// When tCollapsed > 0, the indicators move closer together // When tCollapsed > 0, the indicators move closer together
//final double rowIndicatorWidth = 48.0 + (1.0 - tCollapsed) * (rowTitleWidth - 48.0); //final double rowIndicatorWidth = 48.0 + (1.0 - tCollapsed) * (rowTitleWidth - 48.0);
const double paddedSectionIndicatorWidth = kSectionIndicatorWidth + 8.0; const double paddedSectionIndicatorWidth = kSectionIndicatorWidth + 8.0;
final double rowIndicatorWidth = paddedSectionIndicatorWidth + final double rowIndicatorWidth = paddedSectionIndicatorWidth +
(1.0 - tCollapsed) * (rowTitleWidth - paddedSectionIndicatorWidth); (1.0 - tCollapsed!) * (rowTitleWidth - paddedSectionIndicatorWidth);
double rowIndicatorX = (size.width - rowIndicatorWidth) / 2.0 - selectedIndex * rowIndicatorWidth; double rowIndicatorX = (size.width - rowIndicatorWidth) / 2.0 - selectedIndex! * rowIndicatorWidth;
// Compute the size and origin of each card, title, and indicator for the maxHeight // Compute the size and origin of each card, title, and indicator for the maxHeight
// "column" layout, and the midHeight "row" layout. The actual layout is just the // "column" layout, and the midHeight "row" layout. The actual layout is just the
// interpolated value between the column and row layouts for t. // interpolated value between the column and row layouts for t.
for (int index = 0; index < cardCount; index++) { for (int index = 0; index < cardCount!; index++) {
// Layout the card for index. // Layout the card for index.
final Rect columnCardRect = Rect.fromLTWH(columnCardX, columnCardY, columnCardWidth, columnCardHeight); final Rect columnCardRect = Rect.fromLTWH(columnCardX, columnCardY, columnCardWidth, columnCardHeight);
final Rect rowCardRect = Rect.fromLTWH(rowCardX, 0.0, rowCardWidth, size.height); final Rect rowCardRect = Rect.fromLTWH(rowCardX, 0.0, rowCardWidth, size.height);
final Rect cardRect = _interpolateRect(columnCardRect, rowCardRect).shift(offset); final Rect cardRect = _interpolateRect(columnCardRect, rowCardRect)!.shift(offset);
final String cardId = 'card$index'; final String cardId = 'card$index';
if (hasChild(cardId)) { if (hasChild(cardId)) {
layoutChild(cardId, BoxConstraints.tight(cardRect.size)); layoutChild(cardId, BoxConstraints.tight(cardRect.size));
...@@ -228,7 +228,7 @@ class _AllSectionsLayout extends MultiChildLayoutDelegate { ...@@ -228,7 +228,7 @@ class _AllSectionsLayout extends MultiChildLayoutDelegate {
final double centeredRowTitleX = rowTitleX + (rowTitleWidth - titleSize.width) / 2.0; final double centeredRowTitleX = rowTitleX + (rowTitleWidth - titleSize.width) / 2.0;
final Offset columnTitleOrigin = Offset(columnTitleX, columnTitleY); final Offset columnTitleOrigin = Offset(columnTitleX, columnTitleY);
final Offset rowTitleOrigin = Offset(centeredRowTitleX, rowTitleY); final Offset rowTitleOrigin = Offset(centeredRowTitleX, rowTitleY);
final Offset titleOrigin = _interpolatePoint(columnTitleOrigin, rowTitleOrigin); final Offset titleOrigin = _interpolatePoint(columnTitleOrigin, rowTitleOrigin)!;
positionChild('title$index', titleOrigin + offset); positionChild('title$index', titleOrigin + offset);
// Layout the selection indicator for index. // Layout the selection indicator for index.
...@@ -240,7 +240,7 @@ class _AllSectionsLayout extends MultiChildLayoutDelegate { ...@@ -240,7 +240,7 @@ class _AllSectionsLayout extends MultiChildLayoutDelegate {
final double centeredRowIndicatorX = rowIndicatorX + (rowIndicatorWidth - indicatorSize.width) / 2.0; final double centeredRowIndicatorX = rowIndicatorX + (rowIndicatorWidth - indicatorSize.width) / 2.0;
final double rowIndicatorY = titleRect.bottomCenter.dy + 16.0; final double rowIndicatorY = titleRect.bottomCenter.dy + 16.0;
final Offset rowIndicatorOrigin = Offset(centeredRowIndicatorX, rowIndicatorY); final Offset rowIndicatorOrigin = Offset(centeredRowIndicatorX, rowIndicatorY);
final Offset indicatorOrigin = _interpolatePoint(columnIndicatorOrigin, rowIndicatorOrigin); final Offset indicatorOrigin = _interpolatePoint(columnIndicatorOrigin, rowIndicatorOrigin)!;
positionChild('indicator$index', indicatorOrigin + offset); positionChild('indicator$index', indicatorOrigin + offset);
columnCardY += columnCardHeight; columnCardY += columnCardHeight;
...@@ -260,32 +260,29 @@ class _AllSectionsLayout extends MultiChildLayoutDelegate { ...@@ -260,32 +260,29 @@ class _AllSectionsLayout extends MultiChildLayoutDelegate {
class _AllSectionsView extends AnimatedWidget { class _AllSectionsView extends AnimatedWidget {
_AllSectionsView({ _AllSectionsView({
Key key, Key? key,
this.sectionIndex, required this.sectionIndex,
@required this.sections, required this.sections,
@required this.selectedIndex, required this.selectedIndex,
this.minHeight, this.minHeight,
this.midHeight, this.midHeight,
this.maxHeight, this.maxHeight,
this.sectionCards = const <Widget>[], this.sectionCards = const <Widget>[],
}) : assert(sections != null), }) : assert(sectionCards.length == sections.length),
assert(sectionCards != null),
assert(sectionCards.length == sections.length),
assert(sectionIndex >= 0 && sectionIndex < sections.length), assert(sectionIndex >= 0 && sectionIndex < sections.length),
assert(selectedIndex != null), assert(selectedIndex.value! >= 0.0 && selectedIndex.value! < sections.length.toDouble()),
assert(selectedIndex.value >= 0.0 && selectedIndex.value < sections.length.toDouble()),
super(key: key, listenable: selectedIndex); super(key: key, listenable: selectedIndex);
final int sectionIndex; final int sectionIndex;
final List<Section> sections; final List<Section> sections;
final ValueNotifier<double> selectedIndex; final ValueNotifier<double?> selectedIndex;
final double minHeight; final double? minHeight;
final double midHeight; final double? midHeight;
final double maxHeight; final double? maxHeight;
final List<Widget> sectionCards; final List<Widget> sectionCards;
double _selectedIndexDelta(int index) { double _selectedIndexDelta(int index) {
return (index.toDouble() - selectedIndex.value).abs().clamp(0.0, 1.0) as double; return (index.toDouble() - selectedIndex.value!).abs().clamp(0.0, 1.0);
} }
Widget _build(BuildContext context, BoxConstraints constraints) { Widget _build(BuildContext context, BoxConstraints constraints) {
...@@ -295,16 +292,16 @@ class _AllSectionsView extends AnimatedWidget { ...@@ -295,16 +292,16 @@ class _AllSectionsView extends AnimatedWidget {
// 0.0 when size.height equals the maxHeight, 1.0 when the size.height // 0.0 when size.height equals the maxHeight, 1.0 when the size.height
// equals the midHeight. // equals the midHeight.
final double tColumnToRow = final double tColumnToRow =
1.0 - ((size.height - midHeight) / 1.0 - ((size.height - midHeight!) /
(maxHeight - midHeight)).clamp(0.0, 1.0); (maxHeight! - midHeight!)).clamp(0.0, 1.0);
// The layout's progress from from the midHeight row layout to // The layout's progress from from the midHeight row layout to
// a minHeight row layout. Its value is 0.0 when size.height equals // a minHeight row layout. Its value is 0.0 when size.height equals
// midHeight and 1.0 when size.height equals minHeight. // midHeight and 1.0 when size.height equals minHeight.
final double tCollapsed = final double tCollapsed =
1.0 - ((size.height - minHeight) / 1.0 - ((size.height - minHeight!) /
(midHeight - minHeight)).clamp(0.0, 1.0); (midHeight! - minHeight!)).clamp(0.0, 1.0);
double _indicatorOpacity(int index) { double _indicatorOpacity(int index) {
return 1.0 - _selectedIndexDelta(index) * 0.5; return 1.0 - _selectedIndexDelta(index) * 0.5;
...@@ -343,7 +340,7 @@ class _AllSectionsView extends AnimatedWidget { ...@@ -343,7 +340,7 @@ class _AllSectionsView extends AnimatedWidget {
return CustomMultiChildLayout( return CustomMultiChildLayout(
delegate: _AllSectionsLayout( delegate: _AllSectionsLayout(
translation: Alignment((selectedIndex.value - sectionIndex) * 2.0 - 1.0, -1.0), translation: Alignment((selectedIndex.value! - sectionIndex) * 2.0 - 1.0, -1.0),
tColumnToRow: tColumnToRow, tColumnToRow: tColumnToRow,
tCollapsed: tCollapsed, tCollapsed: tCollapsed,
cardCount: sections.length, cardCount: sections.length,
...@@ -364,15 +361,14 @@ class _AllSectionsView extends AnimatedWidget { ...@@ -364,15 +361,14 @@ class _AllSectionsView extends AnimatedWidget {
// visible. // visible.
class _SnappingScrollPhysics extends ClampingScrollPhysics { class _SnappingScrollPhysics extends ClampingScrollPhysics {
const _SnappingScrollPhysics({ const _SnappingScrollPhysics({
ScrollPhysics parent, ScrollPhysics? parent,
@required this.midScrollOffset, required this.midScrollOffset,
}) : assert(midScrollOffset != null), }) : super(parent: parent);
super(parent: parent);
final double midScrollOffset; final double midScrollOffset;
@override @override
_SnappingScrollPhysics applyTo(ScrollPhysics ancestor) { _SnappingScrollPhysics applyTo(ScrollPhysics? ancestor) {
return _SnappingScrollPhysics(parent: buildParent(ancestor), midScrollOffset: midScrollOffset); return _SnappingScrollPhysics(parent: buildParent(ancestor), midScrollOffset: midScrollOffset);
} }
...@@ -387,8 +383,8 @@ class _SnappingScrollPhysics extends ClampingScrollPhysics { ...@@ -387,8 +383,8 @@ class _SnappingScrollPhysics extends ClampingScrollPhysics {
} }
@override @override
Simulation createBallisticSimulation(ScrollMetrics position, double dragVelocity) { Simulation? createBallisticSimulation(ScrollMetrics position, double dragVelocity) {
final Simulation simulation = super.createBallisticSimulation(position, dragVelocity); final Simulation? simulation = super.createBallisticSimulation(position, dragVelocity);
final double offset = position.pixels; final double offset = position.pixels;
if (simulation != null) { if (simulation != null) {
...@@ -419,7 +415,7 @@ class _SnappingScrollPhysics extends ClampingScrollPhysics { ...@@ -419,7 +415,7 @@ class _SnappingScrollPhysics extends ClampingScrollPhysics {
} }
class AnimationDemoHome extends StatefulWidget { class AnimationDemoHome extends StatefulWidget {
const AnimationDemoHome({ Key key }) : super(key: key); const AnimationDemoHome({ Key? key }) : super(key: key);
static const String routeName = '/animation'; static const String routeName = '/animation';
...@@ -432,7 +428,7 @@ class _AnimationDemoHomeState extends State<AnimationDemoHome> { ...@@ -432,7 +428,7 @@ class _AnimationDemoHomeState extends State<AnimationDemoHome> {
final PageController _headingPageController = PageController(); final PageController _headingPageController = PageController();
final PageController _detailsPageController = PageController(); final PageController _detailsPageController = PageController();
ScrollPhysics _headingScrollPhysics = const NeverScrollableScrollPhysics(); ScrollPhysics _headingScrollPhysics = const NeverScrollableScrollPhysics();
ValueNotifier<double> selectedIndex = ValueNotifier<double>(0.0); ValueNotifier<double?> selectedIndex = ValueNotifier<double?>(0.0);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -492,7 +488,7 @@ class _AnimationDemoHomeState extends State<AnimationDemoHome> { ...@@ -492,7 +488,7 @@ class _AnimationDemoHomeState extends State<AnimationDemoHome> {
} }
Iterable<Widget> _detailItemsFor(Section section) { Iterable<Widget> _detailItemsFor(Section section) {
final Iterable<Widget> detailItems = section.details.map<Widget>((SectionDetail detail) { final Iterable<Widget> detailItems = section.details!.map<Widget>((SectionDetail detail) {
return SectionDetailView(detail: detail); return SectionDetailView(detail: detail);
}); });
return ListTile.divideTiles(context: context, tiles: detailItems); return ListTile.divideTiles(context: context, tiles: detailItems);
......
...@@ -20,10 +20,10 @@ class SectionDetail { ...@@ -20,10 +20,10 @@ class SectionDetail {
this.imageAsset, this.imageAsset,
this.imageAssetPackage, this.imageAssetPackage,
}); });
final String title; final String? title;
final String subtitle; final String? subtitle;
final String imageAsset; final String? imageAsset;
final String imageAssetPackage; final String? imageAssetPackage;
} }
@immutable @immutable
...@@ -36,12 +36,12 @@ class Section { ...@@ -36,12 +36,12 @@ class Section {
this.rightColor, this.rightColor,
this.details, this.details,
}); });
final String title; final String? title;
final String backgroundAsset; final String? backgroundAsset;
final String backgroundAssetPackage; final String? backgroundAssetPackage;
final Color leftColor; final Color? leftColor;
final Color rightColor; final Color? rightColor;
final List<SectionDetail> details; final List<SectionDetail>? details;
@override @override
bool operator==(Object other) { bool operator==(Object other) {
......
...@@ -10,9 +10,8 @@ const double kSectionIndicatorWidth = 32.0; ...@@ -10,9 +10,8 @@ const double kSectionIndicatorWidth = 32.0;
// The card for a single section. Displays the section's gradient and background image. // The card for a single section. Displays the section's gradient and background image.
class SectionCard extends StatelessWidget { class SectionCard extends StatelessWidget {
const SectionCard({ Key key, @required this.section }) const SectionCard({ Key? key, required this.section })
: assert(section != null), : super(key: key);
super(key: key);
final Section section; final Section section;
...@@ -27,13 +26,13 @@ class SectionCard extends StatelessWidget { ...@@ -27,13 +26,13 @@ class SectionCard extends StatelessWidget {
begin: Alignment.centerLeft, begin: Alignment.centerLeft,
end: Alignment.centerRight, end: Alignment.centerRight,
colors: <Color>[ colors: <Color>[
section.leftColor, section.leftColor!,
section.rightColor, section.rightColor!,
], ],
), ),
), ),
child: Image.asset( child: Image.asset(
section.backgroundAsset, section.backgroundAsset!,
package: section.backgroundAssetPackage, package: section.backgroundAssetPackage,
color: const Color.fromRGBO(255, 255, 255, 0.075), color: const Color.fromRGBO(255, 255, 255, 0.075),
colorBlendMode: BlendMode.modulate, colorBlendMode: BlendMode.modulate,
...@@ -48,13 +47,11 @@ class SectionCard extends StatelessWidget { ...@@ -48,13 +47,11 @@ class SectionCard extends StatelessWidget {
// offset a little. It's supposed to look sort-of 3D. // offset a little. It's supposed to look sort-of 3D.
class SectionTitle extends StatelessWidget { class SectionTitle extends StatelessWidget {
const SectionTitle({ const SectionTitle({
Key key, Key? key,
@required this.section, required this.section,
@required this.scale, required this.scale,
@required this.opacity, required this.opacity,
}) : assert(section != null), }) : assert(opacity >= 0.0 && opacity <= 1.0),
assert(scale != null),
assert(opacity != null && opacity >= 0.0 && opacity <= 1.0),
super(key: key); super(key: key);
final Section section; final Section section;
...@@ -86,9 +83,9 @@ class SectionTitle extends StatelessWidget { ...@@ -86,9 +83,9 @@ class SectionTitle extends StatelessWidget {
children: <Widget>[ children: <Widget>[
Positioned( Positioned(
top: 4.0, top: 4.0,
child: Text(section.title, style: sectionTitleShadowStyle), child: Text(section.title!, style: sectionTitleShadowStyle),
), ),
Text(section.title, style: sectionTitleStyle), Text(section.title!, style: sectionTitleStyle),
], ],
), ),
), ),
...@@ -99,7 +96,7 @@ class SectionTitle extends StatelessWidget { ...@@ -99,7 +96,7 @@ class SectionTitle extends StatelessWidget {
// Small horizontal bar that indicates the selected section. // Small horizontal bar that indicates the selected section.
class SectionIndicator extends StatelessWidget { class SectionIndicator extends StatelessWidget {
const SectionIndicator({ Key key, this.opacity = 1.0 }) : super(key: key); const SectionIndicator({ Key? key, this.opacity = 1.0 }) : super(key: key);
final double opacity; final double opacity;
...@@ -117,8 +114,8 @@ class SectionIndicator extends StatelessWidget { ...@@ -117,8 +114,8 @@ class SectionIndicator extends StatelessWidget {
// Display a single SectionDetail. // Display a single SectionDetail.
class SectionDetailView extends StatelessWidget { class SectionDetailView extends StatelessWidget {
SectionDetailView({ Key key, @required this.detail }) SectionDetailView({ Key? key, required this.detail })
: assert(detail != null && detail.imageAsset != null), : assert(detail.imageAsset != null),
assert((detail.imageAsset ?? detail.title) != null), assert((detail.imageAsset ?? detail.title) != null),
super(key: key); super(key: key);
...@@ -131,7 +128,7 @@ class SectionDetailView extends StatelessWidget { ...@@ -131,7 +128,7 @@ class SectionDetailView extends StatelessWidget {
borderRadius: BorderRadius.circular(6.0), borderRadius: BorderRadius.circular(6.0),
image: DecorationImage( image: DecorationImage(
image: AssetImage( image: AssetImage(
detail.imageAsset, detail.imageAsset!,
package: detail.imageAssetPackage, package: detail.imageAssetPackage,
), ),
fit: BoxFit.cover, fit: BoxFit.cover,
...@@ -153,8 +150,8 @@ class SectionDetailView extends StatelessWidget { ...@@ -153,8 +150,8 @@ class SectionDetailView extends StatelessWidget {
); );
} else { } else {
item = ListTile( item = ListTile(
title: Text(detail.title), title: Text(detail.title!),
subtitle: Text(detail.subtitle), subtitle: Text(detail.subtitle!),
leading: SizedBox(width: 32.0, height: 32.0, child: image), leading: SizedBox(width: 32.0, height: 32.0, child: image),
); );
} }
......
...@@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; ...@@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
import 'animation/home.dart'; import 'animation/home.dart';
class AnimationDemo extends StatelessWidget { class AnimationDemo extends StatelessWidget {
const AnimationDemo({Key key}) : super(key: key); const AnimationDemo({Key? key}) : super(key: key);
static const String routeName = '/animation'; static const String routeName = '/animation';
......
...@@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; ...@@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
import 'logic.dart'; import 'logic.dart';
class Calculator extends StatefulWidget { class Calculator extends StatefulWidget {
const Calculator({Key key}) : super(key: key); const Calculator({Key? key}) : super(key: key);
@override @override
_CalculatorState createState() => _CalculatorState(); _CalculatorState createState() => _CalculatorState();
...@@ -43,7 +43,7 @@ class _CalculatorState extends State<Calculator> { ...@@ -43,7 +43,7 @@ class _CalculatorState extends State<Calculator> {
} }
void handleNumberTap(int n) { void handleNumberTap(int n) {
final CalcExpression expression = _expression.appendDigit(n); final CalcExpression? expression = _expression.appendDigit(n);
if (expression != null) { if (expression != null) {
setState(() { setState(() {
pushExpression(expression); pushExpression(expression);
...@@ -52,7 +52,7 @@ class _CalculatorState extends State<Calculator> { ...@@ -52,7 +52,7 @@ class _CalculatorState extends State<Calculator> {
} }
void handlePointTap() { void handlePointTap() {
final CalcExpression expression = _expression.appendPoint(); final CalcExpression? expression = _expression.appendPoint();
if (expression != null) { if (expression != null) {
setState(() { setState(() {
pushExpression(expression); pushExpression(expression);
...@@ -61,7 +61,7 @@ class _CalculatorState extends State<Calculator> { ...@@ -61,7 +61,7 @@ class _CalculatorState extends State<Calculator> {
} }
void handlePlusTap() { void handlePlusTap() {
final CalcExpression expression = _expression.appendOperation(Operation.Addition); final CalcExpression? expression = _expression.appendOperation(Operation.Addition);
if (expression != null) { if (expression != null) {
setState(() { setState(() {
pushExpression(expression); pushExpression(expression);
...@@ -70,7 +70,7 @@ class _CalculatorState extends State<Calculator> { ...@@ -70,7 +70,7 @@ class _CalculatorState extends State<Calculator> {
} }
void handleMinusTap() { void handleMinusTap() {
final CalcExpression expression = _expression.appendMinus(); final CalcExpression? expression = _expression.appendMinus();
if (expression != null) { if (expression != null) {
setState(() { setState(() {
pushExpression(expression); pushExpression(expression);
...@@ -79,7 +79,7 @@ class _CalculatorState extends State<Calculator> { ...@@ -79,7 +79,7 @@ class _CalculatorState extends State<Calculator> {
} }
void handleMultTap() { void handleMultTap() {
final CalcExpression expression = _expression.appendOperation(Operation.Multiplication); final CalcExpression? expression = _expression.appendOperation(Operation.Multiplication);
if (expression != null) { if (expression != null) {
setState(() { setState(() {
pushExpression(expression); pushExpression(expression);
...@@ -88,7 +88,7 @@ class _CalculatorState extends State<Calculator> { ...@@ -88,7 +88,7 @@ class _CalculatorState extends State<Calculator> {
} }
void handleDivTap() { void handleDivTap() {
final CalcExpression expression = _expression.appendOperation(Operation.Division); final CalcExpression? expression = _expression.appendOperation(Operation.Division);
if (expression != null) { if (expression != null) {
setState(() { setState(() {
pushExpression(expression); pushExpression(expression);
...@@ -97,7 +97,7 @@ class _CalculatorState extends State<Calculator> { ...@@ -97,7 +97,7 @@ class _CalculatorState extends State<Calculator> {
} }
void handleEqualsTap() { void handleEqualsTap() {
final CalcExpression resultExpression = _expression.computeResult(); final CalcExpression? resultExpression = _expression.computeResult();
if (resultExpression != null) { if (resultExpression != null) {
setState(() { setState(() {
setResult(resultExpression); setResult(resultExpression);
...@@ -140,13 +140,13 @@ class _CalculatorState extends State<Calculator> { ...@@ -140,13 +140,13 @@ class _CalculatorState extends State<Calculator> {
class CalcDisplay extends StatelessWidget { class CalcDisplay extends StatelessWidget {
const CalcDisplay({ this.content }); const CalcDisplay({ this.content });
final String content; final String? content;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Center( return Center(
child: Text( child: Text(
content, content!,
style: const TextStyle(fontSize: 24.0), style: const TextStyle(fontSize: 24.0),
), ),
); );
...@@ -156,7 +156,7 @@ class CalcDisplay extends StatelessWidget { ...@@ -156,7 +156,7 @@ class CalcDisplay extends StatelessWidget {
class KeyPad extends StatelessWidget { class KeyPad extends StatelessWidget {
const KeyPad({ this.calcState }); const KeyPad({ this.calcState });
final _CalculatorState calcState; final _CalculatorState? calcState;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -193,9 +193,9 @@ class KeyPad extends StatelessWidget { ...@@ -193,9 +193,9 @@ class KeyPad extends StatelessWidget {
NumberKey(3, calcState), NumberKey(3, calcState),
]), ]),
KeyRow(<Widget>[ KeyRow(<Widget>[
CalcKey('.', calcState.handlePointTap), CalcKey('.', calcState!.handlePointTap),
NumberKey(0, calcState), NumberKey(0, calcState),
CalcKey('=', calcState.handleEqualsTap), CalcKey('=', calcState!.handleEqualsTap),
]), ]),
], ],
), ),
...@@ -205,11 +205,11 @@ class KeyPad extends StatelessWidget { ...@@ -205,11 +205,11 @@ class KeyPad extends StatelessWidget {
color: themeData.backgroundColor, color: themeData.backgroundColor,
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
CalcKey('\u232B', calcState.handleDelTap), CalcKey('\u232B', calcState!.handleDelTap),
CalcKey('\u00F7', calcState.handleDivTap), CalcKey('\u00F7', calcState!.handleDivTap),
CalcKey('\u00D7', calcState.handleMultTap), CalcKey('\u00D7', calcState!.handleMultTap),
CalcKey('-', calcState.handleMinusTap), CalcKey('-', calcState!.handleMinusTap),
CalcKey('+', calcState.handlePlusTap), CalcKey('+', calcState!.handlePlusTap),
], ],
), ),
), ),
...@@ -263,8 +263,8 @@ class CalcKey extends StatelessWidget { ...@@ -263,8 +263,8 @@ class CalcKey extends StatelessWidget {
} }
class NumberKey extends CalcKey { class NumberKey extends CalcKey {
NumberKey(int value, _CalculatorState calcState) NumberKey(int value, _CalculatorState? calcState)
: super('$value', () { : super('$value', () {
calcState.handleNumberTap(value); calcState!.handleNumberTap(value);
}); });
} }
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
class ExpressionToken { class ExpressionToken {
ExpressionToken(this.stringRep); ExpressionToken(this.stringRep);
final String stringRep; final String? stringRep;
@override @override
String toString() => stringRep; String toString() => stringRep!;
} }
/// A token that represents a number. /// A token that represents a number.
...@@ -71,7 +71,7 @@ class OperationToken extends ExpressionToken { ...@@ -71,7 +71,7 @@ class OperationToken extends ExpressionToken {
Operation operation; Operation operation;
static String opString(Operation operation) { static String? opString(Operation operation) {
switch (operation) { switch (operation) {
case Operation.Addition: case Operation.Addition:
return ' + '; return ' + ';
...@@ -82,8 +82,6 @@ class OperationToken extends ExpressionToken { ...@@ -82,8 +82,6 @@ class OperationToken extends ExpressionToken {
case Operation.Division: case Operation.Division:
return ' \u00F7 '; return ' \u00F7 ';
} }
assert(operation != null);
return null;
} }
} }
...@@ -124,13 +122,13 @@ class CalcExpression { ...@@ -124,13 +122,13 @@ class CalcExpression {
: this(<ExpressionToken>[], ExpressionState.Start); : this(<ExpressionToken>[], ExpressionState.Start);
CalcExpression.result(FloatToken result) CalcExpression.result(FloatToken result)
: _list = <ExpressionToken>[], : _list = <ExpressionToken?>[],
state = ExpressionState.Result { state = ExpressionState.Result {
_list.add(result); _list.add(result);
} }
/// The tokens comprising the expression. /// The tokens comprising the expression.
final List<ExpressionToken> _list; final List<ExpressionToken?> _list;
/// The state of the expression. /// The state of the expression.
final ExpressionState state; final ExpressionState state;
...@@ -146,10 +144,10 @@ class CalcExpression { ...@@ -146,10 +144,10 @@ class CalcExpression {
/// Append a digit to the current expression and return a new expression /// Append a digit to the current expression and return a new expression
/// representing the result. Returns null to indicate that it is not legal /// representing the result. Returns null to indicate that it is not legal
/// to append a digit in the current state. /// to append a digit in the current state.
CalcExpression appendDigit(int digit) { CalcExpression? appendDigit(int digit) {
ExpressionState newState = ExpressionState.Number; ExpressionState newState = ExpressionState.Number;
ExpressionToken newToken; ExpressionToken? newToken;
final List<ExpressionToken> outList = _list.toList(); final List<ExpressionToken?> outList = _list.toList();
switch (state) { switch (state) {
case ExpressionState.Start: case ExpressionState.Start:
// Start a new number with digit. // Start a new number with digit.
...@@ -161,12 +159,12 @@ class CalcExpression { ...@@ -161,12 +159,12 @@ class CalcExpression {
newToken = IntToken('-$digit'); newToken = IntToken('-$digit');
break; break;
case ExpressionState.Number: case ExpressionState.Number:
final ExpressionToken last = outList.removeLast(); final ExpressionToken last = outList.removeLast()!;
newToken = IntToken('${last.stringRep}$digit'); newToken = IntToken('${last.stringRep}$digit');
break; break;
case ExpressionState.Point: case ExpressionState.Point:
case ExpressionState.NumberWithPoint: case ExpressionState.NumberWithPoint:
final ExpressionToken last = outList.removeLast(); final ExpressionToken last = outList.removeLast()!;
newState = ExpressionState.NumberWithPoint; newState = ExpressionState.NumberWithPoint;
newToken = FloatToken('${last.stringRep}$digit'); newToken = FloatToken('${last.stringRep}$digit');
break; break;
...@@ -181,17 +179,17 @@ class CalcExpression { ...@@ -181,17 +179,17 @@ class CalcExpression {
/// Append a point to the current expression and return a new expression /// Append a point to the current expression and return a new expression
/// representing the result. Returns null to indicate that it is not legal /// representing the result. Returns null to indicate that it is not legal
/// to append a point in the current state. /// to append a point in the current state.
CalcExpression appendPoint() { CalcExpression? appendPoint() {
ExpressionToken newToken; ExpressionToken? newToken;
final List<ExpressionToken> outList = _list.toList(); final List<ExpressionToken?> outList = _list.toList();
switch (state) { switch (state) {
case ExpressionState.Start: case ExpressionState.Start:
newToken = FloatToken('.'); newToken = FloatToken('.');
break; break;
case ExpressionState.LeadingNeg: case ExpressionState.LeadingNeg:
case ExpressionState.Number: case ExpressionState.Number:
final ExpressionToken last = outList.removeLast(); final ExpressionToken last = outList.removeLast()!;
newToken = FloatToken(last.stringRep + '.'); newToken = FloatToken(last.stringRep! + '.');
break; break;
case ExpressionState.Point: case ExpressionState.Point:
case ExpressionState.NumberWithPoint: case ExpressionState.NumberWithPoint:
...@@ -206,7 +204,7 @@ class CalcExpression { ...@@ -206,7 +204,7 @@ class CalcExpression {
/// Append an operation symbol to the current expression and return a new /// Append an operation symbol to the current expression and return a new
/// expression representing the result. Returns null to indicate that it is not /// expression representing the result. Returns null to indicate that it is not
/// legal to append an operation symbol in the current state. /// legal to append an operation symbol in the current state.
CalcExpression appendOperation(Operation op) { CalcExpression? appendOperation(Operation op) {
switch (state) { switch (state) {
case ExpressionState.Start: case ExpressionState.Start:
case ExpressionState.LeadingNeg: case ExpressionState.LeadingNeg:
...@@ -218,7 +216,7 @@ class CalcExpression { ...@@ -218,7 +216,7 @@ class CalcExpression {
case ExpressionState.Result: case ExpressionState.Result:
break; break;
} }
final List<ExpressionToken> outList = _list.toList(); final List<ExpressionToken?> outList = _list.toList();
outList.add(OperationToken(op)); outList.add(OperationToken(op));
return CalcExpression(outList, ExpressionState.Start); return CalcExpression(outList, ExpressionState.Start);
} }
...@@ -226,7 +224,7 @@ class CalcExpression { ...@@ -226,7 +224,7 @@ class CalcExpression {
/// Append a leading minus sign to the current expression and return a new /// Append a leading minus sign to the current expression and return a new
/// expression representing the result. Returns null to indicate that it is not /// expression representing the result. Returns null to indicate that it is not
/// legal to append a leading minus sign in the current state. /// legal to append a leading minus sign in the current state.
CalcExpression appendLeadingNeg() { CalcExpression? appendLeadingNeg() {
switch (state) { switch (state) {
case ExpressionState.Start: case ExpressionState.Start:
break; break;
...@@ -238,7 +236,7 @@ class CalcExpression { ...@@ -238,7 +236,7 @@ class CalcExpression {
// Cannot enter leading neg now. // Cannot enter leading neg now.
return null; return null;
} }
final List<ExpressionToken> outList = _list.toList(); final List<ExpressionToken?> outList = _list.toList();
outList.add(LeadingNegToken()); outList.add(LeadingNegToken());
return CalcExpression(outList, ExpressionState.LeadingNeg); return CalcExpression(outList, ExpressionState.LeadingNeg);
} }
...@@ -248,7 +246,7 @@ class CalcExpression { ...@@ -248,7 +246,7 @@ class CalcExpression {
/// to append a minus sign in the current state. Depending on the current /// to append a minus sign in the current state. Depending on the current
/// state the minus sign will be interpreted as either a leading negative /// state the minus sign will be interpreted as either a leading negative
/// sign or a subtraction operation. /// sign or a subtraction operation.
CalcExpression appendMinus() { CalcExpression? appendMinus() {
switch (state) { switch (state) {
case ExpressionState.Start: case ExpressionState.Start:
return appendLeadingNeg(); return appendLeadingNeg();
...@@ -266,7 +264,7 @@ class CalcExpression { ...@@ -266,7 +264,7 @@ class CalcExpression {
/// Computes the result of the current expression and returns a new /// Computes the result of the current expression and returns a new
/// ResultExpression containing the result. Returns null to indicate that /// ResultExpression containing the result. Returns null to indicate that
/// it is not legal to compute a result in the current state. /// it is not legal to compute a result in the current state.
CalcExpression computeResult() { CalcExpression? computeResult() {
switch (state) { switch (state) {
case ExpressionState.Start: case ExpressionState.Start:
case ExpressionState.LeadingNeg: case ExpressionState.LeadingNeg:
...@@ -281,13 +279,13 @@ class CalcExpression { ...@@ -281,13 +279,13 @@ class CalcExpression {
// We make a copy of _list because CalcExpressions are supposed to // We make a copy of _list because CalcExpressions are supposed to
// be immutable. // be immutable.
final List<ExpressionToken> list = _list.toList(); final List<ExpressionToken?> list = _list.toList();
// We obey order-of-operations by computing the sum of the 'terms', // We obey order-of-operations by computing the sum of the 'terms',
// where a "term" is defined to be a sequence of numbers separated by // where a "term" is defined to be a sequence of numbers separated by
// multiplication or division symbols. // multiplication or division symbols.
num currentTermValue = removeNextTerm(list); num currentTermValue = removeNextTerm(list);
while (list.isNotEmpty) { while (list.isNotEmpty) {
final OperationToken opToken = list.removeAt(0) as OperationToken; final OperationToken opToken = list.removeAt(0)! as OperationToken;
final num nextTermValue = removeNextTerm(list); final num nextTermValue = removeNextTerm(list);
switch (opToken.operation) { switch (opToken.operation) {
case Operation.Addition: case Operation.Addition:
...@@ -311,13 +309,13 @@ class CalcExpression { ...@@ -311,13 +309,13 @@ class CalcExpression {
/// Removes the next "term" from `list` and returns its numeric value. /// Removes the next "term" from `list` and returns its numeric value.
/// A "term" is a sequence of number tokens separated by multiplication /// A "term" is a sequence of number tokens separated by multiplication
/// and division symbols. /// and division symbols.
static num removeNextTerm(List<ExpressionToken> list) { static num removeNextTerm(List<ExpressionToken?> list) {
assert(list != null && list.isNotEmpty); assert(list.isNotEmpty);
final NumberToken firstNumToken = list.removeAt(0) as NumberToken; final NumberToken firstNumToken = list.removeAt(0)! as NumberToken;
num currentValue = firstNumToken.number; num currentValue = firstNumToken.number;
while (list.isNotEmpty) { while (list.isNotEmpty) {
bool isDivision = false; bool isDivision = false;
final OperationToken nextOpToken = list.first as OperationToken; final OperationToken nextOpToken = list.first! as OperationToken;
switch (nextOpToken.operation) { switch (nextOpToken.operation) {
case Operation.Addition: case Operation.Addition:
case Operation.Subtraction: case Operation.Subtraction:
...@@ -331,7 +329,7 @@ class CalcExpression { ...@@ -331,7 +329,7 @@ class CalcExpression {
// Remove the operation token. // Remove the operation token.
list.removeAt(0); list.removeAt(0);
// Remove the next number token. // Remove the next number token.
final NumberToken nextNumToken = list.removeAt(0) as NumberToken; final NumberToken nextNumToken = list.removeAt(0)! as NumberToken;
final num nextNumber = nextNumToken.number; final num nextNumber = nextNumToken.number;
if (isDivision) if (isDivision)
currentValue /= nextNumber; currentValue /= nextNumber;
......
...@@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; ...@@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
import 'calculator/home.dart'; import 'calculator/home.dart';
class CalculatorDemo extends StatelessWidget { class CalculatorDemo extends StatelessWidget {
const CalculatorDemo({Key key}) : super(key: key); const CalculatorDemo({Key? key}) : super(key: key);
static const String routeName = '/calculator'; static const String routeName = '/calculator';
......
...@@ -9,12 +9,12 @@ const double kColorItemHeight = 48.0; ...@@ -9,12 +9,12 @@ const double kColorItemHeight = 48.0;
class Palette { class Palette {
Palette({ this.name, this.primary, this.accent, this.threshold = 900}); Palette({ this.name, this.primary, this.accent, this.threshold = 900});
final String name; final String? name;
final MaterialColor primary; final MaterialColor? primary;
final MaterialAccentColor accent; final MaterialAccentColor? accent;
final int threshold; // titles for indices > threshold are white, otherwise black final int threshold; // titles for indices > threshold are white, otherwise black
bool get isValid => name != null && primary != null && threshold != null; bool get isValid => name != null && primary != null;
} }
final List<Palette> allPalettes = <Palette>[ final List<Palette> allPalettes = <Palette>[
...@@ -42,14 +42,11 @@ final List<Palette> allPalettes = <Palette>[ ...@@ -42,14 +42,11 @@ final List<Palette> allPalettes = <Palette>[
class ColorItem extends StatelessWidget { class ColorItem extends StatelessWidget {
const ColorItem({ const ColorItem({
Key key, Key? key,
@required this.index, required this.index,
@required this.color, required this.color,
this.prefix = '', this.prefix = '',
}) : assert(index != null), }) : super(key: key);
assert(color != null),
assert(prefix != null),
super(key: key);
final int index; final int index;
final Color color; final Color color;
...@@ -84,9 +81,9 @@ class ColorItem extends StatelessWidget { ...@@ -84,9 +81,9 @@ class ColorItem extends StatelessWidget {
class PaletteTabView extends StatelessWidget { class PaletteTabView extends StatelessWidget {
PaletteTabView({ PaletteTabView({
Key key, Key? key,
@required this.colors, required this.colors,
}) : assert(colors != null && colors.isValid), }) : assert(colors.isValid),
super(key: key); super(key: key);
final Palette colors; final Palette colors;
...@@ -97,8 +94,8 @@ class PaletteTabView extends StatelessWidget { ...@@ -97,8 +94,8 @@ class PaletteTabView extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final TextTheme textTheme = Theme.of(context).textTheme; final TextTheme textTheme = Theme.of(context).textTheme;
final TextStyle whiteTextStyle = textTheme.bodyText2.copyWith(color: Colors.white); final TextStyle whiteTextStyle = textTheme.bodyText2!.copyWith(color: Colors.white);
final TextStyle blackTextStyle = textTheme.bodyText2.copyWith(color: Colors.black); final TextStyle blackTextStyle = textTheme.bodyText2!.copyWith(color: Colors.black);
return Scrollbar( return Scrollbar(
child: ListView( child: ListView(
itemExtent: kColorItemHeight, itemExtent: kColorItemHeight,
...@@ -106,14 +103,14 @@ class PaletteTabView extends StatelessWidget { ...@@ -106,14 +103,14 @@ class PaletteTabView extends StatelessWidget {
...primaryKeys.map<Widget>((int index) { ...primaryKeys.map<Widget>((int index) {
return DefaultTextStyle( return DefaultTextStyle(
style: index > colors.threshold ? whiteTextStyle : blackTextStyle, style: index > colors.threshold ? whiteTextStyle : blackTextStyle,
child: ColorItem(index: index, color: colors.primary[index]), child: ColorItem(index: index, color: colors.primary![index]!),
); );
}), }),
if (colors.accent != null) if (colors.accent != null)
...accentKeys.map<Widget>((int index) { ...accentKeys.map<Widget>((int index) {
return DefaultTextStyle( return DefaultTextStyle(
style: index > colors.threshold ? whiteTextStyle : blackTextStyle, style: index > colors.threshold ? whiteTextStyle : blackTextStyle,
child: ColorItem(index: index, color: colors.accent[index], prefix: 'A'), child: ColorItem(index: index, color: colors.accent![index]!, prefix: 'A'),
); );
}), }),
], ],
......
...@@ -6,10 +6,10 @@ import 'package:flutter/material.dart'; ...@@ -6,10 +6,10 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
class _ContactCategory extends StatelessWidget { class _ContactCategory extends StatelessWidget {
const _ContactCategory({ Key key, this.icon, this.children }) : super(key: key); const _ContactCategory({ Key? key, this.icon, this.children }) : super(key: key);
final IconData icon; final IconData? icon;
final List<Widget> children; final List<Widget>? children;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -20,7 +20,7 @@ class _ContactCategory extends StatelessWidget { ...@@ -20,7 +20,7 @@ class _ContactCategory extends StatelessWidget {
border: Border(bottom: BorderSide(color: themeData.dividerColor)) border: Border(bottom: BorderSide(color: themeData.dividerColor))
), ),
child: DefaultTextStyle( child: DefaultTextStyle(
style: Theme.of(context).textTheme.subtitle1, style: Theme.of(context).textTheme.subtitle1!,
child: SafeArea( child: SafeArea(
top: false, top: false,
bottom: false, bottom: false,
...@@ -32,7 +32,7 @@ class _ContactCategory extends StatelessWidget { ...@@ -32,7 +32,7 @@ class _ContactCategory extends StatelessWidget {
width: 72.0, width: 72.0,
child: Icon(icon, color: themeData.primaryColor), child: Icon(icon, color: themeData.primaryColor),
), ),
Expanded(child: Column(children: children)), Expanded(child: Column(children: children!)),
], ],
), ),
), ),
...@@ -42,14 +42,14 @@ class _ContactCategory extends StatelessWidget { ...@@ -42,14 +42,14 @@ class _ContactCategory extends StatelessWidget {
} }
class _ContactItem extends StatelessWidget { class _ContactItem extends StatelessWidget {
const _ContactItem({ Key key, this.icon, this.lines, this.tooltip, this.onPressed }) const _ContactItem({ Key? key, this.icon, required this.lines, this.tooltip, this.onPressed })
: assert(lines.length > 1), : assert(lines.length > 1),
super(key: key); super(key: key);
final IconData icon; final IconData? icon;
final List<String> lines; final List<String> lines;
final String tooltip; final String? tooltip;
final VoidCallback onPressed; final VoidCallback? onPressed;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
......
...@@ -14,24 +14,24 @@ class CupertinoAlertDemo extends StatefulWidget { ...@@ -14,24 +14,24 @@ class CupertinoAlertDemo extends StatefulWidget {
} }
class _CupertinoAlertDemoState extends State<CupertinoAlertDemo> { class _CupertinoAlertDemoState extends State<CupertinoAlertDemo> {
String lastSelectedValue; String? lastSelectedValue;
void showDemoDialog({BuildContext context, Widget child}) { void showDemoDialog({required BuildContext context, Widget? child}) {
showCupertinoDialog<String>( showCupertinoDialog<String>(
context: context, context: context,
builder: (BuildContext context) => child, builder: (BuildContext context) => child!,
).then((String value) { ).then((String? value) {
if (value != null) { if (value != null) {
setState(() { lastSelectedValue = value; }); setState(() { lastSelectedValue = value; });
} }
}); });
} }
void showDemoActionSheet({BuildContext context, Widget child}) { void showDemoActionSheet({required BuildContext context, Widget? child}) {
showCupertinoModalPopup<String>( showCupertinoModalPopup<String>(
context: context, context: context,
builder: (BuildContext context) => child, builder: (BuildContext context) => child!,
).then((String value) { ).then((String? value) {
if (value != null) { if (value != null) {
setState(() { lastSelectedValue = value; }); setState(() { lastSelectedValue = value; });
} }
...@@ -196,10 +196,10 @@ class _CupertinoAlertDemoState extends State<CupertinoAlertDemo> { ...@@ -196,10 +196,10 @@ class _CupertinoAlertDemoState extends State<CupertinoAlertDemo> {
} }
class CupertinoDessertDialog extends StatelessWidget { class CupertinoDessertDialog extends StatelessWidget {
const CupertinoDessertDialog({Key key, this.title, this.content}) : super(key: key); const CupertinoDessertDialog({Key? key, this.title, this.content}) : super(key: key);
final Widget title; final Widget? title;
final Widget content; final Widget? content;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
......
...@@ -44,7 +44,7 @@ class CupertinoNavigationDemo extends StatelessWidget { ...@@ -44,7 +44,7 @@ class CupertinoNavigationDemo extends StatelessWidget {
final List<Color> colorItems; final List<Color> colorItems;
final List<String> colorNameItems; final List<String> colorNameItems;
final int randomSeed; final int? randomSeed;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -71,7 +71,6 @@ class CupertinoNavigationDemo extends StatelessWidget { ...@@ -71,7 +71,6 @@ class CupertinoNavigationDemo extends StatelessWidget {
], ],
), ),
tabBuilder: (BuildContext context, int index) { tabBuilder: (BuildContext context, int index) {
assert(index >= 0 && index <= 2);
switch (index) { switch (index) {
case 0: case 0:
return CupertinoTabView( return CupertinoTabView(
...@@ -84,21 +83,19 @@ class CupertinoNavigationDemo extends StatelessWidget { ...@@ -84,21 +83,19 @@ class CupertinoNavigationDemo extends StatelessWidget {
}, },
defaultTitle: 'Colors', defaultTitle: 'Colors',
); );
break;
case 1: case 1:
return CupertinoTabView( return CupertinoTabView(
builder: (BuildContext context) => CupertinoDemoTab2(), builder: (BuildContext context) => CupertinoDemoTab2(),
defaultTitle: 'Support Chat', defaultTitle: 'Support Chat',
); );
break;
case 2: case 2:
return CupertinoTabView( return CupertinoTabView(
builder: (BuildContext context) => CupertinoDemoTab3(), builder: (BuildContext context) => CupertinoDemoTab3(),
defaultTitle: 'Account', defaultTitle: 'Account',
); );
break;
} }
return null; assert(false);
return const CupertinoTabView();
}, },
), ),
), ),
...@@ -120,7 +117,7 @@ class ExitButton extends StatelessWidget { ...@@ -120,7 +117,7 @@ class ExitButton extends StatelessWidget {
), ),
onPressed: () { onPressed: () {
// The demo is on the root navigator. // The demo is on the root navigator.
Navigator.of(context, rootNavigator: true).pop(); Navigator.of(context, rootNavigator: true)!.pop();
}, },
); );
} }
...@@ -142,9 +139,9 @@ class CupertinoDemoTab1 extends StatelessWidget { ...@@ -142,9 +139,9 @@ class CupertinoDemoTab1 extends StatelessWidget {
this.randomSeed, this.randomSeed,
}); });
final List<Color> colorItems; final List<Color>? colorItems;
final List<String> colorNameItems; final List<String>? colorNameItems;
final int randomSeed; final int? randomSeed;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -170,8 +167,8 @@ class CupertinoDemoTab1 extends StatelessWidget { ...@@ -170,8 +167,8 @@ class CupertinoDemoTab1 extends StatelessWidget {
return Tab1RowItem( return Tab1RowItem(
index: index, index: index,
lastItem: index == _kChildCount - 1, lastItem: index == _kChildCount - 1,
color: colorItems[index], color: colorItems![index],
colorName: colorNameItems[index], colorName: colorNameItems![index],
randomSeed: randomSeed, randomSeed: randomSeed,
); );
}, },
...@@ -194,18 +191,18 @@ class Tab1RowItem extends StatelessWidget { ...@@ -194,18 +191,18 @@ class Tab1RowItem extends StatelessWidget {
this.randomSeed, this.randomSeed,
}); });
final int index; final int? index;
final bool lastItem; final bool? lastItem;
final Color color; final Color? color;
final String colorName; final String? colorName;
final int randomSeed; final int? randomSeed;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final Widget row = GestureDetector( final Widget row = GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: () { onTap: () {
Navigator.of(context).push(CupertinoPageRoute<void>( Navigator.of(context)!.push(CupertinoPageRoute<void>(
title: colorName, title: colorName,
builder: (BuildContext context) => Tab1ItemPage( builder: (BuildContext context) => Tab1ItemPage(
color: color, color: color,
...@@ -238,7 +235,7 @@ class Tab1RowItem extends StatelessWidget { ...@@ -238,7 +235,7 @@ class Tab1RowItem extends StatelessWidget {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Text(colorName), Text(colorName!),
const Padding(padding: EdgeInsets.only(top: 8.0)), const Padding(padding: EdgeInsets.only(top: 8.0)),
Text( Text(
'Buy this cool color', 'Buy this cool color',
...@@ -273,7 +270,7 @@ class Tab1RowItem extends StatelessWidget { ...@@ -273,7 +270,7 @@ class Tab1RowItem extends StatelessWidget {
), ),
); );
if (lastItem) { if (lastItem!) {
return row; return row;
} }
...@@ -292,10 +289,10 @@ class Tab1RowItem extends StatelessWidget { ...@@ -292,10 +289,10 @@ class Tab1RowItem extends StatelessWidget {
class Tab1ItemPage extends StatefulWidget { class Tab1ItemPage extends StatefulWidget {
const Tab1ItemPage({this.color, this.colorName, this.index, this.randomSeed}); const Tab1ItemPage({this.color, this.colorName, this.index, this.randomSeed});
final Color color; final Color? color;
final String colorName; final String? colorName;
final int index; final int? index;
final int randomSeed; final int? randomSeed;
@override @override
State<StatefulWidget> createState() => Tab1ItemPageState(); State<StatefulWidget> createState() => Tab1ItemPageState();
...@@ -309,14 +306,14 @@ class Tab1ItemPageState extends State<Tab1ItemPage> { ...@@ -309,14 +306,14 @@ class Tab1ItemPageState extends State<Tab1ItemPage> {
final math.Random random = math.Random(widget.randomSeed); final math.Random random = math.Random(widget.randomSeed);
return Color.fromARGB( return Color.fromARGB(
255, 255,
(widget.color.red + random.nextInt(100) - 50).clamp(0, 255) as int, (widget.color!.red + random.nextInt(100) - 50).clamp(0, 255),
(widget.color.green + random.nextInt(100) - 50).clamp(0, 255) as int, (widget.color!.green + random.nextInt(100) - 50).clamp(0, 255),
(widget.color.blue + random.nextInt(100) - 50).clamp(0, 255) as int, (widget.color!.blue + random.nextInt(100) - 50).clamp(0, 255),
); );
}); });
} }
List<Color> relatedColors; late List<Color> relatedColors;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -350,7 +347,7 @@ class Tab1ItemPageState extends State<Tab1ItemPage> { ...@@ -350,7 +347,7 @@ class Tab1ItemPageState extends State<Tab1ItemPage> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
Text( Text(
widget.colorName, widget.colorName!,
style: const TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold), style: const TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold),
), ),
const Padding(padding: EdgeInsets.only(top: 6.0)), const Padding(padding: EdgeInsets.only(top: 6.0)),
...@@ -594,13 +591,13 @@ enum Tab2ConversationBubbleColor { ...@@ -594,13 +591,13 @@ enum Tab2ConversationBubbleColor {
class Tab2ConversationBubble extends StatelessWidget { class Tab2ConversationBubble extends StatelessWidget {
const Tab2ConversationBubble({this.text, this.color}); const Tab2ConversationBubble({this.text, this.color});
final String text; final String? text;
final Tab2ConversationBubbleColor color; final Tab2ConversationBubbleColor? color;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Color backgroundColor; Color? backgroundColor;
Color foregroundColor; Color? foregroundColor;
switch (color) { switch (color) {
case Tab2ConversationBubbleColor.gray: case Tab2ConversationBubbleColor.gray:
...@@ -611,6 +608,8 @@ class Tab2ConversationBubble extends StatelessWidget { ...@@ -611,6 +608,8 @@ class Tab2ConversationBubble extends StatelessWidget {
backgroundColor = CupertinoTheme.of(context).primaryColor; backgroundColor = CupertinoTheme.of(context).primaryColor;
foregroundColor = CupertinoColors.white; foregroundColor = CupertinoColors.white;
break; break;
default:
break;
} }
return Container( return Container(
...@@ -621,7 +620,7 @@ class Tab2ConversationBubble extends StatelessWidget { ...@@ -621,7 +620,7 @@ class Tab2ConversationBubble extends StatelessWidget {
margin: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0), margin: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0),
padding: const EdgeInsets.symmetric(horizontal: 14.0, vertical: 10.0), padding: const EdgeInsets.symmetric(horizontal: 14.0, vertical: 10.0),
child: Text( child: Text(
text, text!,
style: TextStyle( style: TextStyle(
color: foregroundColor, color: foregroundColor,
letterSpacing: -0.4, letterSpacing: -0.4,
...@@ -636,8 +635,8 @@ class Tab2ConversationBubble extends StatelessWidget { ...@@ -636,8 +635,8 @@ class Tab2ConversationBubble extends StatelessWidget {
class Tab2ConversationAvatar extends StatelessWidget { class Tab2ConversationAvatar extends StatelessWidget {
const Tab2ConversationAvatar({this.text, this.color}); const Tab2ConversationAvatar({this.text, this.color});
final String text; final String? text;
final Color color; final Color? color;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -648,20 +647,20 @@ class Tab2ConversationAvatar extends StatelessWidget { ...@@ -648,20 +647,20 @@ class Tab2ConversationAvatar extends StatelessWidget {
begin: FractionalOffset.topCenter, begin: FractionalOffset.topCenter,
end: FractionalOffset.bottomCenter, end: FractionalOffset.bottomCenter,
colors: <Color>[ colors: <Color>[
color, color!,
Color.fromARGB( Color.fromARGB(
color.alpha, color!.alpha,
(color.red - 60).clamp(0, 255) as int, (color!.red - 60).clamp(0, 255),
(color.green - 60).clamp(0, 255) as int, (color!.green - 60).clamp(0, 255),
(color.blue - 60).clamp(0, 255) as int, (color!.blue - 60).clamp(0, 255),
), ),
], ]
), ),
), ),
margin: const EdgeInsets.only(left: 8.0, bottom: 8.0), margin: const EdgeInsets.only(left: 8.0, bottom: 8.0),
padding: const EdgeInsets.all(12.0), padding: const EdgeInsets.all(12.0),
child: Text( child: Text(
text, text!,
style: const TextStyle( style: const TextStyle(
color: CupertinoColors.white, color: CupertinoColors.white,
fontSize: 13.0, fontSize: 13.0,
...@@ -675,8 +674,8 @@ class Tab2ConversationAvatar extends StatelessWidget { ...@@ -675,8 +674,8 @@ class Tab2ConversationAvatar extends StatelessWidget {
class Tab2ConversationRow extends StatelessWidget { class Tab2ConversationRow extends StatelessWidget {
const Tab2ConversationRow({this.avatar, this.text}); const Tab2ConversationRow({this.avatar, this.text});
final Tab2ConversationAvatar avatar; final Tab2ConversationAvatar? avatar;
final String text; final String? text;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -687,7 +686,8 @@ class Tab2ConversationRow extends StatelessWidget { ...@@ -687,7 +686,8 @@ class Tab2ConversationRow extends StatelessWidget {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: isSelf ? CrossAxisAlignment.center : CrossAxisAlignment.end, crossAxisAlignment: isSelf ? CrossAxisAlignment.center : CrossAxisAlignment.end,
children: <Widget>[ children: <Widget>[
if (avatar != null) avatar, if (avatar != null)
avatar!,
CupertinoUserInterfaceLevel( CupertinoUserInterfaceLevel(
data: CupertinoUserInterfaceLevelData.elevated, data: CupertinoUserInterfaceLevelData.elevated,
child: Tab2ConversationBubble( child: Tab2ConversationBubble(
...@@ -752,7 +752,7 @@ class CupertinoDemoTab3 extends StatelessWidget { ...@@ -752,7 +752,7 @@ class CupertinoDemoTab3 extends StatelessWidget {
const Padding(padding: EdgeInsets.only(top: 32.0)), const Padding(padding: EdgeInsets.only(top: 32.0)),
GestureDetector( GestureDetector(
onTap: () { onTap: () {
Navigator.of(context, rootNavigator: true).push( Navigator.of(context, rootNavigator: true)!.push(
CupertinoPageRoute<bool>( CupertinoPageRoute<bool>(
fullscreenDialog: true, fullscreenDialog: true,
builder: (BuildContext context) => Tab3Dialog(), builder: (BuildContext context) => Tab3Dialog(),
...@@ -800,7 +800,7 @@ class Tab3Dialog extends StatelessWidget { ...@@ -800,7 +800,7 @@ class Tab3Dialog extends StatelessWidget {
child: const Text('Cancel'), child: const Text('Cancel'),
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
onPressed: () { onPressed: () {
Navigator.of(context).pop(false); Navigator.of(context)!.pop(false);
}, },
), ),
), ),
......
...@@ -20,10 +20,9 @@ class CupertinoPickerDemo extends StatefulWidget { ...@@ -20,10 +20,9 @@ class CupertinoPickerDemo extends StatefulWidget {
class _BottomPicker extends StatelessWidget { class _BottomPicker extends StatelessWidget {
const _BottomPicker({ const _BottomPicker({
Key key, Key? key,
@required this.child, required this.child,
}) : assert(child != null), }) : super(key: key);
super(key: key);
final Widget child; final Widget child;
...@@ -53,10 +52,9 @@ class _BottomPicker extends StatelessWidget { ...@@ -53,10 +52,9 @@ class _BottomPicker extends StatelessWidget {
class _Menu extends StatelessWidget { class _Menu extends StatelessWidget {
const _Menu({ const _Menu({
Key key, Key? key,
@required this.children, required this.children,
}) : assert(children != null), }) : super(key: key);
super(key: key);
final List<Widget> children; final List<Widget> children;
......
...@@ -16,7 +16,7 @@ class CupertinoRefreshControlDemo extends StatefulWidget { ...@@ -16,7 +16,7 @@ class CupertinoRefreshControlDemo extends StatefulWidget {
} }
class _CupertinoRefreshControlDemoState extends State<CupertinoRefreshControlDemo> { class _CupertinoRefreshControlDemoState extends State<CupertinoRefreshControlDemo> {
List<List<String>> randomizedContacts; late List<List<String>> randomizedContacts;
@override @override
void initState() { void initState() {
...@@ -64,7 +64,7 @@ class _CupertinoRefreshControlDemoState extends State<CupertinoRefreshControlDem ...@@ -64,7 +64,7 @@ class _CupertinoRefreshControlDemoState extends State<CupertinoRefreshControlDem
CupertinoSliverRefreshControl( CupertinoSliverRefreshControl(
onRefresh: () { onRefresh: () {
return Future<void>.delayed(const Duration(seconds: 2)) return Future<void>.delayed(const Duration(seconds: 2))
..then<void>((_) { ..then((_) {
if (mounted) { if (mounted) {
setState(() => repopulateList()); setState(() => repopulateList());
} }
...@@ -149,10 +149,10 @@ class _ListItem extends StatelessWidget { ...@@ -149,10 +149,10 @@ class _ListItem extends StatelessWidget {
this.called, this.called,
}); });
final String name; final String? name;
final String place; final String? place;
final String date; final String? date;
final bool called; final bool? called;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -164,7 +164,7 @@ class _ListItem extends StatelessWidget { ...@@ -164,7 +164,7 @@ class _ListItem extends StatelessWidget {
children: <Widget>[ children: <Widget>[
Container( Container(
width: 38.0, width: 38.0,
child: called child: called!
? Align( ? Align(
alignment: Alignment.topCenter, alignment: Alignment.topCenter,
child: Icon( child: Icon(
...@@ -191,7 +191,7 @@ class _ListItem extends StatelessWidget { ...@@ -191,7 +191,7 @@ class _ListItem extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[ children: <Widget>[
Text( Text(
name, name!,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: const TextStyle( style: const TextStyle(
...@@ -200,7 +200,7 @@ class _ListItem extends StatelessWidget { ...@@ -200,7 +200,7 @@ class _ListItem extends StatelessWidget {
), ),
), ),
Text( Text(
place, place!,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
...@@ -213,7 +213,7 @@ class _ListItem extends StatelessWidget { ...@@ -213,7 +213,7 @@ class _ListItem extends StatelessWidget {
), ),
), ),
Text( Text(
date, date!,
style: TextStyle( style: TextStyle(
color: CupertinoColors.inactiveGray.resolveFrom(context), color: CupertinoColors.inactiveGray.resolveFrom(context),
fontSize: 15.0, fontSize: 15.0,
......
...@@ -43,9 +43,9 @@ class _CupertinoSegmentedControlDemoState extends State<CupertinoSegmentedContro ...@@ -43,9 +43,9 @@ class _CupertinoSegmentedControlDemoState extends State<CupertinoSegmentedContro
), ),
}; };
int currentSegment = 0; int? currentSegment = 0;
void onValueChanged(int newValue) { void onValueChanged(int? newValue) {
setState(() { setState(() {
currentSegment = newValue; currentSegment = newValue;
}); });
...@@ -126,7 +126,7 @@ class _CupertinoSegmentedControlDemoState extends State<CupertinoSegmentedContro ...@@ -126,7 +126,7 @@ class _CupertinoSegmentedControlDemoState extends State<CupertinoSegmentedContro
), ),
], ],
), ),
child: icons[currentSegment], child: icons[currentSegment!],
); );
}, },
), ),
......
...@@ -14,8 +14,8 @@ class CupertinoTextFieldDemo extends StatefulWidget { ...@@ -14,8 +14,8 @@ class CupertinoTextFieldDemo extends StatefulWidget {
} }
class _CupertinoTextFieldDemoState extends State<CupertinoTextFieldDemo> { class _CupertinoTextFieldDemoState extends State<CupertinoTextFieldDemo> {
TextEditingController _chatTextController; TextEditingController? _chatTextController;
TextEditingController _locationTextController; TextEditingController? _locationTextController;
@override @override
void initState() { void initState() {
...@@ -49,12 +49,12 @@ class _CupertinoTextFieldDemoState extends State<CupertinoTextFieldDemo> { ...@@ -49,12 +49,12 @@ class _CupertinoTextFieldDemoState extends State<CupertinoTextFieldDemo> {
color: CupertinoColors.activeGreen, color: CupertinoColors.activeGreen,
), ),
padding: const EdgeInsets.only(bottom: 4), padding: const EdgeInsets.only(bottom: 4),
onPressed: ()=> setState(()=> _chatTextController.clear()), onPressed: ()=> setState(()=> _chatTextController!.clear()),
), ),
), ),
autofocus: true, autofocus: true,
suffixMode: OverlayVisibilityMode.editing, suffixMode: OverlayVisibilityMode.editing,
onSubmitted: (String text)=> setState(()=> _chatTextController.clear()), onSubmitted: (String text)=> setState(()=> _chatTextController!.clear()),
); );
} }
......
...@@ -33,7 +33,7 @@ class FortnightlyDemo extends StatelessWidget { ...@@ -33,7 +33,7 @@ class FortnightlyDemo extends StatelessWidget {
class ShortAppBar extends StatelessWidget { class ShortAppBar extends StatelessWidget {
const ShortAppBar({ this.onBackPressed }); const ShortAppBar({ this.onBackPressed });
final VoidCallback onBackPressed; final VoidCallback? onBackPressed;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -118,7 +118,7 @@ over water meant for the whole central valley of California? The story will shoc ...@@ -118,7 +118,7 @@ over water meant for the whole central valley of California? The story will shoc
Text( Text(
' ¬ ', ' ¬ ',
// TODO(larche): Replace textTheme.headline2.color with a ColorScheme value when known. // TODO(larche): Replace textTheme.headline2.color with a ColorScheme value when known.
style: textTheme.overline.apply(color: textTheme.headline2.color), style: textTheme.overline!.apply(color: textTheme.headline2!.color),
), ),
Text( Text(
'CULTURE', 'CULTURE',
...@@ -196,7 +196,7 @@ TextTheme _buildTextTheme(TextTheme base) { ...@@ -196,7 +196,7 @@ TextTheme _buildTextTheme(TextTheme base) {
theme = theme.apply(displayColor: Colors.black); theme = theme.apply(displayColor: Colors.black);
theme = theme.copyWith( theme = theme.copyWith(
headline4: base.headline4.copyWith( headline4: base.headline4!.copyWith(
fontFamily: 'Merriweather', fontFamily: 'Merriweather',
fontStyle: FontStyle.italic, fontStyle: FontStyle.italic,
fontSize: 28, fontSize: 28,
...@@ -204,21 +204,21 @@ TextTheme _buildTextTheme(TextTheme base) { ...@@ -204,21 +204,21 @@ TextTheme _buildTextTheme(TextTheme base) {
color: Colors.black, color: Colors.black,
height: .88, height: .88,
), ),
headline2: base.headline2.copyWith( headline2: base.headline2!.copyWith(
fontFamily: 'LibreFranklin', fontFamily: 'LibreFranklin',
fontSize: 18, fontSize: 18,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
color: Colors.black.withAlpha(153), color: Colors.black.withAlpha(153),
), ),
headline5: base.headline5.copyWith(fontWeight: FontWeight.w500), headline5: base.headline5!.copyWith(fontWeight: FontWeight.w500),
bodyText2: base.bodyText2.copyWith( bodyText2: base.bodyText2!.copyWith(
fontFamily: 'Merriweather', fontFamily: 'Merriweather',
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.w300, fontWeight: FontWeight.w300,
color: const Color(0xFF666666), color: const Color(0xFF666666),
height: 1.11, height: 1.11,
), ),
bodyText1: base.bodyText1.copyWith( bodyText1: base.bodyText1!.copyWith(
fontFamily: 'Merriweather', fontFamily: 'Merriweather',
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.w300, fontWeight: FontWeight.w300,
......
...@@ -12,8 +12,8 @@ import 'package:flutter/material.dart'; ...@@ -12,8 +12,8 @@ import 'package:flutter/material.dart';
class Category { class Category {
const Category({ this.title, this.assets }); const Category({ this.title, this.assets });
final String title; final String? title;
final List<String> assets; final List<String>? assets;
@override @override
String toString() => '$runtimeType("$title")'; String toString() => '$runtimeType("$title")';
} }
...@@ -95,21 +95,21 @@ const List<Category> allCategories = <Category>[ ...@@ -95,21 +95,21 @@ const List<Category> allCategories = <Category>[
]; ];
class CategoryView extends StatelessWidget { class CategoryView extends StatelessWidget {
const CategoryView({ Key key, this.category }) : super(key: key); const CategoryView({ Key? key, this.category }) : super(key: key);
final Category category; final Category? category;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
return Scrollbar( return Scrollbar(
child: ListView( child: ListView(
key: PageStorageKey<Category>(category), key: PageStorageKey<Category?>(category),
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
vertical: 16.0, vertical: 16.0,
horizontal: 64.0, horizontal: 64.0,
), ),
children: category.assets.map<Widget>((String asset) { children: category!.assets!.map<Widget>((String asset) {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[ children: <Widget>[
...@@ -149,7 +149,7 @@ class CategoryView extends StatelessWidget { ...@@ -149,7 +149,7 @@ class CategoryView extends StatelessWidget {
// BackdropDemo. // BackdropDemo.
class BackdropPanel extends StatelessWidget { class BackdropPanel extends StatelessWidget {
const BackdropPanel({ const BackdropPanel({
Key key, Key? key,
this.onTap, this.onTap,
this.onVerticalDragUpdate, this.onVerticalDragUpdate,
this.onVerticalDragEnd, this.onVerticalDragEnd,
...@@ -157,11 +157,11 @@ class BackdropPanel extends StatelessWidget { ...@@ -157,11 +157,11 @@ class BackdropPanel extends StatelessWidget {
this.child, this.child,
}) : super(key: key); }) : super(key: key);
final VoidCallback onTap; final VoidCallback? onTap;
final GestureDragUpdateCallback onVerticalDragUpdate; final GestureDragUpdateCallback? onVerticalDragUpdate;
final GestureDragEndCallback onVerticalDragEnd; final GestureDragEndCallback? onVerticalDragEnd;
final Widget title; final Widget? title;
final Widget child; final Widget? child;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -185,7 +185,7 @@ class BackdropPanel extends StatelessWidget { ...@@ -185,7 +185,7 @@ class BackdropPanel extends StatelessWidget {
padding: const EdgeInsetsDirectional.only(start: 16.0), padding: const EdgeInsetsDirectional.only(start: 16.0),
alignment: AlignmentDirectional.centerStart, alignment: AlignmentDirectional.centerStart,
child: DefaultTextStyle( child: DefaultTextStyle(
style: theme.textTheme.subtitle1, style: theme.textTheme.subtitle1!,
child: Tooltip( child: Tooltip(
message: 'Tap to dismiss', message: 'Tap to dismiss',
child: title, child: title,
...@@ -194,7 +194,7 @@ class BackdropPanel extends StatelessWidget { ...@@ -194,7 +194,7 @@ class BackdropPanel extends StatelessWidget {
), ),
), ),
const Divider(height: 1.0), const Divider(height: 1.0),
Expanded(child: child), Expanded(child: child!),
], ],
), ),
); );
...@@ -204,15 +204,15 @@ class BackdropPanel extends StatelessWidget { ...@@ -204,15 +204,15 @@ class BackdropPanel extends StatelessWidget {
// Cross fades between 'Select a Category' and 'Asset Viewer'. // Cross fades between 'Select a Category' and 'Asset Viewer'.
class BackdropTitle extends AnimatedWidget { class BackdropTitle extends AnimatedWidget {
const BackdropTitle({ const BackdropTitle({
Key key, Key? key,
Animation<double> listenable, required Animation<double> listenable,
}) : super(key: key, listenable: listenable); }) : super(key: key, listenable: listenable);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final Animation<double> animation = listenable as Animation<double>; final Animation<double> animation = listenable as Animation<double>;
return DefaultTextStyle( return DefaultTextStyle(
style: Theme.of(context).primaryTextTheme.headline6, style: Theme.of(context).primaryTextTheme.headline6!,
softWrap: false, softWrap: false,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
child: Stack( child: Stack(
...@@ -247,7 +247,7 @@ class BackdropDemo extends StatefulWidget { ...@@ -247,7 +247,7 @@ class BackdropDemo extends StatefulWidget {
class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderStateMixin { class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderStateMixin {
final GlobalKey _backdropKey = GlobalKey(debugLabel: 'Backdrop'); final GlobalKey _backdropKey = GlobalKey(debugLabel: 'Backdrop');
AnimationController _controller; late AnimationController _controller;
Category _category = allCategories[0]; Category _category = allCategories[0];
@override @override
...@@ -283,7 +283,7 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt ...@@ -283,7 +283,7 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt
} }
double get _backdropHeight { double get _backdropHeight {
final RenderBox renderBox = _backdropKey.currentContext.findRenderObject() as RenderBox; final RenderBox renderBox = _backdropKey.currentContext!.findRenderObject()! as RenderBox;
return renderBox.size.height; return renderBox.size.height;
} }
...@@ -294,7 +294,7 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt ...@@ -294,7 +294,7 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt
if (_controller.isAnimating || _controller.status == AnimationStatus.completed) if (_controller.isAnimating || _controller.status == AnimationStatus.completed)
return; return;
_controller.value -= details.primaryDelta / (_backdropHeight ?? details.primaryDelta); _controller.value -= details.primaryDelta! / _backdropHeight;
} }
void _handleDragEnd(DragEndDetails details) { void _handleDragEnd(DragEndDetails details) {
...@@ -343,7 +343,7 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt ...@@ -343,7 +343,7 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt
? Colors.white.withOpacity(0.25) ? Colors.white.withOpacity(0.25)
: Colors.transparent, : Colors.transparent,
child: ListTile( child: ListTile(
title: Text(category.title), title: Text(category.title!),
selected: selected, selected: selected,
onTap: () { onTap: () {
_changeCategory(category); _changeCategory(category);
...@@ -359,8 +359,8 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt ...@@ -359,8 +359,8 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt
children: <Widget>[ children: <Widget>[
ListTileTheme( ListTileTheme(
iconColor: theme.primaryIconTheme.color, iconColor: theme.primaryIconTheme.color,
textColor: theme.primaryTextTheme.headline6.color.withOpacity(0.6), textColor: theme.primaryTextTheme.headline6!.color!.withOpacity(0.6),
selectedColor: theme.primaryTextTheme.headline6.color, selectedColor: theme.primaryTextTheme.headline6!.color,
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0), padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Column( child: Column(
...@@ -375,7 +375,7 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt ...@@ -375,7 +375,7 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt
onTap: _toggleBackdropPanelVisibility, onTap: _toggleBackdropPanelVisibility,
onVerticalDragUpdate: _handleDragUpdate, onVerticalDragUpdate: _handleDragUpdate,
onVerticalDragEnd: _handleDragEnd, onVerticalDragEnd: _handleDragEnd,
title: Text(_category.title), title: Text(_category.title!),
child: CategoryView(category: _category), child: CategoryView(category: _category),
), ),
), ),
......
...@@ -13,7 +13,7 @@ enum BannerDemoAction { ...@@ -13,7 +13,7 @@ enum BannerDemoAction {
} }
class BannerDemo extends StatefulWidget { class BannerDemo extends StatefulWidget {
const BannerDemo({ Key key }) : super(key: key); const BannerDemo({ Key? key }) : super(key: key);
static const String routeName = '/material/banner'; static const String routeName = '/material/banner';
......
...@@ -92,7 +92,7 @@ class _BottomAppBarDemoState extends State<BottomAppBarDemo> { ...@@ -92,7 +92,7 @@ class _BottomAppBarDemoState extends State<BottomAppBarDemo> {
"When the Scaffold's floating action button location changes, " "When the Scaffold's floating action button location changes, "
'the floating action button animates to its new position. ' 'the floating action button animates to its new position. '
'The BottomAppBar adapts its shape appropriately.'; 'The BottomAppBar adapts its shape appropriately.';
_scaffoldMessengerKey.currentState.showSnackBar( _scaffoldMessengerKey.currentState!.showSnackBar(
const SnackBar(content: Text(text)), const SnackBar(content: Text(text)),
); );
} }
...@@ -111,27 +111,27 @@ class _BottomAppBarDemoState extends State<BottomAppBarDemo> { ...@@ -111,27 +111,27 @@ class _BottomAppBarDemoState extends State<BottomAppBarDemo> {
_ChoiceValue<Widget> _fabShape = kCircularFab; _ChoiceValue<Widget> _fabShape = kCircularFab;
_ChoiceValue<bool> _showNotch = kShowNotchTrue; _ChoiceValue<bool> _showNotch = kShowNotchTrue;
_ChoiceValue<FloatingActionButtonLocation> _fabLocation = kFabEndDocked; _ChoiceValue<FloatingActionButtonLocation> _fabLocation = kFabEndDocked;
Color _babColor = kBabColors.first.color; Color? _babColor = kBabColors.first.color;
void _onShowNotchChanged(_ChoiceValue<bool> value) { void _onShowNotchChanged(_ChoiceValue<bool>? value) {
setState(() { setState(() {
_showNotch = value; _showNotch = value!;
}); });
} }
void _onFabShapeChanged(_ChoiceValue<Widget> value) { void _onFabShapeChanged(_ChoiceValue<Widget>? value) {
setState(() { setState(() {
_fabShape = value; _fabShape = value!;
}); });
} }
void _onFabLocationChanged(_ChoiceValue<FloatingActionButtonLocation> value) { void _onFabLocationChanged(_ChoiceValue<FloatingActionButtonLocation>? value) {
setState(() { setState(() {
_fabLocation = value; _fabLocation = value!;
}); });
} }
void _onBabColorChanged(Color value) { void _onBabColorChanged(Color? value) {
setState(() { setState(() {
_babColor = value; _babColor = value;
}); });
...@@ -201,8 +201,8 @@ class _BottomAppBarDemoState extends State<BottomAppBarDemo> { ...@@ -201,8 +201,8 @@ class _BottomAppBarDemoState extends State<BottomAppBarDemo> {
); );
} }
NotchedShape _selectNotch() { NotchedShape? _selectNotch() {
if (!_showNotch.value) if (!_showNotch.value!)
return null; return null;
if (_fabShape == kCircularFab) if (_fabShape == kCircularFab)
return const CircularNotchedRectangle(); return const CircularNotchedRectangle();
...@@ -215,9 +215,9 @@ class _BottomAppBarDemoState extends State<BottomAppBarDemo> { ...@@ -215,9 +215,9 @@ class _BottomAppBarDemoState extends State<BottomAppBarDemo> {
class _ChoiceValue<T> { class _ChoiceValue<T> {
const _ChoiceValue({ this.value, this.title, this.label }); const _ChoiceValue({ this.value, this.title, this.label });
final T value; final T? value;
final String title; final String? title;
final String label; // For the Semantics widget that contains title final String? label; // For the Semantics widget that contains title
@override @override
String toString() => '$runtimeType("$title")'; String toString() => '$runtimeType("$title")';
...@@ -228,7 +228,7 @@ class _RadioItem<T> extends StatelessWidget { ...@@ -228,7 +228,7 @@ class _RadioItem<T> extends StatelessWidget {
final _ChoiceValue<T> value; final _ChoiceValue<T> value;
final _ChoiceValue<T> groupValue; final _ChoiceValue<T> groupValue;
final ValueChanged<_ChoiceValue<T>> onChanged; final ValueChanged<_ChoiceValue<T>?> onChanged;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -256,7 +256,7 @@ class _RadioItem<T> extends StatelessWidget { ...@@ -256,7 +256,7 @@ class _RadioItem<T> extends StatelessWidget {
onChanged(value); onChanged(value);
}, },
child: Text( child: Text(
value.title, value.title!,
style: theme.textTheme.subtitle1, style: theme.textTheme.subtitle1,
), ),
), ),
...@@ -272,7 +272,7 @@ class _RadioItem<T> extends StatelessWidget { ...@@ -272,7 +272,7 @@ class _RadioItem<T> extends StatelessWidget {
class _NamedColor { class _NamedColor {
const _NamedColor(this.color, this.name); const _NamedColor(this.color, this.name);
final Color color; final Color? color;
final String name; final String name;
} }
...@@ -280,8 +280,8 @@ class _ColorsItem extends StatelessWidget { ...@@ -280,8 +280,8 @@ class _ColorsItem extends StatelessWidget {
const _ColorsItem(this.colors, this.selectedColor, this.onChanged); const _ColorsItem(this.colors, this.selectedColor, this.onChanged);
final List<_NamedColor> colors; final List<_NamedColor> colors;
final Color selectedColor; final Color? selectedColor;
final ValueChanged<Color> onChanged; final ValueChanged<Color?> onChanged;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -340,9 +340,9 @@ class _DemoBottomAppBar extends StatelessWidget { ...@@ -340,9 +340,9 @@ class _DemoBottomAppBar extends StatelessWidget {
this.shape, this.shape,
}); });
final Color color; final Color? color;
final FloatingActionButtonLocation fabLocation; final FloatingActionButtonLocation? fabLocation;
final NotchedShape shape; final NotchedShape? shape;
static final List<FloatingActionButtonLocation> kCenterLocations = <FloatingActionButtonLocation>[ static final List<FloatingActionButtonLocation> kCenterLocations = <FloatingActionButtonLocation>[
FloatingActionButtonLocation.centerDocked, FloatingActionButtonLocation.centerDocked,
...@@ -421,8 +421,8 @@ class _DiamondFab extends StatelessWidget { ...@@ -421,8 +421,8 @@ class _DiamondFab extends StatelessWidget {
this.onPressed, this.onPressed,
}); });
final Widget child; final Widget? child;
final VoidCallback onPressed; final VoidCallback? onPressed;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -436,7 +436,7 @@ class _DiamondFab extends StatelessWidget { ...@@ -436,7 +436,7 @@ class _DiamondFab extends StatelessWidget {
height: 56.0, height: 56.0,
child: IconTheme.merge( child: IconTheme.merge(
data: IconThemeData(color: Theme.of(context).accentIconTheme.color), data: IconThemeData(color: Theme.of(context).accentIconTheme.color),
child: child, child: child!,
), ),
), ),
), ),
...@@ -449,8 +449,8 @@ class _DiamondNotchedRectangle implements NotchedShape { ...@@ -449,8 +449,8 @@ class _DiamondNotchedRectangle implements NotchedShape {
const _DiamondNotchedRectangle(); const _DiamondNotchedRectangle();
@override @override
Path getOuterPath(Rect host, Rect guest) { Path getOuterPath(Rect host, Rect? guest) {
if (!host.overlaps(guest)) if (!host.overlaps(guest!))
return Path()..addRect(host); return Path()..addRect(host);
assert(guest.width > 0.0); assert(guest.width > 0.0);
...@@ -492,12 +492,12 @@ class _DiamondBorder extends ShapeBorder { ...@@ -492,12 +492,12 @@ class _DiamondBorder extends ShapeBorder {
} }
@override @override
Path getInnerPath(Rect rect, { TextDirection textDirection }) { Path getInnerPath(Rect rect, { TextDirection? textDirection }) {
return getOuterPath(rect, textDirection: textDirection); return getOuterPath(rect, textDirection: textDirection);
} }
@override @override
Path getOuterPath(Rect rect, { TextDirection textDirection }) { Path getOuterPath(Rect rect, { TextDirection? textDirection }) {
return Path() return Path()
..moveTo(rect.left + rect.width / 2.0, rect.top) ..moveTo(rect.left + rect.width / 2.0, rect.top)
..lineTo(rect.right, rect.top + rect.height / 2.0) ..lineTo(rect.right, rect.top + rect.height / 2.0)
...@@ -507,11 +507,11 @@ class _DiamondBorder extends ShapeBorder { ...@@ -507,11 +507,11 @@ class _DiamondBorder extends ShapeBorder {
} }
@override @override
void paint(Canvas canvas, Rect rect, { TextDirection textDirection }) { } void paint(Canvas canvas, Rect rect, { TextDirection? textDirection }) { }
// This border doesn't support scaling. // This border doesn't support scaling.
@override @override
ShapeBorder scale(double t) { ShapeBorder scale(double t) {
return null; return this;
} }
} }
...@@ -8,11 +8,11 @@ import '../../gallery/demo.dart'; ...@@ -8,11 +8,11 @@ import '../../gallery/demo.dart';
class NavigationIconView { class NavigationIconView {
NavigationIconView({ NavigationIconView({
Widget icon, required Widget icon,
Widget activeIcon, Widget? activeIcon,
String title, String? title,
Color color, Color? color,
TickerProvider vsync, required TickerProvider vsync,
}) : _icon = icon, }) : _icon = icon,
_color = color, _color = color,
_title = title, _title = title,
...@@ -32,14 +32,14 @@ class NavigationIconView { ...@@ -32,14 +32,14 @@ class NavigationIconView {
} }
final Widget _icon; final Widget _icon;
final Color _color; final Color? _color;
final String _title; final String? _title;
final BottomNavigationBarItem item; final BottomNavigationBarItem item;
final AnimationController controller; final AnimationController controller;
Animation<double> _animation; late Animation<double> _animation;
FadeTransition transition(BottomNavigationBarType type, BuildContext context) { FadeTransition transition(BottomNavigationBarType type, BuildContext context) {
Color iconColor; Color? iconColor;
if (type == BottomNavigationBarType.shifting) { if (type == BottomNavigationBarType.shifting) {
iconColor = _color; iconColor = _color;
} else { } else {
...@@ -79,8 +79,8 @@ class CustomIcon extends StatelessWidget { ...@@ -79,8 +79,8 @@ class CustomIcon extends StatelessWidget {
final IconThemeData iconTheme = IconTheme.of(context); final IconThemeData iconTheme = IconTheme.of(context);
return Container( return Container(
margin: const EdgeInsets.all(4.0), margin: const EdgeInsets.all(4.0),
width: iconTheme.size - 8.0, width: iconTheme.size! - 8.0,
height: iconTheme.size - 8.0, height: iconTheme.size! - 8.0,
color: iconTheme.color, color: iconTheme.color,
); );
} }
...@@ -92,10 +92,10 @@ class CustomInactiveIcon extends StatelessWidget { ...@@ -92,10 +92,10 @@ class CustomInactiveIcon extends StatelessWidget {
final IconThemeData iconTheme = IconTheme.of(context); final IconThemeData iconTheme = IconTheme.of(context);
return Container( return Container(
margin: const EdgeInsets.all(4.0), margin: const EdgeInsets.all(4.0),
width: iconTheme.size - 8.0, width: iconTheme.size! - 8.0,
height: iconTheme.size - 8.0, height: iconTheme.size! - 8.0,
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all(color: iconTheme.color, width: 2.0), border: Border.all(color: iconTheme.color!, width: 2.0),
), ),
); );
} }
...@@ -112,7 +112,7 @@ class _BottomNavigationDemoState extends State<BottomNavigationDemo> ...@@ -112,7 +112,7 @@ class _BottomNavigationDemoState extends State<BottomNavigationDemo>
with TickerProviderStateMixin { with TickerProviderStateMixin {
int _currentIndex = 0; int _currentIndex = 0;
BottomNavigationBarType _type = BottomNavigationBarType.shifting; BottomNavigationBarType _type = BottomNavigationBarType.shifting;
List<NavigationIconView> _navigationViews; late List<NavigationIconView> _navigationViews;
@override @override
void initState() { void initState() {
......
...@@ -53,7 +53,7 @@ class ButtonsDemo extends StatefulWidget { ...@@ -53,7 +53,7 @@ class ButtonsDemo extends StatefulWidget {
} }
class _ButtonsDemoState extends State<ButtonsDemo> { class _ButtonsDemoState extends State<ButtonsDemo> {
OutlinedBorder _buttonShape; OutlinedBorder? _buttonShape;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -118,7 +118,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -118,7 +118,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
); );
} }
Widget buildElevatedButton(OutlinedBorder shape) { Widget buildElevatedButton(OutlinedBorder? shape) {
final ButtonStyle style = ElevatedButton.styleFrom(shape: shape); final ButtonStyle style = ElevatedButton.styleFrom(shape: shape);
return Align( return Align(
alignment: const Alignment(0.0, -0.2), alignment: const Alignment(0.0, -0.2),
...@@ -156,7 +156,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -156,7 +156,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
style: style, style: style,
icon: const Icon(Icons.add, size: 18.0), icon: const Icon(Icons.add, size: 18.0),
label: const Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 2'), label: const Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 2'),
onPressed: null, onPressed: () {},
), ),
], ],
), ),
...@@ -165,7 +165,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -165,7 +165,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
); );
} }
Widget buildTextButton(OutlinedBorder shape) { Widget buildTextButton(OutlinedBorder? shape) {
final ButtonStyle style = ElevatedButton.styleFrom(shape: shape); final ButtonStyle style = ElevatedButton.styleFrom(shape: shape);
return Align( return Align(
alignment: const Alignment(0.0, -0.2), alignment: const Alignment(0.0, -0.2),
...@@ -203,7 +203,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -203,7 +203,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
style: style, style: style,
icon: const Icon(Icons.add_circle_outline, size: 18.0), icon: const Icon(Icons.add_circle_outline, size: 18.0),
label: const Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 4'), label: const Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 4'),
onPressed: null, onPressed: () {},
), ),
], ],
), ),
...@@ -212,7 +212,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -212,7 +212,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
); );
} }
Widget buildOutlinedButton(OutlinedBorder shape) { Widget buildOutlinedButton(OutlinedBorder? shape) {
final ButtonStyle style = ElevatedButton.styleFrom(shape: shape); final ButtonStyle style = ElevatedButton.styleFrom(shape: shape);
return Align( return Align(
alignment: const Alignment(0.0, -0.2), alignment: const Alignment(0.0, -0.2),
...@@ -260,9 +260,9 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -260,9 +260,9 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
} }
// https://en.wikipedia.org/wiki/Free_Four // https://en.wikipedia.org/wiki/Free_Four
String dropdown1Value = 'Free'; String? dropdown1Value = 'Free';
String dropdown2Value; String? dropdown2Value;
String dropdown3Value = 'Four'; String? dropdown3Value = 'Four';
Widget buildDropdownButton() { Widget buildDropdownButton() {
return Padding( return Padding(
...@@ -274,7 +274,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -274,7 +274,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
title: const Text('Simple dropdown:'), title: const Text('Simple dropdown:'),
trailing: DropdownButton<String>( trailing: DropdownButton<String>(
value: dropdown1Value, value: dropdown1Value,
onChanged: (String newValue) { onChanged: (String? newValue) {
setState(() { setState(() {
dropdown1Value = newValue; dropdown1Value = newValue;
}); });
...@@ -295,7 +295,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -295,7 +295,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
trailing: DropdownButton<String>( trailing: DropdownButton<String>(
value: dropdown2Value, value: dropdown2Value,
hint: const Text('Choose'), hint: const Text('Choose'),
onChanged: (String newValue) { onChanged: (String? newValue) {
setState(() { setState(() {
dropdown2Value = newValue; dropdown2Value = newValue;
}); });
...@@ -315,7 +315,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -315,7 +315,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
title: const Text('Scrollable dropdown:'), title: const Text('Scrollable dropdown:'),
trailing: DropdownButton<String>( trailing: DropdownButton<String>(
value: dropdown3Value, value: dropdown3Value,
onChanged: (String newValue) { onChanged: (String? newValue) {
setState(() { setState(() {
dropdown3Value = newValue; dropdown3Value = newValue;
}); });
......
...@@ -17,19 +17,14 @@ enum CardDemoType { ...@@ -17,19 +17,14 @@ enum CardDemoType {
class TravelDestination { class TravelDestination {
const TravelDestination({ const TravelDestination({
@required this.assetName, required this.assetName,
@required this.assetPackage, required this.assetPackage,
@required this.title, required this.title,
@required this.description, required this.description,
@required this.city, required this.city,
@required this.location, required this.location,
this.type = CardDemoType.standard, this.type = CardDemoType.standard,
}) : assert(assetName != null), });
assert(assetPackage != null),
assert(title != null),
assert(description != null),
assert(city != null),
assert(location != null);
final String assetName; final String assetName;
final String assetPackage; final String assetPackage;
...@@ -70,14 +65,13 @@ const List<TravelDestination> destinations = <TravelDestination>[ ...@@ -70,14 +65,13 @@ const List<TravelDestination> destinations = <TravelDestination>[
]; ];
class TravelDestinationItem extends StatelessWidget { class TravelDestinationItem extends StatelessWidget {
const TravelDestinationItem({ Key key, @required this.destination, this.shape }) const TravelDestinationItem({ Key? key, required this.destination, this.shape })
: assert(destination != null), : super(key: key);
super(key: key);
// This height will allow for all the Card's content to fit comfortably within the card. // This height will allow for all the Card's content to fit comfortably within the card.
static const double height = 338.0; static const double height = 338.0;
final TravelDestination destination; final TravelDestination destination;
final ShapeBorder shape; final ShapeBorder? shape;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -106,14 +100,13 @@ class TravelDestinationItem extends StatelessWidget { ...@@ -106,14 +100,13 @@ class TravelDestinationItem extends StatelessWidget {
} }
class TappableTravelDestinationItem extends StatelessWidget { class TappableTravelDestinationItem extends StatelessWidget {
const TappableTravelDestinationItem({ Key key, @required this.destination, this.shape }) const TappableTravelDestinationItem({ Key? key, required this.destination, this.shape })
: assert(destination != null), : super(key: key);
super(key: key);
// This height will allow for all the Card's content to fit comfortably within the card. // This height will allow for all the Card's content to fit comfortably within the card.
static const double height = 298.0; static const double height = 298.0;
final TravelDestination destination; final TravelDestination destination;
final ShapeBorder shape; final ShapeBorder? shape;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -151,12 +144,11 @@ class TappableTravelDestinationItem extends StatelessWidget { ...@@ -151,12 +144,11 @@ class TappableTravelDestinationItem extends StatelessWidget {
} }
class SelectableTravelDestinationItem extends StatefulWidget { class SelectableTravelDestinationItem extends StatefulWidget {
const SelectableTravelDestinationItem({ Key key, @required this.destination, this.shape }) const SelectableTravelDestinationItem({ Key? key, required this.destination, this.shape })
: assert(destination != null), : super(key: key);
super(key: key);
final TravelDestination destination; final TravelDestination destination;
final ShapeBorder shape; final ShapeBorder? shape;
@override @override
_SelectableTravelDestinationItemState createState() => _SelectableTravelDestinationItemState(); _SelectableTravelDestinationItemState createState() => _SelectableTravelDestinationItemState();
...@@ -231,11 +223,11 @@ class _SelectableTravelDestinationItemState extends State<SelectableTravelDestin ...@@ -231,11 +223,11 @@ class _SelectableTravelDestinationItemState extends State<SelectableTravelDestin
class SectionTitle extends StatelessWidget { class SectionTitle extends StatelessWidget {
const SectionTitle({ const SectionTitle({
Key key, Key? key,
this.title, this.title,
}) : super(key: key); }) : super(key: key);
final String title; final String? title;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -243,24 +235,23 @@ class SectionTitle extends StatelessWidget { ...@@ -243,24 +235,23 @@ class SectionTitle extends StatelessWidget {
padding: const EdgeInsets.fromLTRB(4.0, 4.0, 4.0, 12.0), padding: const EdgeInsets.fromLTRB(4.0, 4.0, 4.0, 12.0),
child: Align( child: Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: Text(title, style: Theme.of(context).textTheme.subtitle1), child: Text(title!, style: Theme.of(context).textTheme.subtitle1),
), ),
); );
} }
} }
class TravelDestinationContent extends StatelessWidget { class TravelDestinationContent extends StatelessWidget {
const TravelDestinationContent({ Key key, @required this.destination }) const TravelDestinationContent({ Key? key, required this.destination })
: assert(destination != null), : super(key: key);
super(key: key);
final TravelDestination destination; final TravelDestination destination;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
final TextStyle titleStyle = theme.textTheme.headline5.copyWith(color: Colors.white); final TextStyle titleStyle = theme.textTheme.headline5!.copyWith(color: Colors.white);
final TextStyle descriptionStyle = theme.textTheme.subtitle1; final TextStyle descriptionStyle = theme.textTheme.subtitle1!;
final ButtonStyle textButtonStyle = TextButton.styleFrom(primary: Colors.amber.shade500); final ButtonStyle textButtonStyle = TextButton.styleFrom(primary: Colors.amber.shade500);
return Column( return Column(
...@@ -352,7 +343,7 @@ class CardsDemo extends StatefulWidget { ...@@ -352,7 +343,7 @@ class CardsDemo extends StatefulWidget {
} }
class _CardsDemoState extends State<CardsDemo> { class _CardsDemoState extends State<CardsDemo> {
ShapeBorder _shape; ShapeBorder? _shape;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -385,7 +376,7 @@ class _CardsDemoState extends State<CardsDemo> { ...@@ -385,7 +376,7 @@ class _CardsDemoState extends State<CardsDemo> {
child: ListView( child: ListView(
padding: const EdgeInsets.only(top: 8.0, left: 8.0, right: 8.0), padding: const EdgeInsets.only(top: 8.0, left: 8.0, right: 8.0),
children: destinations.map<Widget>((TravelDestination destination) { children: destinations.map<Widget>((TravelDestination destination) {
Widget child; Widget? child;
switch (destination.type) { switch (destination.type) {
case CardDemoType.standard: case CardDemoType.standard:
child = TravelDestinationItem(destination: destination, shape: _shape); child = TravelDestinationItem(destination: destination, shape: _shape);
......
...@@ -88,13 +88,13 @@ const Map<String, Set<String>> _materialActions = <String, Set<String>>{ ...@@ -88,13 +88,13 @@ const Map<String, Set<String>> _materialActions = <String, Set<String>>{
class _ChipsTile extends StatelessWidget { class _ChipsTile extends StatelessWidget {
const _ChipsTile({ const _ChipsTile({
Key key, Key? key,
this.label, this.label,
this.children, this.children,
}) : super(key: key); }) : super(key: key);
final String label; final String? label;
final List<Widget> children; final List<Widget>? children;
// Wraps a list of chips into a ListTile for display as a section in the demo. // Wraps a list of chips into a ListTile for display as a section in the demo.
@override @override
...@@ -107,11 +107,11 @@ class _ChipsTile extends StatelessWidget { ...@@ -107,11 +107,11 @@ class _ChipsTile extends StatelessWidget {
Container( Container(
padding: const EdgeInsets.only(top: 16.0, bottom: 4.0), padding: const EdgeInsets.only(top: 16.0, bottom: 4.0),
alignment: Alignment.center, alignment: Alignment.center,
child: Text(label, textAlign: TextAlign.start), child: Text(label!, textAlign: TextAlign.start),
), ),
if (children.isNotEmpty) if (children!.isNotEmpty)
Wrap( Wrap(
children: children.map<Widget>((Widget chip) { children: children!.map<Widget>((Widget chip) {
return Padding( return Padding(
padding: const EdgeInsets.all(2.0), padding: const EdgeInsets.all(2.0),
child: chip, child: chip,
...@@ -125,7 +125,7 @@ class _ChipsTile extends StatelessWidget { ...@@ -125,7 +125,7 @@ class _ChipsTile extends StatelessWidget {
alignment: Alignment.center, alignment: Alignment.center,
constraints: const BoxConstraints(minWidth: 48.0, minHeight: 48.0), constraints: const BoxConstraints(minWidth: 48.0, minHeight: 48.0),
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Text('None', style: Theme.of(context).textTheme.caption.copyWith(fontStyle: FontStyle.italic)), child: Text('None', style: Theme.of(context).textTheme.caption!.copyWith(fontStyle: FontStyle.italic)),
), ),
), ),
], ],
...@@ -188,7 +188,7 @@ class _ChipDemoState extends State<ChipDemo> { ...@@ -188,7 +188,7 @@ class _ChipDemoState extends State<ChipDemo> {
} }
String _capitalize(String name) { String _capitalize(String name) {
assert(name != null && name.isNotEmpty); assert(name.isNotEmpty);
return name.substring(0, 1).toUpperCase() + name.substring(1); return name.substring(0, 1).toUpperCase() + name.substring(1);
} }
...@@ -209,7 +209,7 @@ class _ChipDemoState extends State<ChipDemo> { ...@@ -209,7 +209,7 @@ class _ChipDemoState extends State<ChipDemo> {
AssetImage _nameToAvatar(String name) { AssetImage _nameToAvatar(String name) {
assert(_avatars.containsKey(name)); assert(_avatars.containsKey(name));
return AssetImage( return AssetImage(
_avatars[name], _avatars[name]!,
package: 'flutter_gallery_assets', package: 'flutter_gallery_assets',
); );
} }
...@@ -218,7 +218,7 @@ class _ChipDemoState extends State<ChipDemo> { ...@@ -218,7 +218,7 @@ class _ChipDemoState extends State<ChipDemo> {
if (_selectedAction.isEmpty) { if (_selectedAction.isEmpty) {
return ''; return '';
} }
return _capitalize(_results[_selectedAction]) + '!'; return _capitalize(_results[_selectedAction]!) + '!';
} }
@override @override
...@@ -285,11 +285,11 @@ class _ChipDemoState extends State<ChipDemo> { ...@@ -285,11 +285,11 @@ class _ChipDemoState extends State<ChipDemo> {
}).toList(); }).toList();
Set<String> allowedActions = <String>{}; Set<String> allowedActions = <String>{};
if (_selectedMaterial != null && _selectedMaterial.isNotEmpty) { if (_selectedMaterial.isNotEmpty) {
for (final String tool in _selectedTools) { for (final String tool in _selectedTools) {
allowedActions.addAll(_toolActions[tool]); allowedActions.addAll(_toolActions[tool]!);
} }
allowedActions = allowedActions.intersection(_materialActions[_selectedMaterial]); allowedActions = allowedActions.intersection(_materialActions[_selectedMaterial]!);
} }
final List<Widget> actionChips = allowedActions.map<Widget>((String name) { final List<Widget> actionChips = allowedActions.map<Widget>((String name) {
......
...@@ -18,7 +18,7 @@ class Dessert { ...@@ -18,7 +18,7 @@ class Dessert {
final int calcium; final int calcium;
final int iron; final int iron;
bool selected = false; bool? selected = false;
} }
class DessertDataSource extends DataTableSource { class DessertDataSource extends DataTableSource {
...@@ -96,17 +96,17 @@ class DessertDataSource extends DataTableSource { ...@@ -96,17 +96,17 @@ class DessertDataSource extends DataTableSource {
int _selectedCount = 0; int _selectedCount = 0;
@override @override
DataRow getRow(int index) { DataRow? getRow(int index) {
assert(index >= 0); assert(index >= 0);
if (index >= _desserts.length) if (index >= _desserts.length)
return null; return null;
final Dessert dessert = _desserts[index]; final Dessert dessert = _desserts[index];
return DataRow.byIndex( return DataRow.byIndex(
index: index, index: index,
selected: dessert.selected, selected: dessert.selected!,
onSelectChanged: (bool value) { onSelectChanged: (bool? value) {
if (dessert.selected != value) { if (dessert.selected != value) {
_selectedCount += value ? 1 : -1; _selectedCount += value! ? 1 : -1;
assert(_selectedCount >= 0); assert(_selectedCount >= 0);
dessert.selected = value; dessert.selected = value;
notifyListeners(); notifyListeners();
...@@ -134,10 +134,10 @@ class DessertDataSource extends DataTableSource { ...@@ -134,10 +134,10 @@ class DessertDataSource extends DataTableSource {
@override @override
int get selectedRowCount => _selectedCount; int get selectedRowCount => _selectedCount;
void _selectAll(bool checked) { void _selectAll(bool? checked) {
for (final Dessert dessert in _desserts) for (final Dessert dessert in _desserts)
dessert.selected = checked; dessert.selected = checked;
_selectedCount = checked ? _desserts.length : 0; _selectedCount = checked! ? _desserts.length : 0;
notifyListeners(); notifyListeners();
} }
} }
...@@ -150,8 +150,8 @@ class DataTableDemo extends StatefulWidget { ...@@ -150,8 +150,8 @@ class DataTableDemo extends StatefulWidget {
} }
class _DataTableDemoState extends State<DataTableDemo> { class _DataTableDemoState extends State<DataTableDemo> {
int _rowsPerPage = PaginatedDataTable.defaultRowsPerPage; int? _rowsPerPage = PaginatedDataTable.defaultRowsPerPage;
int _sortColumnIndex; int? _sortColumnIndex;
bool _sortAscending = true; bool _sortAscending = true;
final DessertDataSource _dessertsDataSource = DessertDataSource(); final DessertDataSource _dessertsDataSource = DessertDataSource();
...@@ -178,8 +178,8 @@ class _DataTableDemoState extends State<DataTableDemo> { ...@@ -178,8 +178,8 @@ class _DataTableDemoState extends State<DataTableDemo> {
children: <Widget>[ children: <Widget>[
PaginatedDataTable( PaginatedDataTable(
header: const Text('Nutrition'), header: const Text('Nutrition'),
rowsPerPage: _rowsPerPage, rowsPerPage: _rowsPerPage!,
onRowsPerPageChanged: (int value) { setState(() { _rowsPerPage = value; }); }, onRowsPerPageChanged: (int? value) { setState(() { _rowsPerPage = value; }); },
sortColumnIndex: _sortColumnIndex, sortColumnIndex: _sortColumnIndex,
sortAscending: _sortAscending, sortAscending: _sortAscending,
onSelectAll: _dessertsDataSource._selectAll, onSelectAll: _dessertsDataSource._selectAll,
......
...@@ -9,7 +9,7 @@ import '../../gallery/demo.dart'; ...@@ -9,7 +9,7 @@ import '../../gallery/demo.dart';
class _InputDropdown extends StatelessWidget { class _InputDropdown extends StatelessWidget {
const _InputDropdown({ const _InputDropdown({
Key key, Key? key,
this.child, this.child,
this.labelText, this.labelText,
this.valueText, this.valueText,
...@@ -17,11 +17,11 @@ class _InputDropdown extends StatelessWidget { ...@@ -17,11 +17,11 @@ class _InputDropdown extends StatelessWidget {
this.onPressed, this.onPressed,
}) : super(key: key); }) : super(key: key);
final String labelText; final String? labelText;
final String valueText; final String? valueText;
final TextStyle valueStyle; final TextStyle? valueStyle;
final VoidCallback onPressed; final VoidCallback? onPressed;
final Widget child; final Widget? child;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -36,7 +36,7 @@ class _InputDropdown extends StatelessWidget { ...@@ -36,7 +36,7 @@ class _InputDropdown extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
Text(valueText, style: valueStyle), Text(valueText!, style: valueStyle),
Icon(Icons.arrow_drop_down, Icon(Icons.arrow_drop_down,
color: Theme.of(context).brightness == Brightness.light ? Colors.grey.shade700 : Colors.white70, color: Theme.of(context).brightness == Brightness.light ? Colors.grey.shade700 : Colors.white70,
), ),
...@@ -49,7 +49,7 @@ class _InputDropdown extends StatelessWidget { ...@@ -49,7 +49,7 @@ class _InputDropdown extends StatelessWidget {
class _DateTimePicker extends StatelessWidget { class _DateTimePicker extends StatelessWidget {
const _DateTimePicker({ const _DateTimePicker({
Key key, Key? key,
this.labelText, this.labelText,
this.selectedDate, this.selectedDate,
this.selectedTime, this.selectedTime,
...@@ -57,35 +57,35 @@ class _DateTimePicker extends StatelessWidget { ...@@ -57,35 +57,35 @@ class _DateTimePicker extends StatelessWidget {
this.selectTime, this.selectTime,
}) : super(key: key); }) : super(key: key);
final String labelText; final String? labelText;
final DateTime selectedDate; final DateTime? selectedDate;
final TimeOfDay selectedTime; final TimeOfDay? selectedTime;
final ValueChanged<DateTime> selectDate; final ValueChanged<DateTime>? selectDate;
final ValueChanged<TimeOfDay> selectTime; final ValueChanged<TimeOfDay>? selectTime;
Future<void> _selectDate(BuildContext context) async { Future<void> _selectDate(BuildContext context) async {
final DateTime picked = await showDatePicker( final DateTime? picked = await showDatePicker(
context: context, context: context,
initialDate: selectedDate, initialDate: selectedDate!,
firstDate: DateTime(2015, 8), firstDate: DateTime(2015, 8),
lastDate: DateTime(2101), lastDate: DateTime(2101),
); );
if (picked != null && picked != selectedDate) if (picked != null && picked != selectedDate)
selectDate(picked); selectDate!(picked);
} }
Future<void> _selectTime(BuildContext context) async { Future<void> _selectTime(BuildContext context) async {
final TimeOfDay picked = await showTimePicker( final TimeOfDay? picked = await showTimePicker(
context: context, context: context,
initialTime: selectedTime, initialTime: selectedTime!,
); );
if (picked != null && picked != selectedTime) if (picked != null && picked != selectedTime)
selectTime(picked); selectTime!(picked);
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final TextStyle valueStyle = Theme.of(context).textTheme.headline6; final TextStyle? valueStyle = Theme.of(context).textTheme.headline6;
return Row( return Row(
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[ children: <Widget>[
...@@ -93,7 +93,7 @@ class _DateTimePicker extends StatelessWidget { ...@@ -93,7 +93,7 @@ class _DateTimePicker extends StatelessWidget {
flex: 4, flex: 4,
child: _InputDropdown( child: _InputDropdown(
labelText: labelText, labelText: labelText,
valueText: DateFormat.yMMMd().format(selectedDate), valueText: DateFormat.yMMMd().format(selectedDate!),
valueStyle: valueStyle, valueStyle: valueStyle,
onPressed: () { _selectDate(context); }, onPressed: () { _selectDate(context); },
), ),
...@@ -102,7 +102,7 @@ class _DateTimePicker extends StatelessWidget { ...@@ -102,7 +102,7 @@ class _DateTimePicker extends StatelessWidget {
Expanded( Expanded(
flex: 3, flex: 3,
child: _InputDropdown( child: _InputDropdown(
valueText: selectedTime.format(context), valueText: selectedTime!.format(context),
valueStyle: valueStyle, valueStyle: valueStyle,
onPressed: () { _selectTime(context); }, onPressed: () { _selectTime(context); },
), ),
...@@ -125,7 +125,7 @@ class _DateAndTimePickerDemoState extends State<DateAndTimePickerDemo> { ...@@ -125,7 +125,7 @@ class _DateAndTimePickerDemoState extends State<DateAndTimePickerDemo> {
DateTime _toDate = DateTime.now(); DateTime _toDate = DateTime.now();
TimeOfDay _toTime = const TimeOfDay(hour: 8, minute: 28); TimeOfDay _toTime = const TimeOfDay(hour: 8, minute: 28);
final List<String> _allActivities = <String>['hiking', 'swimming', 'boating', 'fishing']; final List<String> _allActivities = <String>['hiking', 'swimming', 'boating', 'fishing'];
String _activity = 'fishing'; String? _activity = 'fishing';
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -153,7 +153,7 @@ class _DateAndTimePickerDemoState extends State<DateAndTimePickerDemo> { ...@@ -153,7 +153,7 @@ class _DateAndTimePickerDemoState extends State<DateAndTimePickerDemo> {
decoration: const InputDecoration( decoration: const InputDecoration(
labelText: 'Location', labelText: 'Location',
), ),
style: Theme.of(context).textTheme.headline4.copyWith(fontSize: 20.0), style: Theme.of(context).textTheme.headline4!.copyWith(fontSize: 20.0),
), ),
_DateTimePicker( _DateTimePicker(
labelText: 'From', labelText: 'From',
...@@ -195,7 +195,7 @@ class _DateAndTimePickerDemoState extends State<DateAndTimePickerDemo> { ...@@ -195,7 +195,7 @@ class _DateAndTimePickerDemoState extends State<DateAndTimePickerDemo> {
isEmpty: _activity == null, isEmpty: _activity == null,
child: DropdownButton<String>( child: DropdownButton<String>(
value: _activity, value: _activity,
onChanged: (String newValue) { onChanged: (String? newValue) {
setState(() { setState(() {
_activity = newValue; _activity = newValue;
}); });
......
...@@ -21,12 +21,12 @@ const String _alertWithTitleText = ...@@ -21,12 +21,12 @@ const String _alertWithTitleText =
'data to Google, even when no apps are running.'; 'data to Google, even when no apps are running.';
class DialogDemoItem extends StatelessWidget { class DialogDemoItem extends StatelessWidget {
const DialogDemoItem({ Key key, this.icon, this.color, this.text, this.onPressed }) : super(key: key); const DialogDemoItem({ Key? key, this.icon, this.color, this.text, this.onPressed }) : super(key: key);
final IconData icon; final IconData? icon;
final Color color; final Color? color;
final String text; final String? text;
final VoidCallback onPressed; final VoidCallback? onPressed;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -39,7 +39,7 @@ class DialogDemoItem extends StatelessWidget { ...@@ -39,7 +39,7 @@ class DialogDemoItem extends StatelessWidget {
Icon(icon, size: 36.0, color: color), Icon(icon, size: 36.0, color: color),
Padding( Padding(
padding: const EdgeInsets.only(left: 16.0), padding: const EdgeInsets.only(left: 16.0),
child: Text(text), child: Text(text!),
), ),
], ],
), ),
...@@ -56,7 +56,7 @@ class DialogDemo extends StatefulWidget { ...@@ -56,7 +56,7 @@ class DialogDemo extends StatefulWidget {
class DialogDemoState extends State<DialogDemo> { class DialogDemoState extends State<DialogDemo> {
TimeOfDay _selectedTime; TimeOfDay? _selectedTime;
@override @override
void initState() { void initState() {
...@@ -65,12 +65,12 @@ class DialogDemoState extends State<DialogDemo> { ...@@ -65,12 +65,12 @@ class DialogDemoState extends State<DialogDemo> {
_selectedTime = TimeOfDay(hour: now.hour, minute: now.minute); _selectedTime = TimeOfDay(hour: now.hour, minute: now.minute);
} }
void showDemoDialog<T>({ BuildContext context, Widget child }) { void showDemoDialog<T>({ required BuildContext context, Widget? child }) {
showDialog<T>( showDialog<T>(
context: context, context: context,
builder: (BuildContext context) => child, builder: (BuildContext context) => child!,
) )
.then<void>((T value) { // The value passed to Navigator.pop() or null. .then((T? value) { // The value passed to Navigator.pop() or null.
if (value != null) { if (value != null) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar( ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('You selected: $value'), content: Text('You selected: $value'),
...@@ -82,7 +82,7 @@ class DialogDemoState extends State<DialogDemo> { ...@@ -82,7 +82,7 @@ class DialogDemoState extends State<DialogDemo> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
final TextStyle dialogTextStyle = theme.textTheme.subtitle1.copyWith(color: theme.textTheme.caption.color); final TextStyle dialogTextStyle = theme.textTheme.subtitle1!.copyWith(color: theme.textTheme.caption!.color);
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
...@@ -176,9 +176,9 @@ class DialogDemoState extends State<DialogDemo> { ...@@ -176,9 +176,9 @@ class DialogDemoState extends State<DialogDemo> {
onPressed: () { onPressed: () {
showTimePicker( showTimePicker(
context: context, context: context,
initialTime: _selectedTime, initialTime: _selectedTime!,
) )
.then<void>((TimeOfDay value) { .then((TimeOfDay? value) {
if (value != null && value != _selectedTime) { if (value != null && value != _selectedTime) {
_selectedTime = value; _selectedTime = value;
ScaffoldMessenger.of(context).showSnackBar(SnackBar( ScaffoldMessenger.of(context).showSnackBar(SnackBar(
......
...@@ -33,9 +33,9 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin { ...@@ -33,9 +33,9 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
curve: Curves.fastOutSlowIn, curve: Curves.fastOutSlowIn,
)); ));
AnimationController _controller; late AnimationController _controller;
Animation<double> _drawerContentsOpacity; late Animation<double> _drawerContentsOpacity;
Animation<Offset> _drawerDetailsPosition; late Animation<Offset> _drawerDetailsPosition;
bool _showDrawerContents = true; bool _showDrawerContents = true;
@override @override
...@@ -58,7 +58,7 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin { ...@@ -58,7 +58,7 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
super.dispose(); super.dispose();
} }
IconData _backIcon() { IconData? _backIcon() {
switch (Theme.of(context).platform) { switch (Theme.of(context).platform) {
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
...@@ -69,8 +69,6 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin { ...@@ -69,8 +69,6 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
case TargetPlatform.macOS: case TargetPlatform.macOS:
return Icons.arrow_back_ios; return Icons.arrow_back_ios;
} }
assert(false);
return null;
} }
void _showNotImplementedMessage() { void _showNotImplementedMessage() {
...@@ -211,7 +209,7 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin { ...@@ -211,7 +209,7 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
body: Center( body: Center(
child: InkWell( child: InkWell(
onTap: () { onTap: () {
_scaffoldKey.currentState.openDrawer(); _scaffoldKey.currentState!.openDrawer();
}, },
child: Semantics( child: Semantics(
button: true, button: true,
......
...@@ -14,7 +14,7 @@ enum Location { ...@@ -14,7 +14,7 @@ enum Location {
} }
typedef DemoItemBodyBuilder<T> = Widget Function(DemoItem<T> item); typedef DemoItemBodyBuilder<T> = Widget Function(DemoItem<T> item);
typedef ValueToString<T> = String Function(T value); typedef ValueToString<T> = String? Function(T value);
class DualHeaderWithHint extends StatelessWidget { class DualHeaderWithHint extends StatelessWidget {
const DualHeaderWithHint({ const DualHeaderWithHint({
...@@ -24,10 +24,10 @@ class DualHeaderWithHint extends StatelessWidget { ...@@ -24,10 +24,10 @@ class DualHeaderWithHint extends StatelessWidget {
this.showHint, this.showHint,
}); });
final String name; final String? name;
final String value; final String? value;
final String hint; final String? hint;
final bool showHint; final bool? showHint;
Widget _crossFade(Widget first, Widget second, bool isExpanded) { Widget _crossFade(Widget first, Widget second, bool isExpanded) {
return AnimatedCrossFade( return AnimatedCrossFade(
...@@ -56,8 +56,8 @@ class DualHeaderWithHint extends StatelessWidget { ...@@ -56,8 +56,8 @@ class DualHeaderWithHint extends StatelessWidget {
fit: BoxFit.scaleDown, fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: Text( child: Text(
name, name!,
style: textTheme.bodyText2.copyWith(fontSize: 15.0), style: textTheme.bodyText2!.copyWith(fontSize: 15.0),
), ),
), ),
), ),
...@@ -67,9 +67,9 @@ class DualHeaderWithHint extends StatelessWidget { ...@@ -67,9 +67,9 @@ class DualHeaderWithHint extends StatelessWidget {
child: Container( child: Container(
margin: const EdgeInsets.only(left: 24.0), margin: const EdgeInsets.only(left: 24.0),
child: _crossFade( child: _crossFade(
Text(value, style: textTheme.caption.copyWith(fontSize: 15.0)), Text(value!, style: textTheme.caption!.copyWith(fontSize: 15.0)),
Text(hint, style: textTheme.caption.copyWith(fontSize: 15.0)), Text(hint!, style: textTheme.caption!.copyWith(fontSize: 15.0)),
showHint, showHint!,
), ),
), ),
), ),
...@@ -87,9 +87,9 @@ class CollapsibleBody extends StatelessWidget { ...@@ -87,9 +87,9 @@ class CollapsibleBody extends StatelessWidget {
}); });
final EdgeInsets margin; final EdgeInsets margin;
final Widget child; final Widget? child;
final VoidCallback onSave; final VoidCallback? onSave;
final VoidCallback onCancel; final VoidCallback? onCancel;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -106,8 +106,8 @@ class CollapsibleBody extends StatelessWidget { ...@@ -106,8 +106,8 @@ class CollapsibleBody extends StatelessWidget {
) - margin, ) - margin,
child: Center( child: Center(
child: DefaultTextStyle( child: DefaultTextStyle(
style: textTheme.caption.copyWith(fontSize: 15.0), style: textTheme.caption!.copyWith(fontSize: 15.0),
child: child, child: child!,
), ),
), ),
), ),
...@@ -149,15 +149,15 @@ class DemoItem<T> { ...@@ -149,15 +149,15 @@ class DemoItem<T> {
this.value, this.value,
this.hint, this.hint,
this.builder, this.builder,
this.valueToString, required this.valueToString,
}) : textController = TextEditingController(text: valueToString(value)); }) : textController = TextEditingController(text: valueToString(value));
final String name; final String? name;
final String hint; final String? hint;
final TextEditingController textController; final TextEditingController textController;
final DemoItemBodyBuilder<T> builder; final DemoItemBodyBuilder<T>? builder;
final ValueToString<T> valueToString; final ValueToString<T?> valueToString;
T value; T? value;
bool isExpanded = false; bool isExpanded = false;
ExpansionPanelHeaderBuilder get headerBuilder { ExpansionPanelHeaderBuilder get headerBuilder {
...@@ -171,7 +171,7 @@ class DemoItem<T> { ...@@ -171,7 +171,7 @@ class DemoItem<T> {
}; };
} }
Widget build() => builder(this); Widget build() => builder!(this);
} }
class ExpansionPanelsDemo extends StatefulWidget { class ExpansionPanelsDemo extends StatefulWidget {
...@@ -182,7 +182,7 @@ class ExpansionPanelsDemo extends StatefulWidget { ...@@ -182,7 +182,7 @@ class ExpansionPanelsDemo extends StatefulWidget {
} }
class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> { class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> {
List<DemoItem<dynamic>> _demoItems; late List<DemoItem<dynamic>> _demoItems;
@override @override
void initState() { void initState() {
...@@ -193,7 +193,7 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> { ...@@ -193,7 +193,7 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> {
name: 'Trip', name: 'Trip',
value: 'Caribbean cruise', value: 'Caribbean cruise',
hint: 'Change trip name', hint: 'Change trip name',
valueToString: (String value) => value, valueToString: (String? value) => value,
builder: (DemoItem<String> item) { builder: (DemoItem<String> item) {
void close() { void close() {
setState(() { setState(() {
...@@ -206,8 +206,8 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> { ...@@ -206,8 +206,8 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> {
builder: (BuildContext context) { builder: (BuildContext context) {
return CollapsibleBody( return CollapsibleBody(
margin: const EdgeInsets.symmetric(horizontal: 16.0), margin: const EdgeInsets.symmetric(horizontal: 16.0),
onSave: () { Form.of(context).save(); close(); }, onSave: () { Form.of(context)!.save(); close(); },
onCancel: () { Form.of(context).reset(); close(); }, onCancel: () { Form.of(context)!.reset(); close(); },
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0), padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: TextFormField( child: TextFormField(
...@@ -216,7 +216,7 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> { ...@@ -216,7 +216,7 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> {
hintText: item.hint, hintText: item.hint,
labelText: item.name, labelText: item.name,
), ),
onSaved: (String value) { item.value = value; }, onSaved: (String? value) { item.value = value; },
), ),
), ),
); );
...@@ -229,7 +229,7 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> { ...@@ -229,7 +229,7 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> {
name: 'Location', name: 'Location',
value: Location.Bahamas, value: Location.Bahamas,
hint: 'Select location', hint: 'Select location',
valueToString: (Location location) => location.toString().split('.')[1], valueToString: (Location? location) => location.toString().split('.')[1],
builder: (DemoItem<Location> item) { builder: (DemoItem<Location> item) {
void close() { void close() {
setState(() { setState(() {
...@@ -240,11 +240,11 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> { ...@@ -240,11 +240,11 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> {
child: Builder( child: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
return CollapsibleBody( return CollapsibleBody(
onSave: () { Form.of(context).save(); close(); }, onSave: () { Form.of(context)!.save(); close(); },
onCancel: () { Form.of(context).reset(); close(); }, onCancel: () { Form.of(context)!.reset(); close(); },
child: FormField<Location>( child: FormField<Location>(
initialValue: item.value, initialValue: item.value,
onSaved: (Location result) { item.value = result; }, onSaved: (Location? result) { item.value = result; },
builder: (FormFieldState<Location> field) { builder: (FormFieldState<Location> field) {
return Column( return Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
...@@ -282,7 +282,7 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> { ...@@ -282,7 +282,7 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> {
name: 'Sun', name: 'Sun',
value: 80.0, value: 80.0,
hint: 'Select sun level', hint: 'Select sun level',
valueToString: (double amount) => '${amount.round()}', valueToString: (double? amount) => '${amount!.round()}',
builder: (DemoItem<double> item) { builder: (DemoItem<double> item) {
void close() { void close() {
setState(() { setState(() {
...@@ -294,11 +294,11 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> { ...@@ -294,11 +294,11 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> {
child: Builder( child: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
return CollapsibleBody( return CollapsibleBody(
onSave: () { Form.of(context).save(); close(); }, onSave: () { Form.of(context)!.save(); close(); },
onCancel: () { Form.of(context).reset(); close(); }, onCancel: () { Form.of(context)!.reset(); close(); },
child: FormField<double>( child: FormField<double>(
initialValue: item.value, initialValue: item.value,
onSaved: (double value) { item.value = value; }, onSaved: (double? value) { item.value = value; },
builder: (FormFieldState<double> field) { builder: (FormFieldState<double> field) {
return Container( return Container(
// Allow room for the value indicator. // Allow room for the value indicator.
...@@ -307,9 +307,9 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> { ...@@ -307,9 +307,9 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> {
min: 0.0, min: 0.0,
max: 100.0, max: 100.0,
divisions: 5, divisions: 5,
activeColor: Colors.orange[100 + (field.value * 5.0).round()], activeColor: Colors.orange[100 + (field.value! * 5.0).round()],
label: '${field.value.round()}', label: '${field.value!.round()}',
value: field.value, value: field.value!,
onChanged: field.didChange, onChanged: field.didChange,
), ),
); );
......
...@@ -15,9 +15,8 @@ enum DismissDialogAction { ...@@ -15,9 +15,8 @@ enum DismissDialogAction {
} }
class DateTimeItem extends StatelessWidget { class DateTimeItem extends StatelessWidget {
DateTimeItem({ Key key, DateTime dateTime, @required this.onChanged }) DateTimeItem({ Key? key, required DateTime dateTime, required this.onChanged })
: assert(onChanged != null), : date = DateTime(dateTime.year, dateTime.month, dateTime.day),
date = DateTime(dateTime.year, dateTime.month, dateTime.day),
time = TimeOfDay(hour: dateTime.hour, minute: dateTime.minute), time = TimeOfDay(hour: dateTime.hour, minute: dateTime.minute),
super(key: key); super(key: key);
...@@ -30,7 +29,7 @@ class DateTimeItem extends StatelessWidget { ...@@ -30,7 +29,7 @@ class DateTimeItem extends StatelessWidget {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
return DefaultTextStyle( return DefaultTextStyle(
style: theme.textTheme.subtitle1, style: theme.textTheme.subtitle1!,
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
...@@ -47,7 +46,7 @@ class DateTimeItem extends StatelessWidget { ...@@ -47,7 +46,7 @@ class DateTimeItem extends StatelessWidget {
firstDate: date.subtract(const Duration(days: 30)), firstDate: date.subtract(const Duration(days: 30)),
lastDate: date.add(const Duration(days: 30)), lastDate: date.add(const Duration(days: 30)),
) )
.then<void>((DateTime value) { .then((DateTime? value) {
if (value != null) if (value != null)
onChanged(DateTime(value.year, value.month, value.day, time.hour, time.minute)); onChanged(DateTime(value.year, value.month, value.day, time.hour, time.minute));
}); });
...@@ -74,7 +73,7 @@ class DateTimeItem extends StatelessWidget { ...@@ -74,7 +73,7 @@ class DateTimeItem extends StatelessWidget {
context: context, context: context,
initialTime: time, initialTime: time,
) )
.then<void>((TimeOfDay value) { .then((TimeOfDay? value) {
if (value != null) if (value != null)
onChanged(DateTime(date.year, date.month, date.day, value.hour, value.minute)); onChanged(DateTime(date.year, date.month, date.day, value.hour, value.minute));
}); });
...@@ -101,11 +100,11 @@ class FullScreenDialogDemo extends StatefulWidget { ...@@ -101,11 +100,11 @@ class FullScreenDialogDemo extends StatefulWidget {
class FullScreenDialogDemoState extends State<FullScreenDialogDemo> { class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
DateTime _fromDateTime = DateTime.now(); DateTime _fromDateTime = DateTime.now();
DateTime _toDateTime = DateTime.now(); DateTime _toDateTime = DateTime.now();
bool _allDayValue = false; bool? _allDayValue = false;
bool _saveNeeded = false; bool _saveNeeded = false;
bool _hasLocation = false; bool _hasLocation = false;
bool _hasName = false; bool _hasName = false;
String _eventName; late String _eventName;
Future<bool> _onWillPop() async { Future<bool> _onWillPop() async {
_saveNeeded = _hasLocation || _hasName || _saveNeeded; _saveNeeded = _hasLocation || _hasName || _saveNeeded;
...@@ -113,9 +112,9 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> { ...@@ -113,9 +112,9 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
return true; return true;
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
final TextStyle dialogTextStyle = theme.textTheme.subtitle1.copyWith(color: theme.textTheme.caption.color); final TextStyle dialogTextStyle = theme.textTheme.subtitle1!.copyWith(color: theme.textTheme.caption!.color);
return await showDialog<bool>( return await (showDialog<bool>(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return AlertDialog( return AlertDialog(
...@@ -127,19 +126,19 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> { ...@@ -127,19 +126,19 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
TextButton( TextButton(
child: const Text('CANCEL'), child: const Text('CANCEL'),
onPressed: () { onPressed: () {
Navigator.of(context).pop(false); // Pops the confirmation dialog but not the page. Navigator.of(context)!.pop(false); // Pops the confirmation dialog but not the page.
}, },
), ),
TextButton( TextButton(
child: const Text('DISCARD'), child: const Text('DISCARD'),
onPressed: () { onPressed: () {
Navigator.of(context).pop(true); // Returning true to _onWillPop will pop again. Navigator.of(context)!.pop(true); // Returning true to _onWillPop will pop again.
}, },
), ),
], ],
); );
}, },
) ?? false; ) as Future<bool>);
} }
@override @override
...@@ -151,7 +150,7 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> { ...@@ -151,7 +150,7 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
title: Text(_hasName ? _eventName : 'Event Name TBD'), title: Text(_hasName ? _eventName : 'Event Name TBD'),
actions: <Widget> [ actions: <Widget> [
TextButton( TextButton(
child: Text('SAVE', style: theme.textTheme.bodyText2.copyWith(color: Colors.white)), child: Text('SAVE', style: theme.textTheme.bodyText2!.copyWith(color: Colors.white)),
onPressed: () { onPressed: () {
Navigator.pop(context, DismissDialogAction.save); Navigator.pop(context, DismissDialogAction.save);
}, },
...@@ -238,7 +237,7 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> { ...@@ -238,7 +237,7 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
children: <Widget> [ children: <Widget> [
Checkbox( Checkbox(
value: _allDayValue, value: _allDayValue,
onChanged: (bool value) { onChanged: (bool? value) {
setState(() { setState(() {
_allDayValue = value; _allDayValue = value;
_saveNeeded = true; _saveNeeded = true;
......
...@@ -26,21 +26,21 @@ class Photo { ...@@ -26,21 +26,21 @@ class Photo {
this.isFavorite = false, this.isFavorite = false,
}); });
final String assetName; final String? assetName;
final String assetPackage; final String? assetPackage;
final String title; final String? title;
final String caption; final String? caption;
bool isFavorite; bool isFavorite;
String get tag => assetName; // Assuming that all asset names are unique. String? get tag => assetName; // Assuming that all asset names are unique.
bool get isValid => assetName != null && title != null && caption != null && isFavorite != null; bool get isValid => assetName != null && title != null && caption != null;
} }
class GridPhotoViewer extends StatefulWidget { class GridPhotoViewer extends StatefulWidget {
const GridPhotoViewer({ Key key, this.photo }) : super(key: key); const GridPhotoViewer({ Key? key, this.photo }) : super(key: key);
final Photo photo; final Photo? photo;
@override @override
_GridPhotoViewerState createState() => _GridPhotoViewerState(); _GridPhotoViewerState createState() => _GridPhotoViewerState();
...@@ -49,25 +49,25 @@ class GridPhotoViewer extends StatefulWidget { ...@@ -49,25 +49,25 @@ class GridPhotoViewer extends StatefulWidget {
class _GridTitleText extends StatelessWidget { class _GridTitleText extends StatelessWidget {
const _GridTitleText(this.text); const _GridTitleText(this.text);
final String text; final String? text;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return FittedBox( return FittedBox(
fit: BoxFit.scaleDown, fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: Text(text), child: Text(text!),
); );
} }
} }
class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProviderStateMixin { class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProviderStateMixin {
AnimationController _controller; late AnimationController _controller;
Animation<Offset> _flingAnimation; late Animation<Offset> _flingAnimation;
Offset _offset = Offset.zero; Offset _offset = Offset.zero;
double _scale = 1.0; double _scale = 1.0;
Offset _normalizedOffset; late Offset _normalizedOffset;
double _previousScale; late double _previousScale;
@override @override
void initState() { void initState() {
...@@ -85,11 +85,11 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv ...@@ -85,11 +85,11 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv
// The maximum offset value is 0,0. If the size of this renderer's box is w,h // The maximum offset value is 0,0. If the size of this renderer's box is w,h
// then the minimum offset value is w - _scale * w, h - _scale * h. // then the minimum offset value is w - _scale * w, h - _scale * h.
Offset _clampOffset(Offset offset) { Offset _clampOffset(Offset offset) {
final Size size = context.size; final Size size = context.size!;
final Offset minOffset = Offset(size.width, size.height) * (1.0 - _scale); final Offset minOffset = Offset(size.width, size.height) * (1.0 - _scale);
return Offset( return Offset(
offset.dx.clamp(minOffset.dx, 0.0) as double, offset.dx.clamp(minOffset.dx, 0.0),
offset.dy.clamp(minOffset.dy, 0.0) as double, offset.dy.clamp(minOffset.dy, 0.0),
); );
} }
...@@ -110,7 +110,7 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv ...@@ -110,7 +110,7 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv
void _handleOnScaleUpdate(ScaleUpdateDetails details) { void _handleOnScaleUpdate(ScaleUpdateDetails details) {
setState(() { setState(() {
_scale = (_previousScale * details.scale).clamp(1.0, 4.0) as double; _scale = (_previousScale * details.scale).clamp(1.0, 4.0);
// Ensure that image location under the focal point stays in the same place despite scaling. // Ensure that image location under the focal point stays in the same place despite scaling.
_offset = _clampOffset(details.focalPoint - _normalizedOffset * _scale); _offset = _clampOffset(details.focalPoint - _normalizedOffset * _scale);
}); });
...@@ -121,7 +121,7 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv ...@@ -121,7 +121,7 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv
if (magnitude < _kMinFlingVelocity) if (magnitude < _kMinFlingVelocity)
return; return;
final Offset direction = details.velocity.pixelsPerSecond / magnitude; final Offset direction = details.velocity.pixelsPerSecond / magnitude;
final double distance = (Offset.zero & context.size).shortestSide; final double distance = (Offset.zero & context.size!).shortestSide;
_flingAnimation = _controller.drive(Tween<Offset>( _flingAnimation = _controller.drive(Tween<Offset>(
begin: _offset, begin: _offset,
end: _clampOffset(_offset + direction * distance), end: _clampOffset(_offset + direction * distance),
...@@ -143,8 +143,8 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv ...@@ -143,8 +143,8 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv
..translate(_offset.dx, _offset.dy) ..translate(_offset.dx, _offset.dy)
..scale(_scale), ..scale(_scale),
child: Image.asset( child: Image.asset(
widget.photo.assetName, widget.photo!.assetName!,
package: widget.photo.assetPackage, package: widget.photo!.assetPackage,
fit: BoxFit.cover, fit: BoxFit.cover,
), ),
), ),
...@@ -155,13 +155,11 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv ...@@ -155,13 +155,11 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv
class GridDemoPhotoItem extends StatelessWidget { class GridDemoPhotoItem extends StatelessWidget {
GridDemoPhotoItem({ GridDemoPhotoItem({
Key key, Key? key,
@required this.photo, required this.photo,
@required this.tileStyle, required this.tileStyle,
@required this.onBannerTap, required this.onBannerTap,
}) : assert(photo != null && photo.isValid), }) : assert(photo.isValid),
assert(tileStyle != null),
assert(onBannerTap != null),
super(key: key); super(key: key);
final Photo photo; final Photo photo;
...@@ -173,11 +171,11 @@ class GridDemoPhotoItem extends StatelessWidget { ...@@ -173,11 +171,11 @@ class GridDemoPhotoItem extends StatelessWidget {
builder: (BuildContext context) { builder: (BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(photo.title), title: Text(photo.title!),
), ),
body: SizedBox.expand( body: SizedBox.expand(
child: Hero( child: Hero(
tag: photo.tag, tag: photo.tag!,
child: GridPhotoViewer(photo: photo), child: GridPhotoViewer(photo: photo),
), ),
), ),
...@@ -193,10 +191,10 @@ class GridDemoPhotoItem extends StatelessWidget { ...@@ -193,10 +191,10 @@ class GridDemoPhotoItem extends StatelessWidget {
child: GestureDetector( child: GestureDetector(
onTap: () { showPhoto(context); }, onTap: () { showPhoto(context); },
child: Hero( child: Hero(
key: Key(photo.assetName), key: Key(photo.assetName!),
tag: photo.tag, tag: photo.tag!,
child: Image.asset( child: Image.asset(
photo.assetName, photo.assetName!,
package: photo.assetPackage, package: photo.assetPackage,
fit: BoxFit.cover, fit: BoxFit.cover,
), ),
...@@ -243,13 +241,11 @@ class GridDemoPhotoItem extends StatelessWidget { ...@@ -243,13 +241,11 @@ class GridDemoPhotoItem extends StatelessWidget {
child: image, child: image,
); );
} }
assert(tileStyle != null);
return null;
} }
} }
class GridListDemo extends StatefulWidget { class GridListDemo extends StatefulWidget {
const GridListDemo({ Key key }) : super(key: key); const GridListDemo({ Key? key }) : super(key: key);
static const String routeName = '/material/grid-list'; static const String routeName = '/material/grid-list';
......
...@@ -109,7 +109,7 @@ class _IconsDemoCard extends StatelessWidget { ...@@ -109,7 +109,7 @@ class _IconsDemoCard extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
final TextStyle textStyle = theme.textTheme.subtitle1.copyWith(color: theme.textTheme.caption.color); final TextStyle textStyle = theme.textTheme.subtitle1!.copyWith(color: theme.textTheme.caption!.color);
return Card( return Card(
child: DefaultTextStyle( child: DefaultTextStyle(
style: textStyle, style: textStyle,
......
...@@ -23,17 +23,17 @@ class LeaveBehindItem implements Comparable<LeaveBehindItem> { ...@@ -23,17 +23,17 @@ class LeaveBehindItem implements Comparable<LeaveBehindItem> {
LeaveBehindItem.from(LeaveBehindItem item) LeaveBehindItem.from(LeaveBehindItem item)
: index = item.index, name = item.name, subject = item.subject, body = item.body; : index = item.index, name = item.name, subject = item.subject, body = item.body;
final int index; final int? index;
final String name; final String? name;
final String subject; final String? subject;
final String body; final String? body;
@override @override
int compareTo(LeaveBehindItem other) => index.compareTo(other.index); int compareTo(LeaveBehindItem other) => index!.compareTo(other.index!);
} }
class LeaveBehindDemo extends StatefulWidget { class LeaveBehindDemo extends StatefulWidget {
const LeaveBehindDemo({ Key key }) : super(key: key); const LeaveBehindDemo({ Key? key }) : super(key: key);
static const String routeName = '/material/leave-behind'; static const String routeName = '/material/leave-behind';
...@@ -44,7 +44,7 @@ class LeaveBehindDemo extends StatefulWidget { ...@@ -44,7 +44,7 @@ class LeaveBehindDemo extends StatefulWidget {
class LeaveBehindDemoState extends State<LeaveBehindDemo> { class LeaveBehindDemoState extends State<LeaveBehindDemo> {
DismissDirection _dismissDirection = DismissDirection.horizontal; DismissDirection _dismissDirection = DismissDirection.horizontal;
bool _confirmDismiss = true; bool _confirmDismiss = true;
List<LeaveBehindItem> leaveBehindItems; late List<LeaveBehindItem> leaveBehindItems;
void initListItems() { void initListItems() {
leaveBehindItems = List<LeaveBehindItem>.generate(16, (int index) { leaveBehindItems = List<LeaveBehindItem>.generate(16, (int index) {
...@@ -188,12 +188,12 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> { ...@@ -188,12 +188,12 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
class _LeaveBehindListItem extends StatelessWidget { class _LeaveBehindListItem extends StatelessWidget {
const _LeaveBehindListItem({ const _LeaveBehindListItem({
Key key, Key? key,
@required this.item, required this.item,
@required this.onArchive, required this.onArchive,
@required this.onDelete, required this.onDelete,
@required this.dismissDirection, required this.dismissDirection,
@required this.confirmDismiss, required this.confirmDismiss,
}) : super(key: key); }) : super(key: key);
final LeaveBehindItem item; final LeaveBehindItem item;
...@@ -263,7 +263,7 @@ class _LeaveBehindListItem extends StatelessWidget { ...@@ -263,7 +263,7 @@ class _LeaveBehindListItem extends StatelessWidget {
border: Border(bottom: BorderSide(color: theme.dividerColor)), border: Border(bottom: BorderSide(color: theme.dividerColor)),
), ),
child: ListTile( child: ListTile(
title: Text(item.name), title: Text(item.name!),
subtitle: Text('${item.subject}\n${item.body}'), subtitle: Text('${item.subject}\n${item.body}'),
isThreeLine: true, isThreeLine: true,
), ),
...@@ -272,7 +272,7 @@ class _LeaveBehindListItem extends StatelessWidget { ...@@ -272,7 +272,7 @@ class _LeaveBehindListItem extends StatelessWidget {
); );
} }
Future<bool> _showConfirmationDialog(BuildContext context, String action) { Future<bool?> _showConfirmationDialog(BuildContext context, String action) {
return showDialog<bool>( return showDialog<bool>(
context: context, context: context,
barrierDismissible: true, barrierDismissible: true,
......
...@@ -21,7 +21,7 @@ enum _MaterialListType { ...@@ -21,7 +21,7 @@ enum _MaterialListType {
} }
class ListDemo extends StatefulWidget { class ListDemo extends StatefulWidget {
const ListDemo({ Key key }) : super(key: key); const ListDemo({ Key? key }) : super(key: key);
static const String routeName = '/material/list'; static const String routeName = '/material/list';
...@@ -32,26 +32,26 @@ class ListDemo extends StatefulWidget { ...@@ -32,26 +32,26 @@ class ListDemo extends StatefulWidget {
class _ListDemoState extends State<ListDemo> { class _ListDemoState extends State<ListDemo> {
static final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); static final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
PersistentBottomSheetController<void> _bottomSheet; PersistentBottomSheetController<void>? _bottomSheet;
_MaterialListType _itemType = _MaterialListType.threeLine; _MaterialListType? _itemType = _MaterialListType.threeLine;
bool _dense = false; bool? _dense = false;
bool _showAvatars = true; bool? _showAvatars = true;
bool _showIcons = false; bool? _showIcons = false;
bool _showDividers = false; bool? _showDividers = false;
bool _reverseSort = false; bool _reverseSort = false;
List<String> items = <String>[ List<String> items = <String>[
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
]; ];
void changeItemType(_MaterialListType type) { void changeItemType(_MaterialListType? type) {
setState(() { setState(() {
_itemType = type; _itemType = type;
}); });
_bottomSheet?.setState(() { }); _bottomSheet?.setState!(() { });
} }
void _showConfigurationSheet() { void _showConfigurationSheet() {
final PersistentBottomSheetController<void> bottomSheet = scaffoldKey.currentState.showBottomSheet<void>((BuildContext bottomSheetContext) { final PersistentBottomSheetController<void> bottomSheet = scaffoldKey.currentState!.showBottomSheet<void>((BuildContext bottomSheetContext) {
return Container( return Container(
decoration: const BoxDecoration( decoration: const BoxDecoration(
border: Border(top: BorderSide(color: Colors.black26)), border: Border(top: BorderSide(color: Colors.black26)),
...@@ -65,7 +65,7 @@ class _ListDemoState extends State<ListDemo> { ...@@ -65,7 +65,7 @@ class _ListDemoState extends State<ListDemo> {
dense: true, dense: true,
title: const Text('One-line'), title: const Text('One-line'),
trailing: Radio<_MaterialListType>( trailing: Radio<_MaterialListType>(
value: _showAvatars ? _MaterialListType.oneLineWithAvatar : _MaterialListType.oneLine, value: _showAvatars! ? _MaterialListType.oneLineWithAvatar : _MaterialListType.oneLine,
groupValue: _itemType, groupValue: _itemType,
onChanged: changeItemType, onChanged: changeItemType,
), ),
...@@ -99,11 +99,14 @@ class _ListDemoState extends State<ListDemo> { ...@@ -99,11 +99,14 @@ class _ListDemoState extends State<ListDemo> {
title: const Text('Show avatar'), title: const Text('Show avatar'),
trailing: Checkbox( trailing: Checkbox(
value: _showAvatars, value: _showAvatars,
onChanged: (bool value) { onChanged: (bool? value) {
setState(() { setState(() {
_showAvatars = value; _showAvatars = value;
}); });
_bottomSheet?.setState(() { }); final StateSetter? bottomSheetSetState = _bottomSheet?.setState;
if (bottomSheetSetState != null) {
bottomSheetSetState(() { });
}
}, },
), ),
), ),
...@@ -114,11 +117,14 @@ class _ListDemoState extends State<ListDemo> { ...@@ -114,11 +117,14 @@ class _ListDemoState extends State<ListDemo> {
title: const Text('Show icon'), title: const Text('Show icon'),
trailing: Checkbox( trailing: Checkbox(
value: _showIcons, value: _showIcons,
onChanged: (bool value) { onChanged: (bool? value) {
setState(() { setState(() {
_showIcons = value; _showIcons = value;
}); });
_bottomSheet?.setState(() { }); final StateSetter? bottomSheetSetState = _bottomSheet?.setState;
if (bottomSheetSetState != null) {
bottomSheetSetState(() { });
}
}, },
), ),
), ),
...@@ -129,11 +135,14 @@ class _ListDemoState extends State<ListDemo> { ...@@ -129,11 +135,14 @@ class _ListDemoState extends State<ListDemo> {
title: const Text('Show dividers'), title: const Text('Show dividers'),
trailing: Checkbox( trailing: Checkbox(
value: _showDividers, value: _showDividers,
onChanged: (bool value) { onChanged: (bool? value) {
setState(() { setState(() {
_showDividers = value; _showDividers = value;
}); });
_bottomSheet?.setState(() { }); final StateSetter? bottomSheetSetState = _bottomSheet?.setState;
if (bottomSheetSetState != null) {
bottomSheetSetState(() { });
}
}, },
), ),
), ),
...@@ -144,11 +153,14 @@ class _ListDemoState extends State<ListDemo> { ...@@ -144,11 +153,14 @@ class _ListDemoState extends State<ListDemo> {
title: const Text('Dense layout'), title: const Text('Dense layout'),
trailing: Checkbox( trailing: Checkbox(
value: _dense, value: _dense,
onChanged: (bool value) { onChanged: (bool? value) {
setState(() { setState(() {
_dense = value; _dense = value;
}); });
_bottomSheet?.setState(() { }); final StateSetter? bottomSheetSetState = _bottomSheet?.setState;
if (bottomSheetSetState != null) {
bottomSheetSetState(() { });
}
}, },
), ),
), ),
...@@ -162,7 +174,7 @@ class _ListDemoState extends State<ListDemo> { ...@@ -162,7 +174,7 @@ class _ListDemoState extends State<ListDemo> {
_bottomSheet = bottomSheet; _bottomSheet = bottomSheet;
}); });
_bottomSheet.closed.whenComplete(() { _bottomSheet?.closed.whenComplete(() {
if (mounted) { if (mounted) {
setState(() { setState(() {
_bottomSheet = null; _bottomSheet = null;
...@@ -172,7 +184,7 @@ class _ListDemoState extends State<ListDemo> { ...@@ -172,7 +184,7 @@ class _ListDemoState extends State<ListDemo> {
} }
Widget buildListTile(BuildContext context, String item) { Widget buildListTile(BuildContext context, String item) {
Widget secondary; Widget? secondary;
if (_itemType == _MaterialListType.twoLine) { if (_itemType == _MaterialListType.twoLine) {
secondary = const Text('Additional item information.'); secondary = const Text('Additional item information.');
} else if (_itemType == _MaterialListType.threeLine) { } else if (_itemType == _MaterialListType.threeLine) {
...@@ -184,18 +196,18 @@ class _ListDemoState extends State<ListDemo> { ...@@ -184,18 +196,18 @@ class _ListDemoState extends State<ListDemo> {
child: ListTile( child: ListTile(
isThreeLine: _itemType == _MaterialListType.threeLine, isThreeLine: _itemType == _MaterialListType.threeLine,
dense: _dense, dense: _dense,
leading: _showAvatars ? ExcludeSemantics(child: CircleAvatar(child: Text(item))) : null, leading: _showAvatars != null ? ExcludeSemantics(child: CircleAvatar(child: Text(item))) : null,
title: Text('This item represents $item.'), title: Text('This item represents $item.'),
subtitle: secondary, subtitle: secondary,
trailing: _showIcons ? Icon(Icons.info, color: Theme.of(context).disabledColor) : null, trailing: _showIcons != null ? Icon(Icons.info, color: Theme.of(context).disabledColor) : null,
), ),
); );
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final String layoutText = _dense ? ' \u2013 Dense' : ''; final String layoutText = _dense != null ? ' \u2013 Dense' : '';
String itemTypeText; String? itemTypeText;
switch (_itemType) { switch (_itemType) {
case _MaterialListType.oneLine: case _MaterialListType.oneLine:
case _MaterialListType.oneLineWithAvatar: case _MaterialListType.oneLineWithAvatar:
...@@ -207,10 +219,12 @@ class _ListDemoState extends State<ListDemo> { ...@@ -207,10 +219,12 @@ class _ListDemoState extends State<ListDemo> {
case _MaterialListType.threeLine: case _MaterialListType.threeLine:
itemTypeText = 'Three-line'; itemTypeText = 'Three-line';
break; break;
default:
break;
} }
Iterable<Widget> listTiles = items.map<Widget>((String item) => buildListTile(context, item)); Iterable<Widget> listTiles = items.map<Widget>((String item) => buildListTile(context, item));
if (_showDividers) if (_showDividers != null)
listTiles = ListTile.divideTiles(context: context, tiles: listTiles); listTiles = ListTile.divideTiles(context: context, tiles: listTiles);
return Scaffold( return Scaffold(
...@@ -242,7 +256,7 @@ class _ListDemoState extends State<ListDemo> { ...@@ -242,7 +256,7 @@ class _ListDemoState extends State<ListDemo> {
), ),
body: Scrollbar( body: Scrollbar(
child: ListView( child: ListView(
padding: EdgeInsets.symmetric(vertical: _dense ? 4.0 : 8.0), padding: EdgeInsets.symmetric(vertical: _dense != null ? 4.0 : 8.0),
children: listTiles.toList(), children: listTiles.toList(),
), ),
), ),
......
...@@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; ...@@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
import '../../gallery/demo.dart'; import '../../gallery/demo.dart';
class MenuDemo extends StatefulWidget { class MenuDemo extends StatefulWidget {
const MenuDemo({ Key key }) : super(key: key); const MenuDemo({ Key? key }) : super(key: key);
static const String routeName = '/material/menu'; static const String routeName = '/material/menu';
...@@ -20,13 +20,13 @@ class MenuDemoState extends State<MenuDemo> { ...@@ -20,13 +20,13 @@ class MenuDemoState extends State<MenuDemo> {
final String _simpleValue1 = 'Menu item value one'; final String _simpleValue1 = 'Menu item value one';
final String _simpleValue2 = 'Menu item value two'; final String _simpleValue2 = 'Menu item value two';
final String _simpleValue3 = 'Menu item value three'; final String _simpleValue3 = 'Menu item value three';
String _simpleValue; String? _simpleValue;
final String _checkedValue1 = 'One'; final String _checkedValue1 = 'One';
final String _checkedValue2 = 'Two'; final String _checkedValue2 = 'Two';
final String _checkedValue3 = 'Free'; final String _checkedValue3 = 'Free';
final String _checkedValue4 = 'Four'; final String _checkedValue4 = 'Four';
List<String> _checkedValues; late List<String> _checkedValues;
@override @override
void initState() { void initState() {
...@@ -165,7 +165,7 @@ class MenuDemoState extends State<MenuDemo> { ...@@ -165,7 +165,7 @@ class MenuDemoState extends State<MenuDemo> {
onSelected: showMenuSelection, onSelected: showMenuSelection,
child: ListTile( child: ListTile(
title: const Text('An item with a simple menu'), title: const Text('An item with a simple menu'),
subtitle: Text(_simpleValue), subtitle: Text(_simpleValue!),
), ),
itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[ itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
PopupMenuItem<String>( PopupMenuItem<String>(
......
...@@ -11,7 +11,7 @@ import '../../gallery/demo.dart'; ...@@ -11,7 +11,7 @@ import '../../gallery/demo.dart';
enum IndicatorType { overscroll, refresh } enum IndicatorType { overscroll, refresh }
class OverscrollDemo extends StatefulWidget { class OverscrollDemo extends StatefulWidget {
const OverscrollDemo({ Key key }) : super(key: key); const OverscrollDemo({ Key? key }) : super(key: key);
static const String routeName = '/material/overscroll'; static const String routeName = '/material/overscroll';
...@@ -28,13 +28,13 @@ class OverscrollDemoState extends State<OverscrollDemo> { ...@@ -28,13 +28,13 @@ class OverscrollDemoState extends State<OverscrollDemo> {
Future<void> _handleRefresh() { Future<void> _handleRefresh() {
final Completer<void> completer = Completer<void>(); final Completer<void> completer = Completer<void>();
Timer(const Duration(seconds: 3), () { completer.complete(); }); Timer(const Duration(seconds: 3), () { completer.complete(); });
return completer.future.then<void>((_) { return completer.future.then((_) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar( ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: const Text('Refresh complete'), content: const Text('Refresh complete'),
action: SnackBarAction( action: SnackBarAction(
label: 'RETRY', label: 'RETRY',
onPressed: () { onPressed: () {
_refreshIndicatorKey.currentState.show(); _refreshIndicatorKey.currentState!.show();
}, },
), ),
)); ));
...@@ -52,7 +52,7 @@ class OverscrollDemoState extends State<OverscrollDemo> { ...@@ -52,7 +52,7 @@ class OverscrollDemoState extends State<OverscrollDemo> {
icon: const Icon(Icons.refresh), icon: const Icon(Icons.refresh),
tooltip: 'Refresh', tooltip: 'Refresh',
onPressed: () { onPressed: () {
_refreshIndicatorKey.currentState.show(); _refreshIndicatorKey.currentState!.show();
}, },
), ),
], ],
......
...@@ -9,17 +9,17 @@ import '../../gallery/demo.dart'; ...@@ -9,17 +9,17 @@ import '../../gallery/demo.dart';
class _PageSelector extends StatelessWidget { class _PageSelector extends StatelessWidget {
const _PageSelector({ this.icons }); const _PageSelector({ this.icons });
final List<Icon> icons; final List<Icon>? icons;
void _handleArrowButtonPress(BuildContext context, int delta) { void _handleArrowButtonPress(BuildContext context, int delta) {
final TabController controller = DefaultTabController.of(context); final TabController controller = DefaultTabController.of(context)!;
if (!controller.indexIsChanging) if (!controller.indexIsChanging)
controller.animateTo((controller.index + delta).clamp(0, icons.length - 1) as int); controller.animateTo((controller.index + delta).clamp(0, icons!.length - 1));
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final TabController controller = DefaultTabController.of(context); final TabController? controller = DefaultTabController.of(context);
final Color color = Theme.of(context).accentColor; final Color color = Theme.of(context).accentColor;
return SafeArea( return SafeArea(
top: false, top: false,
...@@ -54,7 +54,7 @@ class _PageSelector extends StatelessWidget { ...@@ -54,7 +54,7 @@ class _PageSelector extends StatelessWidget {
color: color, color: color,
), ),
child: TabBarView( child: TabBarView(
children: icons.map<Widget>((Icon icon) { children: icons!.map<Widget>((Icon icon) {
return Container( return Container(
padding: const EdgeInsets.all(12.0), padding: const EdgeInsets.all(12.0),
child: Card( child: Card(
......
...@@ -16,7 +16,7 @@ class PersistentBottomSheetDemo extends StatefulWidget { ...@@ -16,7 +16,7 @@ class PersistentBottomSheetDemo extends StatefulWidget {
class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> { class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> {
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
VoidCallback _showBottomSheetCallback; VoidCallback? _showBottomSheetCallback;
@override @override
void initState() { void initState() {
...@@ -28,7 +28,7 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> { ...@@ -28,7 +28,7 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> {
setState(() { // disable the button setState(() { // disable the button
_showBottomSheetCallback = null; _showBottomSheetCallback = null;
}); });
_scaffoldKey.currentState.showBottomSheet<void>((BuildContext context) { _scaffoldKey.currentState!.showBottomSheet<void>((BuildContext context) {
final ThemeData themeData = Theme.of(context); final ThemeData themeData = Theme.of(context);
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
......
...@@ -14,8 +14,8 @@ class ProgressIndicatorDemo extends StatefulWidget { ...@@ -14,8 +14,8 @@ class ProgressIndicatorDemo extends StatefulWidget {
} }
class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> with SingleTickerProviderStateMixin { class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> with SingleTickerProviderStateMixin {
AnimationController _controller; late AnimationController _controller;
Animation<double> _animation; late Animation<double> _animation;
@override @override
void initState() { void initState() {
...@@ -64,7 +64,7 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> with Sing ...@@ -64,7 +64,7 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> with Sing
}); });
} }
Widget _buildIndicators(BuildContext context, Widget child) { Widget _buildIndicators(BuildContext context, Widget? child) {
final List<Widget> indicators = <Widget>[ final List<Widget> indicators = <Widget>[
const SizedBox( const SizedBox(
width: 200.0, width: 200.0,
...@@ -109,7 +109,7 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> with Sing ...@@ -109,7 +109,7 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> with Sing
body: Center( body: Center(
child: SingleChildScrollView( child: SingleChildScrollView(
child: DefaultTextStyle( child: DefaultTextStyle(
style: Theme.of(context).textTheme.headline6, style: Theme.of(context).textTheme.headline6!,
child: GestureDetector( child: GestureDetector(
onTap: _handleTap, onTap: _handleTap,
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
......
...@@ -20,7 +20,7 @@ enum _ReorderableListType { ...@@ -20,7 +20,7 @@ enum _ReorderableListType {
} }
class ReorderableListDemo extends StatefulWidget { class ReorderableListDemo extends StatefulWidget {
const ReorderableListDemo({ Key key }) : super(key: key); const ReorderableListDemo({ Key? key }) : super(key: key);
static const String routeName = '/material/reorderable-list'; static const String routeName = '/material/reorderable-list';
...@@ -33,38 +33,38 @@ class _ListItem { ...@@ -33,38 +33,38 @@ class _ListItem {
final String value; final String value;
bool checkState; bool? checkState;
} }
class _ListDemoState extends State<ReorderableListDemo> { class _ListDemoState extends State<ReorderableListDemo> {
static final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); static final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
PersistentBottomSheetController<void> _bottomSheet; PersistentBottomSheetController<void>? _bottomSheet;
_ReorderableListType _itemType = _ReorderableListType.threeLine; _ReorderableListType? _itemType = _ReorderableListType.threeLine;
bool _reverse = false; bool? _reverse = false;
bool _reverseSort = false; bool _reverseSort = false;
final List<_ListItem> _items = <String>[ final List<_ListItem> _items = <String>[
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
].map<_ListItem>((String item) => _ListItem(item, false)).toList(); ].map<_ListItem>((String item) => _ListItem(item, false)).toList();
void changeItemType(_ReorderableListType type) { void changeItemType(_ReorderableListType? type) {
setState(() { setState(() {
_itemType = type; _itemType = type;
}); });
// Rebuild the bottom sheet to reflect the selected list view. // Rebuild the bottom sheet to reflect the selected list view.
_bottomSheet?.setState(() { _bottomSheet?.setState!(() {
// Trigger a rebuild. // Trigger a rebuild.
}); });
// Close the bottom sheet to give the user a clear view of the list. // Close the bottom sheet to give the user a clear view of the list.
_bottomSheet?.close(); _bottomSheet?.close();
} }
void changeReverse(bool newValue) { void changeReverse(bool? newValue) {
setState(() { setState(() {
_reverse = newValue; _reverse = newValue;
}); });
// Rebuild the bottom sheet to reflect the selected list view. // Rebuild the bottom sheet to reflect the selected list view.
_bottomSheet?.setState(() { _bottomSheet?.setState!(() {
// Trigger a rebuild. // Trigger a rebuild.
}); });
// Close the bottom sheet to give the user a clear view of the list. // Close the bottom sheet to give the user a clear view of the list.
...@@ -73,7 +73,7 @@ class _ListDemoState extends State<ReorderableListDemo> { ...@@ -73,7 +73,7 @@ class _ListDemoState extends State<ReorderableListDemo> {
void _showConfigurationSheet() { void _showConfigurationSheet() {
setState(() { setState(() {
_bottomSheet = scaffoldKey.currentState.showBottomSheet<void>((BuildContext bottomSheetContext) { _bottomSheet = scaffoldKey.currentState!.showBottomSheet<void>((BuildContext bottomSheetContext) {
return DecoratedBox( return DecoratedBox(
decoration: const BoxDecoration( decoration: const BoxDecoration(
border: Border(top: BorderSide(color: Colors.black26)), border: Border(top: BorderSide(color: Colors.black26)),
...@@ -115,7 +115,7 @@ class _ListDemoState extends State<ReorderableListDemo> { ...@@ -115,7 +115,7 @@ class _ListDemoState extends State<ReorderableListDemo> {
}); });
// Garbage collect the bottom sheet when it closes. // Garbage collect the bottom sheet when it closes.
_bottomSheet.closed.whenComplete(() { _bottomSheet?.closed.whenComplete(() {
if (mounted) { if (mounted) {
setState(() { setState(() {
_bottomSheet = null; _bottomSheet = null;
...@@ -129,14 +129,14 @@ class _ListDemoState extends State<ReorderableListDemo> { ...@@ -129,14 +129,14 @@ class _ListDemoState extends State<ReorderableListDemo> {
const Widget secondary = Text( const Widget secondary = Text(
'Even more additional list item information appears on line three.', 'Even more additional list item information appears on line three.',
); );
Widget listTile; late Widget listTile;
switch (_itemType) { switch (_itemType) {
case _ReorderableListType.threeLine: case _ReorderableListType.threeLine:
listTile = CheckboxListTile( listTile = CheckboxListTile(
key: Key(item.value), key: Key(item.value),
isThreeLine: true, isThreeLine: true,
value: item.checkState ?? false, value: item.checkState ?? false,
onChanged: (bool newValue) { onChanged: (bool? newValue) {
setState(() { setState(() {
item.checkState = newValue; item.checkState = newValue;
}); });
...@@ -157,6 +157,11 @@ class _ListDemoState extends State<ReorderableListDemo> { ...@@ -157,6 +157,11 @@ class _ListDemoState extends State<ReorderableListDemo> {
), ),
); );
break; break;
default:
listTile = Container(
key: Key(item.value),
);
break;
} }
return listTile; return listTile;
...@@ -210,7 +215,7 @@ class _ListDemoState extends State<ReorderableListDemo> { ...@@ -210,7 +215,7 @@ class _ListDemoState extends State<ReorderableListDemo> {
child: Text('Header of the list', style: Theme.of(context).textTheme.headline5)) child: Text('Header of the list', style: Theme.of(context).textTheme.headline5))
: null, : null,
onReorder: _onReorder, onReorder: _onReorder,
reverse: _reverse, reverse: _reverse!,
scrollDirection: _itemType == _ReorderableListType.horizontalAvatar ? Axis.horizontal : Axis.vertical, scrollDirection: _itemType == _ReorderableListType.horizontalAvatar ? Axis.horizontal : Axis.vertical,
padding: const EdgeInsets.symmetric(vertical: 8.0), padding: const EdgeInsets.symmetric(vertical: 8.0),
children: _items.map<Widget>(buildListTile).toList(), children: _items.map<Widget>(buildListTile).toList(),
......
...@@ -14,8 +14,8 @@ enum TabsDemoStyle { ...@@ -14,8 +14,8 @@ enum TabsDemoStyle {
class _Page { class _Page {
const _Page({ this.icon, this.text }); const _Page({ this.icon, this.text });
final IconData icon; final IconData? icon;
final String text; final String? text;
} }
const List<_Page> _allPages = <_Page>[ const List<_Page> _allPages = <_Page>[
...@@ -43,7 +43,7 @@ class ScrollableTabsDemo extends StatefulWidget { ...@@ -43,7 +43,7 @@ class ScrollableTabsDemo extends StatefulWidget {
} }
class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTickerProviderStateMixin { class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTickerProviderStateMixin {
TabController _controller; TabController? _controller;
TabsDemoStyle _demoStyle = TabsDemoStyle.iconsAndText; TabsDemoStyle _demoStyle = TabsDemoStyle.iconsAndText;
bool _customIndicator = false; bool _customIndicator = false;
...@@ -55,7 +55,7 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke ...@@ -55,7 +55,7 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke
@override @override
void dispose() { void dispose() {
_controller.dispose(); _controller!.dispose();
super.dispose(); super.dispose();
} }
...@@ -65,7 +65,7 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke ...@@ -65,7 +65,7 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke
}); });
} }
Decoration getIndicator() { Decoration? getIndicator() {
if (!_customIndicator) if (!_customIndicator)
return const UnderlineTabIndicator(); return const UnderlineTabIndicator();
...@@ -117,7 +117,6 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke ...@@ -117,7 +117,6 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke
), ),
); );
} }
return null;
} }
@override @override
...@@ -161,7 +160,6 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke ...@@ -161,7 +160,6 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke
isScrollable: true, isScrollable: true,
indicator: getIndicator(), indicator: getIndicator(),
tabs: _allPages.map<Tab>((_Page page) { tabs: _allPages.map<Tab>((_Page page) {
assert(_demoStyle != null);
switch (_demoStyle) { switch (_demoStyle) {
case TabsDemoStyle.iconsAndText: case TabsDemoStyle.iconsAndText:
return Tab(text: page.text, icon: Icon(page.icon)); return Tab(text: page.text, icon: Icon(page.icon));
...@@ -169,9 +167,10 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke ...@@ -169,9 +167,10 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke
return Tab(icon: Icon(page.icon)); return Tab(icon: Icon(page.icon));
case TabsDemoStyle.textOnly: case TabsDemoStyle.textOnly:
return Tab(text: page.text); return Tab(text: page.text);
default:
return Tab();
} }
return null; }).toList()
}).toList(),
), ),
), ),
body: TabBarView( body: TabBarView(
......
...@@ -17,7 +17,7 @@ class _SearchDemoState extends State<SearchDemo> { ...@@ -17,7 +17,7 @@ class _SearchDemoState extends State<SearchDemo> {
final _SearchDemoSearchDelegate _delegate = _SearchDemoSearchDelegate(); final _SearchDemoSearchDelegate _delegate = _SearchDemoSearchDelegate();
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
int _lastIntegerSelected; int? _lastIntegerSelected;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -32,7 +32,7 @@ class _SearchDemoState extends State<SearchDemo> { ...@@ -32,7 +32,7 @@ class _SearchDemoState extends State<SearchDemo> {
progress: _delegate.transitionAnimation, progress: _delegate.transitionAnimation,
), ),
onPressed: () { onPressed: () {
_scaffoldKey.currentState.openDrawer(); _scaffoldKey.currentState!.openDrawer();
}, },
), ),
title: const Text('Numbers'), title: const Text('Numbers'),
...@@ -41,7 +41,7 @@ class _SearchDemoState extends State<SearchDemo> { ...@@ -41,7 +41,7 @@ class _SearchDemoState extends State<SearchDemo> {
tooltip: 'Search', tooltip: 'Search',
icon: const Icon(Icons.search), icon: const Icon(Icons.search),
onPressed: () async { onPressed: () async {
final int selected = await showSearch<int>( final int? selected = await showSearch<int?>(
context: context, context: context,
delegate: _delegate, delegate: _delegate,
); );
...@@ -98,7 +98,7 @@ class _SearchDemoState extends State<SearchDemo> { ...@@ -98,7 +98,7 @@ class _SearchDemoState extends State<SearchDemo> {
floatingActionButton: FloatingActionButton.extended( floatingActionButton: FloatingActionButton.extended(
tooltip: 'Back', // Tests depend on this label to exit the demo. tooltip: 'Back', // Tests depend on this label to exit the demo.
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context)!.pop();
}, },
label: const Text('Close demo'), label: const Text('Close demo'),
icon: const Icon(Icons.close), icon: const Icon(Icons.close),
...@@ -133,7 +133,7 @@ class _SearchDemoState extends State<SearchDemo> { ...@@ -133,7 +133,7 @@ class _SearchDemoState extends State<SearchDemo> {
} }
} }
class _SearchDemoSearchDelegate extends SearchDelegate<int> { class _SearchDemoSearchDelegate extends SearchDelegate<int?> {
final List<int> _data = List<int>.generate(100001, (int i) => i).reversed.toList(); final List<int> _data = List<int>.generate(100001, (int i) => i).reversed.toList();
final List<int> _history = <int>[42607, 85604, 66374, 44, 174]; final List<int> _history = <int>[42607, 85604, 66374, 44, 174];
...@@ -170,7 +170,7 @@ class _SearchDemoSearchDelegate extends SearchDelegate<int> { ...@@ -170,7 +170,7 @@ class _SearchDemoSearchDelegate extends SearchDelegate<int> {
@override @override
Widget buildResults(BuildContext context) { Widget buildResults(BuildContext context) {
final int searched = int.tryParse(query); final int? searched = int.tryParse(query);
if (searched == null || !_data.contains(searched)) { if (searched == null || !_data.contains(searched)) {
return Center( return Center(
child: Text( child: Text(
...@@ -228,26 +228,26 @@ class _SearchDemoSearchDelegate extends SearchDelegate<int> { ...@@ -228,26 +228,26 @@ class _SearchDemoSearchDelegate extends SearchDelegate<int> {
class _ResultCard extends StatelessWidget { class _ResultCard extends StatelessWidget {
const _ResultCard({this.integer, this.title, this.searchDelegate}); const _ResultCard({this.integer, this.title, this.searchDelegate});
final int integer; final int? integer;
final String title; final String? title;
final SearchDelegate<int> searchDelegate; final SearchDelegate<int?>? searchDelegate;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
searchDelegate.close(context, integer); searchDelegate!.close(context, integer);
}, },
child: Card( child: Card(
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
Text(title), Text(title!),
Text( Text(
'$integer', '$integer',
style: theme.textTheme.headline5.copyWith(fontSize: 72.0), style: theme.textTheme.headline5!.copyWith(fontSize: 72.0),
), ),
], ],
), ),
...@@ -260,33 +260,33 @@ class _ResultCard extends StatelessWidget { ...@@ -260,33 +260,33 @@ class _ResultCard extends StatelessWidget {
class _SuggestionList extends StatelessWidget { class _SuggestionList extends StatelessWidget {
const _SuggestionList({this.suggestions, this.query, this.onSelected}); const _SuggestionList({this.suggestions, this.query, this.onSelected});
final List<String> suggestions; final List<String>? suggestions;
final String query; final String? query;
final ValueChanged<String> onSelected; final ValueChanged<String>? onSelected;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
return ListView.builder( return ListView.builder(
itemCount: suggestions.length, itemCount: suggestions!.length,
itemBuilder: (BuildContext context, int i) { itemBuilder: (BuildContext context, int i) {
final String suggestion = suggestions[i]; final String suggestion = suggestions![i];
return ListTile( return ListTile(
leading: query.isEmpty ? const Icon(Icons.history) : const Icon(null), leading: query!.isEmpty ? const Icon(Icons.history) : const Icon(null),
title: RichText( title: RichText(
text: TextSpan( text: TextSpan(
text: suggestion.substring(0, query.length), text: suggestion.substring(0, query!.length),
style: theme.textTheme.subtitle1.copyWith(fontWeight: FontWeight.bold), style: theme.textTheme.subtitle1!.copyWith(fontWeight: FontWeight.bold),
children: <TextSpan>[ children: <TextSpan>[
TextSpan( TextSpan(
text: suggestion.substring(query.length), text: suggestion.substring(query!.length),
style: theme.textTheme.subtitle1, style: theme.textTheme.subtitle1,
), ),
], ],
), ),
), ),
onTap: () { onTap: () {
onSelected(suggestion); onSelected!(suggestion);
}, },
); );
}, },
......
...@@ -67,13 +67,13 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> { ...@@ -67,13 +67,13 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> {
); );
} }
bool checkboxValueA = true; bool? checkboxValueA = true;
bool checkboxValueB = false; bool? checkboxValueB = false;
bool checkboxValueC; bool? checkboxValueC;
int radioValue = 0; int? radioValue = 0;
bool switchValue = false; bool switchValue = false;
void handleRadioValueChanged(int value) { void handleRadioValueChanged(int? value) {
setState(() { setState(() {
radioValue = value; radioValue = value;
}); });
...@@ -92,7 +92,7 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> { ...@@ -92,7 +92,7 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> {
label: 'Checkbox A', label: 'Checkbox A',
child: Checkbox( child: Checkbox(
value: checkboxValueA, value: checkboxValueA,
onChanged: (bool value) { onChanged: (bool? value) {
setState(() { setState(() {
checkboxValueA = value; checkboxValueA = value;
}); });
...@@ -103,7 +103,7 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> { ...@@ -103,7 +103,7 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> {
label: 'Checkbox B', label: 'Checkbox B',
child: Checkbox( child: Checkbox(
value: checkboxValueB, value: checkboxValueB,
onChanged: (bool value) { onChanged: (bool? value) {
setState(() { setState(() {
checkboxValueB = value; checkboxValueB = value;
}); });
...@@ -115,7 +115,7 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> { ...@@ -115,7 +115,7 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> {
child: Checkbox( child: Checkbox(
value: checkboxValueC, value: checkboxValueC,
tristate: true, tristate: true,
onChanged: (bool value) { onChanged: (bool? value) {
setState(() { setState(() {
checkboxValueC = value; checkboxValueC = value;
}); });
......
...@@ -61,15 +61,15 @@ class _CustomRangeThumbShape extends RangeSliderThumbShape { ...@@ -61,15 +61,15 @@ class _CustomRangeThumbShape extends RangeSliderThumbShape {
void paint( void paint(
PaintingContext context, PaintingContext context,
Offset center, { Offset center, {
@required Animation<double> activationAnimation, required Animation<double> activationAnimation,
@required Animation<double> enableAnimation, required Animation<double> enableAnimation,
bool isDiscrete = false, bool isDiscrete = false,
bool isEnabled = false, bool isEnabled = false,
bool isOnTop, bool? isOnTop,
@required SliderThemeData sliderTheme, required SliderThemeData sliderTheme,
TextDirection textDirection, TextDirection? textDirection,
Thumb thumb, Thumb? thumb,
bool isPressed, bool? isPressed,
}) { }) {
final Canvas canvas = context.canvas; final Canvas canvas = context.canvas;
final ColorTween colorTween = ColorTween( final ColorTween colorTween = ColorTween(
...@@ -78,7 +78,7 @@ class _CustomRangeThumbShape extends RangeSliderThumbShape { ...@@ -78,7 +78,7 @@ class _CustomRangeThumbShape extends RangeSliderThumbShape {
); );
final double size = _thumbSize * sizeTween.evaluate(enableAnimation); final double size = _thumbSize * sizeTween.evaluate(enableAnimation);
Path thumbPath; late Path thumbPath;
switch (textDirection) { switch (textDirection) {
case TextDirection.rtl: case TextDirection.rtl:
switch (thumb) { switch (thumb) {
...@@ -88,6 +88,8 @@ class _CustomRangeThumbShape extends RangeSliderThumbShape { ...@@ -88,6 +88,8 @@ class _CustomRangeThumbShape extends RangeSliderThumbShape {
case Thumb.end: case Thumb.end:
thumbPath = _leftTriangle(size, center); thumbPath = _leftTriangle(size, center);
break; break;
default:
break;
} }
break; break;
case TextDirection.ltr: case TextDirection.ltr:
...@@ -98,10 +100,14 @@ class _CustomRangeThumbShape extends RangeSliderThumbShape { ...@@ -98,10 +100,14 @@ class _CustomRangeThumbShape extends RangeSliderThumbShape {
case Thumb.end: case Thumb.end:
thumbPath = _rightTriangle(size, center); thumbPath = _rightTriangle(size, center);
break; break;
default:
break;
} }
break; break;
default:
break;
} }
canvas.drawPath(thumbPath, Paint()..color = colorTween.evaluate(enableAnimation)); canvas.drawPath(thumbPath, Paint()..color = colorTween.evaluate(enableAnimation)!);
} }
} }
...@@ -123,16 +129,16 @@ class _CustomThumbShape extends SliderComponentShape { ...@@ -123,16 +129,16 @@ class _CustomThumbShape extends SliderComponentShape {
void paint( void paint(
PaintingContext context, PaintingContext context,
Offset thumbCenter, { Offset thumbCenter, {
Animation<double> activationAnimation, Animation<double>? activationAnimation,
Animation<double> enableAnimation, required Animation<double> enableAnimation,
bool isDiscrete, bool? isDiscrete,
TextPainter labelPainter, TextPainter? labelPainter,
RenderBox parentBox, RenderBox? parentBox,
SliderThemeData sliderTheme, required SliderThemeData sliderTheme,
TextDirection textDirection, TextDirection? textDirection,
double value, double? value,
double textScaleFactor, double? textScaleFactor,
Size sizeWithOverflow, Size? sizeWithOverflow,
}) { }) {
final Canvas canvas = context.canvas; final Canvas canvas = context.canvas;
final ColorTween colorTween = ColorTween( final ColorTween colorTween = ColorTween(
...@@ -141,7 +147,7 @@ class _CustomThumbShape extends SliderComponentShape { ...@@ -141,7 +147,7 @@ class _CustomThumbShape extends SliderComponentShape {
); );
final double size = _thumbSize * sizeTween.evaluate(enableAnimation); final double size = _thumbSize * sizeTween.evaluate(enableAnimation);
final Path thumbPath = _downTriangle(size, thumbCenter); final Path thumbPath = _downTriangle(size, thumbCenter);
canvas.drawPath(thumbPath, Paint()..color = colorTween.evaluate(enableAnimation)); canvas.drawPath(thumbPath, Paint()..color = colorTween.evaluate(enableAnimation)!);
} }
} }
...@@ -164,16 +170,16 @@ class _CustomValueIndicatorShape extends SliderComponentShape { ...@@ -164,16 +170,16 @@ class _CustomValueIndicatorShape extends SliderComponentShape {
void paint( void paint(
PaintingContext context, PaintingContext context,
Offset thumbCenter, { Offset thumbCenter, {
Animation<double> activationAnimation, required Animation<double> activationAnimation,
Animation<double> enableAnimation, required Animation<double> enableAnimation,
bool isDiscrete, bool? isDiscrete,
TextPainter labelPainter, required TextPainter labelPainter,
RenderBox parentBox, RenderBox? parentBox,
SliderThemeData sliderTheme, required SliderThemeData sliderTheme,
TextDirection textDirection, TextDirection? textDirection,
double value, double? value,
double textScaleFactor, double? textScaleFactor,
Size sizeWithOverflow, Size? sizeWithOverflow,
}) { }) {
final Canvas canvas = context.canvas; final Canvas canvas = context.canvas;
final ColorTween enableColor = ColorTween( final ColorTween enableColor = ColorTween(
...@@ -187,7 +193,7 @@ class _CustomValueIndicatorShape extends SliderComponentShape { ...@@ -187,7 +193,7 @@ class _CustomValueIndicatorShape extends SliderComponentShape {
final double size = _indicatorSize * sizeTween.evaluate(enableAnimation); final double size = _indicatorSize * sizeTween.evaluate(enableAnimation);
final Offset slideUpOffset = Offset(0.0, -slideUpTween.evaluate(activationAnimation)); final Offset slideUpOffset = Offset(0.0, -slideUpTween.evaluate(activationAnimation));
final Path thumbPath = _upTriangle(size, thumbCenter + slideUpOffset); final Path thumbPath = _upTriangle(size, thumbCenter + slideUpOffset);
final Color paintColor = enableColor.evaluate(enableAnimation).withAlpha((255.0 * activationAnimation.value).round()); final Color paintColor = enableColor.evaluate(enableAnimation)!.withAlpha((255.0 * activationAnimation.value).round());
canvas.drawPath( canvas.drawPath(
thumbPath, thumbPath,
Paint()..color = paintColor, Paint()..color = paintColor,
...@@ -259,10 +265,10 @@ class _SlidersState extends State<_Sliders> { ...@@ -259,10 +265,10 @@ class _SlidersState extends State<_Sliders> {
child: TextField( child: TextField(
textAlign: TextAlign.center, textAlign: TextAlign.center,
onSubmitted: (String value) { onSubmitted: (String value) {
final double newValue = double.tryParse(value); final double? newValue = double.tryParse(value);
if (newValue != null && newValue != _continuousValue) { if (newValue != null && newValue != _continuousValue) {
setState(() { setState(() {
_continuousValue = newValue.clamp(0.0, 100.0) as double; _continuousValue = newValue.clamp(0.0, 100.0);
}); });
} }
}, },
...@@ -326,7 +332,7 @@ class _SlidersState extends State<_Sliders> { ...@@ -326,7 +332,7 @@ class _SlidersState extends State<_Sliders> {
valueIndicatorColor: Colors.deepPurpleAccent, valueIndicatorColor: Colors.deepPurpleAccent,
thumbShape: _CustomThumbShape(), thumbShape: _CustomThumbShape(),
valueIndicatorShape: _CustomValueIndicatorShape(), valueIndicatorShape: _CustomValueIndicatorShape(),
valueIndicatorTextStyle: theme.accentTextTheme.bodyText1.copyWith(color: theme.colorScheme.onSurface), valueIndicatorTextStyle: theme.accentTextTheme.bodyText1!.copyWith(color: theme.colorScheme.onSurface),
), ),
child: Slider( child: Slider(
value: _discreteCustomValue, value: _discreteCustomValue,
......
...@@ -19,7 +19,7 @@ const String _text3 = ...@@ -19,7 +19,7 @@ const String _text3 =
'By default snackbars automatically disappear after a few seconds '; 'By default snackbars automatically disappear after a few seconds ';
class SnackBarDemo extends StatefulWidget { class SnackBarDemo extends StatefulWidget {
const SnackBarDemo({ Key key }) : super(key: key); const SnackBarDemo({ Key? key }) : super(key: key);
static const String routeName = '/material/snack-bar'; static const String routeName = '/material/snack-bar';
......
...@@ -13,17 +13,17 @@ const String _kGalleryAssetsPackage = 'flutter_gallery_assets'; ...@@ -13,17 +13,17 @@ const String _kGalleryAssetsPackage = 'flutter_gallery_assets';
class _Page { class _Page {
_Page({ this.label }); _Page({ this.label });
final String label; final String? label;
String get id => label.characters.first; String get id => label!.characters.first;
@override @override
String toString() => '$runtimeType("$label")'; String toString() => '$runtimeType("$label")';
} }
class _CardData { class _CardData {
const _CardData({ this.title, this.imageAsset, this.imageAssetPackage }); const _CardData({ this.title, this.imageAsset, this.imageAssetPackage });
final String title; final String? title;
final String imageAsset; final String? imageAsset;
final String imageAssetPackage; final String? imageAssetPackage;
} }
final Map<_Page, List<_CardData>> _allPages = <_Page, List<_CardData>>{ final Map<_Page, List<_CardData>> _allPages = <_Page, List<_CardData>>{
...@@ -97,8 +97,8 @@ class _CardDataItem extends StatelessWidget { ...@@ -97,8 +97,8 @@ class _CardDataItem extends StatelessWidget {
const _CardDataItem({ this.page, this.data }); const _CardDataItem({ this.page, this.data });
static const double height = 272.0; static const double height = 272.0;
final _Page page; final _Page? page;
final _CardData data; final _CardData? data;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -110,23 +110,23 @@ class _CardDataItem extends StatelessWidget { ...@@ -110,23 +110,23 @@ class _CardDataItem extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Align( Align(
alignment: page.id == 'H' alignment: page!.id == 'H'
? Alignment.centerLeft ? Alignment.centerLeft
: Alignment.centerRight, : Alignment.centerRight,
child: CircleAvatar(child: Text(page.id)), child: CircleAvatar(child: Text(page!.id)),
), ),
SizedBox( SizedBox(
width: 144.0, width: 144.0,
height: 144.0, height: 144.0,
child: Image.asset( child: Image.asset(
data.imageAsset, data!.imageAsset!,
package: data.imageAssetPackage, package: data!.imageAssetPackage,
fit: BoxFit.contain, fit: BoxFit.contain,
), ),
), ),
Center( Center(
child: Text( child: Text(
data.title, data!.title!,
style: Theme.of(context).textTheme.headline6, style: Theme.of(context).textTheme.headline6,
), ),
), ),
...@@ -187,7 +187,7 @@ class TabsDemo extends StatelessWidget { ...@@ -187,7 +187,7 @@ class TabsDemo extends StatelessWidget {
itemExtent: _CardDataItem.height, itemExtent: _CardDataItem.height,
delegate: SliverChildBuilderDelegate( delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) { (BuildContext context, int index) {
final _CardData data = _allPages[page][index]; final _CardData data = _allPages[page]![index];
return Padding( return Padding(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
vertical: 8.0, vertical: 8.0,
...@@ -198,7 +198,7 @@ class TabsDemo extends StatelessWidget { ...@@ -198,7 +198,7 @@ class TabsDemo extends StatelessWidget {
), ),
); );
}, },
childCount: _allPages[page].length, childCount: _allPages[page]!.length,
), ),
), ),
), ),
......
...@@ -15,13 +15,13 @@ const String _explanatoryText = ...@@ -15,13 +15,13 @@ const String _explanatoryText =
class _Page { class _Page {
_Page({ this.label, this.colors, this.icon }); _Page({ this.label, this.colors, this.icon });
final String label; final String? label;
final MaterialColor colors; final MaterialColor? colors;
final IconData icon; final IconData? icon;
Color get labelColor => colors != null ? colors.shade300 : Colors.grey.shade300; Color get labelColor => colors != null ? colors!.shade300 : Colors.grey.shade300;
bool get fabDefined => colors != null && icon != null; bool get fabDefined => colors != null && icon != null;
Color get fabColor => colors.shade400; Color get fabColor => colors!.shade400;
Icon get fabIcon => Icon(icon); Icon get fabIcon => Icon(icon);
Key get fabKey => ValueKey<Color>(fabColor); Key get fabKey => ValueKey<Color>(fabColor);
} }
...@@ -44,32 +44,32 @@ class TabsFabDemo extends StatefulWidget { ...@@ -44,32 +44,32 @@ class TabsFabDemo extends StatefulWidget {
class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStateMixin { class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStateMixin {
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
TabController _controller; TabController? _controller;
_Page _selectedPage; late _Page _selectedPage;
bool _extendedButtons = false; bool _extendedButtons = false;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_controller = TabController(vsync: this, length: _allPages.length); _controller = TabController(vsync: this, length: _allPages.length);
_controller.addListener(_handleTabSelection); _controller!.addListener(_handleTabSelection);
_selectedPage = _allPages[0]; _selectedPage = _allPages[0];
} }
@override @override
void dispose() { void dispose() {
_controller.dispose(); _controller!.dispose();
super.dispose(); super.dispose();
} }
void _handleTabSelection() { void _handleTabSelection() {
setState(() { setState(() {
_selectedPage = _allPages[_controller.index]; _selectedPage = _allPages[_controller!.index];
}); });
} }
void _showExplanatoryText() { void _showExplanatoryText() {
_scaffoldKey.currentState.showBottomSheet<void>((BuildContext context) { _scaffoldKey.currentState!.showBottomSheet<void>((BuildContext context) {
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border(top: BorderSide(color: Theme.of(context).dividerColor)) border: Border(top: BorderSide(color: Theme.of(context).dividerColor))
...@@ -86,11 +86,11 @@ class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStat ...@@ -86,11 +86,11 @@ class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStat
return Builder( return Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
return Container( return Container(
key: ValueKey<String>(page.label), key: ValueKey<String?>(page.label),
padding: const EdgeInsets.fromLTRB(48.0, 48.0, 48.0, 96.0), padding: const EdgeInsets.fromLTRB(48.0, 48.0, 48.0, 96.0),
child: Card( child: Card(
child: Center( child: Center(
child: Text(page.label, child: Text(page.label!,
style: TextStyle( style: TextStyle(
color: page.labelColor, color: page.labelColor,
fontSize: 32.0, fontSize: 32.0,
...@@ -104,7 +104,7 @@ class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStat ...@@ -104,7 +104,7 @@ class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStat
); );
} }
Widget buildFloatingActionButton(_Page page) { Widget? buildFloatingActionButton(_Page page) {
if (!page.fabDefined) if (!page.fabDefined)
return null; return null;
...@@ -114,7 +114,7 @@ class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStat ...@@ -114,7 +114,7 @@ class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStat
tooltip: 'Show explanation', tooltip: 'Show explanation',
backgroundColor: page.fabColor, backgroundColor: page.fabColor,
icon: page.fabIcon, icon: page.fabIcon,
label: Text(page.label.toUpperCase()), label: Text(page.label!.toUpperCase()),
onPressed: _showExplanatoryText, onPressed: _showExplanatoryText,
); );
} }
...@@ -136,7 +136,7 @@ class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStat ...@@ -136,7 +136,7 @@ class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStat
title: const Text('FAB per tab'), title: const Text('FAB per tab'),
bottom: TabBar( bottom: TabBar(
controller: _controller, controller: _controller,
tabs: _allPages.map<Widget>((_Page page) => Tab(text: page.label.toUpperCase())).toList(), tabs: _allPages.map<Widget>((_Page page) => Tab(text: page.label!.toUpperCase())).toList(),
), ),
actions: <Widget>[ actions: <Widget>[
MaterialDemoDocumentationButton(TabsFabDemo.routeName), MaterialDemoDocumentationButton(TabsFabDemo.routeName),
......
...@@ -9,7 +9,7 @@ import 'package:flutter/gestures.dart' show DragStartBehavior; ...@@ -9,7 +9,7 @@ import 'package:flutter/gestures.dart' show DragStartBehavior;
import '../../gallery/demo.dart'; import '../../gallery/demo.dart';
class TextFormFieldDemo extends StatefulWidget { class TextFormFieldDemo extends StatefulWidget {
const TextFormFieldDemo({ Key key }) : super(key: key); const TextFormFieldDemo({ Key? key }) : super(key: key);
static const String routeName = '/material/text-form-field'; static const String routeName = '/material/text-form-field';
...@@ -18,9 +18,9 @@ class TextFormFieldDemo extends StatefulWidget { ...@@ -18,9 +18,9 @@ class TextFormFieldDemo extends StatefulWidget {
} }
class PersonData { class PersonData {
String name = ''; String? name = '';
String phoneNumber = ''; String? phoneNumber = '';
String email = ''; String? email = '';
String password = ''; String password = '';
} }
...@@ -35,13 +35,13 @@ class PasswordField extends StatefulWidget { ...@@ -35,13 +35,13 @@ class PasswordField extends StatefulWidget {
this.onFieldSubmitted, this.onFieldSubmitted,
}); });
final Key fieldKey; final Key? fieldKey;
final String hintText; final String? hintText;
final String labelText; final String? labelText;
final String helperText; final String? helperText;
final FormFieldSetter<String> onSaved; final FormFieldSetter<String>? onSaved;
final FormFieldValidator<String> validator; final FormFieldValidator<String>? validator;
final ValueChanged<String> onFieldSubmitted; final ValueChanged<String>? onFieldSubmitted;
@override @override
_PasswordFieldState createState() => _PasswordFieldState(); _PasswordFieldState createState() => _PasswordFieldState();
...@@ -99,7 +99,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> { ...@@ -99,7 +99,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
final GlobalKey<FormFieldState<String>> _passwordFieldKey = GlobalKey<FormFieldState<String>>(); final GlobalKey<FormFieldState<String>> _passwordFieldKey = GlobalKey<FormFieldState<String>>();
final _UsNumberTextInputFormatter _phoneNumberFormatter = _UsNumberTextInputFormatter(); final _UsNumberTextInputFormatter _phoneNumberFormatter = _UsNumberTextInputFormatter();
void _handleSubmitted() { void _handleSubmitted() {
final FormState form = _formKey.currentState; final FormState form = _formKey.currentState!;
if (!form.validate()) { if (!form.validate()) {
_autovalidateMode = AutovalidateMode.always; // Start validating on every change. _autovalidateMode = AutovalidateMode.always; // Start validating on every change.
showInSnackBar('Please fix the errors in red before submitting.'); showInSnackBar('Please fix the errors in red before submitting.');
...@@ -109,9 +109,9 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> { ...@@ -109,9 +109,9 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
} }
} }
String _validateName(String value) { String? _validateName(String? value) {
_formWasEdited = true; _formWasEdited = true;
if (value.isEmpty) if (value!.isEmpty)
return 'Name is required.'; return 'Name is required.';
final RegExp nameExp = RegExp(r'^[A-Za-z ]+$'); final RegExp nameExp = RegExp(r'^[A-Za-z ]+$');
if (!nameExp.hasMatch(value)) if (!nameExp.hasMatch(value))
...@@ -119,18 +119,18 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> { ...@@ -119,18 +119,18 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
return null; return null;
} }
String _validatePhoneNumber(String value) { String? _validatePhoneNumber(String? value) {
_formWasEdited = true; _formWasEdited = true;
final RegExp phoneExp = RegExp(r'^\(\d\d\d\) \d\d\d\-\d\d\d\d$'); final RegExp phoneExp = RegExp(r'^\(\d\d\d\) \d\d\d\-\d\d\d\d$');
if (!phoneExp.hasMatch(value)) if (!phoneExp.hasMatch(value!))
return '(###) ###-#### - Enter a US phone number.'; return '(###) ###-#### - Enter a US phone number.';
return null; return null;
} }
String _validatePassword(String value) { String? _validatePassword(String? value) {
_formWasEdited = true; _formWasEdited = true;
final FormFieldState<String> passwordField = _passwordFieldKey.currentState; final FormFieldState<String> passwordField = _passwordFieldKey.currentState!;
if (passwordField.value == null || passwordField.value.isEmpty) if (passwordField.value == null || passwordField.value!.isEmpty)
return 'Please enter a password.'; return 'Please enter a password.';
if (passwordField.value != value) if (passwordField.value != value)
return "The passwords don't match"; return "The passwords don't match";
...@@ -138,11 +138,11 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> { ...@@ -138,11 +138,11 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
} }
Future<bool> _warnUserAboutInvalidData() async { Future<bool> _warnUserAboutInvalidData() async {
final FormState form = _formKey.currentState; final FormState? form = _formKey.currentState;
if (form == null || !_formWasEdited || form.validate()) if (form == null || !_formWasEdited || form.validate())
return true; return true;
return await showDialog<bool>( return await (showDialog<bool>(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return AlertDialog( return AlertDialog(
...@@ -151,16 +151,16 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> { ...@@ -151,16 +151,16 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
actions: <Widget> [ actions: <Widget> [
TextButton( TextButton(
child: const Text('YES'), child: const Text('YES'),
onPressed: () { Navigator.of(context).pop(true); }, onPressed: () { Navigator.of(context)!.pop(true); },
), ),
TextButton( TextButton(
child: const Text('NO'), child: const Text('NO'),
onPressed: () { Navigator.of(context).pop(false); }, onPressed: () { Navigator.of(context)!.pop(false); },
), ),
], ],
); );
}, },
) ?? false; ) as Future<bool>);
} }
@override @override
...@@ -195,7 +195,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> { ...@@ -195,7 +195,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
hintText: 'What do people call you?', hintText: 'What do people call you?',
labelText: 'Name *', labelText: 'Name *',
), ),
onSaved: (String value) { person.name = value; }, onSaved: (String? value) { person.name = value; },
validator: _validateName, validator: _validateName,
), ),
const SizedBox(height: 24.0), const SizedBox(height: 24.0),
...@@ -209,7 +209,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> { ...@@ -209,7 +209,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
prefixText: '+1', prefixText: '+1',
), ),
keyboardType: TextInputType.phone, keyboardType: TextInputType.phone,
onSaved: (String value) { person.phoneNumber = value; }, onSaved: (String? value) { person.phoneNumber = value; },
validator: _validatePhoneNumber, validator: _validatePhoneNumber,
// TextInputFormatters are applied in sequence. // TextInputFormatters are applied in sequence.
inputFormatters: <TextInputFormatter> [ inputFormatters: <TextInputFormatter> [
...@@ -228,7 +228,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> { ...@@ -228,7 +228,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
labelText: 'E-mail', labelText: 'E-mail',
), ),
keyboardType: TextInputType.emailAddress, keyboardType: TextInputType.emailAddress,
onSaved: (String value) { person.email = value; }, onSaved: (String? value) { person.email = value; },
), ),
const SizedBox(height: 24.0), const SizedBox(height: 24.0),
TextFormField( TextFormField(
...@@ -265,7 +265,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> { ...@@ -265,7 +265,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
), ),
const SizedBox(height: 24.0), const SizedBox(height: 24.0),
TextFormField( TextFormField(
enabled: person.password != null && person.password.isNotEmpty, enabled: person.password.isNotEmpty,
decoration: const InputDecoration( decoration: const InputDecoration(
border: UnderlineInputBorder(), border: UnderlineInputBorder(),
filled: true, filled: true,
......
...@@ -6,7 +6,7 @@ import 'package:flutter/material.dart'; ...@@ -6,7 +6,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
class PestoDemo extends StatelessWidget { class PestoDemo extends StatelessWidget {
const PestoDemo({ Key key }) : super(key: key); const PestoDemo({ Key? key }) : super(key: key);
static const String routeName = '/pesto'; static const String routeName = '/pesto';
...@@ -21,7 +21,7 @@ const double _kAppBarHeight = 128.0; ...@@ -21,7 +21,7 @@ const double _kAppBarHeight = 128.0;
const double _kFabHalfSize = 28.0; // TODO(mpcomplete): needs to adapt to screen size const double _kFabHalfSize = 28.0; // TODO(mpcomplete): needs to adapt to screen size
const double _kRecipePageMaxWidth = 500.0; const double _kRecipePageMaxWidth = 500.0;
final Set<Recipe> _favoriteRecipes = <Recipe>{}; final Set<Recipe?> _favoriteRecipes = <Recipe?>{};
final ThemeData _kTheme = ThemeData( final ThemeData _kTheme = ThemeData(
brightness: Brightness.light, brightness: Brightness.light,
...@@ -46,10 +46,10 @@ class PestoFavorites extends StatelessWidget { ...@@ -46,10 +46,10 @@ class PestoFavorites extends StatelessWidget {
class PestoStyle extends TextStyle { class PestoStyle extends TextStyle {
const PestoStyle({ const PestoStyle({
double fontSize = 12.0, double fontSize = 12.0,
FontWeight fontWeight, FontWeight? fontWeight,
Color color = Colors.black87, Color color = Colors.black87,
double letterSpacing, double? letterSpacing,
double height, double? height,
}) : super( }) : super(
inherit: false, inherit: false,
color: color, color: color,
...@@ -64,9 +64,9 @@ class PestoStyle extends TextStyle { ...@@ -64,9 +64,9 @@ class PestoStyle extends TextStyle {
// Displays a grid of recipe cards. // Displays a grid of recipe cards.
class RecipeGridPage extends StatefulWidget { class RecipeGridPage extends StatefulWidget {
const RecipeGridPage({ Key key, this.recipes }) : super(key: key); const RecipeGridPage({ Key? key, this.recipes }) : super(key: key);
final List<Recipe> recipes; final List<Recipe?>? recipes;
@override @override
_RecipeGridPageState createState() => _RecipeGridPageState(); _RecipeGridPageState createState() => _RecipeGridPageState();
...@@ -89,7 +89,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> { ...@@ -89,7 +89,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
}, },
), ),
body: CustomScrollView( body: CustomScrollView(
semanticChildCount: widget.recipes.length, semanticChildCount: widget.recipes!.length,
slivers: <Widget>[ slivers: <Widget>[
_buildAppBar(context, statusBarHeight), _buildAppBar(context, statusBarHeight),
_buildBody(context, statusBarHeight), _buildBody(context, statusBarHeight),
...@@ -127,7 +127,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> { ...@@ -127,7 +127,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
bottom: extraPadding, bottom: extraPadding,
), ),
child: Center( child: Center(
child: PestoLogo(height: logoHeight, t: t.clamp(0.0, 1.0) as double), child: PestoLogo(height: logoHeight, t: t.clamp(0.0, 1.0)),
), ),
); );
}, },
...@@ -153,13 +153,13 @@ class _RecipeGridPageState extends State<RecipeGridPage> { ...@@ -153,13 +153,13 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
), ),
delegate: SliverChildBuilderDelegate( delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) { (BuildContext context, int index) {
final Recipe recipe = widget.recipes[index]; final Recipe? recipe = widget.recipes![index];
return RecipeCard( return RecipeCard(
recipe: recipe, recipe: recipe,
onTap: () { showRecipePage(context, recipe); }, onTap: () { showRecipePage(context, recipe); },
); );
}, },
childCount: widget.recipes.length, childCount: widget.recipes!.length,
), ),
), ),
); );
...@@ -172,7 +172,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> { ...@@ -172,7 +172,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
)); ));
} }
void showRecipePage(BuildContext context, Recipe recipe) { void showRecipePage(BuildContext context, Recipe? recipe) {
Navigator.push(context, MaterialPageRoute<void>( Navigator.push(context, MaterialPageRoute<void>(
settings: const RouteSettings(name: '/pesto/recipe'), settings: const RouteSettings(name: '/pesto/recipe'),
builder: (BuildContext context) { builder: (BuildContext context) {
...@@ -188,8 +188,8 @@ class _RecipeGridPageState extends State<RecipeGridPage> { ...@@ -188,8 +188,8 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
class PestoLogo extends StatefulWidget { class PestoLogo extends StatefulWidget {
const PestoLogo({this.height, this.t}); const PestoLogo({this.height, this.t});
final double height; final double? height;
final double t; final double? t;
@override @override
_PestoLogoState createState() => _PestoLogoState(); _PestoLogoState createState() => _PestoLogoState();
...@@ -217,7 +217,7 @@ class _PestoLogoState extends State<PestoLogo> { ...@@ -217,7 +217,7 @@ class _PestoLogoState extends State<PestoLogo> {
return Semantics( return Semantics(
namesRoute: true, namesRoute: true,
child: Transform( child: Transform(
transform: Matrix4.identity()..scale(widget.height / kLogoHeight), transform: Matrix4.identity()..scale(widget.height! / kLogoHeight),
alignment: Alignment.topCenter, alignment: Alignment.topCenter,
child: SizedBox( child: SizedBox(
width: kLogoWidth, width: kLogoWidth,
...@@ -225,7 +225,7 @@ class _PestoLogoState extends State<PestoLogo> { ...@@ -225,7 +225,7 @@ class _PestoLogoState extends State<PestoLogo> {
clipBehavior: Clip.none, clipBehavior: Clip.none,
children: <Widget>[ children: <Widget>[
Positioned.fromRect( Positioned.fromRect(
rect: _imageRectTween.lerp(widget.t), rect: _imageRectTween.lerp(widget.t!)!,
child: Image.asset( child: Image.asset(
_kSmallLogoImage, _kSmallLogoImage,
package: _kGalleryAssetsPackage, package: _kGalleryAssetsPackage,
...@@ -233,9 +233,9 @@ class _PestoLogoState extends State<PestoLogo> { ...@@ -233,9 +233,9 @@ class _PestoLogoState extends State<PestoLogo> {
), ),
), ),
Positioned.fromRect( Positioned.fromRect(
rect: _textRectTween.lerp(widget.t), rect: _textRectTween.lerp(widget.t!)!,
child: Opacity( child: Opacity(
opacity: _textOpacity.transform(widget.t), opacity: _textOpacity.transform(widget.t!),
child: Text('PESTO', style: titleStyle, textAlign: TextAlign.center), child: Text('PESTO', style: titleStyle, textAlign: TextAlign.center),
), ),
), ),
...@@ -249,10 +249,10 @@ class _PestoLogoState extends State<PestoLogo> { ...@@ -249,10 +249,10 @@ class _PestoLogoState extends State<PestoLogo> {
// A card with the recipe's image, author, and title. // A card with the recipe's image, author, and title.
class RecipeCard extends StatelessWidget { class RecipeCard extends StatelessWidget {
const RecipeCard({ Key key, this.recipe, this.onTap }) : super(key: key); const RecipeCard({ Key? key, this.recipe, this.onTap }) : super(key: key);
final Recipe recipe; final Recipe? recipe;
final VoidCallback onTap; final VoidCallback? onTap;
TextStyle get titleStyle => const PestoStyle(fontSize: 24.0, fontWeight: FontWeight.w600); TextStyle get titleStyle => const PestoStyle(fontSize: 24.0, fontWeight: FontWeight.w600);
TextStyle get authorStyle => const PestoStyle(fontWeight: FontWeight.w500, color: Colors.black54); TextStyle get authorStyle => const PestoStyle(fontWeight: FontWeight.w500, color: Colors.black54);
...@@ -266,14 +266,14 @@ class RecipeCard extends StatelessWidget { ...@@ -266,14 +266,14 @@ class RecipeCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Hero( Hero(
tag: 'packages/$_kGalleryAssetsPackage/${recipe.imagePath}', tag: 'packages/$_kGalleryAssetsPackage/${recipe!.imagePath}',
child: AspectRatio( child: AspectRatio(
aspectRatio: 4.0 / 3.0, aspectRatio: 4.0 / 3.0,
child: Image.asset( child: Image.asset(
recipe.imagePath, recipe!.imagePath!,
package: recipe.imagePackage, package: recipe!.imagePackage,
fit: BoxFit.cover, fit: BoxFit.cover,
semanticLabel: recipe.name, semanticLabel: recipe!.name,
), ),
), ),
), ),
...@@ -283,8 +283,8 @@ class RecipeCard extends StatelessWidget { ...@@ -283,8 +283,8 @@ class RecipeCard extends StatelessWidget {
Padding( Padding(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
child: Image.asset( child: Image.asset(
recipe.ingredientsImagePath, recipe!.ingredientsImagePath!,
package: recipe.ingredientsImagePackage, package: recipe!.ingredientsImagePackage,
width: 48.0, width: 48.0,
height: 48.0, height: 48.0,
), ),
...@@ -294,8 +294,8 @@ class RecipeCard extends StatelessWidget { ...@@ -294,8 +294,8 @@ class RecipeCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Text(recipe.name, style: titleStyle, softWrap: false, overflow: TextOverflow.ellipsis), Text(recipe!.name!, style: titleStyle, softWrap: false, overflow: TextOverflow.ellipsis),
Text(recipe.author, style: authorStyle), Text(recipe!.author!, style: authorStyle),
], ],
), ),
), ),
...@@ -311,9 +311,9 @@ class RecipeCard extends StatelessWidget { ...@@ -311,9 +311,9 @@ class RecipeCard extends StatelessWidget {
// Displays one recipe. Includes the recipe sheet with a background image. // Displays one recipe. Includes the recipe sheet with a background image.
class RecipePage extends StatefulWidget { class RecipePage extends StatefulWidget {
const RecipePage({ Key key, this.recipe }) : super(key: key); const RecipePage({ Key? key, this.recipe }) : super(key: key);
final Recipe recipe; final Recipe? recipe;
@override @override
_RecipePageState createState() => _RecipePageState(); _RecipePageState createState() => _RecipePageState();
...@@ -342,10 +342,10 @@ class _RecipePageState extends State<RecipePage> { ...@@ -342,10 +342,10 @@ class _RecipePageState extends State<RecipePage> {
right: 0.0, right: 0.0,
height: appBarHeight + _kFabHalfSize, height: appBarHeight + _kFabHalfSize,
child: Hero( child: Hero(
tag: 'packages/$_kGalleryAssetsPackage/${widget.recipe.imagePath}', tag: 'packages/$_kGalleryAssetsPackage/${widget.recipe!.imagePath}',
child: Image.asset( child: Image.asset(
widget.recipe.imagePath, widget.recipe!.imagePath!,
package: widget.recipe.imagePackage, package: widget.recipe!.imagePackage,
fit: fullWidth ? BoxFit.fitWidth : BoxFit.cover, fit: fullWidth ? BoxFit.fitWidth : BoxFit.cover,
), ),
), ),
...@@ -429,7 +429,7 @@ class _RecipePageState extends State<RecipePage> { ...@@ -429,7 +429,7 @@ class _RecipePageState extends State<RecipePage> {
/// Displays the recipe's name and instructions. /// Displays the recipe's name and instructions.
class RecipeSheet extends StatelessWidget { class RecipeSheet extends StatelessWidget {
RecipeSheet({ Key key, this.recipe }) : super(key: key); RecipeSheet({ Key? key, this.recipe }) : super(key: key);
final TextStyle titleStyle = const PestoStyle(fontSize: 34.0); final TextStyle titleStyle = const PestoStyle(fontSize: 34.0);
final TextStyle descriptionStyle = const PestoStyle(fontSize: 15.0, color: Colors.black54, height: 24.0/15.0); final TextStyle descriptionStyle = const PestoStyle(fontSize: 15.0, color: Colors.black54, height: 24.0/15.0);
...@@ -437,7 +437,7 @@ class RecipeSheet extends StatelessWidget { ...@@ -437,7 +437,7 @@ class RecipeSheet extends StatelessWidget {
final TextStyle itemAmountStyle = PestoStyle(fontSize: 15.0, color: _kTheme.primaryColor, height: 24.0/15.0); final TextStyle itemAmountStyle = PestoStyle(fontSize: 15.0, color: _kTheme.primaryColor, height: 24.0/15.0);
final TextStyle headingStyle = const PestoStyle(fontSize: 16.0, fontWeight: FontWeight.bold, height: 24.0/15.0); final TextStyle headingStyle = const PestoStyle(fontSize: 16.0, fontWeight: FontWeight.bold, height: 24.0/15.0);
final Recipe recipe; final Recipe? recipe;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -457,8 +457,8 @@ class RecipeSheet extends StatelessWidget { ...@@ -457,8 +457,8 @@ class RecipeSheet extends StatelessWidget {
TableCell( TableCell(
verticalAlignment: TableCellVerticalAlignment.middle, verticalAlignment: TableCellVerticalAlignment.middle,
child: Image.asset( child: Image.asset(
recipe.ingredientsImagePath, recipe!.ingredientsImagePath!,
package: recipe.ingredientsImagePackage, package: recipe!.ingredientsImagePackage,
width: 32.0, width: 32.0,
height: 32.0, height: 32.0,
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
...@@ -467,7 +467,7 @@ class RecipeSheet extends StatelessWidget { ...@@ -467,7 +467,7 @@ class RecipeSheet extends StatelessWidget {
), ),
TableCell( TableCell(
verticalAlignment: TableCellVerticalAlignment.middle, verticalAlignment: TableCellVerticalAlignment.middle,
child: Text(recipe.name, style: titleStyle), child: Text(recipe!.name!, style: titleStyle),
), ),
] ]
), ),
...@@ -476,7 +476,7 @@ class RecipeSheet extends StatelessWidget { ...@@ -476,7 +476,7 @@ class RecipeSheet extends StatelessWidget {
const SizedBox(), const SizedBox(),
Padding( Padding(
padding: const EdgeInsets.only(top: 8.0, bottom: 4.0), padding: const EdgeInsets.only(top: 8.0, bottom: 4.0),
child: Text(recipe.description, style: descriptionStyle), child: Text(recipe!.description!, style: descriptionStyle),
), ),
] ]
), ),
...@@ -489,8 +489,8 @@ class RecipeSheet extends StatelessWidget { ...@@ -489,8 +489,8 @@ class RecipeSheet extends StatelessWidget {
), ),
] ]
), ),
...recipe.ingredients.map<TableRow>((RecipeIngredient ingredient) { ...recipe!.ingredients!.map<TableRow>((RecipeIngredient ingredient) {
return _buildItemRow(ingredient.amount, ingredient.description); return _buildItemRow(ingredient.amount!, ingredient.description!);
}), }),
TableRow( TableRow(
children: <Widget>[ children: <Widget>[
...@@ -501,8 +501,8 @@ class RecipeSheet extends StatelessWidget { ...@@ -501,8 +501,8 @@ class RecipeSheet extends StatelessWidget {
), ),
] ]
), ),
...recipe.steps.map<TableRow>((RecipeStep step) { ...recipe!.steps!.map<TableRow>((RecipeStep step) {
return _buildItemRow(step.duration ?? '', step.description); return _buildItemRow(step.duration ?? '', step.description!);
}), }),
], ],
), ),
...@@ -540,29 +540,29 @@ class Recipe { ...@@ -540,29 +540,29 @@ class Recipe {
this.steps, this.steps,
}); });
final String name; final String? name;
final String author; final String? author;
final String description; final String? description;
final String imagePath; final String? imagePath;
final String imagePackage; final String? imagePackage;
final String ingredientsImagePath; final String? ingredientsImagePath;
final String ingredientsImagePackage; final String? ingredientsImagePackage;
final List<RecipeIngredient> ingredients; final List<RecipeIngredient>? ingredients;
final List<RecipeStep> steps; final List<RecipeStep>? steps;
} }
class RecipeIngredient { class RecipeIngredient {
const RecipeIngredient({this.amount, this.description}); const RecipeIngredient({this.amount, this.description});
final String amount; final String? amount;
final String description; final String? description;
} }
class RecipeStep { class RecipeStep {
const RecipeStep({this.duration, this.description}); const RecipeStep({this.duration, this.description});
final String duration; final String? duration;
final String description; final String? description;
} }
const List<Recipe> kPestoRecipes = <Recipe>[ const List<Recipe> kPestoRecipes = <Recipe>[
......
...@@ -20,7 +20,7 @@ class ShrineApp extends StatefulWidget { ...@@ -20,7 +20,7 @@ class ShrineApp extends StatefulWidget {
class _ShrineAppState extends State<ShrineApp> with SingleTickerProviderStateMixin { class _ShrineAppState extends State<ShrineApp> with SingleTickerProviderStateMixin {
// Controller to coordinate both the opening/closing of backdrop and sliding // Controller to coordinate both the opening/closing of backdrop and sliding
// of expanding bottom sheet // of expanding bottom sheet
AnimationController _controller; late AnimationController _controller;
@override @override
void initState() { void initState() {
...@@ -55,7 +55,7 @@ class _ShrineAppState extends State<ShrineApp> with SingleTickerProviderStateMix ...@@ -55,7 +55,7 @@ class _ShrineAppState extends State<ShrineApp> with SingleTickerProviderStateMix
} }
} }
Route<dynamic> _getRoute(RouteSettings settings) { Route<dynamic>? _getRoute(RouteSettings settings) {
if (settings.name != '/login') { if (settings.name != '/login') {
return null; return null;
} }
...@@ -98,11 +98,11 @@ ThemeData _buildShrineTheme() { ...@@ -98,11 +98,11 @@ ThemeData _buildShrineTheme() {
TextTheme _buildShrineTextTheme(TextTheme base) { TextTheme _buildShrineTextTheme(TextTheme base) {
return base.copyWith( return base.copyWith(
headline5: base.headline5.copyWith(fontWeight: FontWeight.w500), headline5: base.headline5!.copyWith(fontWeight: FontWeight.w500),
headline6: base.headline6.copyWith(fontSize: 18.0), headline6: base.headline6!.copyWith(fontSize: 18.0),
caption: base.caption.copyWith(fontWeight: FontWeight.w400, fontSize: 14.0), caption: base.caption!.copyWith(fontWeight: FontWeight.w400, fontSize: 14.0),
bodyText1: base.bodyText1.copyWith(fontWeight: FontWeight.w500, fontSize: 16.0), bodyText1: base.bodyText1!.copyWith(fontWeight: FontWeight.w500, fontSize: 16.0),
button: base.button.copyWith(fontWeight: FontWeight.w500, fontSize: 14.0), button: base.button!.copyWith(fontWeight: FontWeight.w500, fontSize: 14.0),
).apply( ).apply(
fontFamily: 'Raleway', fontFamily: 'Raleway',
displayColor: kShrineBrown900, displayColor: kShrineBrown900,
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:meta/meta.dart';
import 'package:flutter_gallery/demo/shrine/login.dart'; import 'package:flutter_gallery/demo/shrine/login.dart';
...@@ -15,37 +14,37 @@ const double _kPeakVelocityProgress = 0.379146; ...@@ -15,37 +14,37 @@ const double _kPeakVelocityProgress = 0.379146;
class _TappableWhileStatusIs extends StatefulWidget { class _TappableWhileStatusIs extends StatefulWidget {
const _TappableWhileStatusIs( const _TappableWhileStatusIs(
this.status, { this.status, {
Key key, Key? key,
this.controller, this.controller,
this.child, this.child,
}) : super(key: key); }) : super(key: key);
final AnimationController controller; final AnimationController? controller;
final AnimationStatus status; final AnimationStatus status;
final Widget child; final Widget? child;
@override @override
_TappableWhileStatusIsState createState() => _TappableWhileStatusIsState(); _TappableWhileStatusIsState createState() => _TappableWhileStatusIsState();
} }
class _TappableWhileStatusIsState extends State<_TappableWhileStatusIs> { class _TappableWhileStatusIsState extends State<_TappableWhileStatusIs> {
bool _active; bool? _active;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
widget.controller.addStatusListener(_handleStatusChange); widget.controller!.addStatusListener(_handleStatusChange);
_active = widget.controller.status == widget.status; _active = widget.controller!.status == widget.status;
} }
@override @override
void dispose() { void dispose() {
widget.controller.removeStatusListener(_handleStatusChange); widget.controller!.removeStatusListener(_handleStatusChange);
super.dispose(); super.dispose();
} }
void _handleStatusChange(AnimationStatus status) { void _handleStatusChange(AnimationStatus status) {
final bool value = widget.controller.status == widget.status; final bool value = widget.controller!.status == widget.status;
if (_active != value) { if (_active != value) {
setState(() { setState(() {
_active = value; _active = value;
...@@ -56,11 +55,11 @@ class _TappableWhileStatusIsState extends State<_TappableWhileStatusIs> { ...@@ -56,11 +55,11 @@ class _TappableWhileStatusIsState extends State<_TappableWhileStatusIs> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Widget child = AbsorbPointer( Widget child = AbsorbPointer(
absorbing: !_active, absorbing: !_active!,
child: widget.child, child: widget.child,
); );
if (!_active) { if (!_active!) {
child = FocusScope( child = FocusScope(
canRequestFocus: false, canRequestFocus: false,
debugLabel: '$_TappableWhileStatusIs', debugLabel: '$_TappableWhileStatusIs',
...@@ -73,13 +72,13 @@ class _TappableWhileStatusIsState extends State<_TappableWhileStatusIs> { ...@@ -73,13 +72,13 @@ class _TappableWhileStatusIsState extends State<_TappableWhileStatusIs> {
class _FrontLayer extends StatelessWidget { class _FrontLayer extends StatelessWidget {
const _FrontLayer({ const _FrontLayer({
Key key, Key? key,
this.onTap, this.onTap,
this.child, this.child,
}) : super(key: key); }) : super(key: key);
final VoidCallback onTap; final VoidCallback? onTap;
final Widget child; final Widget? child;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -100,7 +99,7 @@ class _FrontLayer extends StatelessWidget { ...@@ -100,7 +99,7 @@ class _FrontLayer extends StatelessWidget {
), ),
), ),
Expanded( Expanded(
child: child, child: child!,
), ),
], ],
), ),
...@@ -110,16 +109,14 @@ class _FrontLayer extends StatelessWidget { ...@@ -110,16 +109,14 @@ class _FrontLayer extends StatelessWidget {
class _BackdropTitle extends AnimatedWidget { class _BackdropTitle extends AnimatedWidget {
const _BackdropTitle({ const _BackdropTitle({
Key key, Key? key,
Animation<double> listenable, required Animation<double> listenable,
this.onPress, this.onPress,
@required this.frontTitle, required this.frontTitle,
@required this.backTitle, required this.backTitle,
}) : assert(frontTitle != null), }) : super(key: key, listenable: listenable);
assert(backTitle != null),
super(key: key, listenable: listenable);
final void Function() onPress; final void Function()? onPress;
final Widget frontTitle; final Widget frontTitle;
final Widget backTitle; final Widget backTitle;
...@@ -131,7 +128,7 @@ class _BackdropTitle extends AnimatedWidget { ...@@ -131,7 +128,7 @@ class _BackdropTitle extends AnimatedWidget {
); );
return DefaultTextStyle( return DefaultTextStyle(
style: Theme.of(context).primaryTextTheme.headline6, style: Theme.of(context).primaryTextTheme.headline6!,
softWrap: false, softWrap: false,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
child: Row(children: <Widget>[ child: Row(children: <Widget>[
...@@ -201,16 +198,12 @@ class _BackdropTitle extends AnimatedWidget { ...@@ -201,16 +198,12 @@ class _BackdropTitle extends AnimatedWidget {
/// front or back layer is showing. /// front or back layer is showing.
class Backdrop extends StatefulWidget { class Backdrop extends StatefulWidget {
const Backdrop({ const Backdrop({
@required this.frontLayer, required this.frontLayer,
@required this.backLayer, required this.backLayer,
@required this.frontTitle, required this.frontTitle,
@required this.backTitle, required this.backTitle,
@required this.controller, required this.controller,
}) : assert(frontLayer != null), });
assert(backLayer != null),
assert(frontTitle != null),
assert(backTitle != null),
assert(controller != null);
final Widget frontLayer; final Widget frontLayer;
final Widget backLayer; final Widget backLayer;
...@@ -224,8 +217,8 @@ class Backdrop extends StatefulWidget { ...@@ -224,8 +217,8 @@ class Backdrop extends StatefulWidget {
class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin { class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin {
final GlobalKey _backdropKey = GlobalKey(debugLabel: 'Backdrop'); final GlobalKey _backdropKey = GlobalKey(debugLabel: 'Backdrop');
AnimationController _controller; AnimationController? _controller;
Animation<RelativeRect> _layerAnimation; late Animation<RelativeRect> _layerAnimation;
@override @override
void initState() { void initState() {
...@@ -235,19 +228,19 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin ...@@ -235,19 +228,19 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
@override @override
void dispose() { void dispose() {
_controller.dispose(); _controller!.dispose();
super.dispose(); super.dispose();
} }
bool get _frontLayerVisible { bool get _frontLayerVisible {
final AnimationStatus status = _controller.status; final AnimationStatus status = _controller!.status;
return status == AnimationStatus.completed || status == AnimationStatus.forward; return status == AnimationStatus.completed || status == AnimationStatus.forward;
} }
void _toggleBackdropLayerVisibility() { void _toggleBackdropLayerVisibility() {
// Call setState here to update layerAnimation if that's necessary // Call setState here to update layerAnimation if that's necessary
setState(() { setState(() {
_frontLayerVisible ? _controller.reverse() : _controller.forward(); _frontLayerVisible ? _controller!.reverse() : _controller!.forward();
}); });
} }
...@@ -267,7 +260,7 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin ...@@ -267,7 +260,7 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
firstWeight = _kPeakVelocityTime; firstWeight = _kPeakVelocityTime;
secondWeight = 1.0 - _kPeakVelocityTime; secondWeight = 1.0 - _kPeakVelocityTime;
animation = CurvedAnimation( animation = CurvedAnimation(
parent: _controller.view, parent: _controller!.view,
curve: const Interval(0.0, 0.78), curve: const Interval(0.0, 0.78),
); );
} else { } else {
...@@ -276,7 +269,7 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin ...@@ -276,7 +269,7 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
secondCurve = _kAccelerateCurve.flipped; secondCurve = _kAccelerateCurve.flipped;
firstWeight = 1.0 - _kPeakVelocityTime; firstWeight = 1.0 - _kPeakVelocityTime;
secondWeight = _kPeakVelocityTime; secondWeight = _kPeakVelocityTime;
animation = _controller.view; animation = _controller!.view;
} }
return TweenSequence<RelativeRect>( return TweenSequence<RelativeRect>(
...@@ -351,7 +344,7 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin ...@@ -351,7 +344,7 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
elevation: 0.0, elevation: 0.0,
titleSpacing: 0.0, titleSpacing: 0.0,
title: _BackdropTitle( title: _BackdropTitle(
listenable: _controller.view, listenable: _controller!.view,
onPress: _toggleBackdropLayerVisibility, onPress: _toggleBackdropLayerVisibility,
frontTitle: widget.frontTitle, frontTitle: widget.frontTitle,
backTitle: widget.backTitle, backTitle: widget.backTitle,
......
...@@ -11,22 +11,22 @@ import 'package:flutter_gallery/demo/shrine/model/product.dart'; ...@@ -11,22 +11,22 @@ import 'package:flutter_gallery/demo/shrine/model/product.dart';
class CategoryMenuPage extends StatelessWidget { class CategoryMenuPage extends StatelessWidget {
const CategoryMenuPage({ const CategoryMenuPage({
Key key, Key? key,
this.onCategoryTap, this.onCategoryTap,
}) : super(key: key); }) : super(key: key);
final VoidCallback onCategoryTap; final VoidCallback? onCategoryTap;
Widget _buildCategory(Category category, BuildContext context) { Widget _buildCategory(Category category, BuildContext context) {
final String categoryString = category.toString().replaceAll('Category.', '').toUpperCase(); final String categoryString = category.toString().replaceAll('Category.', '').toUpperCase();
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
return ScopedModelDescendant<AppStateModel>( return ScopedModelDescendant<AppStateModel>(
builder: (BuildContext context, Widget child, AppStateModel model) => builder: (BuildContext context, Widget? child, AppStateModel model) =>
GestureDetector( GestureDetector(
onTap: () { onTap: () {
model.setCategory(category); model.setCategory(category);
if (onCategoryTap != null) { if (onCategoryTap != null) {
onCategoryTap(); onCategoryTap!();
} }
}, },
child: model.selectedCategory == category child: model.selectedCategory == category
...@@ -50,7 +50,7 @@ class CategoryMenuPage extends StatelessWidget { ...@@ -50,7 +50,7 @@ class CategoryMenuPage extends StatelessWidget {
padding: const EdgeInsets.symmetric(vertical: 16.0), padding: const EdgeInsets.symmetric(vertical: 16.0),
child: Text( child: Text(
categoryString, categoryString,
style: theme.textTheme.bodyText1.copyWith( style: theme.textTheme.bodyText1!.copyWith(
color: kShrineBrown900.withAlpha(153) color: kShrineBrown900.withAlpha(153)
), ),
textAlign: TextAlign.center, textAlign: TextAlign.center,
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:meta/meta.dart';
import 'package:scoped_model/scoped_model.dart'; import 'package:scoped_model/scoped_model.dart';
import 'package:flutter_gallery/demo/shrine/colors.dart'; import 'package:flutter_gallery/demo/shrine/colors.dart';
...@@ -26,19 +25,16 @@ const double _kCornerRadius = 24.0; ...@@ -26,19 +25,16 @@ const double _kCornerRadius = 24.0;
const double _kWidthForCartIcon = 64.0; const double _kWidthForCartIcon = 64.0;
class ExpandingBottomSheet extends StatefulWidget { class ExpandingBottomSheet extends StatefulWidget {
const ExpandingBottomSheet({Key key, @required this.hideController}) const ExpandingBottomSheet({Key? key, required this.hideController})
: assert(hideController != null), : super(key: key);
super(key: key);
final AnimationController hideController; final AnimationController hideController;
@override @override
_ExpandingBottomSheetState createState() => _ExpandingBottomSheetState(); _ExpandingBottomSheetState createState() => _ExpandingBottomSheetState();
static _ExpandingBottomSheetState of(BuildContext context, {bool isNullOk = false}) { static _ExpandingBottomSheetState? of(BuildContext context, {bool isNullOk = false}) {
assert(isNullOk != null); final _ExpandingBottomSheetState? result = context.findAncestorStateOfType<_ExpandingBottomSheetState>();
assert(context != null);
final _ExpandingBottomSheetState result = context.findAncestorStateOfType<_ExpandingBottomSheetState>();
if (isNullOk || result != null) { if (isNullOk || result != null) {
return result; return result;
} }
...@@ -53,11 +49,11 @@ class ExpandingBottomSheet extends StatefulWidget { ...@@ -53,11 +49,11 @@ class ExpandingBottomSheet extends StatefulWidget {
// curve formula. It's quintic, not cubic. But it _can_ be expressed as one // curve formula. It's quintic, not cubic. But it _can_ be expressed as one
// curve followed by another, which we do here. // curve followed by another, which we do here.
Animation<T> _getEmphasizedEasingAnimation<T>({ Animation<T> _getEmphasizedEasingAnimation<T>({
@required T begin, required T begin,
@required T peak, required T peak,
@required T end, required T end,
@required bool isForward, required bool isForward,
@required Animation<double> parent, required Animation<double> parent,
}) { }) {
Curve firstCurve; Curve firstCurve;
Curve secondCurve; Curve secondCurve;
...@@ -98,7 +94,7 @@ Animation<T> _getEmphasizedEasingAnimation<T>({ ...@@ -98,7 +94,7 @@ Animation<T> _getEmphasizedEasingAnimation<T>({
// Calculates the value where two double Animations should be joined. Used by // Calculates the value where two double Animations should be joined. Used by
// callers of _getEmphasisedEasing<double>(). // callers of _getEmphasisedEasing<double>().
double _getPeakPoint({double begin, double end}) { double _getPeakPoint({required double begin, required double end}) {
return begin + (end - begin) * _kPeakVelocityProgress; return begin + (end - begin) * _kPeakVelocityProgress;
} }
...@@ -111,15 +107,15 @@ class _ExpandingBottomSheetState extends State<ExpandingBottomSheet> with Ticker ...@@ -111,15 +107,15 @@ class _ExpandingBottomSheetState extends State<ExpandingBottomSheet> with Ticker
double _width = _kWidthForCartIcon; double _width = _kWidthForCartIcon;
// Controller for the opening and closing of the ExpandingBottomSheet // Controller for the opening and closing of the ExpandingBottomSheet
AnimationController _controller; late AnimationController _controller;
// Animations for the opening and closing of the ExpandingBottomSheet // Animations for the opening and closing of the ExpandingBottomSheet
Animation<double> _widthAnimation; late Animation<double> _widthAnimation;
Animation<double> _heightAnimation; late Animation<double> _heightAnimation;
Animation<double> _thumbnailOpacityAnimation; late Animation<double> _thumbnailOpacityAnimation;
Animation<double> _cartOpacityAnimation; late Animation<double> _cartOpacityAnimation;
Animation<double> _shapeAnimation; late Animation<double> _shapeAnimation;
Animation<Offset> _slideAnimation; late Animation<Offset> _slideAnimation;
@override @override
void initState() { void initState() {
...@@ -308,7 +304,7 @@ class _ExpandingBottomSheetState extends State<ExpandingBottomSheet> with Ticker ...@@ -308,7 +304,7 @@ class _ExpandingBottomSheetState extends State<ExpandingBottomSheet> with Ticker
); );
} }
Widget _buildCart(BuildContext context, Widget child) { Widget _buildCart(BuildContext context, Widget? child) {
// numProducts is the number of different products in the cart (does not // numProducts is the number of different products in the cart (does not
// include multiples of the same product). // include multiples of the same product).
final AppStateModel model = ScopedModel.of<AppStateModel>(context); final AppStateModel model = ScopedModel.of<AppStateModel>(context);
...@@ -349,7 +345,7 @@ class _ExpandingBottomSheetState extends State<ExpandingBottomSheet> with Ticker ...@@ -349,7 +345,7 @@ class _ExpandingBottomSheetState extends State<ExpandingBottomSheet> with Ticker
} }
// Builder for the hide and reveal animation when the backdrop opens and closes // Builder for the hide and reveal animation when the backdrop opens and closes
Widget _buildSlideAnimation(BuildContext context, Widget child) { Widget _buildSlideAnimation(BuildContext context, Widget? child) {
_slideAnimation = _getEmphasizedEasingAnimation( _slideAnimation = _getEmphasizedEasingAnimation(
begin: const Offset(1.0, 0.0), begin: const Offset(1.0, 0.0),
peak: const Offset(_kPeakVelocityProgress, 0.0), peak: const Offset(_kPeakVelocityProgress, 0.0),
...@@ -393,7 +389,7 @@ class _ExpandingBottomSheetState extends State<ExpandingBottomSheet> with Ticker ...@@ -393,7 +389,7 @@ class _ExpandingBottomSheetState extends State<ExpandingBottomSheet> with Ticker
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: open, onTap: open,
child: ScopedModelDescendant<AppStateModel>( child: ScopedModelDescendant<AppStateModel>(
builder: (BuildContext context, Widget child, AppStateModel model) { builder: (BuildContext context, Widget? child, AppStateModel model) {
return AnimatedBuilder( return AnimatedBuilder(
builder: _buildCart, builder: _buildCart,
animation: _controller, animation: _controller,
...@@ -417,10 +413,10 @@ class _ProductThumbnailRowState extends State<ProductThumbnailRow> { ...@@ -417,10 +413,10 @@ class _ProductThumbnailRowState extends State<ProductThumbnailRow> {
// _list represents what's currently on screen. If _internalList updates, // _list represents what's currently on screen. If _internalList updates,
// it will need to be updated to match it. // it will need to be updated to match it.
_ListModel _list; late _ListModel _list;
// _internalList represents the list as it is updated by the AppStateModel. // _internalList represents the list as it is updated by the AppStateModel.
List<int> _internalList; late List<int> _internalList;
@override @override
void initState() { void initState() {
...@@ -436,7 +432,6 @@ class _ProductThumbnailRowState extends State<ProductThumbnailRow> { ...@@ -436,7 +432,6 @@ class _ProductThumbnailRowState extends State<ProductThumbnailRow> {
Product _productWithId(int productId) { Product _productWithId(int productId) {
final AppStateModel model = ScopedModel.of<AppStateModel>(context); final AppStateModel model = ScopedModel.of<AppStateModel>(context);
final Product product = model.getProductById(productId); final Product product = model.getProductById(productId);
assert(product != null);
return product; return product;
} }
...@@ -510,7 +505,7 @@ class _ProductThumbnailRowState extends State<ProductThumbnailRow> { ...@@ -510,7 +505,7 @@ class _ProductThumbnailRowState extends State<ProductThumbnailRow> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
_updateLists(); _updateLists();
return ScopedModelDescendant<AppStateModel>( return ScopedModelDescendant<AppStateModel>(
builder: (BuildContext context, Widget child, AppStateModel model) => _buildAnimatedList(), builder: (BuildContext context, Widget? child, AppStateModel model) => _buildAnimatedList(),
); );
} }
} }
...@@ -529,7 +524,7 @@ class ExtraProductsNumber extends StatelessWidget { ...@@ -529,7 +524,7 @@ class ExtraProductsNumber extends StatelessWidget {
final int numProducts = products.length; final int numProducts = products.length;
if (numProducts > 3) { if (numProducts > 3) {
for (int i = 3; i < numProducts; i++) { for (int i = 3; i < numProducts; i++) {
overflow += productMap[products[i]]; overflow += productMap[products[i]]!;
} }
} }
return overflow; return overflow;
...@@ -553,7 +548,7 @@ class ExtraProductsNumber extends StatelessWidget { ...@@ -553,7 +548,7 @@ class ExtraProductsNumber extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ScopedModelDescendant<AppStateModel>( return ScopedModelDescendant<AppStateModel>(
builder: (BuildContext builder, Widget child, AppStateModel model) => _buildOverflow(model, context), builder: (BuildContext builder, Widget? child, AppStateModel model) => _buildOverflow(model, context),
); );
} }
} }
...@@ -594,18 +589,16 @@ class ProductThumbnail extends StatelessWidget { ...@@ -594,18 +589,16 @@ class ProductThumbnail extends StatelessWidget {
// _ListModel manipulates an internal list and an AnimatedList // _ListModel manipulates an internal list and an AnimatedList
class _ListModel { class _ListModel {
_ListModel({ _ListModel({
@required this.listKey, required this.listKey,
@required this.removedItemBuilder, required this.removedItemBuilder,
Iterable<int> initialItems, Iterable<int>? initialItems,
}) : assert(listKey != null), }) : _items = initialItems?.toList() ?? <int>[];
assert(removedItemBuilder != null),
_items = initialItems?.toList() ?? <int>[];
final GlobalKey<AnimatedListState> listKey; final GlobalKey<AnimatedListState> listKey;
final Widget Function(int item, BuildContext context, Animation<double> animation) removedItemBuilder; final Widget Function(int item, BuildContext context, Animation<double> animation) removedItemBuilder;
final List<int> _items; final List<int> _items;
AnimatedListState get _animatedList => listKey.currentState; AnimatedListState? get _animatedList => listKey.currentState;
void add(int product) { void add(int product) {
_insert(_items.length, product); _insert(_items.length, product);
...@@ -613,7 +606,7 @@ class _ListModel { ...@@ -613,7 +606,7 @@ class _ListModel {
void _insert(int index, int item) { void _insert(int index, int item) {
_items.insert(index, item); _items.insert(index, item);
_animatedList.insertItem(index, duration: const Duration(milliseconds: 225)); _animatedList!.insertItem(index, duration: const Duration(milliseconds: 225));
} }
void remove(int product) { void remove(int product) {
...@@ -625,12 +618,10 @@ class _ListModel { ...@@ -625,12 +618,10 @@ class _ListModel {
void _removeAt(int index) { void _removeAt(int index) {
final int removedItem = _items.removeAt(index); final int removedItem = _items.removeAt(index);
if (removedItem != null) { _animatedList!.removeItem(index, (BuildContext context, Animation<double> animation) {
_animatedList.removeItem(index, (BuildContext context, Animation<double> animation) {
return removedItemBuilder(removedItem, context, animation); return removedItemBuilder(removedItem, context, animation);
}); });
} }
}
int get length => _items.length; int get length => _items.length;
......
...@@ -19,7 +19,7 @@ class ProductPage extends StatelessWidget { ...@@ -19,7 +19,7 @@ class ProductPage extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ScopedModelDescendant<AppStateModel>( return ScopedModelDescendant<AppStateModel>(
builder: (BuildContext context, Widget child, AppStateModel model) { builder: (BuildContext context, Widget? child, AppStateModel model) {
return AsymmetricView(products: model.getProducts()); return AsymmetricView(products: model.getProducts());
}); });
} }
...@@ -29,17 +29,18 @@ class HomePage extends StatelessWidget { ...@@ -29,17 +29,18 @@ class HomePage extends StatelessWidget {
const HomePage({ const HomePage({
this.expandingBottomSheet, this.expandingBottomSheet,
this.backdrop, this.backdrop,
Key key, Key? key,
}) : super(key: key); }) : super(key: key);
final ExpandingBottomSheet expandingBottomSheet; final ExpandingBottomSheet? expandingBottomSheet;
final Backdrop backdrop; final Backdrop? backdrop;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Stack( return Stack(
children: <Widget>[ children: <Widget>[
backdrop, if (backdrop != null)
backdrop!,
Align(child: expandingBottomSheet, alignment: Alignment.bottomRight), Align(child: expandingBottomSheet, alignment: Alignment.bottomRight),
], ],
); );
......
...@@ -35,7 +35,7 @@ class _LoginPageState extends State<LoginPage> { ...@@ -35,7 +35,7 @@ class _LoginPageState extends State<LoginPage> {
// The login screen is immediately displayed on top of the Shrine // The login screen is immediately displayed on top of the Shrine
// home screen using onGenerateRoute and so rootNavigator must be // home screen using onGenerateRoute and so rootNavigator must be
// set to true in order to get out of Shrine completely. // set to true in order to get out of Shrine completely.
Navigator.of(context, rootNavigator: true).pop(); Navigator.of(context, rootNavigator: true)!.pop();
}, },
), ),
), ),
...@@ -95,7 +95,7 @@ class _LoginPageState extends State<LoginPage> { ...@@ -95,7 +95,7 @@ class _LoginPageState extends State<LoginPage> {
// the Shrine home screen using onGenerateRoute and so // the Shrine home screen using onGenerateRoute and so
// rootNavigator must be set to true in order to get out // rootNavigator must be set to true in order to get out
// of Shrine completely. // of Shrine completely.
Navigator.of(context, rootNavigator: true).pop(); Navigator.of(context, rootNavigator: true)!.pop();
}, },
child: const Text('CANCEL'), child: const Text('CANCEL'),
), ),
...@@ -123,15 +123,15 @@ class _LoginPageState extends State<LoginPage> { ...@@ -123,15 +123,15 @@ class _LoginPageState extends State<LoginPage> {
} }
class PrimaryColorOverride extends StatelessWidget { class PrimaryColorOverride extends StatelessWidget {
const PrimaryColorOverride({Key key, this.color, this.child}) : super(key: key); const PrimaryColorOverride({Key? key, this.color, this.child}) : super(key: key);
final Color color; final Color? color;
final Widget child; final Widget? child;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Theme( return Theme(
child: child, child: child!,
data: Theme.of(context).copyWith(primaryColor: color), data: Theme.of(context).copyWith(primaryColor: color),
); );
} }
......
...@@ -12,7 +12,7 @@ double _shippingCostPerItem = 7.0; ...@@ -12,7 +12,7 @@ double _shippingCostPerItem = 7.0;
class AppStateModel extends Model { class AppStateModel extends Model {
// All the available products. // All the available products.
List<Product> _availableProducts; List<Product>? _availableProducts;
// The currently selected category of products. // The currently selected category of products.
Category _selectedCategory = Category.all; Category _selectedCategory = Category.all;
...@@ -30,7 +30,7 @@ class AppStateModel extends Model { ...@@ -30,7 +30,7 @@ class AppStateModel extends Model {
// Totaled prices of the items in the cart. // Totaled prices of the items in the cart.
double get subtotalCost { double get subtotalCost {
return _productsInCart.keys return _productsInCart.keys
.map((int id) => _availableProducts[id].price * _productsInCart[id]) .map((int id) => _availableProducts![id].price * _productsInCart[id]!)
.fold(0.0, (double sum, int e) => sum + e); .fold(0.0, (double sum, int e) => sum + e);
} }
...@@ -52,9 +52,9 @@ class AppStateModel extends Model { ...@@ -52,9 +52,9 @@ class AppStateModel extends Model {
} }
if (_selectedCategory == Category.all) { if (_selectedCategory == Category.all) {
return List<Product>.from(_availableProducts); return List<Product>.from(_availableProducts!);
} else { } else {
return _availableProducts return _availableProducts!
.where((Product p) => p.category == _selectedCategory) .where((Product p) => p.category == _selectedCategory)
.toList(); .toList();
} }
...@@ -62,10 +62,11 @@ class AppStateModel extends Model { ...@@ -62,10 +62,11 @@ class AppStateModel extends Model {
// Adds a product to the cart. // Adds a product to the cart.
void addProductToCart(int productId) { void addProductToCart(int productId) {
if (!_productsInCart.containsKey(productId)) { final int? value = _productsInCart[productId];
if (value == null) {
_productsInCart[productId] = 1; _productsInCart[productId] = 1;
} else { } else {
_productsInCart[productId]++; _productsInCart[productId] = value+1;
} }
notifyListeners(); notifyListeners();
...@@ -73,11 +74,13 @@ class AppStateModel extends Model { ...@@ -73,11 +74,13 @@ class AppStateModel extends Model {
// Removes an item from the cart. // Removes an item from the cart.
void removeItemFromCart(int productId) { void removeItemFromCart(int productId) {
if (_productsInCart.containsKey(productId)) { final int? value = _productsInCart[productId];
if (value != null) {
if (_productsInCart[productId] == 1) { if (_productsInCart[productId] == 1) {
_productsInCart.remove(productId); _productsInCart.remove(productId);
} else { } else {
_productsInCart[productId]--; _productsInCart[productId] = value - 1;
} }
} }
...@@ -86,7 +89,7 @@ class AppStateModel extends Model { ...@@ -86,7 +89,7 @@ class AppStateModel extends Model {
// Returns the Product instance matching the provided id. // Returns the Product instance matching the provided id.
Product getProductById(int id) { Product getProductById(int id) {
return _availableProducts.firstWhere((Product p) => p.id == id); return _availableProducts!.firstWhere((Product p) => p.id == id);
} }
// Removes everything from the cart. // Removes everything from the cart.
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'package:flutter/foundation.dart';
enum Category { enum Category {
all, all,
accessories, accessories,
...@@ -13,16 +11,12 @@ enum Category { ...@@ -13,16 +11,12 @@ enum Category {
class Product { class Product {
const Product({ const Product({
@required this.category, required this.category,
@required this.id, required this.id,
@required this.isFeatured, required this.isFeatured,
@required this.name, required this.name,
@required this.price, required this.price,
}) : assert(category != null), });
assert(id != null),
assert(isFeatured != null),
assert(name != null),
assert(price != null);
final Category category; final Category category;
final int id; final int id;
......
...@@ -41,7 +41,7 @@ class _ShoppingCartPageState extends State<ShoppingCartPage> { ...@@ -41,7 +41,7 @@ class _ShoppingCartPageState extends State<ShoppingCartPage> {
body: SafeArea( body: SafeArea(
child: Container( child: Container(
child: ScopedModelDescendant<AppStateModel>( child: ScopedModelDescendant<AppStateModel>(
builder: (BuildContext context, Widget child, AppStateModel model) { builder: (BuildContext context, Widget? child, AppStateModel model) {
return Stack( return Stack(
children: <Widget>[ children: <Widget>[
ListView( ListView(
...@@ -52,12 +52,12 @@ class _ShoppingCartPageState extends State<ShoppingCartPage> { ...@@ -52,12 +52,12 @@ class _ShoppingCartPageState extends State<ShoppingCartPage> {
width: _leftColumnWidth, width: _leftColumnWidth,
child: IconButton( child: IconButton(
icon: const Icon(Icons.keyboard_arrow_down), icon: const Icon(Icons.keyboard_arrow_down),
onPressed: () => ExpandingBottomSheet.of(context).close(), onPressed: () => ExpandingBottomSheet.of(context)!.close(),
), ),
), ),
Text( Text(
'CART', 'CART',
style: localTheme.textTheme.subtitle1.copyWith(fontWeight: FontWeight.w600), style: localTheme.textTheme.subtitle1!.copyWith(fontWeight: FontWeight.w600),
), ),
const SizedBox(width: 16.0), const SizedBox(width: 16.0),
Text('${model.totalCartQuantity} ITEMS'), Text('${model.totalCartQuantity} ITEMS'),
...@@ -88,7 +88,7 @@ class _ShoppingCartPageState extends State<ShoppingCartPage> { ...@@ -88,7 +88,7 @@ class _ShoppingCartPageState extends State<ShoppingCartPage> {
), ),
onPressed: () { onPressed: () {
model.clearCart(); model.clearCart();
ExpandingBottomSheet.of(context).close(); ExpandingBottomSheet.of(context)!.close();
}, },
), ),
), ),
...@@ -105,12 +105,12 @@ class _ShoppingCartPageState extends State<ShoppingCartPage> { ...@@ -105,12 +105,12 @@ class _ShoppingCartPageState extends State<ShoppingCartPage> {
class ShoppingCartSummary extends StatelessWidget { class ShoppingCartSummary extends StatelessWidget {
const ShoppingCartSummary({this.model}); const ShoppingCartSummary({this.model});
final AppStateModel model; final AppStateModel? model;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final TextStyle smallAmountStyle = Theme.of(context).textTheme.bodyText2.copyWith(color: kShrineBrown600); final TextStyle smallAmountStyle = Theme.of(context).textTheme.bodyText2!.copyWith(color: kShrineBrown600);
final TextStyle largeAmountStyle = Theme.of(context).textTheme.headline4; final TextStyle? largeAmountStyle = Theme.of(context).textTheme.headline4;
final NumberFormat formatter = NumberFormat.simpleCurrency( final NumberFormat formatter = NumberFormat.simpleCurrency(
decimalDigits: 2, decimalDigits: 2,
locale: Localizations.localeOf(context).toString(), locale: Localizations.localeOf(context).toString(),
...@@ -131,7 +131,7 @@ class ShoppingCartSummary extends StatelessWidget { ...@@ -131,7 +131,7 @@ class ShoppingCartSummary extends StatelessWidget {
child: Text('TOTAL'), child: Text('TOTAL'),
), ),
Text( Text(
formatter.format(model.totalCost), formatter.format(model!.totalCost),
style: largeAmountStyle, style: largeAmountStyle,
), ),
], ],
...@@ -143,7 +143,7 @@ class ShoppingCartSummary extends StatelessWidget { ...@@ -143,7 +143,7 @@ class ShoppingCartSummary extends StatelessWidget {
child: Text('Subtotal:'), child: Text('Subtotal:'),
), ),
Text( Text(
formatter.format(model.subtotalCost), formatter.format(model!.subtotalCost),
style: smallAmountStyle, style: smallAmountStyle,
), ),
], ],
...@@ -155,7 +155,7 @@ class ShoppingCartSummary extends StatelessWidget { ...@@ -155,7 +155,7 @@ class ShoppingCartSummary extends StatelessWidget {
child: Text('Shipping:'), child: Text('Shipping:'),
), ),
Text( Text(
formatter.format(model.shippingCost), formatter.format(model!.shippingCost),
style: smallAmountStyle, style: smallAmountStyle,
), ),
], ],
...@@ -167,7 +167,7 @@ class ShoppingCartSummary extends StatelessWidget { ...@@ -167,7 +167,7 @@ class ShoppingCartSummary extends StatelessWidget {
child: Text('Tax:'), child: Text('Tax:'),
), ),
Text( Text(
formatter.format(model.tax), formatter.format(model!.tax),
style: smallAmountStyle, style: smallAmountStyle,
), ),
], ],
...@@ -183,14 +183,14 @@ class ShoppingCartSummary extends StatelessWidget { ...@@ -183,14 +183,14 @@ class ShoppingCartSummary extends StatelessWidget {
class ShoppingCartRow extends StatelessWidget { class ShoppingCartRow extends StatelessWidget {
const ShoppingCartRow({ const ShoppingCartRow({
@required this.product, required this.product,
@required this.quantity, required this.quantity,
this.onPressed, this.onPressed,
}); });
final Product product; final Product product;
final int quantity; final int? quantity;
final VoidCallback onPressed; final VoidCallback? onPressed;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -243,7 +243,7 @@ class ShoppingCartRow extends StatelessWidget { ...@@ -243,7 +243,7 @@ class ShoppingCartRow extends StatelessWidget {
), ),
Text( Text(
product.name, product.name,
style: localTheme.textTheme.subtitle1.copyWith(fontWeight: FontWeight.w600), style: localTheme.textTheme.subtitle1!.copyWith(fontWeight: FontWeight.w600),
), ),
], ],
), ),
......
...@@ -8,12 +8,12 @@ import 'package:flutter_gallery/demo/shrine/model/product.dart'; ...@@ -8,12 +8,12 @@ import 'package:flutter_gallery/demo/shrine/model/product.dart';
import 'package:flutter_gallery/demo/shrine/supplemental/product_columns.dart'; import 'package:flutter_gallery/demo/shrine/supplemental/product_columns.dart';
class AsymmetricView extends StatelessWidget { class AsymmetricView extends StatelessWidget {
const AsymmetricView({Key key, this.products}) : super(key: key); const AsymmetricView({Key? key, this.products}) : super(key: key);
final List<Product> products; final List<Product>? products;
List<Container> _buildColumns(BuildContext context) { List<Container> _buildColumns(BuildContext context) {
if (products == null || products.isEmpty) { if (products == null || products!.isEmpty) {
return const <Container>[]; return const <Container>[];
} }
...@@ -25,23 +25,23 @@ class AsymmetricView extends StatelessWidget { ...@@ -25,23 +25,23 @@ class AsymmetricView extends StatelessWidget {
// some kinda awkward math so we use _evenCasesIndex and _oddCasesIndex as // some kinda awkward math so we use _evenCasesIndex and _oddCasesIndex as
// helpers for creating the index of the product list that will correspond // helpers for creating the index of the product list that will correspond
// to the index of the list of columns. // to the index of the list of columns.
return List<Container>.generate(_listItemCount(products.length), (int index) { return List<Container>.generate(_listItemCount(products!.length), (int index) {
double width = .59 * MediaQuery.of(context).size.width; double width = .59 * MediaQuery.of(context).size.width;
Widget column; Widget column;
if (index.isEven) { if (index.isEven) {
/// Even cases /// Even cases
final int bottom = _evenCasesIndex(index); final int bottom = _evenCasesIndex(index);
column = TwoProductCardColumn( column = TwoProductCardColumn(
bottom: products[bottom], bottom: products![bottom],
top: products.length - 1 >= bottom + 1 top: products!.length - 1 >= bottom + 1
? products[bottom + 1] ? products![bottom + 1]
: null, : null,
); );
width += 32.0; width += 32.0;
} else { } else {
/// Odd cases /// Odd cases
column = OneProductCardColumn( column = OneProductCardColumn(
product: products[_oddCasesIndex(index)], product: products![_oddCasesIndex(index)],
); );
} }
return Container( return Container(
......
...@@ -21,10 +21,10 @@ class CutCornersBorder extends OutlineInputBorder { ...@@ -21,10 +21,10 @@ class CutCornersBorder extends OutlineInputBorder {
@override @override
CutCornersBorder copyWith({ CutCornersBorder copyWith({
BorderSide borderSide, BorderSide? borderSide,
BorderRadius borderRadius, BorderRadius? borderRadius,
double gapPadding, double? gapPadding,
double cut, double? cut,
}) { }) {
return CutCornersBorder( return CutCornersBorder(
borderSide: borderSide ?? this.borderSide, borderSide: borderSide ?? this.borderSide,
...@@ -37,11 +37,11 @@ class CutCornersBorder extends OutlineInputBorder { ...@@ -37,11 +37,11 @@ class CutCornersBorder extends OutlineInputBorder {
final double cut; final double cut;
@override @override
ShapeBorder lerpFrom(ShapeBorder a, double t) { ShapeBorder? lerpFrom(ShapeBorder? a, double t) {
if (a is CutCornersBorder) { if (a is CutCornersBorder) {
final CutCornersBorder outline = a; final CutCornersBorder outline = a;
return CutCornersBorder( return CutCornersBorder(
borderRadius: BorderRadius.lerp(outline.borderRadius, borderRadius, t), borderRadius: BorderRadius.lerp(outline.borderRadius, borderRadius, t)!,
borderSide: BorderSide.lerp(outline.borderSide, borderSide, t), borderSide: BorderSide.lerp(outline.borderSide, borderSide, t),
cut: cut, cut: cut,
gapPadding: outline.gapPadding, gapPadding: outline.gapPadding,
...@@ -51,11 +51,11 @@ class CutCornersBorder extends OutlineInputBorder { ...@@ -51,11 +51,11 @@ class CutCornersBorder extends OutlineInputBorder {
} }
@override @override
ShapeBorder lerpTo(ShapeBorder b, double t) { ShapeBorder? lerpTo(ShapeBorder? b, double t) {
if (b is CutCornersBorder) { if (b is CutCornersBorder) {
final CutCornersBorder outline = b; final CutCornersBorder outline = b;
return CutCornersBorder( return CutCornersBorder(
borderRadius: BorderRadius.lerp(borderRadius, outline.borderRadius, t), borderRadius: BorderRadius.lerp(borderRadius, outline.borderRadius, t)!,
borderSide: BorderSide.lerp(borderSide, outline.borderSide, t), borderSide: BorderSide.lerp(borderSide, outline.borderSide, t),
cut: cut, cut: cut,
gapPadding: outline.gapPadding, gapPadding: outline.gapPadding,
...@@ -64,10 +64,10 @@ class CutCornersBorder extends OutlineInputBorder { ...@@ -64,10 +64,10 @@ class CutCornersBorder extends OutlineInputBorder {
return super.lerpTo(b, t); return super.lerpTo(b, t);
} }
Path _notchedCornerPath(Rect center, [double start = 0.0, double extent = 0.0]) { Path _notchedCornerPath(Rect center, [double start = 0.0, double? extent = 0.0]) {
final Path path = Path(); final Path path = Path();
if (start > 0.0 || extent > 0.0) { if (start > 0.0 || extent! > 0.0) {
path.relativeMoveTo(extent + start, center.top); path.relativeMoveTo(extent! + start, center.top);
_notchedSidesAndBottom(center, path); _notchedSidesAndBottom(center, path);
path..lineTo(center.left + cut, center.top)..lineTo(start, center.top); path..lineTo(center.left + cut, center.top)..lineTo(start, center.top);
} else { } else {
...@@ -93,12 +93,11 @@ class CutCornersBorder extends OutlineInputBorder { ...@@ -93,12 +93,11 @@ class CutCornersBorder extends OutlineInputBorder {
void paint( void paint(
Canvas canvas, Canvas canvas,
Rect rect, { Rect rect, {
double gapStart, double? gapStart,
double gapExtent = 0.0, double gapExtent = 0.0,
double gapPercentage = 0.0, double gapPercentage = 0.0,
TextDirection textDirection, TextDirection? textDirection,
}) { }) {
assert(gapExtent != null);
assert(gapPercentage >= 0.0 && gapPercentage <= 1.0); assert(gapPercentage >= 0.0 && gapPercentage <= 1.0);
final Paint paint = borderSide.toPaint(); final Paint paint = borderSide.toPaint();
...@@ -106,10 +105,10 @@ class CutCornersBorder extends OutlineInputBorder { ...@@ -106,10 +105,10 @@ class CutCornersBorder extends OutlineInputBorder {
if (gapStart == null || gapExtent <= 0.0 || gapPercentage == 0.0) { if (gapStart == null || gapExtent <= 0.0 || gapPercentage == 0.0) {
canvas.drawPath(_notchedCornerPath(outer.middleRect), paint); canvas.drawPath(_notchedCornerPath(outer.middleRect), paint);
} else { } else {
final double extent = lerpDouble(0.0, gapExtent + gapPadding * 2.0, gapPercentage); final double? extent = lerpDouble(0.0, gapExtent + gapPadding * 2.0, gapPercentage);
switch (textDirection) { switch (textDirection) {
case TextDirection.rtl: { case TextDirection.rtl: {
final Path path = _notchedCornerPath(outer.middleRect, gapStart + gapPadding - extent, extent); final Path path = _notchedCornerPath(outer.middleRect, gapStart + gapPadding - extent!, extent);
canvas.drawPath(path, paint); canvas.drawPath(path, paint);
break; break;
} }
...@@ -118,6 +117,8 @@ class CutCornersBorder extends OutlineInputBorder { ...@@ -118,6 +117,8 @@ class CutCornersBorder extends OutlineInputBorder {
canvas.drawPath(path, paint); canvas.drawPath(path, paint);
break; break;
} }
default:
break;
} }
} }
} }
......
...@@ -11,10 +11,10 @@ import 'package:flutter_gallery/demo/shrine/model/product.dart'; ...@@ -11,10 +11,10 @@ import 'package:flutter_gallery/demo/shrine/model/product.dart';
class ProductCard extends StatelessWidget { class ProductCard extends StatelessWidget {
const ProductCard({ this.imageAspectRatio = 33 / 49, this.product }) const ProductCard({ this.imageAspectRatio = 33 / 49, this.product })
: assert(imageAspectRatio == null || imageAspectRatio > 0); : assert(imageAspectRatio > 0);
final double imageAspectRatio; final double imageAspectRatio;
final Product product; final Product? product;
static const double kTextBoxHeight = 65.0; static const double kTextBoxHeight = 65.0;
...@@ -28,16 +28,16 @@ class ProductCard extends StatelessWidget { ...@@ -28,16 +28,16 @@ class ProductCard extends StatelessWidget {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
final Image imageWidget = Image.asset( final Image imageWidget = Image.asset(
product.assetName, product!.assetName,
package: product.assetPackage, package: product!.assetPackage,
fit: BoxFit.cover, fit: BoxFit.cover,
); );
return ScopedModelDescendant<AppStateModel>( return ScopedModelDescendant<AppStateModel>(
builder: (BuildContext context, Widget child, AppStateModel model) { builder: (BuildContext context, Widget? child, AppStateModel model) {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
model.addProductToCart(product.id); model.addProductToCart(product!.id);
}, },
child: child, child: child,
); );
...@@ -60,7 +60,7 @@ class ProductCard extends StatelessWidget { ...@@ -60,7 +60,7 @@ class ProductCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Text( Text(
product == null ? '' : product.name, product == null ? '' : product!.name,
style: theme.textTheme.button, style: theme.textTheme.button,
softWrap: false, softWrap: false,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
...@@ -68,7 +68,7 @@ class ProductCard extends StatelessWidget { ...@@ -68,7 +68,7 @@ class ProductCard extends StatelessWidget {
), ),
const SizedBox(height: 4.0), const SizedBox(height: 4.0),
Text( Text(
product == null ? '' : formatter.format(product.price), product == null ? '' : formatter.format(product!.price),
style: theme.textTheme.caption, style: theme.textTheme.caption,
), ),
], ],
......
...@@ -9,11 +9,11 @@ import 'package:flutter_gallery/demo/shrine/supplemental/product_card.dart'; ...@@ -9,11 +9,11 @@ import 'package:flutter_gallery/demo/shrine/supplemental/product_card.dart';
class TwoProductCardColumn extends StatelessWidget { class TwoProductCardColumn extends StatelessWidget {
const TwoProductCardColumn({ const TwoProductCardColumn({
@required this.bottom, required this.bottom,
this.top, this.top,
}) : assert(bottom != null); });
final Product bottom, top; final Product? bottom, top;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -59,7 +59,7 @@ class TwoProductCardColumn extends StatelessWidget { ...@@ -59,7 +59,7 @@ class TwoProductCardColumn extends StatelessWidget {
class OneProductCardColumn extends StatelessWidget { class OneProductCardColumn extends StatelessWidget {
const OneProductCardColumn({this.product}); const OneProductCardColumn({this.product});
final Product product; final Product? product;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
......
...@@ -6,7 +6,7 @@ import 'package:flutter/material.dart'; ...@@ -6,7 +6,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_gallery/demo/shrine/app.dart'; import 'package:flutter_gallery/demo/shrine/app.dart';
class ShrineDemo extends StatelessWidget { class ShrineDemo extends StatelessWidget {
const ShrineDemo({ Key key }) : super(key: key); const ShrineDemo({ Key? key }) : super(key: key);
static const String routeName = '/shrine'; // Used by the Gallery app. static const String routeName = '/shrine'; // Used by the Gallery app.
......
...@@ -9,7 +9,7 @@ import 'transformations_demo_edit_board_point.dart'; ...@@ -9,7 +9,7 @@ import 'transformations_demo_edit_board_point.dart';
import 'transformations_demo_gesture_transformable.dart'; import 'transformations_demo_gesture_transformable.dart';
class TransformationsDemo extends StatefulWidget { class TransformationsDemo extends StatefulWidget {
const TransformationsDemo({ Key key }) : super(key: key); const TransformationsDemo({ Key? key }) : super(key: key);
static const String routeName = '/transformations'; static const String routeName = '/transformations';
...@@ -107,7 +107,7 @@ class _TransformationsDemoState extends State<TransformationsDemo> { ...@@ -107,7 +107,7 @@ class _TransformationsDemoState extends State<TransformationsDemo> {
TextButton( TextButton(
child: const Text('OK'), child: const Text('OK'),
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context)!.pop();
}, },
), ),
], ],
...@@ -139,10 +139,10 @@ class _TransformationsDemoState extends State<TransformationsDemo> { ...@@ -139,10 +139,10 @@ class _TransformationsDemoState extends State<TransformationsDemo> {
height: 150, height: 150,
padding: const EdgeInsets.all(12.0), padding: const EdgeInsets.all(12.0),
child: EditBoardPoint( child: EditBoardPoint(
boardPoint: _board.selected, boardPoint: _board.selected!,
onColorSelection: (Color color) { onColorSelection: (Color color) {
setState(() { setState(() {
_board = _board.copyWithBoardPointColor(_board.selected, color); _board = _board.copyWithBoardPointColor(_board.selected!, color);
Navigator.pop(context); Navigator.pop(context);
}); });
}, },
...@@ -157,7 +157,7 @@ class _TransformationsDemoState extends State<TransformationsDemo> { ...@@ -157,7 +157,7 @@ class _TransformationsDemoState extends State<TransformationsDemo> {
void _onTapUp(TapUpDetails details) { void _onTapUp(TapUpDetails details) {
final Offset scenePoint = details.globalPosition; final Offset scenePoint = details.globalPosition;
final BoardPoint boardPoint = _board.pointToBoardPoint(scenePoint); final BoardPoint? boardPoint = _board.pointToBoardPoint(scenePoint);
setState(() { setState(() {
_board = _board.copyWithSelected(boardPoint); _board = _board.copyWithSelected(boardPoint);
}); });
...@@ -171,19 +171,19 @@ class BoardPainter extends CustomPainter { ...@@ -171,19 +171,19 @@ class BoardPainter extends CustomPainter {
this.board, this.board,
}); });
final Board board; final Board? board;
@override @override
void paint(Canvas canvas, Size size) { void paint(Canvas canvas, Size size) {
void drawBoardPoint(BoardPoint boardPoint) { void drawBoardPoint(BoardPoint? boardPoint) {
final Color color = boardPoint.color.withOpacity( final Color color = boardPoint!.color.withOpacity(
board.selected == boardPoint ? 0.2 : 1.0, board!.selected == boardPoint ? 0.2 : 1.0,
); );
final Vertices vertices = board.getVerticesForBoardPoint(boardPoint, color); final Vertices vertices = board!.getVerticesForBoardPoint(boardPoint, color);
canvas.drawVertices(vertices, BlendMode.color, Paint()); canvas.drawVertices(vertices, BlendMode.color, Paint());
} }
board.forEach(drawBoardPoint); board!.forEach(drawBoardPoint);
} }
// We should repaint whenever the board changes, such as board.selected. // We should repaint whenever the board changes, such as board.selected.
......
...@@ -11,13 +11,13 @@ import 'package:vector_math/vector_math_64.dart' show Vector3; ...@@ -11,13 +11,13 @@ import 'package:vector_math/vector_math_64.dart' show Vector3;
// The entire state of the hex board and abstraction to get information about // The entire state of the hex board and abstraction to get information about
// it. Iterable so that all BoardPoints on the board can be iterated over. // it. Iterable so that all BoardPoints on the board can be iterated over.
@immutable @immutable
class Board extends Object with IterableMixin<BoardPoint> { class Board extends Object with IterableMixin<BoardPoint?> {
Board({ Board({
@required this.boardRadius, required this.boardRadius,
@required this.hexagonRadius, required this.hexagonRadius,
@required this.hexagonMargin, required this.hexagonMargin,
this.selected, this.selected,
List<BoardPoint> boardPoints, List<BoardPoint>? boardPoints,
}) : assert(boardRadius > 0), }) : assert(boardRadius > 0),
assert(hexagonRadius > 0), assert(hexagonRadius > 0),
assert(hexagonMargin >= 0) { assert(hexagonMargin >= 0) {
...@@ -43,7 +43,7 @@ class Board extends Object with IterableMixin<BoardPoint> { ...@@ -43,7 +43,7 @@ class Board extends Object with IterableMixin<BoardPoint> {
_boardPoints.addAll(boardPoints); _boardPoints.addAll(boardPoints);
} else { } else {
// Generate boardPoints for a fresh board. // Generate boardPoints for a fresh board.
BoardPoint boardPoint = _getNextBoardPoint(null); BoardPoint? boardPoint = _getNextBoardPoint(null);
while (boardPoint != null) { while (boardPoint != null) {
_boardPoints.add(boardPoint); _boardPoints.add(boardPoint);
boardPoint = _getNextBoardPoint(boardPoint); boardPoint = _getNextBoardPoint(boardPoint);
...@@ -55,11 +55,11 @@ class Board extends Object with IterableMixin<BoardPoint> { ...@@ -55,11 +55,11 @@ class Board extends Object with IterableMixin<BoardPoint> {
final double hexagonRadius; // Pixel radius of a hexagon (center to vertex). final double hexagonRadius; // Pixel radius of a hexagon (center to vertex).
final double hexagonMargin; // Margin between hexagons. final double hexagonMargin; // Margin between hexagons.
final List<Offset> positionsForHexagonAtOrigin = <Offset>[]; final List<Offset> positionsForHexagonAtOrigin = <Offset>[];
final BoardPoint selected; final BoardPoint? selected;
final List<BoardPoint> _boardPoints = <BoardPoint>[]; final List<BoardPoint> _boardPoints = <BoardPoint>[];
@override @override
Iterator<BoardPoint> get iterator => _BoardIterator(_boardPoints); Iterator<BoardPoint?> get iterator => _BoardIterator(_boardPoints);
// For a given q axial coordinate, get the range of possible r values // For a given q axial coordinate, get the range of possible r values
// See the definition of BoardPoint for more information about hex grids and // See the definition of BoardPoint for more information about hex grids and
...@@ -81,7 +81,7 @@ class Board extends Object with IterableMixin<BoardPoint> { ...@@ -81,7 +81,7 @@ class Board extends Object with IterableMixin<BoardPoint> {
// Get the BoardPoint that comes after the given BoardPoint. If given null, // Get the BoardPoint that comes after the given BoardPoint. If given null,
// returns the origin BoardPoint. If given BoardPoint is the last, returns // returns the origin BoardPoint. If given BoardPoint is the last, returns
// null. // null.
BoardPoint _getNextBoardPoint (BoardPoint boardPoint) { BoardPoint? _getNextBoardPoint (BoardPoint? boardPoint) {
// If before the first element. // If before the first element.
if (boardPoint == null) { if (boardPoint == null) {
return BoardPoint(-boardRadius, 0); return BoardPoint(-boardRadius, 0);
...@@ -121,7 +121,7 @@ class Board extends Object with IterableMixin<BoardPoint> { ...@@ -121,7 +121,7 @@ class Board extends Object with IterableMixin<BoardPoint> {
// Return the q,r BoardPoint for a point in the scene, where the origin is in // Return the q,r BoardPoint for a point in the scene, where the origin is in
// the center of the board in both coordinate systems. If no BoardPoint at the // the center of the board in both coordinate systems. If no BoardPoint at the
// location, return null. // location, return null.
BoardPoint pointToBoardPoint(Offset point) { BoardPoint? pointToBoardPoint(Offset point) {
final BoardPoint boardPoint = BoardPoint( final BoardPoint boardPoint = BoardPoint(
((sqrt(3) / 3 * point.dx - 1 / 3 * point.dy) / hexagonRadius).round(), ((sqrt(3) / 3 * point.dx - 1 / 3 * point.dy) / hexagonRadius).round(),
((2 / 3 * point.dy) / hexagonRadius).round(), ((2 / 3 * point.dy) / hexagonRadius).round(),
...@@ -160,7 +160,7 @@ class Board extends Object with IterableMixin<BoardPoint> { ...@@ -160,7 +160,7 @@ class Board extends Object with IterableMixin<BoardPoint> {
} }
// Return a new board with the given BoardPoint selected. // Return a new board with the given BoardPoint selected.
Board copyWithSelected(BoardPoint boardPoint) { Board copyWithSelected(BoardPoint? boardPoint) {
if (selected == boardPoint) { if (selected == boardPoint) {
return this; return this;
} }
...@@ -187,7 +187,7 @@ class Board extends Object with IterableMixin<BoardPoint> { ...@@ -187,7 +187,7 @@ class Board extends Object with IterableMixin<BoardPoint> {
final List<BoardPoint> nextBoardPoints = List<BoardPoint>.from(_boardPoints); final List<BoardPoint> nextBoardPoints = List<BoardPoint>.from(_boardPoints);
nextBoardPoints[boardPointIndex] = nextBoardPoint; nextBoardPoints[boardPointIndex] = nextBoardPoint;
final BoardPoint selectedBoardPoint = boardPoint == selected final BoardPoint? selectedBoardPoint = boardPoint == selected
? nextBoardPoint ? nextBoardPoint
: selected; : selected;
return Board( return Board(
...@@ -200,29 +200,30 @@ class Board extends Object with IterableMixin<BoardPoint> { ...@@ -200,29 +200,30 @@ class Board extends Object with IterableMixin<BoardPoint> {
} }
} }
class _BoardIterator extends Iterator<BoardPoint> { class _BoardIterator extends Iterator<BoardPoint?> {
_BoardIterator(this.boardPoints); _BoardIterator(this.boardPoints);
final List<BoardPoint> boardPoints; final List<BoardPoint> boardPoints;
int currentIndex; int? currentIndex;
@override @override
BoardPoint current; BoardPoint? current;
@override @override
bool moveNext() { bool moveNext() {
if (currentIndex == null) { final int? index = currentIndex;
if (index == null) {
currentIndex = 0; currentIndex = 0;
} else { } else {
currentIndex++; currentIndex = index + 1;
} }
if (currentIndex >= boardPoints.length) { if (currentIndex! >= boardPoints.length) {
current = null; current = null;
return false; return false;
} }
current = boardPoints[currentIndex]; current = boardPoints[currentIndex!];
return true; return true;
} }
} }
...@@ -231,9 +232,7 @@ class _BoardIterator extends Iterator<BoardPoint> { ...@@ -231,9 +232,7 @@ class _BoardIterator extends Iterator<BoardPoint> {
@immutable @immutable
class _Range { class _Range {
const _Range(this.min, this.max) const _Range(this.min, this.max)
: assert(min != null), : assert(min <= max);
assert(max != null),
assert(min <= max);
final int min; final int min;
final int max; final int max;
......
...@@ -8,15 +8,14 @@ import 'package:flutter/material.dart'; ...@@ -8,15 +8,14 @@ import 'package:flutter/material.dart';
@immutable @immutable
class ColorPicker extends StatelessWidget { class ColorPicker extends StatelessWidget {
const ColorPicker({ const ColorPicker({
@required this.colors, required this.colors,
@required this.selectedColor, required this.selectedColor,
this.onColorSelection, this.onColorSelection,
}) : assert(colors != null), });
assert(selectedColor != null);
final Set<Color> colors; final Set<Color> colors;
final Color selectedColor; final Color selectedColor;
final ValueChanged<Color> onColorSelection; final ValueChanged<Color>? onColorSelection;
@override @override
Widget build (BuildContext context) { Widget build (BuildContext context) {
...@@ -28,7 +27,7 @@ class ColorPicker extends StatelessWidget { ...@@ -28,7 +27,7 @@ class ColorPicker extends StatelessWidget {
selected: color == selectedColor, selected: color == selectedColor,
onTap: () { onTap: () {
if (onColorSelection != null) { if (onColorSelection != null) {
onColorSelection(color); onColorSelection!(color);
} }
}, },
); );
...@@ -41,15 +40,14 @@ class ColorPicker extends StatelessWidget { ...@@ -41,15 +40,14 @@ class ColorPicker extends StatelessWidget {
@immutable @immutable
class _ColorPickerSwatch extends StatelessWidget { class _ColorPickerSwatch extends StatelessWidget {
const _ColorPickerSwatch({ const _ColorPickerSwatch({
@required this.color, required this.color,
@required this.selected, required this.selected,
this.onTap, this.onTap,
}) : assert(color != null), });
assert(selected != null);
final Color color; final Color color;
final bool selected; final bool selected;
final Function onTap; final Function? onTap;
@override @override
Widget build (BuildContext context) { Widget build (BuildContext context) {
...@@ -61,7 +59,7 @@ class _ColorPickerSwatch extends StatelessWidget { ...@@ -61,7 +59,7 @@ class _ColorPickerSwatch extends StatelessWidget {
fillColor: color, fillColor: color,
onPressed: () { onPressed: () {
if (onTap != null) { if (onTap != null) {
onTap(); onTap!();
} }
}, },
child: !selected ? null : const Icon( child: !selected ? null : const Icon(
......
...@@ -10,14 +10,13 @@ import 'transformations_demo_color_picker.dart'; ...@@ -10,14 +10,13 @@ import 'transformations_demo_color_picker.dart';
@immutable @immutable
class EditBoardPoint extends StatelessWidget { class EditBoardPoint extends StatelessWidget {
const EditBoardPoint({ const EditBoardPoint({
Key key, Key? key,
@required this.boardPoint, required this.boardPoint,
this.onColorSelection, this.onColorSelection,
}) : assert(boardPoint != null), }) : super(key: key);
super(key: key);
final BoardPoint boardPoint; final BoardPoint boardPoint;
final ValueChanged<Color> onColorSelection; final ValueChanged<Color>? onColorSelection;
@override @override
Widget build (BuildContext context) { Widget build (BuildContext context) {
......
...@@ -14,14 +14,14 @@ import 'transformations_demo_inertial_motion.dart'; ...@@ -14,14 +14,14 @@ import 'transformations_demo_inertial_motion.dart';
@immutable @immutable
class GestureTransformable extends StatefulWidget { class GestureTransformable extends StatefulWidget {
const GestureTransformable({ const GestureTransformable({
Key key, Key? key,
// The child to perform the transformations on. // The child to perform the transformations on.
@required this.child, required this.child,
// The desired visible size of the widget and the area that is receptive to // The desired visible size of the widget and the area that is receptive to
// gestures. If a widget that's as big as possible is desired, then wrap // gestures. If a widget that's as big as possible is desired, then wrap
// this in a LayoutBuilder and pass // this in a LayoutBuilder and pass
// `Size(constraints.maxWidth, constraints.maxHeight)`. // `Size(constraints.maxWidth, constraints.maxHeight)`.
@required this.size, required this.size,
// The scale will be clamped to between these values. A maxScale of null has // The scale will be clamped to between these values. A maxScale of null has
// no bounds. minScale must be greater than zero. // no bounds. minScale must be greater than zero.
this.maxScale = 2.5, this.maxScale = 2.5,
...@@ -71,14 +71,7 @@ class GestureTransformable extends StatefulWidget { ...@@ -71,14 +71,7 @@ class GestureTransformable extends StatefulWidget {
this.onScaleStart, this.onScaleStart,
this.onScaleUpdate, this.onScaleUpdate,
this.onScaleEnd, this.onScaleEnd,
}) : assert(child != null), }) : assert(minScale > 0),
assert(size != null),
assert(minScale != null),
assert(minScale > 0),
assert(disableTranslation != null),
assert(disableScale != null),
assert(disableRotation != null),
assert(reset != null),
assert( assert(
!reset || onResetEnd != null, !reset || onResetEnd != null,
'Must implement onResetEnd to use reset.', 'Must implement onResetEnd to use reset.',
...@@ -88,41 +81,41 @@ class GestureTransformable extends StatefulWidget { ...@@ -88,41 +81,41 @@ class GestureTransformable extends StatefulWidget {
final Widget child; final Widget child;
final Size size; final Size size;
final bool reset; final bool reset;
final GestureTapDownCallback onTapDown; final GestureTapDownCallback? onTapDown;
final GestureTapUpCallback onTapUp; final GestureTapUpCallback? onTapUp;
final GestureTapCallback onTap; final GestureTapCallback? onTap;
final GestureTapCancelCallback onTapCancel; final GestureTapCancelCallback? onTapCancel;
final GestureTapCallback onDoubleTap; final GestureTapCallback? onDoubleTap;
final GestureLongPressCallback onLongPress; final GestureLongPressCallback? onLongPress;
final GestureLongPressUpCallback onLongPressUp; final GestureLongPressUpCallback? onLongPressUp;
final GestureDragDownCallback onVerticalDragDown; final GestureDragDownCallback? onVerticalDragDown;
final GestureDragStartCallback onVerticalDragStart; final GestureDragStartCallback? onVerticalDragStart;
final GestureDragUpdateCallback onVerticalDragUpdate; final GestureDragUpdateCallback? onVerticalDragUpdate;
final GestureDragEndCallback onVerticalDragEnd; final GestureDragEndCallback? onVerticalDragEnd;
final GestureDragCancelCallback onVerticalDragCancel; final GestureDragCancelCallback? onVerticalDragCancel;
final GestureDragDownCallback onHorizontalDragDown; final GestureDragDownCallback? onHorizontalDragDown;
final GestureDragStartCallback onHorizontalDragStart; final GestureDragStartCallback? onHorizontalDragStart;
final GestureDragUpdateCallback onHorizontalDragUpdate; final GestureDragUpdateCallback? onHorizontalDragUpdate;
final GestureDragEndCallback onHorizontalDragEnd; final GestureDragEndCallback? onHorizontalDragEnd;
final GestureDragCancelCallback onHorizontalDragCancel; final GestureDragCancelCallback? onHorizontalDragCancel;
final GestureDragDownCallback onPanDown; final GestureDragDownCallback? onPanDown;
final GestureDragStartCallback onPanStart; final GestureDragStartCallback? onPanStart;
final GestureDragUpdateCallback onPanUpdate; final GestureDragUpdateCallback? onPanUpdate;
final GestureDragEndCallback onPanEnd; final GestureDragEndCallback? onPanEnd;
final GestureDragCancelCallback onPanCancel; final GestureDragCancelCallback? onPanCancel;
final VoidCallback onResetEnd; final VoidCallback? onResetEnd;
final GestureScaleStartCallback onScaleStart; final GestureScaleStartCallback? onScaleStart;
final GestureScaleUpdateCallback onScaleUpdate; final GestureScaleUpdateCallback? onScaleUpdate;
final GestureScaleEndCallback onScaleEnd; final GestureScaleEndCallback? onScaleEnd;
final double maxScale; final double maxScale;
final double minScale; final double minScale;
final Rect boundaryRect; final Rect? boundaryRect;
final bool disableTranslation; final bool disableTranslation;
final bool disableScale; final bool disableScale;
final bool disableRotation; final bool disableRotation;
final Offset initialTranslation; final Offset? initialTranslation;
final double initialScale; final double? initialScale;
final double initialRotation; final double? initialRotation;
@override _GestureTransformableState createState() => _GestureTransformableState(); @override _GestureTransformableState createState() => _GestureTransformableState();
} }
...@@ -137,20 +130,20 @@ enum _GestureType { ...@@ -137,20 +130,20 @@ enum _GestureType {
// This is public only for access from a unit test. // This is public only for access from a unit test.
class _GestureTransformableState extends State<GestureTransformable> with TickerProviderStateMixin { class _GestureTransformableState extends State<GestureTransformable> with TickerProviderStateMixin {
Animation<Offset> _animation; Animation<Offset>? _animation;
AnimationController _controller; late AnimationController _controller;
Animation<Matrix4> _animationReset; Animation<Matrix4>? _animationReset;
AnimationController _controllerReset; late AnimationController _controllerReset;
// The translation that will be applied to the scene (not viewport). // The translation that will be applied to the scene (not viewport).
// A positive x offset moves the scene right, viewport left. // A positive x offset moves the scene right, viewport left.
// A positive y offset moves the scene down, viewport up. // A positive y offset moves the scene down, viewport up.
Offset _translateFromScene; // Point where a single translation began. Offset? _translateFromScene; // Point where a single translation began.
double _scaleStart; // Scale value at start of scaling gesture. double? _scaleStart; // Scale value at start of scaling gesture.
double _rotationStart = 0.0; // Rotation at start of rotation gesture. double? _rotationStart = 0.0; // Rotation at start of rotation gesture.
Rect _boundaryRect; late Rect _boundaryRect;
Matrix4 _transform = Matrix4.identity(); Matrix4 _transform = Matrix4.identity();
double _currentRotation = 0.0; double _currentRotation = 0.0;
_GestureType gestureType; _GestureType? gestureType;
// The transformation matrix that gives the initial home position. // The transformation matrix that gives the initial home position.
Matrix4 get _initialTransform { Matrix4 get _initialTransform {
...@@ -183,7 +176,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker ...@@ -183,7 +176,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker
// Get the offset of the current widget from the global screen coordinates. // Get the offset of the current widget from the global screen coordinates.
// TODO(justinmc): Protect against calling this during first build. // TODO(justinmc): Protect against calling this during first build.
static Offset getOffset(BuildContext context) { static Offset getOffset(BuildContext context) {
final RenderBox renderObject = context.findRenderObject() as RenderBox; final RenderBox renderObject = context.findRenderObject()! as RenderBox;
return renderObject.localToGlobal(Offset.zero); return renderObject.localToGlobal(Offset.zero);
} }
...@@ -220,12 +213,12 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker ...@@ -220,12 +213,12 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker
return GestureDetector( return GestureDetector(
behavior: HitTestBehavior.opaque, // Necessary when translating off screen behavior: HitTestBehavior.opaque, // Necessary when translating off screen
onTapDown: widget.onTapDown == null ? null : (TapDownDetails details) { onTapDown: widget.onTapDown == null ? null : (TapDownDetails details) {
widget.onTapDown(TapDownDetails( widget.onTapDown!(TapDownDetails(
globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform),
)); ));
}, },
onTapUp: widget.onTapUp == null ? null : (TapUpDetails details) { onTapUp: widget.onTapUp == null ? null : (TapUpDetails details) {
widget.onTapUp(TapUpDetails( widget.onTapUp!(TapUpDetails(
kind: details.kind, kind: details.kind,
globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform),
)); ));
...@@ -236,51 +229,51 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker ...@@ -236,51 +229,51 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker
onLongPress: widget.onLongPress, onLongPress: widget.onLongPress,
onLongPressUp: widget.onLongPressUp, onLongPressUp: widget.onLongPressUp,
onVerticalDragDown: widget.onVerticalDragDown == null ? null : (DragDownDetails details) { onVerticalDragDown: widget.onVerticalDragDown == null ? null : (DragDownDetails details) {
widget.onVerticalDragDown(DragDownDetails( widget.onVerticalDragDown!(DragDownDetails(
globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform),
)); ));
}, },
onVerticalDragStart: widget.onVerticalDragStart == null ? null : (DragStartDetails details) { onVerticalDragStart: widget.onVerticalDragStart == null ? null : (DragStartDetails details) {
widget.onVerticalDragStart(DragStartDetails( widget.onVerticalDragStart!(DragStartDetails(
globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform),
)); ));
}, },
onVerticalDragUpdate: widget.onVerticalDragUpdate == null ? null : (DragUpdateDetails details) { onVerticalDragUpdate: widget.onVerticalDragUpdate == null ? null : (DragUpdateDetails details) {
widget.onVerticalDragUpdate(DragUpdateDetails( widget.onVerticalDragUpdate!(DragUpdateDetails(
globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform),
)); ));
}, },
onVerticalDragEnd: widget.onVerticalDragEnd, onVerticalDragEnd: widget.onVerticalDragEnd,
onVerticalDragCancel: widget.onVerticalDragCancel, onVerticalDragCancel: widget.onVerticalDragCancel,
onHorizontalDragDown: widget.onHorizontalDragDown == null ? null : (DragDownDetails details) { onHorizontalDragDown: widget.onHorizontalDragDown == null ? null : (DragDownDetails details) {
widget.onHorizontalDragDown(DragDownDetails( widget.onHorizontalDragDown!(DragDownDetails(
globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform),
)); ));
}, },
onHorizontalDragStart: widget.onHorizontalDragStart == null ? null : (DragStartDetails details) { onHorizontalDragStart: widget.onHorizontalDragStart == null ? null : (DragStartDetails details) {
widget.onHorizontalDragStart(DragStartDetails( widget.onHorizontalDragStart!(DragStartDetails(
globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform),
)); ));
}, },
onHorizontalDragUpdate: widget.onHorizontalDragUpdate == null ? null : (DragUpdateDetails details) { onHorizontalDragUpdate: widget.onHorizontalDragUpdate == null ? null : (DragUpdateDetails details) {
widget.onHorizontalDragUpdate(DragUpdateDetails( widget.onHorizontalDragUpdate!(DragUpdateDetails(
globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform),
)); ));
}, },
onHorizontalDragEnd: widget.onHorizontalDragEnd, onHorizontalDragEnd: widget.onHorizontalDragEnd,
onHorizontalDragCancel: widget.onHorizontalDragCancel, onHorizontalDragCancel: widget.onHorizontalDragCancel,
onPanDown: widget.onPanDown == null ? null : (DragDownDetails details) { onPanDown: widget.onPanDown == null ? null : (DragDownDetails details) {
widget.onPanDown(DragDownDetails( widget.onPanDown!(DragDownDetails(
globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform),
)); ));
}, },
onPanStart: widget.onPanStart == null ? null : (DragStartDetails details) { onPanStart: widget.onPanStart == null ? null : (DragStartDetails details) {
widget.onPanStart(DragStartDetails( widget.onPanStart!(DragStartDetails(
globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform),
)); ));
}, },
onPanUpdate: widget.onPanUpdate == null ? null : (DragUpdateDetails details) { onPanUpdate: widget.onPanUpdate == null ? null : (DragUpdateDetails details) {
widget.onPanUpdate(DragUpdateDetails( widget.onPanUpdate!(DragUpdateDetails(
globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform), globalPosition: fromViewport(details.globalPosition - getOffset(context), _transform),
)); ));
}, },
...@@ -305,7 +298,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker ...@@ -305,7 +298,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker
// Return a new matrix representing the given matrix after applying the given // Return a new matrix representing the given matrix after applying the given
// translation. // translation.
Matrix4 matrixTranslate(Matrix4 matrix, Offset translation) { Matrix4 matrixTranslate(Matrix4 matrix, Offset? translation) {
if (widget.disableTranslation || translation == Offset.zero) { if (widget.disableTranslation || translation == Offset.zero) {
return matrix; return matrix;
} }
...@@ -328,7 +321,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker ...@@ -328,7 +321,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker
-scale * viewportBoundaries.top, -scale * viewportBoundaries.top,
); );
final Matrix4 nextMatrix = matrix.clone()..translate( final Matrix4 nextMatrix = matrix.clone()..translate(
translation.dx, translation!.dx,
translation.dy, translation.dy,
); );
final Vector3 nextTranslationVector = nextMatrix.getTranslation(); final Vector3 nextTranslationVector = nextMatrix.getTranslation();
...@@ -350,7 +343,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker ...@@ -350,7 +343,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker
// Return a new matrix representing the given matrix after applying the given // Return a new matrix representing the given matrix after applying the given
// scale transform. // scale transform.
Matrix4 matrixScale(Matrix4 matrix, double scale) { Matrix4 matrixScale(Matrix4 matrix, double? scale) {
if (widget.disableScale || scale == 1) { if (widget.disableScale || scale == 1) {
return matrix; return matrix;
} }
...@@ -374,11 +367,11 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker ...@@ -374,11 +367,11 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker
// Don't allow a scale that results in an overall scale beyond min/max // Don't allow a scale that results in an overall scale beyond min/max
// scale. // scale.
final double currentScale = _transform.getMaxScaleOnAxis(); final double currentScale = _transform.getMaxScaleOnAxis();
final double totalScale = currentScale * scale; final double totalScale = currentScale * scale!;
final double clampedTotalScale = totalScale.clamp( final double clampedTotalScale = totalScale.clamp(
widget.minScale, widget.minScale,
widget.maxScale, widget.maxScale,
) as double; );
final double clampedScale = clampedTotalScale / currentScale; final double clampedScale = clampedTotalScale / currentScale;
return matrix..scale(clampedScale); return matrix..scale(clampedScale);
} }
...@@ -386,21 +379,21 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker ...@@ -386,21 +379,21 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker
// Return a new matrix representing the given matrix after applying the given // Return a new matrix representing the given matrix after applying the given
// rotation transform. // rotation transform.
// Rotating the scene cannot cause the viewport to view beyond _boundaryRect. // Rotating the scene cannot cause the viewport to view beyond _boundaryRect.
Matrix4 matrixRotate(Matrix4 matrix, double rotation, Offset focalPoint) { Matrix4 matrixRotate(Matrix4 matrix, double? rotation, Offset focalPoint) {
if (widget.disableRotation || rotation == 0) { if (widget.disableRotation || rotation == 0) {
return matrix; return matrix;
} }
final Offset focalPointScene = fromViewport(focalPoint, matrix); final Offset focalPointScene = fromViewport(focalPoint, matrix);
return matrix return matrix
..translate(focalPointScene.dx, focalPointScene.dy) ..translate(focalPointScene.dx, focalPointScene.dy)
..rotateZ(-rotation) ..rotateZ(-rotation!)
..translate(-focalPointScene.dx, -focalPointScene.dy); ..translate(-focalPointScene.dx, -focalPointScene.dy);
} }
// Handle the start of a gesture of _GestureType. // Handle the start of a gesture of _GestureType.
void _onScaleStart(ScaleStartDetails details) { void _onScaleStart(ScaleStartDetails details) {
if (widget.onScaleStart != null) { if (widget.onScaleStart != null) {
widget.onScaleStart(details); widget.onScaleStart!(details);
} }
if (_controller.isAnimating) { if (_controller.isAnimating) {
...@@ -425,7 +418,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker ...@@ -425,7 +418,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker
void _onScaleUpdate(ScaleUpdateDetails details) { void _onScaleUpdate(ScaleUpdateDetails details) {
double scale = _transform.getMaxScaleOnAxis(); double scale = _transform.getMaxScaleOnAxis();
if (widget.onScaleUpdate != null) { if (widget.onScaleUpdate != null) {
widget.onScaleUpdate(ScaleUpdateDetails( widget.onScaleUpdate!(ScaleUpdateDetails(
focalPoint: fromViewport(details.focalPoint, _transform), focalPoint: fromViewport(details.focalPoint, _transform),
scale: details.scale, scale: details.scale,
rotation: details.rotation, rotation: details.rotation,
...@@ -453,7 +446,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker ...@@ -453,7 +446,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker
// details.scale gives us the amount to change the scale as of the // details.scale gives us the amount to change the scale as of the
// start of this gesture, so calculate the amount to scale as of the // start of this gesture, so calculate the amount to scale as of the
// previous call to _onScaleUpdate. // previous call to _onScaleUpdate.
final double desiredScale = _scaleStart * details.scale; final double desiredScale = _scaleStart! * details.scale;
final double scaleChange = desiredScale / scale; final double scaleChange = desiredScale / scale;
_transform = matrixScale(_transform, scaleChange); _transform = matrixScale(_transform, scaleChange);
scale = _transform.getMaxScaleOnAxis(); scale = _transform.getMaxScaleOnAxis();
...@@ -468,13 +461,13 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker ...@@ -468,13 +461,13 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker
); );
_transform = matrixTranslate(_transform, focalPointSceneNext - focalPointScene); _transform = matrixTranslate(_transform, focalPointSceneNext - focalPointScene);
} else if (gestureType == _GestureType.rotate && details.rotation != 0.0) { } else if (gestureType == _GestureType.rotate && details.rotation != 0.0) {
final double desiredRotation = _rotationStart + details.rotation; final double desiredRotation = _rotationStart! + details.rotation;
_transform = matrixRotate(_transform, _currentRotation - desiredRotation, details.focalPoint); _transform = matrixRotate(_transform, _currentRotation - desiredRotation, details.focalPoint);
_currentRotation = desiredRotation; _currentRotation = desiredRotation;
} else if (_translateFromScene != null && details.scale == 1.0) { } else if (_translateFromScene != null && details.scale == 1.0) {
// Translate so that the same point in the scene is underneath the // Translate so that the same point in the scene is underneath the
// focal point before and after the movement. // focal point before and after the movement.
final Offset translationChange = focalPointScene - _translateFromScene; final Offset translationChange = focalPointScene - _translateFromScene!;
_transform = matrixTranslate(_transform, translationChange); _transform = matrixTranslate(_transform, translationChange);
_translateFromScene = fromViewport(details.focalPoint, _transform); _translateFromScene = fromViewport(details.focalPoint, _transform);
} }
...@@ -484,7 +477,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker ...@@ -484,7 +477,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker
// Handle the end of a gesture of _GestureType. // Handle the end of a gesture of _GestureType.
void _onScaleEnd(ScaleEndDetails details) { void _onScaleEnd(ScaleEndDetails details) {
if (widget.onScaleEnd != null) { if (widget.onScaleEnd != null) {
widget.onScaleEnd(details); widget.onScaleEnd!(details);
} }
setState(() { setState(() {
_scaleStart = null; _scaleStart = null;
...@@ -510,7 +503,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker ...@@ -510,7 +503,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker
end: inertialMotion.finalPosition, end: inertialMotion.finalPosition,
).animate(_controller); ).animate(_controller);
_controller.duration = Duration(milliseconds: inertialMotion.duration.toInt()); _controller.duration = Duration(milliseconds: inertialMotion.duration.toInt());
_animation.addListener(_onAnimate); _animation!.addListener(_onAnimate);
_controller.fling(); _controller.fling();
} }
...@@ -522,7 +515,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker ...@@ -522,7 +515,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker
final Vector3 translationVector = _transform.getTranslation(); final Vector3 translationVector = _transform.getTranslation();
final Offset translation = Offset(translationVector.x, translationVector.y); final Offset translation = Offset(translationVector.x, translationVector.y);
final Offset translationScene = fromViewport(translation, _transform); final Offset translationScene = fromViewport(translation, _transform);
final Offset animationScene = fromViewport(_animation.value, _transform); final Offset animationScene = fromViewport(_animation!.value, _transform);
final Offset translationChangeScene = animationScene - translationScene; final Offset translationChangeScene = animationScene - translationScene;
_transform = matrixTranslate(_transform, translationChangeScene); _transform = matrixTranslate(_transform, translationChangeScene);
}); });
...@@ -536,13 +529,13 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker ...@@ -536,13 +529,13 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker
// Handle reset to home transform animation. // Handle reset to home transform animation.
void _onAnimateReset() { void _onAnimateReset() {
setState(() { setState(() {
_transform = _animationReset.value; _transform = _animationReset!.value;
}); });
if (!_controllerReset.isAnimating) { if (!_controllerReset.isAnimating) {
_animationReset?.removeListener(_onAnimateReset); _animationReset?.removeListener(_onAnimateReset);
_animationReset = null; _animationReset = null;
_controllerReset.reset(); _controllerReset.reset();
widget.onResetEnd(); widget.onResetEnd!();
} }
} }
...@@ -554,7 +547,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker ...@@ -554,7 +547,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker
end: _initialTransform, end: _initialTransform,
).animate(_controllerReset); ).animate(_controllerReset);
_controllerReset.duration = const Duration(milliseconds: 400); _controllerReset.duration = const Duration(milliseconds: 400);
_animationReset.addListener(_onAnimateReset); _animationReset!.addListener(_onAnimateReset);
_controllerReset.forward(); _controllerReset.forward();
} }
...@@ -564,7 +557,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker ...@@ -564,7 +557,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker
_animationReset?.removeListener(_onAnimateReset); _animationReset?.removeListener(_onAnimateReset);
_animationReset = null; _animationReset = null;
_controllerReset.reset(); _controllerReset.reset();
widget.onResetEnd(); widget.onResetEnd!();
} }
@override @override
......
...@@ -60,7 +60,7 @@ class InertialMotion { ...@@ -60,7 +60,7 @@ class InertialMotion {
// Solve the equation of motion to find the position at a given point in time // Solve the equation of motion to find the position at a given point in time
// in one dimension. // in one dimension.
double _getPosition({double r0, double v0, int t, double a}) { double _getPosition({required double r0, required double v0, required int t, required double a}) {
// Stop movement when it would otherwise reverse direction. // Stop movement when it would otherwise reverse direction.
final double stopTime = (v0 / a).abs(); final double stopTime = (v0 / a).abs();
if (t > stopTime) { if (t > stopTime) {
......
...@@ -6,14 +6,11 @@ import 'package:flutter/material.dart'; ...@@ -6,14 +6,11 @@ import 'package:flutter/material.dart';
class TextStyleItem extends StatelessWidget { class TextStyleItem extends StatelessWidget {
const TextStyleItem({ const TextStyleItem({
Key key, Key? key,
@required this.name, required this.name,
@required this.style, required this.style,
@required this.text, required this.text,
}) : assert(name != null), }) : super(key: key);
assert(style != null),
assert(text != null),
super(key: key);
final String name; final String name;
final TextStyle style; final TextStyle style;
...@@ -22,7 +19,7 @@ class TextStyleItem extends StatelessWidget { ...@@ -22,7 +19,7 @@ class TextStyleItem extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
final TextStyle nameStyle = theme.textTheme.caption.copyWith(color: theme.textTheme.caption.color); final TextStyle nameStyle = theme.textTheme.caption!.copyWith(color: theme.textTheme.caption!.color);
return Padding( return Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 16.0), padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 16.0),
child: Row( child: Row(
...@@ -49,17 +46,17 @@ class TypographyDemo extends StatelessWidget { ...@@ -49,17 +46,17 @@ class TypographyDemo extends StatelessWidget {
final TextTheme textTheme = Theme.of(context).textTheme; final TextTheme textTheme = Theme.of(context).textTheme;
final List<Widget> styleItems = <Widget>[ final List<Widget> styleItems = <Widget>[
if (MediaQuery.of(context).size.width > 500.0) if (MediaQuery.of(context).size.width > 500.0)
TextStyleItem(name: 'Headline 1', style: textTheme.headline1, text: 'Light 112sp'), TextStyleItem(name: 'Headline 1', style: textTheme.headline1!, text: 'Light 112sp'),
TextStyleItem(name: 'Headline 2', style: textTheme.headline2, text: 'Regular 56sp'), TextStyleItem(name: 'Headline 2', style: textTheme.headline2!, text: 'Regular 56sp'),
TextStyleItem(name: 'Headline 3', style: textTheme.headline3, text: 'Regular 45sp'), TextStyleItem(name: 'Headline 3', style: textTheme.headline3!, text: 'Regular 45sp'),
TextStyleItem(name: 'Headline 4', style: textTheme.headline4, text: 'Regular 34sp'), TextStyleItem(name: 'Headline 4', style: textTheme.headline4!, text: 'Regular 34sp'),
TextStyleItem(name: 'Headline 5', style: textTheme.headline5, text: 'Regular 24sp'), TextStyleItem(name: 'Headline 5', style: textTheme.headline5!, text: 'Regular 24sp'),
TextStyleItem(name: 'Headline 6', style: textTheme.headline6, text: 'Medium 20sp'), TextStyleItem(name: 'Headline 6', style: textTheme.headline6!, text: 'Medium 20sp'),
TextStyleItem(name: 'Subtitle 1', style: textTheme.subtitle1, text: 'Regular 16sp'), TextStyleItem(name: 'Subtitle 1', style: textTheme.subtitle1!, text: 'Regular 16sp'),
TextStyleItem(name: 'Body 1', style: textTheme.bodyText1, text: 'Medium 14sp'), TextStyleItem(name: 'Body 1', style: textTheme.bodyText1!, text: 'Medium 14sp'),
TextStyleItem(name: 'Body 2', style: textTheme.bodyText2, text: 'Regular 14sp'), TextStyleItem(name: 'Body 2', style: textTheme.bodyText2!, text: 'Regular 14sp'),
TextStyleItem(name: 'Caption', style: textTheme.caption, text: 'Regular 12sp'), TextStyleItem(name: 'Caption', style: textTheme.caption!, text: 'Regular 12sp'),
TextStyleItem(name: 'Button', style: textTheme.button, text: 'MEDIUM (ALL CAPS) 14sp'), TextStyleItem(name: 'Button', style: textTheme.button!, text: 'MEDIUM (ALL CAPS) 14sp'),
]; ];
return Scaffold( return Scaffold(
......
...@@ -11,11 +11,11 @@ import 'package:video_player/video_player.dart'; ...@@ -11,11 +11,11 @@ import 'package:video_player/video_player.dart';
import 'package:device_info/device_info.dart'; import 'package:device_info/device_info.dart';
class VideoCard extends StatelessWidget { class VideoCard extends StatelessWidget {
const VideoCard({ Key key, this.controller, this.title, this.subtitle }) : super(key: key); const VideoCard({ Key? key, this.controller, this.title, this.subtitle }) : super(key: key);
final VideoPlayerController controller; final VideoPlayerController? controller;
final String title; final String? title;
final String subtitle; final String? subtitle;
Widget _buildInlineVideo() { Widget _buildInlineVideo() {
return Padding( return Padding(
...@@ -24,7 +24,7 @@ class VideoCard extends StatelessWidget { ...@@ -24,7 +24,7 @@ class VideoCard extends StatelessWidget {
child: AspectRatio( child: AspectRatio(
aspectRatio: 3 / 2, aspectRatio: 3 / 2,
child: Hero( child: Hero(
tag: controller, tag: controller!,
child: VideoPlayerLoading(controller), child: VideoPlayerLoading(controller),
), ),
), ),
...@@ -35,13 +35,13 @@ class VideoCard extends StatelessWidget { ...@@ -35,13 +35,13 @@ class VideoCard extends StatelessWidget {
Widget _buildFullScreenVideo() { Widget _buildFullScreenVideo() {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(title), title: Text(title!),
), ),
body: Center( body: Center(
child: AspectRatio( child: AspectRatio(
aspectRatio: 3 / 2, aspectRatio: 3 / 2,
child: Hero( child: Hero(
tag: controller, tag: controller!,
child: VideoPlayPause(controller), child: VideoPlayPause(controller),
), ),
), ),
...@@ -66,11 +66,11 @@ class VideoCard extends StatelessWidget { ...@@ -66,11 +66,11 @@ class VideoCard extends StatelessWidget {
); );
route.completed.then((void value) { route.completed.then((void value) {
controller.setVolume(0.0); controller!.setVolume(0.0);
}); });
controller.setVolume(1.0); controller!.setVolume(1.0);
Navigator.of(context).push(route); Navigator.of(context)!.push(route);
} }
return SafeArea( return SafeArea(
...@@ -79,7 +79,7 @@ class VideoCard extends StatelessWidget { ...@@ -79,7 +79,7 @@ class VideoCard extends StatelessWidget {
child: Card( child: Card(
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
ListTile(title: Text(title), subtitle: Text(subtitle)), ListTile(title: Text(title!), subtitle: Text(subtitle!)),
GestureDetector( GestureDetector(
onTap: pushFullScreenWidget, onTap: pushFullScreenWidget,
child: _buildInlineVideo(), child: _buildInlineVideo(),
...@@ -94,24 +94,24 @@ class VideoCard extends StatelessWidget { ...@@ -94,24 +94,24 @@ class VideoCard extends StatelessWidget {
class VideoPlayerLoading extends StatefulWidget { class VideoPlayerLoading extends StatefulWidget {
const VideoPlayerLoading(this.controller); const VideoPlayerLoading(this.controller);
final VideoPlayerController controller; final VideoPlayerController? controller;
@override @override
_VideoPlayerLoadingState createState() => _VideoPlayerLoadingState(); _VideoPlayerLoadingState createState() => _VideoPlayerLoadingState();
} }
class _VideoPlayerLoadingState extends State<VideoPlayerLoading> { class _VideoPlayerLoadingState extends State<VideoPlayerLoading> {
bool _initialized; bool? _initialized;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_initialized = widget.controller.value.isInitialized; _initialized = widget.controller!.value.isInitialized;
widget.controller.addListener(() { widget.controller!.addListener(() {
if (!mounted) { if (!mounted) {
return; return;
} }
final bool controllerInitialized = widget.controller.value.isInitialized; final bool controllerInitialized = widget.controller!.value.isInitialized;
if (_initialized != controllerInitialized) { if (_initialized != controllerInitialized) {
setState(() { setState(() {
_initialized = controllerInitialized; _initialized = controllerInitialized;
...@@ -122,12 +122,12 @@ class _VideoPlayerLoadingState extends State<VideoPlayerLoading> { ...@@ -122,12 +122,12 @@ class _VideoPlayerLoadingState extends State<VideoPlayerLoading> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (_initialized) { if (_initialized!) {
return VideoPlayer(widget.controller); return VideoPlayer(widget.controller!);
} }
return Stack( return Stack(
children: <Widget>[ children: <Widget>[
VideoPlayer(widget.controller), VideoPlayer(widget.controller!),
const Center(child: CircularProgressIndicator()), const Center(child: CircularProgressIndicator()),
], ],
fit: StackFit.expand, fit: StackFit.expand,
...@@ -138,7 +138,7 @@ class _VideoPlayerLoadingState extends State<VideoPlayerLoading> { ...@@ -138,7 +138,7 @@ class _VideoPlayerLoadingState extends State<VideoPlayerLoading> {
class VideoPlayPause extends StatefulWidget { class VideoPlayPause extends StatefulWidget {
const VideoPlayPause(this.controller); const VideoPlayPause(this.controller);
final VideoPlayerController controller; final VideoPlayerController? controller;
@override @override
State createState() => _VideoPlayPauseState(); State createState() => _VideoPlayPauseState();
...@@ -152,20 +152,20 @@ class _VideoPlayPauseState extends State<VideoPlayPause> { ...@@ -152,20 +152,20 @@ class _VideoPlayPauseState extends State<VideoPlayPause> {
}; };
} }
FadeAnimation imageFadeAnimation; FadeAnimation? imageFadeAnimation;
VoidCallback listener; late VoidCallback listener;
VideoPlayerController get controller => widget.controller; VideoPlayerController? get controller => widget.controller;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
controller.addListener(listener); controller!.addListener(listener);
} }
@override @override
void deactivate() { void deactivate() {
controller.removeListener(listener); controller!.removeListener(listener);
super.deactivate(); super.deactivate();
} }
...@@ -178,19 +178,19 @@ class _VideoPlayPauseState extends State<VideoPlayPause> { ...@@ -178,19 +178,19 @@ class _VideoPlayPauseState extends State<VideoPlayPause> {
GestureDetector( GestureDetector(
child: VideoPlayerLoading(controller), child: VideoPlayerLoading(controller),
onTap: () { onTap: () {
if (!controller.value.isInitialized) { if (!controller!.value.isInitialized) {
return; return;
} }
if (controller.value.isPlaying) { if (controller!.value.isPlaying) {
imageFadeAnimation = const FadeAnimation( imageFadeAnimation = const FadeAnimation(
child: Icon(Icons.pause, size: 100.0), child: Icon(Icons.pause, size: 100.0),
); );
controller.pause(); controller!.pause();
} else { } else {
imageFadeAnimation = const FadeAnimation( imageFadeAnimation = const FadeAnimation(
child: Icon(Icons.play_arrow, size: 100.0), child: Icon(Icons.play_arrow, size: 100.0),
); );
controller.play(); controller!.play();
} }
}, },
), ),
...@@ -206,7 +206,7 @@ class FadeAnimation extends StatefulWidget { ...@@ -206,7 +206,7 @@ class FadeAnimation extends StatefulWidget {
this.duration = const Duration(milliseconds: 500), this.duration = const Duration(milliseconds: 500),
}); });
final Widget child; final Widget? child;
final Duration duration; final Duration duration;
@override @override
...@@ -214,7 +214,7 @@ class FadeAnimation extends StatefulWidget { ...@@ -214,7 +214,7 @@ class FadeAnimation extends StatefulWidget {
} }
class _FadeAnimationState extends State<FadeAnimation> with SingleTickerProviderStateMixin { class _FadeAnimationState extends State<FadeAnimation> with SingleTickerProviderStateMixin {
AnimationController animationController; late AnimationController animationController;
@override @override
void initState() { void initState() {
...@@ -268,15 +268,15 @@ class ConnectivityOverlay extends StatefulWidget { ...@@ -268,15 +268,15 @@ class ConnectivityOverlay extends StatefulWidget {
this.connectedCompleter, this.connectedCompleter,
}); });
final Widget child; final Widget? child;
final Completer<void> connectedCompleter; final Completer<void>? connectedCompleter;
@override @override
_ConnectivityOverlayState createState() => _ConnectivityOverlayState(); _ConnectivityOverlayState createState() => _ConnectivityOverlayState();
} }
class _ConnectivityOverlayState extends State<ConnectivityOverlay> { class _ConnectivityOverlayState extends State<ConnectivityOverlay> {
StreamSubscription<ConnectivityResult> connectivitySubscription; StreamSubscription<ConnectivityResult>? connectivitySubscription;
bool connected = true; bool connected = true;
static const SnackBar errorSnackBar = SnackBar( static const SnackBar errorSnackBar = SnackBar(
...@@ -308,8 +308,8 @@ class _ConnectivityOverlayState extends State<ConnectivityOverlay> { ...@@ -308,8 +308,8 @@ class _ConnectivityOverlayState extends State<ConnectivityOverlay> {
// Assume connectivity // Assume connectivity
// TODO(ditman): Remove this shortcut when `connectivity` support for web // TODO(ditman): Remove this shortcut when `connectivity` support for web
// lands, https://github.com/flutter/flutter/issues/46735 // lands, https://github.com/flutter/flutter/issues/46735
if (!widget.connectedCompleter.isCompleted) { if (!widget.connectedCompleter!.isCompleted) {
widget.connectedCompleter.complete(null); widget.connectedCompleter!.complete();
} }
return; return;
} }
...@@ -321,8 +321,8 @@ class _ConnectivityOverlayState extends State<ConnectivityOverlay> { ...@@ -321,8 +321,8 @@ class _ConnectivityOverlayState extends State<ConnectivityOverlay> {
if (connectivityResult == ConnectivityResult.none) { if (connectivityResult == ConnectivityResult.none) {
ScaffoldMessenger.of(context).showSnackBar(errorSnackBar); ScaffoldMessenger.of(context).showSnackBar(errorSnackBar);
} else { } else {
if (!widget.connectedCompleter.isCompleted) { if (!widget.connectedCompleter!.isCompleted) {
widget.connectedCompleter.complete(null); widget.connectedCompleter!.complete();
} }
} }
}, },
...@@ -336,11 +336,11 @@ class _ConnectivityOverlayState extends State<ConnectivityOverlay> { ...@@ -336,11 +336,11 @@ class _ConnectivityOverlayState extends State<ConnectivityOverlay> {
} }
@override @override
Widget build(BuildContext context) => widget.child; Widget build(BuildContext context) => widget.child!;
} }
class VideoDemo extends StatefulWidget { class VideoDemo extends StatefulWidget {
const VideoDemo({ Key key }) : super(key: key); const VideoDemo({ Key? key }) : super(key: key);
static const String routeName = '/video'; static const String routeName = '/video';
...@@ -389,7 +389,7 @@ class _VideoDemoState extends State<VideoDemo> with SingleTickerProviderStateMix ...@@ -389,7 +389,7 @@ class _VideoDemoState extends State<VideoDemo> with SingleTickerProviderStateMix
initController(butterflyController, 'butterfly'); initController(butterflyController, 'butterfly');
initController(beeController, 'bee'); initController(beeController, 'bee');
isIOSSimulator().then<void>((bool result) { isIOSSimulator().then((bool result) {
isSupported = !result; isSupported = !result;
}); });
} }
......
...@@ -23,19 +23,19 @@ class _LinkTextSpan extends TextSpan { ...@@ -23,19 +23,19 @@ class _LinkTextSpan extends TextSpan {
// manage the recognizer from outside the TextSpan, e.g. in the State of a // manage the recognizer from outside the TextSpan, e.g. in the State of a
// stateful widget that then hands the recognizer to the TextSpan. // stateful widget that then hands the recognizer to the TextSpan.
_LinkTextSpan({ TextStyle style, String url, String text }) : super( _LinkTextSpan({ TextStyle? style, String? url, String? text }) : super(
style: style, style: style,
text: text ?? url, text: text ?? url,
recognizer: TapGestureRecognizer()..onTap = () { recognizer: TapGestureRecognizer()..onTap = () {
launch(url, forceSafariVC: false); launch(url!, forceSafariVC: false);
} }
); );
} }
void showGalleryAboutDialog(BuildContext context) { void showGalleryAboutDialog(BuildContext context) {
final ThemeData themeData = Theme.of(context); final ThemeData themeData = Theme.of(context);
final TextStyle aboutTextStyle = themeData.textTheme.bodyText1; final TextStyle? aboutTextStyle = themeData.textTheme.bodyText1;
final TextStyle linkStyle = themeData.textTheme.bodyText1.copyWith(color: themeData.accentColor); final TextStyle linkStyle = themeData.textTheme.bodyText1!.copyWith(color: themeData.accentColor);
showAboutDialog( showAboutDialog(
context: context, context: context,
......
...@@ -22,7 +22,7 @@ import 'updater.dart'; ...@@ -22,7 +22,7 @@ import 'updater.dart';
class GalleryApp extends StatefulWidget { class GalleryApp extends StatefulWidget {
const GalleryApp({ const GalleryApp({
Key key, Key? key,
this.updateUrlFetcher, this.updateUrlFetcher,
this.enablePerformanceOverlay = true, this.enablePerformanceOverlay = true,
this.enableRasterCacheImagesCheckerboard = true, this.enableRasterCacheImagesCheckerboard = true,
...@@ -31,11 +31,11 @@ class GalleryApp extends StatefulWidget { ...@@ -31,11 +31,11 @@ class GalleryApp extends StatefulWidget {
this.testMode = false, this.testMode = false,
}) : super(key: key); }) : super(key: key);
final UpdateUrlFetcher updateUrlFetcher; final UpdateUrlFetcher? updateUrlFetcher;
final bool enablePerformanceOverlay; final bool enablePerformanceOverlay;
final bool enableRasterCacheImagesCheckerboard; final bool enableRasterCacheImagesCheckerboard;
final bool enableOffscreenLayersCheckerboard; final bool enableOffscreenLayersCheckerboard;
final VoidCallback onSendFeedback; final VoidCallback? onSendFeedback;
final bool testMode; final bool testMode;
@override @override
...@@ -43,9 +43,9 @@ class GalleryApp extends StatefulWidget { ...@@ -43,9 +43,9 @@ class GalleryApp extends StatefulWidget {
} }
class _GalleryAppState extends State<GalleryApp> { class _GalleryAppState extends State<GalleryApp> {
GalleryOptions _options; GalleryOptions? _options;
Timer _timeDilationTimer; Timer? _timeDilationTimer;
AppStateModel model; late AppStateModel model;
Map<String, WidgetBuilder> _buildRoutes() { Map<String, WidgetBuilder> _buildRoutes() {
// For a different example of how to set up an application routing table // For a different example of how to set up an application routing table
...@@ -71,7 +71,7 @@ class _GalleryAppState extends State<GalleryApp> { ...@@ -71,7 +71,7 @@ class _GalleryAppState extends State<GalleryApp> {
@override @override
void reassemble() { void reassemble() {
_options = _options.copyWith(platform: defaultTargetPlatform); _options = _options!.copyWith(platform: defaultTargetPlatform);
super.reassemble(); super.reassemble();
} }
...@@ -84,7 +84,7 @@ class _GalleryAppState extends State<GalleryApp> { ...@@ -84,7 +84,7 @@ class _GalleryAppState extends State<GalleryApp> {
void _handleOptionsChanged(GalleryOptions newOptions) { void _handleOptionsChanged(GalleryOptions newOptions) {
setState(() { setState(() {
if (_options.timeDilation != newOptions.timeDilation) { if (_options!.timeDilation != newOptions.timeDilation) {
_timeDilationTimer?.cancel(); _timeDilationTimer?.cancel();
_timeDilationTimer = null; _timeDilationTimer = null;
if (newOptions.timeDilation > 1.0) { if (newOptions.timeDilation > 1.0) {
...@@ -108,7 +108,7 @@ class _GalleryAppState extends State<GalleryApp> { ...@@ -108,7 +108,7 @@ class _GalleryAppState extends State<GalleryApp> {
builder: (BuildContext context) { builder: (BuildContext context) {
return MediaQuery( return MediaQuery(
data: MediaQuery.of(context).copyWith( data: MediaQuery.of(context).copyWith(
textScaleFactor: _options.textScaleFactor.scale, textScaleFactor: _options!.textScaleFactor!.scale,
), ),
child: child, child: child,
); );
...@@ -131,7 +131,7 @@ class _GalleryAppState extends State<GalleryApp> { ...@@ -131,7 +131,7 @@ class _GalleryAppState extends State<GalleryApp> {
if (widget.updateUrlFetcher != null) { if (widget.updateUrlFetcher != null) {
home = Updater( home = Updater(
updateUrlFetcher: widget.updateUrlFetcher, updateUrlFetcher: widget.updateUrlFetcher!,
child: home, child: home,
); );
} }
...@@ -139,18 +139,18 @@ class _GalleryAppState extends State<GalleryApp> { ...@@ -139,18 +139,18 @@ class _GalleryAppState extends State<GalleryApp> {
return ScopedModel<AppStateModel>( return ScopedModel<AppStateModel>(
model: model, model: model,
child: MaterialApp( child: MaterialApp(
theme: kLightGalleryTheme.copyWith(platform: _options.platform, visualDensity: _options.visualDensity.visualDensity), theme: kLightGalleryTheme.copyWith(platform: _options!.platform, visualDensity: _options!.visualDensity!.visualDensity),
darkTheme: kDarkGalleryTheme.copyWith(platform: _options.platform, visualDensity: _options.visualDensity.visualDensity), darkTheme: kDarkGalleryTheme.copyWith(platform: _options!.platform, visualDensity: _options!.visualDensity!.visualDensity),
themeMode: _options.themeMode, themeMode: _options!.themeMode,
title: 'Flutter Gallery', title: 'Flutter Gallery',
color: Colors.grey, color: Colors.grey,
showPerformanceOverlay: _options.showPerformanceOverlay, showPerformanceOverlay: _options!.showPerformanceOverlay,
checkerboardOffscreenLayers: _options.showOffscreenLayersCheckerboard, checkerboardOffscreenLayers: _options!.showOffscreenLayersCheckerboard,
checkerboardRasterCacheImages: _options.showRasterCacheImagesCheckerboard, checkerboardRasterCacheImages: _options!.showRasterCacheImagesCheckerboard,
routes: _buildRoutes(), routes: _buildRoutes(),
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget? child) {
return Directionality( return Directionality(
textDirection: _options.textDirection, textDirection: _options!.textDirection,
child: _applyTextScaleFactor( child: _applyTextScaleFactor(
// Specifically use a blank Cupertino theme here and do not transfer // Specifically use a blank Cupertino theme here and do not transfer
// over the Material primary color etc except the brightness to // over the Material primary color etc except the brightness to
...@@ -160,7 +160,7 @@ class _GalleryAppState extends State<GalleryApp> { ...@@ -160,7 +160,7 @@ class _GalleryAppState extends State<GalleryApp> {
data: CupertinoThemeData( data: CupertinoThemeData(
brightness: Theme.of(context).brightness, brightness: Theme.of(context).brightness,
), ),
child: child, child: child!,
); );
}), }),
), ),
......
...@@ -26,37 +26,37 @@ final Animatable<BorderRadius> _kFrontHeadingBevelRadius = BorderRadiusTween( ...@@ -26,37 +26,37 @@ final Animatable<BorderRadius> _kFrontHeadingBevelRadius = BorderRadiusTween(
class _TappableWhileStatusIs extends StatefulWidget { class _TappableWhileStatusIs extends StatefulWidget {
const _TappableWhileStatusIs( const _TappableWhileStatusIs(
this.status, { this.status, {
Key key, Key? key,
this.controller, this.controller,
this.child, this.child,
}) : super(key: key); }) : super(key: key);
final AnimationController controller; final AnimationController? controller;
final AnimationStatus status; final AnimationStatus status;
final Widget child; final Widget? child;
@override @override
_TappableWhileStatusIsState createState() => _TappableWhileStatusIsState(); _TappableWhileStatusIsState createState() => _TappableWhileStatusIsState();
} }
class _TappableWhileStatusIsState extends State<_TappableWhileStatusIs> { class _TappableWhileStatusIsState extends State<_TappableWhileStatusIs> {
bool _active; bool? _active;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
widget.controller.addStatusListener(_handleStatusChange); widget.controller!.addStatusListener(_handleStatusChange);
_active = widget.controller.status == widget.status; _active = widget.controller!.status == widget.status;
} }
@override @override
void dispose() { void dispose() {
widget.controller.removeStatusListener(_handleStatusChange); widget.controller!.removeStatusListener(_handleStatusChange);
super.dispose(); super.dispose();
} }
void _handleStatusChange(AnimationStatus status) { void _handleStatusChange(AnimationStatus status) {
final bool value = widget.controller.status == widget.status; final bool value = widget.controller!.status == widget.status;
if (_active != value) { if (_active != value) {
setState(() { setState(() {
_active = value; _active = value;
...@@ -67,11 +67,11 @@ class _TappableWhileStatusIsState extends State<_TappableWhileStatusIs> { ...@@ -67,11 +67,11 @@ class _TappableWhileStatusIsState extends State<_TappableWhileStatusIs> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Widget child = AbsorbPointer( Widget child = AbsorbPointer(
absorbing: !_active, absorbing: !_active!,
child: widget.child, child: widget.child,
); );
if (!_active) { if (!_active!) {
child = FocusScope( child = FocusScope(
canRequestFocus: false, canRequestFocus: false,
debugLabel: '$_TappableWhileStatusIs', debugLabel: '$_TappableWhileStatusIs',
...@@ -84,16 +84,16 @@ class _TappableWhileStatusIsState extends State<_TappableWhileStatusIs> { ...@@ -84,16 +84,16 @@ class _TappableWhileStatusIsState extends State<_TappableWhileStatusIs> {
class _CrossFadeTransition extends AnimatedWidget { class _CrossFadeTransition extends AnimatedWidget {
const _CrossFadeTransition({ const _CrossFadeTransition({
Key key, Key? key,
this.alignment = Alignment.center, this.alignment = Alignment.center,
Animation<double> progress, required Animation<double> progress,
this.child0, this.child0,
this.child1, this.child1,
}) : super(key: key, listenable: progress); }) : super(key: key, listenable: progress);
final AlignmentGeometry alignment; final AlignmentGeometry alignment;
final Widget child0; final Widget? child0;
final Widget child1; final Widget? child1;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -135,15 +135,15 @@ class _CrossFadeTransition extends AnimatedWidget { ...@@ -135,15 +135,15 @@ class _CrossFadeTransition extends AnimatedWidget {
class _BackAppBar extends StatelessWidget { class _BackAppBar extends StatelessWidget {
const _BackAppBar({ const _BackAppBar({
Key key, Key? key,
this.leading = const SizedBox(width: 56.0), this.leading = const SizedBox(width: 56.0),
@required this.title, required this.title,
this.trailing, this.trailing,
}) : assert(leading != null), assert(title != null), super(key: key); }) : super(key: key);
final Widget leading; final Widget leading;
final Widget title; final Widget title;
final Widget trailing; final Widget? trailing;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -151,7 +151,7 @@ class _BackAppBar extends StatelessWidget { ...@@ -151,7 +151,7 @@ class _BackAppBar extends StatelessWidget {
return IconTheme.merge( return IconTheme.merge(
data: theme.primaryIconTheme, data: theme.primaryIconTheme,
child: DefaultTextStyle( child: DefaultTextStyle(
style: theme.primaryTextTheme.headline6, style: theme.primaryTextTheme.headline6!,
child: SizedBox( child: SizedBox(
height: _kBackAppBarHeight, height: _kBackAppBarHeight,
child: Row( child: Row(
...@@ -188,12 +188,12 @@ class Backdrop extends StatefulWidget { ...@@ -188,12 +188,12 @@ class Backdrop extends StatefulWidget {
this.backLayer, this.backLayer,
}); });
final Widget frontAction; final Widget? frontAction;
final Widget frontTitle; final Widget? frontTitle;
final Widget frontLayer; final Widget? frontLayer;
final Widget frontHeading; final Widget? frontHeading;
final Widget backTitle; final Widget? backTitle;
final Widget backLayer; final Widget? backLayer;
@override @override
_BackdropState createState() => _BackdropState(); _BackdropState createState() => _BackdropState();
...@@ -201,8 +201,8 @@ class Backdrop extends StatefulWidget { ...@@ -201,8 +201,8 @@ class Backdrop extends StatefulWidget {
class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin { class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin {
final GlobalKey _backdropKey = GlobalKey(debugLabel: 'Backdrop'); final GlobalKey _backdropKey = GlobalKey(debugLabel: 'Backdrop');
AnimationController _controller; AnimationController? _controller;
Animation<double> _frontOpacity; late Animation<double> _frontOpacity;
static final Animatable<double> _frontOpacityTween = Tween<double>(begin: 0.2, end: 1.0) static final Animatable<double> _frontOpacityTween = Tween<double>(begin: 0.2, end: 1.0)
.chain(CurveTween(curve: const Interval(0.0, 0.4, curve: Curves.easeInOut))); .chain(CurveTween(curve: const Interval(0.0, 0.4, curve: Curves.easeInOut)));
...@@ -215,7 +215,7 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin ...@@ -215,7 +215,7 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
value: 1.0, value: 1.0,
vsync: this, vsync: this,
); );
_controller.addStatusListener((AnimationStatus status) { _controller!.addStatusListener((AnimationStatus status) {
setState(() { setState(() {
// This is intentionally left empty. The state change itself takes // This is intentionally left empty. The state change itself takes
// place inside the AnimationController, so there's nothing to update. // place inside the AnimationController, so there's nothing to update.
...@@ -223,47 +223,47 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin ...@@ -223,47 +223,47 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
// state from the AnimationController. // state from the AnimationController.
}); });
}); });
_frontOpacity = _controller.drive(_frontOpacityTween); _frontOpacity = _controller!.drive(_frontOpacityTween);
} }
@override @override
void dispose() { void dispose() {
_controller.dispose(); _controller!.dispose();
super.dispose(); super.dispose();
} }
double get _backdropHeight { double get _backdropHeight {
// Warning: this can be safely called from the event handlers but it may // Warning: this can be safely called from the event handlers but it may
// not be called at build time. // not be called at build time.
final RenderBox renderBox = _backdropKey.currentContext.findRenderObject() as RenderBox; final RenderBox renderBox = _backdropKey.currentContext!.findRenderObject()! as RenderBox;
return math.max(0.0, renderBox.size.height - _kBackAppBarHeight - _kFrontClosedHeight); return math.max(0.0, renderBox.size.height - _kBackAppBarHeight - _kFrontClosedHeight);
} }
void _handleDragUpdate(DragUpdateDetails details) { void _handleDragUpdate(DragUpdateDetails details) {
_controller.value -= details.primaryDelta / (_backdropHeight ?? details.primaryDelta); _controller!.value -= details.primaryDelta! / _backdropHeight;
} }
void _handleDragEnd(DragEndDetails details) { void _handleDragEnd(DragEndDetails details) {
if (_controller.isAnimating || _controller.status == AnimationStatus.completed) if (_controller!.isAnimating || _controller!.status == AnimationStatus.completed)
return; return;
final double flingVelocity = details.velocity.pixelsPerSecond.dy / _backdropHeight; final double flingVelocity = details.velocity.pixelsPerSecond.dy / _backdropHeight;
if (flingVelocity < 0.0) if (flingVelocity < 0.0)
_controller.fling(velocity: math.max(2.0, -flingVelocity)); _controller!.fling(velocity: math.max(2.0, -flingVelocity));
else if (flingVelocity > 0.0) else if (flingVelocity > 0.0)
_controller.fling(velocity: math.min(-2.0, -flingVelocity)); _controller!.fling(velocity: math.min(-2.0, -flingVelocity));
else else
_controller.fling(velocity: _controller.value < 0.5 ? -2.0 : 2.0); _controller!.fling(velocity: _controller!.value < 0.5 ? -2.0 : 2.0);
} }
void _toggleFrontLayer() { void _toggleFrontLayer() {
final AnimationStatus status = _controller.status; final AnimationStatus status = _controller!.status;
final bool isOpen = status == AnimationStatus.completed || status == AnimationStatus.forward; final bool isOpen = status == AnimationStatus.completed || status == AnimationStatus.forward;
_controller.fling(velocity: isOpen ? -2.0 : 2.0); _controller!.fling(velocity: isOpen ? -2.0 : 2.0);
} }
Widget _buildStack(BuildContext context, BoxConstraints constraints) { Widget _buildStack(BuildContext context, BoxConstraints constraints) {
final Animation<RelativeRect> frontRelativeRect = _controller.drive(RelativeRectTween( final Animation<RelativeRect> frontRelativeRect = _controller!.drive(RelativeRectTween(
begin: RelativeRect.fromLTRB(0.0, constraints.biggest.height - _kFrontClosedHeight, 0.0, 0.0), begin: RelativeRect.fromLTRB(0.0, constraints.biggest.height - _kFrontClosedHeight, 0.0, 0.0),
end: const RelativeRect.fromLTRB(0.0, _kBackAppBarHeight, 0.0, 0.0), end: const RelativeRect.fromLTRB(0.0, _kBackAppBarHeight, 0.0, 0.0),
)); ));
...@@ -275,9 +275,9 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin ...@@ -275,9 +275,9 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[ children: <Widget>[
_BackAppBar( _BackAppBar(
leading: widget.frontAction, leading: widget.frontAction!,
title: _CrossFadeTransition( title: _CrossFadeTransition(
progress: _controller, progress: _controller!,
alignment: AlignmentDirectional.centerStart, alignment: AlignmentDirectional.centerStart,
child0: Semantics(namesRoute: true, child: widget.frontTitle), child0: Semantics(namesRoute: true, child: widget.frontTitle),
child1: Semantics(namesRoute: true, child: widget.backTitle), child1: Semantics(namesRoute: true, child: widget.backTitle),
...@@ -287,7 +287,7 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin ...@@ -287,7 +287,7 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
tooltip: 'Toggle options page', tooltip: 'Toggle options page',
icon: AnimatedIcon( icon: AnimatedIcon(
icon: AnimatedIcons.close_menu, icon: AnimatedIcons.close_menu,
progress: _controller, progress: _controller!,
), ),
), ),
), ),
...@@ -296,8 +296,8 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin ...@@ -296,8 +296,8 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
AnimationStatus.dismissed, AnimationStatus.dismissed,
controller: _controller, controller: _controller,
child: Visibility( child: Visibility(
child: widget.backLayer, child: widget.backLayer!,
visible: _controller.status != AnimationStatus.completed, visible: _controller!.status != AnimationStatus.completed,
maintainState: true, maintainState: true,
), ),
), ),
...@@ -308,14 +308,14 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin ...@@ -308,14 +308,14 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
PositionedTransition( PositionedTransition(
rect: frontRelativeRect, rect: frontRelativeRect,
child: AnimatedBuilder( child: AnimatedBuilder(
animation: _controller, animation: _controller!,
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget? child) {
return PhysicalShape( return PhysicalShape(
elevation: 12.0, elevation: 12.0,
color: Theme.of(context).canvasColor, color: Theme.of(context).canvasColor,
clipper: ShapeBorderClipper( clipper: ShapeBorderClipper(
shape: BeveledRectangleBorder( shape: BeveledRectangleBorder(
borderRadius: _kFrontHeadingBevelRadius.transform(_controller.value), borderRadius: _kFrontHeadingBevelRadius.transform(_controller!.value),
), ),
), ),
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
......
...@@ -20,11 +20,11 @@ class ComponentDemoTabData { ...@@ -20,11 +20,11 @@ class ComponentDemoTabData {
this.documentationUrl, this.documentationUrl,
}); });
final Widget demoWidget; final Widget? demoWidget;
final String exampleCodeTag; final String? exampleCodeTag;
final String description; final String? description;
final String tabName; final String? tabName;
final String documentationUrl; final String? documentationUrl;
@override @override
bool operator==(Object other) { bool operator==(Object other) {
...@@ -49,14 +49,14 @@ class TabbedComponentDemoScaffold extends StatelessWidget { ...@@ -49,14 +49,14 @@ class TabbedComponentDemoScaffold extends StatelessWidget {
this.showExampleCodeAction = true, this.showExampleCodeAction = true,
}); });
final List<ComponentDemoTabData> demos; final List<ComponentDemoTabData>? demos;
final String title; final String? title;
final List<Widget> actions; final List<Widget>? actions;
final bool isScrollable; final bool isScrollable;
final bool showExampleCodeAction; final bool showExampleCodeAction;
void _showExampleCode(BuildContext context) { void _showExampleCode(BuildContext context) {
final String tag = demos[DefaultTabController.of(context).index].exampleCodeTag; final String? tag = demos![DefaultTabController.of(context)!.index].exampleCodeTag;
if (tag != null) { if (tag != null) {
Navigator.push(context, MaterialPageRoute<FullScreenCodeDialog>( Navigator.push(context, MaterialPageRoute<FullScreenCodeDialog>(
builder: (BuildContext context) => FullScreenCodeDialog(exampleCodeTag: tag) builder: (BuildContext context) => FullScreenCodeDialog(exampleCodeTag: tag)
...@@ -65,7 +65,7 @@ class TabbedComponentDemoScaffold extends StatelessWidget { ...@@ -65,7 +65,7 @@ class TabbedComponentDemoScaffold extends StatelessWidget {
} }
Future<void> _showApiDocumentation(BuildContext context) async { Future<void> _showApiDocumentation(BuildContext context) async {
final String url = demos[DefaultTabController.of(context).index].documentationUrl; final String? url = demos![DefaultTabController.of(context)!.index].documentationUrl;
if (url == null) if (url == null)
return; return;
...@@ -92,10 +92,10 @@ class TabbedComponentDemoScaffold extends StatelessWidget { ...@@ -92,10 +92,10 @@ class TabbedComponentDemoScaffold extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return DefaultTabController( return DefaultTabController(
length: demos.length, length: demos!.length,
child: Scaffold( child: Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(title), title: Text(title!),
actions: <Widget>[ actions: <Widget>[
...?actions, ...?actions,
Builder( Builder(
...@@ -119,11 +119,11 @@ class TabbedComponentDemoScaffold extends StatelessWidget { ...@@ -119,11 +119,11 @@ class TabbedComponentDemoScaffold extends StatelessWidget {
], ],
bottom: TabBar( bottom: TabBar(
isScrollable: isScrollable, isScrollable: isScrollable,
tabs: demos.map<Widget>((ComponentDemoTabData data) => Tab(text: data.tabName)).toList(), tabs: demos!.map<Widget>((ComponentDemoTabData data) => Tab(text: data.tabName)).toList(),
), ),
), ),
body: TabBarView( body: TabBarView(
children: demos.map<Widget>((ComponentDemoTabData demo) { children: demos!.map<Widget>((ComponentDemoTabData demo) {
return SafeArea( return SafeArea(
top: false, top: false,
bottom: false, bottom: false,
...@@ -131,11 +131,11 @@ class TabbedComponentDemoScaffold extends StatelessWidget { ...@@ -131,11 +131,11 @@ class TabbedComponentDemoScaffold extends StatelessWidget {
children: <Widget>[ children: <Widget>[
Padding( Padding(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
child: Text(demo.description, child: Text(demo.description!,
style: Theme.of(context).textTheme.subtitle1, style: Theme.of(context).textTheme.subtitle1,
), ),
), ),
Expanded(child: demo.demoWidget), Expanded(child: demo.demoWidget!),
], ],
), ),
); );
...@@ -149,7 +149,7 @@ class TabbedComponentDemoScaffold extends StatelessWidget { ...@@ -149,7 +149,7 @@ class TabbedComponentDemoScaffold extends StatelessWidget {
class FullScreenCodeDialog extends StatefulWidget { class FullScreenCodeDialog extends StatefulWidget {
const FullScreenCodeDialog({ this.exampleCodeTag }); const FullScreenCodeDialog({ this.exampleCodeTag });
final String exampleCodeTag; final String? exampleCodeTag;
@override @override
FullScreenCodeDialogState createState() => FullScreenCodeDialogState(); FullScreenCodeDialogState createState() => FullScreenCodeDialogState();
...@@ -157,11 +157,11 @@ class FullScreenCodeDialog extends StatefulWidget { ...@@ -157,11 +157,11 @@ class FullScreenCodeDialog extends StatefulWidget {
class FullScreenCodeDialogState extends State<FullScreenCodeDialog> { class FullScreenCodeDialogState extends State<FullScreenCodeDialog> {
String _exampleCode; String? _exampleCode;
@override @override
void didChangeDependencies() { void didChangeDependencies() {
getExampleCode(widget.exampleCodeTag, DefaultAssetBundle.of(context)).then<void>((String code) { getExampleCode(widget.exampleCodeTag, DefaultAssetBundle.of(context)).then((String? code) {
if (mounted) { if (mounted) {
setState(() { setState(() {
_exampleCode = code ?? 'Example code not found'; _exampleCode = code ?? 'Example code not found';
...@@ -215,7 +215,7 @@ class FullScreenCodeDialogState extends State<FullScreenCodeDialog> { ...@@ -215,7 +215,7 @@ class FullScreenCodeDialogState extends State<FullScreenCodeDialog> {
} }
class MaterialDemoDocumentationButton extends StatelessWidget { class MaterialDemoDocumentationButton extends StatelessWidget {
MaterialDemoDocumentationButton(String routeName, { Key key }) MaterialDemoDocumentationButton(String routeName, { Key? key })
: documentationUrl = kDemoDocumentationUrl[routeName], : documentationUrl = kDemoDocumentationUrl[routeName],
assert( assert(
kDemoDocumentationUrl[routeName] != null, kDemoDocumentationUrl[routeName] != null,
...@@ -223,20 +223,20 @@ class MaterialDemoDocumentationButton extends StatelessWidget { ...@@ -223,20 +223,20 @@ class MaterialDemoDocumentationButton extends StatelessWidget {
), ),
super(key: key); super(key: key);
final String documentationUrl; final String? documentationUrl;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return IconButton( return IconButton(
icon: const Icon(Icons.library_books), icon: const Icon(Icons.library_books),
tooltip: 'API documentation', tooltip: 'API documentation',
onPressed: () => launch(documentationUrl, forceWebView: true), onPressed: () => launch(documentationUrl!, forceWebView: true),
); );
} }
} }
class CupertinoDemoDocumentationButton extends StatelessWidget { class CupertinoDemoDocumentationButton extends StatelessWidget {
CupertinoDemoDocumentationButton(String routeName, { Key key }) CupertinoDemoDocumentationButton(String routeName, { Key? key })
: documentationUrl = kDemoDocumentationUrl[routeName], : documentationUrl = kDemoDocumentationUrl[routeName],
assert( assert(
kDemoDocumentationUrl[routeName] != null, kDemoDocumentationUrl[routeName] != null,
...@@ -244,7 +244,7 @@ class CupertinoDemoDocumentationButton extends StatelessWidget { ...@@ -244,7 +244,7 @@ class CupertinoDemoDocumentationButton extends StatelessWidget {
), ),
super(key: key); super(key: key);
final String documentationUrl; final String? documentationUrl;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -254,7 +254,7 @@ class CupertinoDemoDocumentationButton extends StatelessWidget { ...@@ -254,7 +254,7 @@ class CupertinoDemoDocumentationButton extends StatelessWidget {
label: 'API documentation', label: 'API documentation',
child: const Icon(CupertinoIcons.book), child: const Icon(CupertinoIcons.book),
), ),
onPressed: () => launch(documentationUrl, forceWebView: true), onPressed: () => launch(documentationUrl!, forceWebView: true),
); );
} }
} }
...@@ -10,8 +10,8 @@ import 'icons.dart'; ...@@ -10,8 +10,8 @@ import 'icons.dart';
@immutable @immutable
class GalleryDemoCategory { class GalleryDemoCategory {
const GalleryDemoCategory._({ const GalleryDemoCategory._({
@required this.name, required this.name,
@required this.icon, required this.icon,
}); });
final String name; final String name;
...@@ -64,25 +64,22 @@ const GalleryDemoCategory _kMedia = GalleryDemoCategory._( ...@@ -64,25 +64,22 @@ const GalleryDemoCategory _kMedia = GalleryDemoCategory._(
class GalleryDemo { class GalleryDemo {
const GalleryDemo({ const GalleryDemo({
@required this.title, required this.title,
@required this.icon, required this.icon,
this.subtitle, this.subtitle,
@required this.category, required this.category,
@required this.routeName, required this.routeName,
this.documentationUrl, this.documentationUrl,
@required this.buildRoute, required this.buildRoute,
}) : assert(title != null), });
assert(category != null),
assert(routeName != null),
assert(buildRoute != null);
final String title; final String title;
final IconData icon; final IconData icon;
final String subtitle; final String? subtitle;
final GalleryDemoCategory category; final GalleryDemoCategory category;
final String routeName; final String routeName;
final WidgetBuilder buildRoute; final WidgetBuilder buildRoute;
final String documentationUrl; final String? documentationUrl;
@override @override
String toString() { String toString() {
...@@ -581,7 +578,7 @@ final Map<GalleryDemoCategory, List<GalleryDemo>> kGalleryCategoryToDemos = ...@@ -581,7 +578,7 @@ final Map<GalleryDemoCategory, List<GalleryDemo>> kGalleryCategoryToDemos =
}, },
); );
final Map<String, String> kDemoDocumentationUrl = <String, String>{ final Map<String, String?> kDemoDocumentationUrl = <String, String?>{
for (final GalleryDemo demo in kAllGalleryDemos) for (final GalleryDemo demo in kAllGalleryDemos)
if (demo.documentationUrl != null) demo.routeName: demo.documentationUrl, if (demo.documentationUrl != null) demo.routeName: demo.documentationUrl,
}; };
...@@ -9,7 +9,7 @@ import 'package:flutter/material.dart'; ...@@ -9,7 +9,7 @@ import 'package:flutter/material.dart';
class ButtonsDemo { class ButtonsDemo {
void setState(VoidCallback callback) { } void setState(VoidCallback callback) { }
BuildContext context; late BuildContext context;
void buttons() { void buttons() {
...@@ -90,12 +90,12 @@ const TextButton( ...@@ -90,12 +90,12 @@ const TextButton(
// START buttons_dropdown // START buttons_dropdown
// Member variable holding value. // Member variable holding value.
String dropdownValue; String? dropdownValue;
// Dropdown button with string values. // Dropdown button with string values.
DropdownButton<String>( DropdownButton<String>(
value: dropdownValue, value: dropdownValue,
onChanged: (String newValue) { onChanged: (String? newValue) {
// null indicates the user didn't select a // null indicates the user didn't select a
// new value. // new value.
setState(() { setState(() {
...@@ -116,7 +116,7 @@ DropdownButton<String>( ...@@ -116,7 +116,7 @@ DropdownButton<String>(
// START buttons_icon // START buttons_icon
// Member variable holding toggle value. // Member variable holding toggle value.
bool value; late bool value;
// Toggleable icon button. // Toggleable icon button.
IconButton( IconButton(
...@@ -152,12 +152,12 @@ class SelectionControls { ...@@ -152,12 +152,12 @@ class SelectionControls {
// START selectioncontrols_checkbox // START selectioncontrols_checkbox
// Member variable holding the checkbox's value. // Member variable holding the checkbox's value.
bool checkboxValue = false; bool? checkboxValue = false;
// Create a checkbox. // Create a checkbox.
Checkbox( Checkbox(
value: checkboxValue, value: checkboxValue,
onChanged: (bool value) { onChanged: (bool? value) {
setState(() { setState(() {
checkboxValue = value; checkboxValue = value;
}); });
...@@ -168,7 +168,7 @@ Checkbox( ...@@ -168,7 +168,7 @@ Checkbox(
Checkbox( Checkbox(
tristate: true, tristate: true,
value: checkboxValue, value: checkboxValue,
onChanged: (bool value) { onChanged: (bool? value) {
setState(() { setState(() {
checkboxValue = value; checkboxValue = value;
}); });
...@@ -184,10 +184,10 @@ const Checkbox(value: false, onChanged: null); ...@@ -184,10 +184,10 @@ const Checkbox(value: false, onChanged: null);
// START selectioncontrols_radio // START selectioncontrols_radio
// Member variable holding value. // Member variable holding value.
int radioValue = 0; int? radioValue = 0;
// Method setting value. // Method setting value.
void handleRadioValueChanged(int value) { void handleRadioValueChanged(int? value) {
setState(() { setState(() {
radioValue = value; radioValue = value;
}); });
......
...@@ -7,23 +7,22 @@ import 'package:flutter/services.dart'; ...@@ -7,23 +7,22 @@ import 'package:flutter/services.dart';
const String _kStartTag = '// START '; const String _kStartTag = '// START ';
const String _kEndTag = '// END'; const String _kEndTag = '// END';
Map<String, String> _exampleCode; Map<String?, String>? _exampleCode;
Future<String> getExampleCode(String tag, AssetBundle bundle) async { Future<String?> getExampleCode(String? tag, AssetBundle bundle) async {
if (_exampleCode == null) if (_exampleCode == null)
await _parseExampleCode(bundle); await _parseExampleCode(bundle);
return _exampleCode[tag]; return _exampleCode![tag];
} }
Future<void> _parseExampleCode(AssetBundle bundle) async { Future<void> _parseExampleCode(AssetBundle bundle) async {
final String code = await bundle.loadString('lib/gallery/example_code.dart') ?? final String code = await bundle.loadString('lib/gallery/example_code.dart');
'// lib/gallery/example_code.dart not found\n'; _exampleCode = <String?, String>{};
_exampleCode = <String, String>{};
final List<String> lines = code.split('\n'); final List<String> lines = code.split('\n');
List<String> codeBlock; List<String>? codeBlock;
String codeTag; String? codeTag;
for (final String line in lines) { for (final String line in lines) {
if (codeBlock == null) { if (codeBlock == null) {
...@@ -39,7 +38,7 @@ Future<void> _parseExampleCode(AssetBundle bundle) async { ...@@ -39,7 +38,7 @@ Future<void> _parseExampleCode(AssetBundle bundle) async {
// Inside a block. // Inside a block.
if (line.startsWith(_kEndTag)) { if (line.startsWith(_kEndTag)) {
// Add the block. // Add the block.
_exampleCode[codeTag] = codeBlock.join('\n'); _exampleCode![codeTag] = codeBlock.join('\n');
codeBlock = null; codeBlock = null;
codeTag = null; codeTag = null;
} else { } else {
......
...@@ -18,7 +18,7 @@ const double _kDemoItemHeight = 64.0; ...@@ -18,7 +18,7 @@ const double _kDemoItemHeight = 64.0;
const Duration _kFrontLayerSwitchDuration = Duration(milliseconds: 300); const Duration _kFrontLayerSwitchDuration = Duration(milliseconds: 300);
class _FlutterLogo extends StatelessWidget { class _FlutterLogo extends StatelessWidget {
const _FlutterLogo({ Key key }) : super(key: key); const _FlutterLogo({ Key? key }) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -41,13 +41,13 @@ class _FlutterLogo extends StatelessWidget { ...@@ -41,13 +41,13 @@ class _FlutterLogo extends StatelessWidget {
class _CategoryItem extends StatelessWidget { class _CategoryItem extends StatelessWidget {
const _CategoryItem({ const _CategoryItem({
Key key, Key? key,
this.category, this.category,
this.onTap, this.onTap,
}) : super (key: key); }) : super (key: key);
final GalleryDemoCategory category; final GalleryDemoCategory? category;
final VoidCallback onTap; final VoidCallback? onTap;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -70,7 +70,7 @@ class _CategoryItem extends StatelessWidget { ...@@ -70,7 +70,7 @@ class _CategoryItem extends StatelessWidget {
Padding( Padding(
padding: const EdgeInsets.all(6.0), padding: const EdgeInsets.all(6.0),
child: Icon( child: Icon(
category.icon, category!.icon,
size: 60.0, size: 60.0,
color: isDark ? Colors.white : _kFlutterBlue, color: isDark ? Colors.white : _kFlutterBlue,
), ),
...@@ -80,9 +80,9 @@ class _CategoryItem extends StatelessWidget { ...@@ -80,9 +80,9 @@ class _CategoryItem extends StatelessWidget {
height: 48.0, height: 48.0,
alignment: Alignment.center, alignment: Alignment.center,
child: Text( child: Text(
category.name, category!.name,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: theme.textTheme.subtitle1.copyWith( style: theme.textTheme.subtitle1!.copyWith(
fontFamily: 'GoogleSans', fontFamily: 'GoogleSans',
color: isDark ? Colors.white : _kFlutterBlue, color: isDark ? Colors.white : _kFlutterBlue,
), ),
...@@ -97,18 +97,18 @@ class _CategoryItem extends StatelessWidget { ...@@ -97,18 +97,18 @@ class _CategoryItem extends StatelessWidget {
class _CategoriesPage extends StatelessWidget { class _CategoriesPage extends StatelessWidget {
const _CategoriesPage({ const _CategoriesPage({
Key key, Key? key,
this.categories, this.categories,
this.onCategoryTap, this.onCategoryTap,
}) : super(key: key); }) : super(key: key);
final Iterable<GalleryDemoCategory> categories; final Iterable<GalleryDemoCategory>? categories;
final ValueChanged<GalleryDemoCategory> onCategoryTap; final ValueChanged<GalleryDemoCategory>? onCategoryTap;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
const double aspectRatio = 160.0 / 180.0; const double aspectRatio = 160.0 / 180.0;
final List<GalleryDemoCategory> categoriesList = categories.toList(); final List<GalleryDemoCategory> categoriesList = categories!.toList();
final int columnCount = (MediaQuery.of(context).orientation == Orientation.portrait) ? 2 : 3; final int columnCount = (MediaQuery.of(context).orientation == Orientation.portrait) ? 2 : 3;
return Semantics( return Semantics(
...@@ -122,7 +122,7 @@ class _CategoriesPage extends StatelessWidget { ...@@ -122,7 +122,7 @@ class _CategoriesPage extends StatelessWidget {
builder: (BuildContext context, BoxConstraints constraints) { builder: (BuildContext context, BoxConstraints constraints) {
final double columnWidth = constraints.biggest.width / columnCount.toDouble(); final double columnWidth = constraints.biggest.width / columnCount.toDouble();
final double rowHeight = math.min(225.0, columnWidth * aspectRatio); final double rowHeight = math.min(225.0, columnWidth * aspectRatio);
final int rowCount = (categories.length + columnCount - 1) ~/ columnCount; final int rowCount = (categories!.length + columnCount - 1) ~/ columnCount;
// This repaint boundary prevents the inner contents of the front layer // This repaint boundary prevents the inner contents of the front layer
// from repainting when the backdrop toggle triggers a repaint on the // from repainting when the backdrop toggle triggers a repaint on the
...@@ -133,7 +133,7 @@ class _CategoriesPage extends StatelessWidget { ...@@ -133,7 +133,7 @@ class _CategoriesPage extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: List<Widget>.generate(rowCount, (int rowIndex) { children: List<Widget>.generate(rowCount, (int rowIndex) {
final int columnCountForRow = rowIndex == rowCount - 1 final int columnCountForRow = rowIndex == rowCount - 1
? categories.length - columnCount * math.max<int>(0, rowCount - 1) ? categories!.length - columnCount * math.max<int>(0, rowCount - 1)
: columnCount; : columnCount;
return Row( return Row(
...@@ -147,7 +147,7 @@ class _CategoriesPage extends StatelessWidget { ...@@ -147,7 +147,7 @@ class _CategoriesPage extends StatelessWidget {
child: _CategoryItem( child: _CategoryItem(
category: category, category: category,
onTap: () { onTap: () {
onCategoryTap(category); onCategoryTap!(category);
}, },
), ),
); );
...@@ -164,17 +164,17 @@ class _CategoriesPage extends StatelessWidget { ...@@ -164,17 +164,17 @@ class _CategoriesPage extends StatelessWidget {
} }
class _DemoItem extends StatelessWidget { class _DemoItem extends StatelessWidget {
const _DemoItem({ Key key, this.demo }) : super(key: key); const _DemoItem({ Key? key, this.demo }) : super(key: key);
final GalleryDemo demo; final GalleryDemo? demo;
void _launchDemo(BuildContext context) { void _launchDemo(BuildContext context) {
if (demo.routeName != null) { if (demo != null) {
Timeline.instantSync('Start Transition', arguments: <String, String>{ Timeline.instantSync('Start Transition', arguments: <String, String>{
'from': '/', 'from': '/',
'to': demo.routeName, 'to': demo!.routeName,
}); });
Navigator.pushNamed(context, demo.routeName); Navigator.pushNamed(context, demo!.routeName);
} }
} }
...@@ -199,7 +199,7 @@ class _DemoItem extends StatelessWidget { ...@@ -199,7 +199,7 @@ class _DemoItem extends StatelessWidget {
height: 56.0, height: 56.0,
alignment: Alignment.center, alignment: Alignment.center,
child: Icon( child: Icon(
demo.icon, demo!.icon,
size: 24.0, size: 24.0,
color: isDark ? Colors.white : _kFlutterBlue, color: isDark ? Colors.white : _kFlutterBlue,
), ),
...@@ -210,15 +210,15 @@ class _DemoItem extends StatelessWidget { ...@@ -210,15 +210,15 @@ class _DemoItem extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[ children: <Widget>[
Text( Text(
demo.title, demo!.title,
style: theme.textTheme.subtitle1.copyWith( style: theme.textTheme.subtitle1!.copyWith(
color: isDark ? Colors.white : const Color(0xFF202124), color: isDark ? Colors.white : const Color(0xFF202124),
), ),
), ),
if (demo.subtitle != null) if (demo!.subtitle != null)
Text( Text(
demo.subtitle, demo!.subtitle!,
style: theme.textTheme.bodyText2.copyWith( style: theme.textTheme.bodyText2!.copyWith(
color: isDark ? Colors.white : const Color(0xFF60646B) color: isDark ? Colors.white : const Color(0xFF60646B)
), ),
), ),
...@@ -236,7 +236,7 @@ class _DemoItem extends StatelessWidget { ...@@ -236,7 +236,7 @@ class _DemoItem extends StatelessWidget {
class _DemosPage extends StatelessWidget { class _DemosPage extends StatelessWidget {
const _DemosPage(this.category); const _DemosPage(this.category);
final GalleryDemoCategory category; final GalleryDemoCategory? category;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -248,13 +248,13 @@ class _DemosPage extends StatelessWidget { ...@@ -248,13 +248,13 @@ class _DemosPage extends StatelessWidget {
child: Semantics( child: Semantics(
scopesRoute: true, scopesRoute: true,
namesRoute: true, namesRoute: true,
label: category.name, label: category!.name,
explicitChildNodes: true, explicitChildNodes: true,
child: ListView( child: ListView(
dragStartBehavior: DragStartBehavior.down, dragStartBehavior: DragStartBehavior.down,
key: PageStorageKey<String>(category.name), key: PageStorageKey<String>(category!.name),
padding: EdgeInsets.only(top: 8.0, bottom: windowBottomPadding), padding: EdgeInsets.only(top: 8.0, bottom: windowBottomPadding),
children: kGalleryCategoryToDemos[category].map<Widget>((GalleryDemo demo) { children: kGalleryCategoryToDemos[category!]!.map<Widget>((GalleryDemo demo) {
return _DemoItem(demo: demo); return _DemoItem(demo: demo);
}).toList(), }).toList(),
), ),
...@@ -265,12 +265,12 @@ class _DemosPage extends StatelessWidget { ...@@ -265,12 +265,12 @@ class _DemosPage extends StatelessWidget {
class GalleryHome extends StatefulWidget { class GalleryHome extends StatefulWidget {
const GalleryHome({ const GalleryHome({
Key key, Key? key,
this.testMode = false, this.testMode = false,
this.optionsPage, this.optionsPage,
}) : super(key: key); }) : super(key: key);
final Widget optionsPage; final Widget? optionsPage;
final bool testMode; final bool testMode;
// In checked mode our MaterialApp will show the default "debug" banner. // In checked mode our MaterialApp will show the default "debug" banner.
...@@ -283,10 +283,10 @@ class GalleryHome extends StatefulWidget { ...@@ -283,10 +283,10 @@ class GalleryHome extends StatefulWidget {
class _GalleryHomeState extends State<GalleryHome> with SingleTickerProviderStateMixin { class _GalleryHomeState extends State<GalleryHome> with SingleTickerProviderStateMixin {
static final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); static final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
AnimationController _controller; late AnimationController _controller;
GalleryDemoCategory _category; GalleryDemoCategory? _category;
static Widget _topHomeLayout(Widget currentChild, List<Widget> previousChildren) { static Widget _topHomeLayout(Widget? currentChild, List<Widget> previousChildren) {
return Stack( return Stack(
children: <Widget>[ children: <Widget>[
...previousChildren, ...previousChildren,
...@@ -357,7 +357,7 @@ class _GalleryHomeState extends State<GalleryHome> with SingleTickerProviderStat ...@@ -357,7 +357,7 @@ class _GalleryHomeState extends State<GalleryHome> with SingleTickerProviderStat
duration: _kFrontLayerSwitchDuration, duration: _kFrontLayerSwitchDuration,
child: _category == null child: _category == null
? const Text('Flutter gallery') ? const Text('Flutter gallery')
: Text(_category.name), : Text(_category!.name),
), ),
frontHeading: widget.testMode ? null : Container(height: 24.0), frontHeading: widget.testMode ? null : Container(height: 24.0),
frontLayer: AnimatedSwitcher( frontLayer: AnimatedSwitcher(
......
...@@ -21,26 +21,26 @@ class GalleryOptions { ...@@ -21,26 +21,26 @@ class GalleryOptions {
this.showPerformanceOverlay = false, this.showPerformanceOverlay = false,
}); });
final ThemeMode themeMode; final ThemeMode? themeMode;
final GalleryTextScaleValue textScaleFactor; final GalleryTextScaleValue? textScaleFactor;
final GalleryVisualDensityValue visualDensity; final GalleryVisualDensityValue? visualDensity;
final TextDirection textDirection; final TextDirection textDirection;
final double timeDilation; final double timeDilation;
final TargetPlatform platform; final TargetPlatform? platform;
final bool showPerformanceOverlay; final bool showPerformanceOverlay;
final bool showRasterCacheImagesCheckerboard; final bool showRasterCacheImagesCheckerboard;
final bool showOffscreenLayersCheckerboard; final bool showOffscreenLayersCheckerboard;
GalleryOptions copyWith({ GalleryOptions copyWith({
ThemeMode themeMode, ThemeMode? themeMode,
GalleryTextScaleValue textScaleFactor, GalleryTextScaleValue? textScaleFactor,
GalleryVisualDensityValue visualDensity, GalleryVisualDensityValue? visualDensity,
TextDirection textDirection, TextDirection? textDirection,
double timeDilation, double? timeDilation,
TargetPlatform platform, TargetPlatform? platform,
bool showPerformanceOverlay, bool? showPerformanceOverlay,
bool showRasterCacheImagesCheckerboard, bool? showRasterCacheImagesCheckerboard,
bool showOffscreenLayersCheckerboard, bool? showOffscreenLayersCheckerboard,
}) { }) {
return GalleryOptions( return GalleryOptions(
themeMode: themeMode ?? this.themeMode, themeMode: themeMode ?? this.themeMode,
...@@ -93,9 +93,9 @@ const double _kItemHeight = 48.0; ...@@ -93,9 +93,9 @@ const double _kItemHeight = 48.0;
const EdgeInsetsDirectional _kItemPadding = EdgeInsetsDirectional.only(start: 56.0); const EdgeInsetsDirectional _kItemPadding = EdgeInsetsDirectional.only(start: 56.0);
class _OptionsItem extends StatelessWidget { class _OptionsItem extends StatelessWidget {
const _OptionsItem({ Key key, this.child }) : super(key: key); const _OptionsItem({ Key? key, this.child }) : super(key: key);
final Widget child; final Widget? child;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -112,7 +112,7 @@ class _OptionsItem extends StatelessWidget { ...@@ -112,7 +112,7 @@ class _OptionsItem extends StatelessWidget {
overflow: TextOverflow.fade, overflow: TextOverflow.fade,
child: IconTheme( child: IconTheme(
data: Theme.of(context).primaryIconTheme, data: Theme.of(context).primaryIconTheme,
child: child, child: child!,
), ),
), ),
), ),
...@@ -127,7 +127,7 @@ class _BooleanItem extends StatelessWidget { ...@@ -127,7 +127,7 @@ class _BooleanItem extends StatelessWidget {
final bool value; final bool value;
final ValueChanged<bool> onChanged; final ValueChanged<bool> onChanged;
// [switchKey] is used for accessing the switch from driver tests. // [switchKey] is used for accessing the switch from driver tests.
final Key switchKey; final Key? switchKey;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -153,7 +153,7 @@ class _ActionItem extends StatelessWidget { ...@@ -153,7 +153,7 @@ class _ActionItem extends StatelessWidget {
const _ActionItem(this.text, this.onTap); const _ActionItem(this.text, this.onTap);
final String text; final String text;
final VoidCallback onTap; final VoidCallback? onTap;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -167,10 +167,10 @@ class _ActionItem extends StatelessWidget { ...@@ -167,10 +167,10 @@ class _ActionItem extends StatelessWidget {
} }
class _TextButton extends StatelessWidget { class _TextButton extends StatelessWidget {
const _TextButton({ Key key, this.onPressed, this.child }) : super(key: key); const _TextButton({ Key? key, this.onPressed, this.child }) : super(key: key);
final VoidCallback onPressed; final VoidCallback? onPressed;
final Widget child; final Widget? child;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -182,7 +182,7 @@ class _TextButton extends StatelessWidget { ...@@ -182,7 +182,7 @@ class _TextButton extends StatelessWidget {
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
), ),
onPressed: onPressed, onPressed: onPressed,
child: child, child: child!,
); );
} }
} }
...@@ -197,7 +197,7 @@ class _Heading extends StatelessWidget { ...@@ -197,7 +197,7 @@ class _Heading extends StatelessWidget {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
return _OptionsItem( return _OptionsItem(
child: DefaultTextStyle( child: DefaultTextStyle(
style: theme.textTheme.headline6.copyWith( style: theme.textTheme.headline6!.copyWith(
fontFamily: 'GoogleSans', fontFamily: 'GoogleSans',
color: theme.colorScheme.onPrimary, color: theme.colorScheme.onPrimary,
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
...@@ -214,8 +214,8 @@ class _Heading extends StatelessWidget { ...@@ -214,8 +214,8 @@ class _Heading extends StatelessWidget {
class _ThemeModeItem extends StatelessWidget { class _ThemeModeItem extends StatelessWidget {
const _ThemeModeItem(this.options, this.onOptionsChanged); const _ThemeModeItem(this.options, this.onOptionsChanged);
final GalleryOptions options; final GalleryOptions? options;
final ValueChanged<GalleryOptions> onOptionsChanged; final ValueChanged<GalleryOptions>? onOptionsChanged;
static final Map<ThemeMode, String> modeLabels = <ThemeMode, String>{ static final Map<ThemeMode, String> modeLabels = <ThemeMode, String>{
ThemeMode.system: 'System Default', ThemeMode.system: 'System Default',
...@@ -234,7 +234,7 @@ class _ThemeModeItem extends StatelessWidget { ...@@ -234,7 +234,7 @@ class _ThemeModeItem extends StatelessWidget {
children: <Widget>[ children: <Widget>[
const Text('Theme'), const Text('Theme'),
Text( Text(
modeLabels[options.themeMode], modeLabels[options!.themeMode!]!,
style: Theme.of(context).primaryTextTheme.bodyText2, style: Theme.of(context).primaryTextTheme.bodyText2,
), ),
], ],
...@@ -243,18 +243,18 @@ class _ThemeModeItem extends StatelessWidget { ...@@ -243,18 +243,18 @@ class _ThemeModeItem extends StatelessWidget {
PopupMenuButton<ThemeMode>( PopupMenuButton<ThemeMode>(
padding: const EdgeInsetsDirectional.only(end: 16.0), padding: const EdgeInsetsDirectional.only(end: 16.0),
icon: const Icon(Icons.arrow_drop_down), icon: const Icon(Icons.arrow_drop_down),
initialValue: options.themeMode, initialValue: options!.themeMode,
itemBuilder: (BuildContext context) { itemBuilder: (BuildContext context) {
return ThemeMode.values.map<PopupMenuItem<ThemeMode>>((ThemeMode mode) { return ThemeMode.values.map<PopupMenuItem<ThemeMode>>((ThemeMode mode) {
return PopupMenuItem<ThemeMode>( return PopupMenuItem<ThemeMode>(
value: mode, value: mode,
child: Text(modeLabels[mode]), child: Text(modeLabels[mode]!),
); );
}).toList(); }).toList();
}, },
onSelected: (ThemeMode mode) { onSelected: (ThemeMode mode) {
onOptionsChanged( onOptionsChanged!(
options.copyWith(themeMode: mode), options!.copyWith(themeMode: mode),
); );
}, },
), ),
...@@ -267,8 +267,8 @@ class _ThemeModeItem extends StatelessWidget { ...@@ -267,8 +267,8 @@ class _ThemeModeItem extends StatelessWidget {
class _TextScaleFactorItem extends StatelessWidget { class _TextScaleFactorItem extends StatelessWidget {
const _TextScaleFactorItem(this.options, this.onOptionsChanged); const _TextScaleFactorItem(this.options, this.onOptionsChanged);
final GalleryOptions options; final GalleryOptions? options;
final ValueChanged<GalleryOptions> onOptionsChanged; final ValueChanged<GalleryOptions>? onOptionsChanged;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -281,7 +281,7 @@ class _TextScaleFactorItem extends StatelessWidget { ...@@ -281,7 +281,7 @@ class _TextScaleFactorItem extends StatelessWidget {
children: <Widget>[ children: <Widget>[
const Text('Text size'), const Text('Text size'),
Text( Text(
options.textScaleFactor.label, options!.textScaleFactor!.label,
style: Theme.of(context).primaryTextTheme.bodyText2, style: Theme.of(context).primaryTextTheme.bodyText2,
), ),
], ],
...@@ -299,8 +299,8 @@ class _TextScaleFactorItem extends StatelessWidget { ...@@ -299,8 +299,8 @@ class _TextScaleFactorItem extends StatelessWidget {
}).toList(); }).toList();
}, },
onSelected: (GalleryTextScaleValue scaleValue) { onSelected: (GalleryTextScaleValue scaleValue) {
onOptionsChanged( onOptionsChanged!(
options.copyWith(textScaleFactor: scaleValue), options!.copyWith(textScaleFactor: scaleValue),
); );
}, },
), ),
...@@ -313,8 +313,8 @@ class _TextScaleFactorItem extends StatelessWidget { ...@@ -313,8 +313,8 @@ class _TextScaleFactorItem extends StatelessWidget {
class _VisualDensityItem extends StatelessWidget { class _VisualDensityItem extends StatelessWidget {
const _VisualDensityItem(this.options, this.onOptionsChanged); const _VisualDensityItem(this.options, this.onOptionsChanged);
final GalleryOptions options; final GalleryOptions? options;
final ValueChanged<GalleryOptions> onOptionsChanged; final ValueChanged<GalleryOptions>? onOptionsChanged;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -327,7 +327,7 @@ class _VisualDensityItem extends StatelessWidget { ...@@ -327,7 +327,7 @@ class _VisualDensityItem extends StatelessWidget {
children: <Widget>[ children: <Widget>[
const Text('Visual density'), const Text('Visual density'),
Text( Text(
options.visualDensity.label, options!.visualDensity!.label,
style: Theme.of(context).primaryTextTheme.bodyText2, style: Theme.of(context).primaryTextTheme.bodyText2,
), ),
], ],
...@@ -345,8 +345,8 @@ class _VisualDensityItem extends StatelessWidget { ...@@ -345,8 +345,8 @@ class _VisualDensityItem extends StatelessWidget {
}).toList(); }).toList();
}, },
onSelected: (GalleryVisualDensityValue densityValue) { onSelected: (GalleryVisualDensityValue densityValue) {
onOptionsChanged( onOptionsChanged!(
options.copyWith(visualDensity: densityValue), options!.copyWith(visualDensity: densityValue),
); );
}, },
), ),
...@@ -359,17 +359,17 @@ class _VisualDensityItem extends StatelessWidget { ...@@ -359,17 +359,17 @@ class _VisualDensityItem extends StatelessWidget {
class _TextDirectionItem extends StatelessWidget { class _TextDirectionItem extends StatelessWidget {
const _TextDirectionItem(this.options, this.onOptionsChanged); const _TextDirectionItem(this.options, this.onOptionsChanged);
final GalleryOptions options; final GalleryOptions? options;
final ValueChanged<GalleryOptions> onOptionsChanged; final ValueChanged<GalleryOptions>? onOptionsChanged;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return _BooleanItem( return _BooleanItem(
'Force RTL', 'Force RTL',
options.textDirection == TextDirection.rtl, options!.textDirection == TextDirection.rtl,
(bool value) { (bool value) {
onOptionsChanged( onOptionsChanged!(
options.copyWith( options!.copyWith(
textDirection: value ? TextDirection.rtl : TextDirection.ltr, textDirection: value ? TextDirection.rtl : TextDirection.ltr,
), ),
); );
...@@ -382,17 +382,17 @@ class _TextDirectionItem extends StatelessWidget { ...@@ -382,17 +382,17 @@ class _TextDirectionItem extends StatelessWidget {
class _TimeDilationItem extends StatelessWidget { class _TimeDilationItem extends StatelessWidget {
const _TimeDilationItem(this.options, this.onOptionsChanged); const _TimeDilationItem(this.options, this.onOptionsChanged);
final GalleryOptions options; final GalleryOptions? options;
final ValueChanged<GalleryOptions> onOptionsChanged; final ValueChanged<GalleryOptions>? onOptionsChanged;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return _BooleanItem( return _BooleanItem(
'Slow motion', 'Slow motion',
options.timeDilation != 1.0, options!.timeDilation != 1.0,
(bool value) { (bool value) {
onOptionsChanged( onOptionsChanged!(
options.copyWith( options!.copyWith(
timeDilation: value ? 20.0 : 1.0, timeDilation: value ? 20.0 : 1.0,
), ),
); );
...@@ -405,10 +405,10 @@ class _TimeDilationItem extends StatelessWidget { ...@@ -405,10 +405,10 @@ class _TimeDilationItem extends StatelessWidget {
class _PlatformItem extends StatelessWidget { class _PlatformItem extends StatelessWidget {
const _PlatformItem(this.options, this.onOptionsChanged); const _PlatformItem(this.options, this.onOptionsChanged);
final GalleryOptions options; final GalleryOptions? options;
final ValueChanged<GalleryOptions> onOptionsChanged; final ValueChanged<GalleryOptions>? onOptionsChanged;
String _platformLabel(TargetPlatform platform) { String? _platformLabel(TargetPlatform? platform) {
switch(platform) { switch(platform) {
case TargetPlatform.android: case TargetPlatform.android:
return 'Mountain View'; return 'Mountain View';
...@@ -422,10 +422,11 @@ class _PlatformItem extends StatelessWidget { ...@@ -422,10 +422,11 @@ class _PlatformItem extends StatelessWidget {
return 'Material Desktop (macOS)'; return 'Material Desktop (macOS)';
case TargetPlatform.windows: case TargetPlatform.windows:
return 'Material Desktop (Windows)'; return 'Material Desktop (Windows)';
} default:
assert(false); assert(false);
return null; return null;
} }
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -438,7 +439,7 @@ class _PlatformItem extends StatelessWidget { ...@@ -438,7 +439,7 @@ class _PlatformItem extends StatelessWidget {
children: <Widget>[ children: <Widget>[
const Text('Platform mechanics'), const Text('Platform mechanics'),
Text( Text(
_platformLabel(options.platform), _platformLabel(options!.platform)!,
style: Theme.of(context).primaryTextTheme.bodyText2, style: Theme.of(context).primaryTextTheme.bodyText2,
), ),
], ],
...@@ -451,13 +452,13 @@ class _PlatformItem extends StatelessWidget { ...@@ -451,13 +452,13 @@ class _PlatformItem extends StatelessWidget {
return TargetPlatform.values.map((TargetPlatform platform) { return TargetPlatform.values.map((TargetPlatform platform) {
return PopupMenuItem<TargetPlatform>( return PopupMenuItem<TargetPlatform>(
value: platform, value: platform,
child: Text(_platformLabel(platform)), child: Text(_platformLabel(platform)!),
); );
}).toList(); }).toList();
}, },
onSelected: (TargetPlatform platform) { onSelected: (TargetPlatform platform) {
onOptionsChanged( onOptionsChanged!(
options.copyWith(platform: platform), options!.copyWith(platform: platform),
); );
}, },
), ),
...@@ -469,49 +470,44 @@ class _PlatformItem extends StatelessWidget { ...@@ -469,49 +470,44 @@ class _PlatformItem extends StatelessWidget {
class GalleryOptionsPage extends StatelessWidget { class GalleryOptionsPage extends StatelessWidget {
const GalleryOptionsPage({ const GalleryOptionsPage({
Key key, Key? key,
this.options, this.options,
this.onOptionsChanged, this.onOptionsChanged,
this.onSendFeedback, this.onSendFeedback,
}) : super(key: key); }) : super(key: key);
final GalleryOptions options; final GalleryOptions? options;
final ValueChanged<GalleryOptions> onOptionsChanged; final ValueChanged<GalleryOptions>? onOptionsChanged;
final VoidCallback onSendFeedback; final VoidCallback? onSendFeedback;
List<Widget> _enabledDiagnosticItems() { List<Widget> _enabledDiagnosticItems() {
// Boolean showFoo options with a value of null: don't display // Boolean showFoo options with a value of null: don't display
// the showFoo option at all. // the showFoo option at all.
if (options.showOffscreenLayersCheckerboard == null && if (options == null)
options.showRasterCacheImagesCheckerboard == null &&
options.showPerformanceOverlay == null)
return const <Widget>[]; return const <Widget>[];
return <Widget>[ return <Widget>[
const Divider(), const Divider(),
const _Heading('Diagnostics'), const _Heading('Diagnostics'),
if (options.showOffscreenLayersCheckerboard != null)
_BooleanItem( _BooleanItem(
'Highlight offscreen layers', 'Highlight offscreen layers',
options.showOffscreenLayersCheckerboard, options!.showOffscreenLayersCheckerboard,
(bool value) { (bool value) {
onOptionsChanged(options.copyWith(showOffscreenLayersCheckerboard: value)); onOptionsChanged!(options!.copyWith(showOffscreenLayersCheckerboard: value));
}, },
), ),
if (options.showRasterCacheImagesCheckerboard != null)
_BooleanItem( _BooleanItem(
'Highlight raster cache images', 'Highlight raster cache images',
options.showRasterCacheImagesCheckerboard, options!.showRasterCacheImagesCheckerboard,
(bool value) { (bool value) {
onOptionsChanged(options.copyWith(showRasterCacheImagesCheckerboard: value)); onOptionsChanged!(options!.copyWith(showRasterCacheImagesCheckerboard: value));
}, },
), ),
if (options.showPerformanceOverlay != null)
_BooleanItem( _BooleanItem(
'Show performance overlay', 'Show performance overlay',
options.showPerformanceOverlay, options!.showPerformanceOverlay,
(bool value) { (bool value) {
onOptionsChanged(options.copyWith(showPerformanceOverlay: value)); onOptionsChanged!(options!.copyWith(showPerformanceOverlay: value));
}, },
), ),
]; ];
...@@ -522,7 +518,7 @@ class GalleryOptionsPage extends StatelessWidget { ...@@ -522,7 +518,7 @@ class GalleryOptionsPage extends StatelessWidget {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
return DefaultTextStyle( return DefaultTextStyle(
style: theme.primaryTextTheme.subtitle1, style: theme.primaryTextTheme.subtitle1!,
child: ListView( child: ListView(
padding: const EdgeInsets.only(bottom: 124.0), padding: const EdgeInsets.only(bottom: 124.0),
children: <Widget>[ children: <Widget>[
......
...@@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; ...@@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
class GalleryTextScaleValue { class GalleryTextScaleValue {
const GalleryTextScaleValue(this.scale, this.label); const GalleryTextScaleValue(this.scale, this.label);
final double scale; final double? scale;
final String label; final String label;
@override @override
......
...@@ -43,14 +43,14 @@ class SyntaxHighlighterStyle { ...@@ -43,14 +43,14 @@ class SyntaxHighlighterStyle {
); );
} }
final TextStyle baseStyle; final TextStyle? baseStyle;
final TextStyle numberStyle; final TextStyle? numberStyle;
final TextStyle commentStyle; final TextStyle? commentStyle;
final TextStyle keywordStyle; final TextStyle? keywordStyle;
final TextStyle stringStyle; final TextStyle? stringStyle;
final TextStyle punctuationStyle; final TextStyle? punctuationStyle;
final TextStyle classStyle; final TextStyle? classStyle;
final TextStyle constantStyle; final TextStyle? constantStyle;
} }
abstract class SyntaxHighlighter { abstract class SyntaxHighlighter {
...@@ -63,7 +63,7 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { ...@@ -63,7 +63,7 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
_style ??= SyntaxHighlighterStyle.darkThemeStyle(); _style ??= SyntaxHighlighterStyle.darkThemeStyle();
} }
SyntaxHighlighterStyle _style; SyntaxHighlighterStyle? _style;
static const List<String> _keywords = <String>[ static const List<String> _keywords = <String>[
'abstract', 'as', 'assert', 'async', 'await', 'break', 'case', 'catch', 'abstract', 'as', 'assert', 'async', 'await', 'break', 'case', 'catch',
...@@ -79,15 +79,15 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { ...@@ -79,15 +79,15 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
'int', 'double', 'num', 'bool', 'int', 'double', 'num', 'bool',
]; ];
String _src; String? _src;
StringScanner _scanner; late StringScanner _scanner;
List<_HighlightSpan> _spans; late List<_HighlightSpan> _spans;
@override @override
TextSpan format(String src) { TextSpan format(String? src) {
_src = src; _src = src;
_scanner = StringScanner(_src); _scanner = StringScanner(_src!);
if (_generateSpans()) { if (_generateSpans()) {
// Successfully parsed the code // Successfully parsed the code
...@@ -96,20 +96,20 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { ...@@ -96,20 +96,20 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
for (final _HighlightSpan span in _spans) { for (final _HighlightSpan span in _spans) {
if (currentPosition != span.start) if (currentPosition != span.start)
formattedText.add(TextSpan(text: _src.substring(currentPosition, span.start))); formattedText.add(TextSpan(text: _src!.substring(currentPosition, span.start)));
formattedText.add(TextSpan(style: span.textStyle(_style), text: span.textForSpan(_src))); formattedText.add(TextSpan(style: span.textStyle(_style), text: span.textForSpan(_src!)));
currentPosition = span.end; currentPosition = span.end;
} }
if (currentPosition != _src.length) if (currentPosition != _src!.length)
formattedText.add(TextSpan(text: _src.substring(currentPosition, _src.length))); formattedText.add(TextSpan(text: _src!.substring(currentPosition, _src!.length)));
return TextSpan(style: _style.baseStyle, children: formattedText); return TextSpan(style: _style!.baseStyle, children: formattedText);
} else { } else {
// Parsing failed, return with only basic formatting // Parsing failed, return with only basic formatting
return TextSpan(style: _style.baseStyle, text: src); return TextSpan(style: _style!.baseStyle, text: src);
} }
} }
...@@ -124,23 +124,23 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { ...@@ -124,23 +124,23 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
if (_scanner.scan(RegExp(r'/\*(.|\n)*\*/'))) { if (_scanner.scan(RegExp(r'/\*(.|\n)*\*/'))) {
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
_HighlightType.comment, _HighlightType.comment,
_scanner.lastMatch.start, _scanner.lastMatch!.start,
_scanner.lastMatch.end, _scanner.lastMatch!.end,
)); ));
continue; continue;
} }
// Line comments // Line comments
if (_scanner.scan('//')) { if (_scanner.scan('//')) {
final int startComment = _scanner.lastMatch.start; final int startComment = _scanner.lastMatch!.start;
bool eof = false; bool eof = false;
int endComment; int endComment;
if (_scanner.scan(RegExp(r'.*\n'))) { if (_scanner.scan(RegExp(r'.*\n'))) {
endComment = _scanner.lastMatch.end - 1; endComment = _scanner.lastMatch!.end - 1;
} else { } else {
eof = true; eof = true;
endComment = _src.length; endComment = _src!.length;
} }
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
...@@ -159,8 +159,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { ...@@ -159,8 +159,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
if (_scanner.scan(RegExp(r'r".*"'))) { if (_scanner.scan(RegExp(r'r".*"'))) {
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
_HighlightType.string, _HighlightType.string,
_scanner.lastMatch.start, _scanner.lastMatch!.start,
_scanner.lastMatch.end, _scanner.lastMatch!.end,
)); ));
continue; continue;
} }
...@@ -169,8 +169,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { ...@@ -169,8 +169,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
if (_scanner.scan(RegExp(r"r'.*'"))) { if (_scanner.scan(RegExp(r"r'.*'"))) {
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
_HighlightType.string, _HighlightType.string,
_scanner.lastMatch.start, _scanner.lastMatch!.start,
_scanner.lastMatch.end, _scanner.lastMatch!.end,
)); ));
continue; continue;
} }
...@@ -179,8 +179,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { ...@@ -179,8 +179,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
if (_scanner.scan(RegExp(r'"""(?:[^"\\]|\\(.|\n))*"""'))) { if (_scanner.scan(RegExp(r'"""(?:[^"\\]|\\(.|\n))*"""'))) {
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
_HighlightType.string, _HighlightType.string,
_scanner.lastMatch.start, _scanner.lastMatch!.start,
_scanner.lastMatch.end, _scanner.lastMatch!.end,
)); ));
continue; continue;
} }
...@@ -189,8 +189,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { ...@@ -189,8 +189,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
if (_scanner.scan(RegExp(r"'''(?:[^'\\]|\\(.|\n))*'''"))) { if (_scanner.scan(RegExp(r"'''(?:[^'\\]|\\(.|\n))*'''"))) {
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
_HighlightType.string, _HighlightType.string,
_scanner.lastMatch.start, _scanner.lastMatch!.start,
_scanner.lastMatch.end, _scanner.lastMatch!.end,
)); ));
continue; continue;
} }
...@@ -199,8 +199,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { ...@@ -199,8 +199,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
if (_scanner.scan(RegExp(r'"(?:[^"\\]|\\.)*"'))) { if (_scanner.scan(RegExp(r'"(?:[^"\\]|\\.)*"'))) {
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
_HighlightType.string, _HighlightType.string,
_scanner.lastMatch.start, _scanner.lastMatch!.start,
_scanner.lastMatch.end, _scanner.lastMatch!.end,
)); ));
continue; continue;
} }
...@@ -209,8 +209,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { ...@@ -209,8 +209,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
if (_scanner.scan(RegExp(r"'(?:[^'\\]|\\.)*'"))) { if (_scanner.scan(RegExp(r"'(?:[^'\\]|\\.)*'"))) {
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
_HighlightType.string, _HighlightType.string,
_scanner.lastMatch.start, _scanner.lastMatch!.start,
_scanner.lastMatch.end, _scanner.lastMatch!.end,
)); ));
continue; continue;
} }
...@@ -219,8 +219,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { ...@@ -219,8 +219,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
if (_scanner.scan(RegExp(r'\d+\.\d+'))) { if (_scanner.scan(RegExp(r'\d+\.\d+'))) {
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
_HighlightType.number, _HighlightType.number,
_scanner.lastMatch.start, _scanner.lastMatch!.start,
_scanner.lastMatch.end, _scanner.lastMatch!.end,
)); ));
continue; continue;
} }
...@@ -229,8 +229,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { ...@@ -229,8 +229,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
if (_scanner.scan(RegExp(r'\d+'))) { if (_scanner.scan(RegExp(r'\d+'))) {
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
_HighlightType.number, _HighlightType.number,
_scanner.lastMatch.start, _scanner.lastMatch!.start,
_scanner.lastMatch.end) _scanner.lastMatch!.end)
); );
continue; continue;
} }
...@@ -239,8 +239,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { ...@@ -239,8 +239,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
if (_scanner.scan(RegExp(r'[\[\]{}().!=<>&\|\?\+\-\*/%\^~;:,]'))) { if (_scanner.scan(RegExp(r'[\[\]{}().!=<>&\|\?\+\-\*/%\^~;:,]'))) {
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
_HighlightType.punctuation, _HighlightType.punctuation,
_scanner.lastMatch.start, _scanner.lastMatch!.start,
_scanner.lastMatch.end, _scanner.lastMatch!.end,
)); ));
continue; continue;
} }
...@@ -249,17 +249,17 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { ...@@ -249,17 +249,17 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
if (_scanner.scan(RegExp(r'@\w+'))) { if (_scanner.scan(RegExp(r'@\w+'))) {
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
_HighlightType.keyword, _HighlightType.keyword,
_scanner.lastMatch.start, _scanner.lastMatch!.start,
_scanner.lastMatch.end, _scanner.lastMatch!.end,
)); ));
continue; continue;
} }
// Words // Words
if (_scanner.scan(RegExp(r'\w+'))) { if (_scanner.scan(RegExp(r'\w+'))) {
_HighlightType type; _HighlightType? type;
String word = _scanner.lastMatch[0]; String word = _scanner.lastMatch![0]!;
if (word.startsWith('_')) if (word.startsWith('_'))
word = word.substring(1); word = word.substring(1);
...@@ -275,8 +275,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { ...@@ -275,8 +275,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
if (type != null) { if (type != null) {
_spans.add(_HighlightSpan( _spans.add(_HighlightSpan(
type, type,
_scanner.lastMatch.start, _scanner.lastMatch!.start,
_scanner.lastMatch.end, _scanner.lastMatch!.end,
)); ));
} }
} }
...@@ -335,22 +335,22 @@ class _HighlightSpan { ...@@ -335,22 +335,22 @@ class _HighlightSpan {
return src.substring(start, end); return src.substring(start, end);
} }
TextStyle textStyle(SyntaxHighlighterStyle style) { TextStyle? textStyle(SyntaxHighlighterStyle? style) {
if (type == _HighlightType.number) if (type == _HighlightType.number)
return style.numberStyle; return style!.numberStyle;
else if (type == _HighlightType.comment) else if (type == _HighlightType.comment)
return style.commentStyle; return style!.commentStyle;
else if (type == _HighlightType.keyword) else if (type == _HighlightType.keyword)
return style.keywordStyle; return style!.keywordStyle;
else if (type == _HighlightType.string) else if (type == _HighlightType.string)
return style.stringStyle; return style!.stringStyle;
else if (type == _HighlightType.punctuation) else if (type == _HighlightType.punctuation)
return style.punctuationStyle; return style!.punctuationStyle;
else if (type == _HighlightType.klass) else if (type == _HighlightType.klass)
return style.classStyle; return style!.classStyle;
else if (type == _HighlightType.constant) else if (type == _HighlightType.constant)
return style.constantStyle; return style!.constantStyle;
else else
return style.baseStyle; return style!.baseStyle;
} }
} }
...@@ -9,7 +9,7 @@ final ThemeData kDarkGalleryTheme = _buildDarkTheme(); ...@@ -9,7 +9,7 @@ final ThemeData kDarkGalleryTheme = _buildDarkTheme();
TextTheme _buildTextTheme(TextTheme base) { TextTheme _buildTextTheme(TextTheme base) {
return base.copyWith( return base.copyWith(
headline6: base.headline6.copyWith( headline6: base.headline6!.copyWith(
fontFamily: 'GoogleSans', fontFamily: 'GoogleSans',
), ),
); );
......
...@@ -9,12 +9,11 @@ import 'package:url_launcher/url_launcher.dart'; ...@@ -9,12 +9,11 @@ import 'package:url_launcher/url_launcher.dart';
typedef UpdateUrlFetcher = Future<String> Function(); typedef UpdateUrlFetcher = Future<String> Function();
class Updater extends StatefulWidget { class Updater extends StatefulWidget {
const Updater({ @required this.updateUrlFetcher, this.child, Key key }) const Updater({ required this.updateUrlFetcher, this.child, Key? key })
: assert(updateUrlFetcher != null), : super(key: key);
super(key: key);
final UpdateUrlFetcher updateUrlFetcher; final UpdateUrlFetcher updateUrlFetcher;
final Widget child; final Widget? child;
@override @override
State createState() => UpdaterState(); State createState() => UpdaterState();
...@@ -27,27 +26,25 @@ class UpdaterState extends State<Updater> { ...@@ -27,27 +26,25 @@ class UpdaterState extends State<Updater> {
_checkForUpdates(); _checkForUpdates();
} }
static DateTime _lastUpdateCheck; static DateTime? _lastUpdateCheck;
Future<void> _checkForUpdates() async { Future<void> _checkForUpdates() async {
// Only prompt once a day // Only prompt once a day
if (_lastUpdateCheck != null && if (_lastUpdateCheck != null &&
DateTime.now().difference(_lastUpdateCheck) < const Duration(days: 1)) { DateTime.now().difference(_lastUpdateCheck!) < const Duration(days: 1)) {
return; // We already checked for updates recently return; // We already checked for updates recently
} }
_lastUpdateCheck = DateTime.now(); _lastUpdateCheck = DateTime.now();
final String updateUrl = await widget.updateUrlFetcher(); final String updateUrl = await widget.updateUrlFetcher();
if (updateUrl != null) { final bool? wantsUpdate = await showDialog<bool>(context: context, builder: _buildDialog);
final bool wantsUpdate = await showDialog<bool>(context: context, builder: _buildDialog);
if (wantsUpdate != null && wantsUpdate) if (wantsUpdate != null && wantsUpdate)
launch(updateUrl); launch(updateUrl);
} }
}
Widget _buildDialog(BuildContext context) { Widget _buildDialog(BuildContext context) {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
final TextStyle dialogTextStyle = final TextStyle dialogTextStyle =
theme.textTheme.subtitle1.copyWith(color: theme.textTheme.caption.color); theme.textTheme.subtitle1!.copyWith(color: theme.textTheme.caption!.color);
return AlertDialog( return AlertDialog(
title: const Text('Update Flutter Gallery?'), title: const Text('Update Flutter Gallery?'),
content: Text('A newer version is available.', style: dialogTextStyle), content: Text('A newer version is available.', style: dialogTextStyle),
...@@ -69,5 +66,5 @@ class UpdaterState extends State<Updater> { ...@@ -69,5 +66,5 @@ class UpdaterState extends State<Updater> {
} }
@override @override
Widget build(BuildContext context) => widget.child; Widget build(BuildContext context) => widget.child!;
} }
...@@ -2,20 +2,23 @@ name: flutter_gallery ...@@ -2,20 +2,23 @@ name: flutter_gallery
environment: environment:
# The pub client defaults to an <2.0.0 sdk constraint which we need to explicitly overwrite. # The pub client defaults to an <2.0.0 sdk constraint which we need to explicitly overwrite.
sdk: ">=2.2.2 <3.0.0" sdk: ">=2.12.0-0 <3.0.0"
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
collection: 1.15.0-nullsafety.5 collection: 1.15.0-nullsafety.5
device_info: 2.0.0-nullsafety.1 device_info: 2.0.0-nullsafety.1
intl: 0.16.1 intl: 0.17.0-nullsafety.2
connectivity: 3.0.0-nullsafety.1 connectivity: 3.0.0-nullsafety.1
string_scanner: 1.1.0-nullsafety.3 string_scanner: 1.1.0-nullsafety.3
url_launcher: 6.0.0-nullsafety.1 url_launcher: 6.0.0-nullsafety.1
cupertino_icons: 1.0.1 cupertino_icons: 1.0.1
video_player: 2.0.0-nullsafety.2 video_player: 2.0.0-nullsafety.2
scoped_model: 1.1.0 scoped_model:
git:
url: https://github.com/kevmoo/scoped_model.git
ref: null_safety
shrine_images: 1.1.2 shrine_images: 1.1.2
# Also update dev/benchmarks/complex_layout/pubspec.yaml # Also update dev/benchmarks/complex_layout/pubspec.yaml
...@@ -24,6 +27,7 @@ dependencies: ...@@ -24,6 +27,7 @@ dependencies:
characters: 1.1.0-nullsafety.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" characters: 1.1.0-nullsafety.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
charcode: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
clock: 1.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
connectivity_macos: 0.1.0+7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" connectivity_macos: 0.1.0+7 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
connectivity_platform_interface: 2.0.0-nullsafety.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" connectivity_platform_interface: 2.0.0-nullsafety.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
device_info_platform_interface: 2.0.0-nullsafety.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" device_info_platform_interface: 2.0.0-nullsafety.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
...@@ -60,7 +64,6 @@ dev_dependencies: ...@@ -60,7 +64,6 @@ dev_dependencies:
async: 2.5.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" async: 2.5.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
boolean_selector: 2.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 2.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
cli_util: 0.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" cli_util: 0.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
clock: 1.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
coverage: 0.14.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" coverage: 0.14.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
crypto: 2.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
...@@ -273,4 +276,4 @@ flutter: ...@@ -273,4 +276,4 @@ flutter:
- asset: packages/flutter_gallery_assets/fonts/merriweather/Merriweather-Regular.ttf - asset: packages/flutter_gallery_assets/fonts/merriweather/Merriweather-Regular.ttf
- asset: packages/flutter_gallery_assets/fonts/merriweather/Merriweather-Light.ttf - asset: packages/flutter_gallery_assets/fonts/merriweather/Merriweather-Light.ttf
# PUBSPEC CHECKSUM: 178a # PUBSPEC CHECKSUM: a678
...@@ -10,80 +10,80 @@ import 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf; ...@@ -10,80 +10,80 @@ import 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf;
void main() { void main() {
test('Test order of operations: 12 + 3 * 4 = 24', () { test('Test order of operations: 12 + 3 * 4 = 24', () {
CalcExpression expression = CalcExpression.empty(); CalcExpression expression = CalcExpression.empty();
expression = expression.appendDigit(1); expression = expression.appendDigit(1)!;
expression = expression.appendDigit(2); expression = expression.appendDigit(2)!;
expression = expression.appendOperation(Operation.Addition); expression = expression.appendOperation(Operation.Addition)!;
expression = expression.appendDigit(3); expression = expression.appendDigit(3)!;
expression = expression.appendOperation(Operation.Multiplication); expression = expression.appendOperation(Operation.Multiplication)!;
expression = expression.appendDigit(4); expression = expression.appendDigit(4)!;
expression = expression.computeResult(); expression = expression.computeResult()!;
expect(expression.state, equals(ExpressionState.Result)); expect(expression.state, equals(ExpressionState.Result));
expect(expression.toString(), equals('24')); expect(expression.toString(), equals('24'));
}); });
test('Test floating point 0.1 + 0.2 = 0.3', () { test('Test floating point 0.1 + 0.2 = 0.3', () {
CalcExpression expression = CalcExpression.empty(); CalcExpression expression = CalcExpression.empty();
expression = expression.appendDigit(0); expression = expression.appendDigit(0)!;
expression = expression.appendPoint(); expression = expression.appendPoint()!;
expression = expression.appendDigit(1); expression = expression.appendDigit(1)!;
expression = expression.appendOperation(Operation.Addition); expression = expression.appendOperation(Operation.Addition)!;
expression = expression.appendDigit(0); expression = expression.appendDigit(0)!;
expression = expression.appendPoint(); expression = expression.appendPoint()!;
expression = expression.appendDigit(2); expression = expression.appendDigit(2)!;
expression = expression.computeResult(); expression = expression.computeResult()!;
expect(expression.state, equals(ExpressionState.Result)); expect(expression.state, equals(ExpressionState.Result));
expect(expression.toString(), equals('0.3')); expect(expression.toString(), equals('0.3'));
}); });
test('Test floating point 1.0/10.0 = 0.1', () { test('Test floating point 1.0/10.0 = 0.1', () {
CalcExpression expression = CalcExpression.empty(); CalcExpression expression = CalcExpression.empty();
expression = expression.appendDigit(1); expression = expression.appendDigit(1)!;
expression = expression.appendPoint(); expression = expression.appendPoint()!;
expression = expression.appendDigit(0); expression = expression.appendDigit(0)!;
expression = expression.appendOperation(Operation.Division); expression = expression.appendOperation(Operation.Division)!;
expression = expression.appendDigit(1); expression = expression.appendDigit(1)!;
expression = expression.appendDigit(0); expression = expression.appendDigit(0)!;
expression = expression.appendPoint(); expression = expression.appendPoint()!;
expression = expression.appendDigit(0); expression = expression.appendDigit(0)!;
expression = expression.computeResult(); expression = expression.computeResult()!;
expect(expression.state, equals(ExpressionState.Result)); expect(expression.state, equals(ExpressionState.Result));
expect(expression.toString(), equals('0.1')); expect(expression.toString(), equals('0.1'));
}); });
test('Test 1/0 = Infinity', () { test('Test 1/0 = Infinity', () {
CalcExpression expression = CalcExpression.empty(); CalcExpression expression = CalcExpression.empty();
expression = expression.appendDigit(1); expression = expression.appendDigit(1)!;
expression = expression.appendOperation(Operation.Division); expression = expression.appendOperation(Operation.Division)!;
expression = expression.appendDigit(0); expression = expression.appendDigit(0)!;
expression = expression.computeResult(); expression = expression.computeResult()!;
expect(expression.state, equals(ExpressionState.Result)); expect(expression.state, equals(ExpressionState.Result));
expect(expression.toString(), equals('Infinity')); expect(expression.toString(), equals('Infinity'));
}); });
test('Test use result in next calculation: 1 + 1 = 2 + 1 = 3 + 1 = 4', () { test('Test use result in next calculation: 1 + 1 = 2 + 1 = 3 + 1 = 4', () {
CalcExpression expression = CalcExpression.empty(); CalcExpression expression = CalcExpression.empty();
expression = expression.appendDigit(1); expression = expression.appendDigit(1)!;
expression = expression.appendOperation(Operation.Addition); expression = expression.appendOperation(Operation.Addition)!;
expression = expression.appendDigit(1); expression = expression.appendDigit(1)!;
expression = expression.computeResult(); expression = expression.computeResult()!;
expression = expression.appendOperation(Operation.Addition); expression = expression.appendOperation(Operation.Addition)!;
expression = expression.appendDigit(1); expression = expression.appendDigit(1)!;
expression = expression.computeResult(); expression = expression.computeResult()!;
expression = expression.appendOperation(Operation.Addition); expression = expression.appendOperation(Operation.Addition)!;
expression = expression.appendDigit(1); expression = expression.appendDigit(1)!;
expression = expression.computeResult(); expression = expression.computeResult()!;
expect(expression.state, equals(ExpressionState.Result)); expect(expression.state, equals(ExpressionState.Result));
expect(expression.toString(), equals('4')); expect(expression.toString(), equals('4'));
}); });
test('Test minus -3 - -2 = -1', () { test('Test minus -3 - -2 = -1', () {
CalcExpression expression = CalcExpression.empty(); CalcExpression expression = CalcExpression.empty();
expression = expression.appendMinus(); expression = expression.appendMinus()!;
expression = expression.appendDigit(3); expression = expression.appendDigit(3)!;
expression = expression.appendMinus(); expression = expression.appendMinus()!;
expression = expression.appendMinus(); expression = expression.appendMinus()!;
expression = expression.appendDigit(2); expression = expression.appendDigit(2)!;
expression = expression.computeResult(); expression = expression.computeResult()!;
expect(expression.state, equals(ExpressionState.Result)); expect(expression.state, equals(ExpressionState.Result));
expect(expression.toString(), equals('-1')); expect(expression.toString(), equals('-1'));
}); });
......
...@@ -37,5 +37,7 @@ void main() { ...@@ -37,5 +37,7 @@ void main() {
find.byType(CupertinoNavigationDemo), find.byType(CupertinoNavigationDemo),
matchesGoldenFile('cupertino_navigation_demo.screen.2.png'), matchesGoldenFile('cupertino_navigation_demo.screen.2.png'),
); );
}); },
// TODO(egarciad): https://github.com/flutter/flutter/issues/69994
skip: true);
} }
...@@ -32,8 +32,8 @@ void main() { ...@@ -32,8 +32,8 @@ void main() {
// Verify theme settings // Verify theme settings
MaterialApp app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp; MaterialApp app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp;
expect(app.theme.brightness, equals(Brightness.light)); expect(app.theme!.brightness, equals(Brightness.light));
expect(app.darkTheme.brightness, equals(Brightness.dark)); expect(app.darkTheme!.brightness, equals(Brightness.dark));
// Switch to the dark theme: first menu button, choose 'Dark' // Switch to the dark theme: first menu button, choose 'Dark'
await tester.tap(find.byIcon(Icons.arrow_drop_down).first); await tester.tap(find.byIcon(Icons.arrow_drop_down).first);
...@@ -63,7 +63,7 @@ void main() { ...@@ -63,7 +63,7 @@ void main() {
expect(app.themeMode, ThemeMode.system); expect(app.themeMode, ThemeMode.system);
// Verify density settings // Verify density settings
expect(app.theme.visualDensity, equals(const VisualDensity())); expect(app.theme!.visualDensity, equals(const VisualDensity()));
// Popup the density menu: third menu button, choose 'Compact' // Popup the density menu: third menu button, choose 'Compact'
await tester.tap(find.byIcon(Icons.arrow_drop_down).at(2)); await tester.tap(find.byIcon(Icons.arrow_drop_down).at(2));
...@@ -71,7 +71,7 @@ void main() { ...@@ -71,7 +71,7 @@ void main() {
await tester.tap(find.text('Compact')); await tester.tap(find.text('Compact'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp; app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp;
expect(app.theme.visualDensity, equals(VisualDensity.compact)); expect(app.theme!.visualDensity, equals(VisualDensity.compact));
await tester.tap(find.byIcon(Icons.arrow_drop_down).at(2)); await tester.tap(find.byIcon(Icons.arrow_drop_down).at(2));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
...@@ -81,10 +81,10 @@ void main() { ...@@ -81,10 +81,10 @@ void main() {
)); ));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp; app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp;
expect(app.theme.visualDensity, equals(const VisualDensity())); expect(app.theme!.visualDensity, equals(const VisualDensity()));
// Verify platform settings // Verify platform settings
expect(app.theme.platform, equals(TargetPlatform.android)); expect(app.theme!.platform, equals(TargetPlatform.android));
// Popup the platform menu: fourth menu button, choose 'Cupertino' // Popup the platform menu: fourth menu button, choose 'Cupertino'
await tester.tap(find.byIcon(Icons.arrow_drop_down).at(3)); await tester.tap(find.byIcon(Icons.arrow_drop_down).at(3));
...@@ -92,7 +92,7 @@ void main() { ...@@ -92,7 +92,7 @@ void main() {
await tester.tap(find.text('Cupertino').at(1)); await tester.tap(find.text('Cupertino').at(1));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp; app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp;
expect(app.theme.platform, equals(TargetPlatform.iOS)); expect(app.theme!.platform, equals(TargetPlatform.iOS));
// Verify the font scale. // Verify the font scale.
final Size origTextSize = tester.getSize(find.text('Text size')); final Size origTextSize = tester.getSize(find.text('Text size'));
......
...@@ -12,13 +12,13 @@ void main() { ...@@ -12,13 +12,13 @@ void main() {
test('Flutter gallery example code parser test', () async { test('Flutter gallery example code parser test', () async {
final TestAssetBundle bundle = TestAssetBundle(); final TestAssetBundle bundle = TestAssetBundle();
final String codeSnippet0 = await getExampleCode('test_0', bundle); final String? codeSnippet0 = await getExampleCode('test_0', bundle);
expect(codeSnippet0, 'test 0 0\ntest 0 1'); expect(codeSnippet0, 'test 0 0\ntest 0 1');
final String codeSnippet1 = await getExampleCode('test_1', bundle); final String? codeSnippet1 = await getExampleCode('test_1', bundle);
expect(codeSnippet1, 'test 1 0\ntest 1 1'); expect(codeSnippet1, 'test 1 0\ntest 1 1');
final String codeSnippet3 = await getExampleCode('test_2_windows_breaks', bundle); final String? codeSnippet3 = await getExampleCode('test_2_windows_breaks', bundle);
expect(codeSnippet3, 'windows test 2 0\nwindows test 2 1'); expect(codeSnippet3, 'windows test 2 0\nwindows test 2 1');
}); });
} }
...@@ -41,13 +41,15 @@ test 1 1 ...@@ -41,13 +41,15 @@ test 1 1
class TestAssetBundle extends AssetBundle { class TestAssetBundle extends AssetBundle {
@override @override
Future<ByteData> load(String key) async => null; Future<ByteData> load(String key) async {
return ByteData.sublistView(Uint8List(0));
}
@override @override
Future<String> loadString(String key, { bool cache = true }) async { Future<String> loadString(String key, { bool cache = true }) async {
if (key == 'lib/gallery/example_code.dart') if (key == 'lib/gallery/example_code.dart')
return testCodeFile; return testCodeFile;
return null; return '';
} }
@override @override
......
...@@ -60,11 +60,11 @@ Future<void> main() async { ...@@ -60,11 +60,11 @@ Future<void> main() async {
print('Starting app...'); print('Starting app...');
runApp(const GalleryApp(testMode: true)); runApp(const GalleryApp(testMode: true));
final _LiveWidgetController controller = _LiveWidgetController(WidgetsBinding.instance); final _LiveWidgetController controller = _LiveWidgetController(WidgetsBinding.instance!);
for (final GalleryDemoCategory category in kAllGalleryDemoCategories) { for (final GalleryDemoCategory category in kAllGalleryDemoCategories) {
print('Tapping "${category.name}" section...'); print('Tapping "${category.name}" section...');
await controller.tap(find.text(category.name)); await controller.tap(find.text(category.name));
for (final GalleryDemo demo in kGalleryCategoryToDemos[category]) { for (final GalleryDemo demo in kGalleryCategoryToDemos[category]!) {
final Finder demoItem = find.text(demo.title); final Finder demoItem = find.text(demo.title);
print('Scrolling to "${demo.title}"...'); print('Scrolling to "${demo.title}"...');
await controller.scrollIntoView(demoItem, alignment: 0.5); await controller.scrollIntoView(demoItem, alignment: 0.5);
...@@ -110,10 +110,10 @@ class _LiveWidgetController extends LiveWidgetController { ...@@ -110,10 +110,10 @@ class _LiveWidgetController extends LiveWidgetController {
bool frameSync = true; bool frameSync = true;
/// Waits until at the end of a frame the provided [condition] is [true]. /// Waits until at the end of a frame the provided [condition] is [true].
Future<void> _waitUntilFrame(bool condition(), [Completer<void> completer]) { Future<void> _waitUntilFrame(bool condition(), [Completer<void>? completer]) {
completer ??= Completer<void>(); completer ??= Completer<void>();
if (!condition()) { if (!condition()) {
SchedulerBinding.instance.addPostFrameCallback((Duration timestamp) { SchedulerBinding.instance!.addPostFrameCallback((Duration timestamp) {
_waitUntilFrame(condition, completer); _waitUntilFrame(condition, completer);
}); });
} else { } else {
...@@ -133,11 +133,11 @@ class _LiveWidgetController extends LiveWidgetController { ...@@ -133,11 +133,11 @@ class _LiveWidgetController extends LiveWidgetController {
} }
@override @override
Future<void> tap(Finder finder, { int pointer, int buttons = kPrimaryButton }) async { Future<void> tap(Finder finder, { int? pointer, int buttons = kPrimaryButton }) async {
await super.tap(await _waitForElement(finder), pointer: pointer, buttons: buttons); await super.tap(await _waitForElement(finder), pointer: pointer, buttons: buttons);
} }
Future<void> scrollIntoView(Finder finder, {double alignment}) async { Future<void> scrollIntoView(Finder finder, {required double alignment}) async {
final Finder target = await _waitForElement(finder); final Finder target = await _waitForElement(finder);
await Scrollable.ensureVisible(target.evaluate().single, duration: const Duration(milliseconds: 100), alignment: alignment); await Scrollable.ensureVisible(target.evaluate().single, duration: const Duration(milliseconds: 100), alignment: alignment);
} }
......
...@@ -77,9 +77,9 @@ Future<void> smokeDemo(WidgetTester tester, GalleryDemo demo) async { ...@@ -77,9 +77,9 @@ Future<void> smokeDemo(WidgetTester tester, GalleryDemo demo) async {
// Verify that the dumps are pretty. // Verify that the dumps are pretty.
final String routeName = demo.routeName; final String routeName = demo.routeName;
verifyToStringOutput('debugDumpApp', routeName, WidgetsBinding.instance.renderViewElement.toStringDeep()); verifyToStringOutput('debugDumpApp', routeName, WidgetsBinding.instance!.renderViewElement!.toStringDeep());
verifyToStringOutput('debugDumpRenderTree', routeName, RendererBinding.instance?.renderView?.toStringDeep()); verifyToStringOutput('debugDumpRenderTree', routeName, RendererBinding.instance?.renderView.toStringDeep() ?? '');
verifyToStringOutput('debugDumpLayerTree', routeName, RendererBinding.instance?.renderView?.debugLayer?.toStringDeep()); verifyToStringOutput('debugDumpLayerTree', routeName, RendererBinding.instance?.renderView.debugLayer?.toStringDeep() ?? '');
// Scroll the demo around a bit more. // Scroll the demo around a bit more.
await tester.flingFrom(const Offset(400.0, 300.0), const Offset(0.0, 400.0), 1000.0); await tester.flingFrom(const Offset(400.0, 300.0), const Offset(0.0, 400.0), 1000.0);
...@@ -161,7 +161,7 @@ Future<void> smokeGallery(WidgetTester tester) async { ...@@ -161,7 +161,7 @@ Future<void> smokeGallery(WidgetTester tester) async {
await Scrollable.ensureVisible(tester.element(find.text(category.name)), alignment: 0.5); await Scrollable.ensureVisible(tester.element(find.text(category.name)), alignment: 0.5);
await tester.tap(find.text(category.name)); await tester.tap(find.text(category.name));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
for (final GalleryDemo demo in kGalleryCategoryToDemos[category]) { for (final GalleryDemo demo in kGalleryCategoryToDemos[category]!) {
await Scrollable.ensureVisible(tester.element(find.text(demo.title)), alignment: 0.0); await Scrollable.ensureVisible(tester.element(find.text(demo.title)), alignment: 0.0);
await smokeDemo(tester, demo); await smokeDemo(tester, demo);
tester.binding.debugAssertNoTransientCallbacks('A transient callback was still active after running $demo'); tester.binding.debugAssertNoTransientCallbacks('A transient callback was still active after running $demo');
...@@ -179,8 +179,8 @@ void main() { ...@@ -179,8 +179,8 @@ void main() {
testWidgets('Flutter Gallery app smoke test', smokeGallery); testWidgets('Flutter Gallery app smoke test', smokeGallery);
testWidgets('Flutter Gallery app smoke test with semantics', (WidgetTester tester) async { testWidgets('Flutter Gallery app smoke test with semantics', (WidgetTester tester) async {
RendererBinding.instance.setSemanticsEnabled(true); RendererBinding.instance!.setSemanticsEnabled(true);
await smokeGallery(tester); await smokeGallery(tester);
RendererBinding.instance.setSemanticsEnabled(false); RendererBinding.instance!.setSemanticsEnabled(false);
}); });
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.9 // @dart = 2.9
import 'package:flutter_driver/flutter_driver.dart'; import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.9 // @dart = 2.9
import 'package:flutter_driver/flutter_driver.dart'; import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
......
...@@ -47,7 +47,7 @@ class _MessageHandler { ...@@ -47,7 +47,7 @@ class _MessageHandler {
} }
void main() { void main() {
enableFlutterDriverExtension(handler: _MessageHandler()); enableFlutterDriverExtension(handler: _MessageHandler().call);
// As in lib/main.dart: overriding https://github.com/flutter/flutter/issues/13736 // As in lib/main.dart: overriding https://github.com/flutter/flutter/issues/13736
// for better visual effect at the cost of performance. // for better visual effect at the cost of performance.
runApp(const GalleryApp(testMode: true)); runApp(const GalleryApp(testMode: true));
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.9 // @dart = 2.9
import 'package:integration_test/integration_test_driver.dart' as driver; import 'package:integration_test/integration_test_driver.dart' as driver;
Future<void> main() => driver.integrationDriver( Future<void> main() => driver.integrationDriver(
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.9 // @dart = 2.9
import 'transitions_perf_test.dart' as transitions_perf_test; import 'transitions_perf_test.dart' as transitions_perf_test;
void main([List<String> args = const <String>[]]) => transitions_perf_test.main( void main([List<String> args = const <String>[]]) => transitions_perf_test.main(
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.9 // @dart = 2.9
import 'dart:convert' show JsonEncoder, json; import 'dart:convert' show JsonEncoder, json;
import 'package:file/file.dart'; import 'package:file/file.dart';
......
...@@ -11,7 +11,7 @@ dependencies: ...@@ -11,7 +11,7 @@ dependencies:
flutter_tools: flutter_tools:
path: '../../packages/flutter_tools' path: '../../packages/flutter_tools'
http: 0.12.2 http: 0.12.2
intl: 0.16.1 intl: 0.17.0-nullsafety.2
meta: 1.3.0-nullsafety.6 meta: 1.3.0-nullsafety.6
path: 1.8.0-nullsafety.3 path: 1.8.0-nullsafety.3
process: 4.0.0-nullsafety.4 process: 4.0.0-nullsafety.4
...@@ -34,9 +34,9 @@ dependencies: ...@@ -34,9 +34,9 @@ dependencies:
crypto: 2.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" crypto: 2.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
csslib: 0.16.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" csslib: 0.16.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
dds: 1.4.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" dds: 1.4.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
devtools: 0.9.3+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" devtools: 0.9.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
devtools_server: 0.9.3+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" devtools_server: 0.9.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
devtools_shared: 0.9.3+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" devtools_shared: 0.9.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
dwds: 7.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" dwds: 7.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
fake_async: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" fake_async: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
file: 6.0.0-nullsafety.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" file: 6.0.0-nullsafety.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
...@@ -99,4 +99,4 @@ dev_dependencies: ...@@ -99,4 +99,4 @@ dev_dependencies:
node_preamble: 1.4.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" node_preamble: 1.4.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
# PUBSPEC CHECKSUM: 2704 # PUBSPEC CHECKSUM: e6c1
...@@ -9,9 +9,10 @@ dependencies: ...@@ -9,9 +9,10 @@ dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
intl: 0.16.1 intl: 0.17.0-nullsafety.2
characters: 1.1.0-nullsafety.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" characters: 1.1.0-nullsafety.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
clock: 1.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
collection: 1.15.0-nullsafety.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" collection: 1.15.0-nullsafety.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
meta: 1.3.0-nullsafety.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" meta: 1.3.0-nullsafety.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
path: 1.8.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" path: 1.8.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
...@@ -26,7 +27,6 @@ dev_dependencies: ...@@ -26,7 +27,6 @@ dev_dependencies:
async: 2.5.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" async: 2.5.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
boolean_selector: 2.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" boolean_selector: 2.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
charcode: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" charcode: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
clock: 1.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
fake_async: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" fake_async: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
matcher: 0.12.10-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" matcher: 0.12.10-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
source_span: 1.8.0-nullsafety.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" source_span: 1.8.0-nullsafety.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
...@@ -36,4 +36,4 @@ dev_dependencies: ...@@ -36,4 +36,4 @@ dev_dependencies:
term_glyph: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" term_glyph: 1.2.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
test_api: 0.2.19-nullsafety.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" test_api: 0.2.19-nullsafety.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
# PUBSPEC CHECKSUM: db22 # PUBSPEC CHECKSUM: 82fa
...@@ -36,6 +36,7 @@ const Map<String, String> _kManuallyPinnedDependencies = <String, String>{ ...@@ -36,6 +36,7 @@ const Map<String, String> _kManuallyPinnedDependencies = <String, String>{
'charcode': '1.2.0-nullsafety.3', 'charcode': '1.2.0-nullsafety.3',
'clock': '1.1.0-nullsafety.3', 'clock': '1.1.0-nullsafety.3',
'collection': '1.15.0-nullsafety.5', 'collection': '1.15.0-nullsafety.5',
'intl': '0.17.0-nullsafety.2',
'fake_async': '1.2.0-nullsafety.3', 'fake_async': '1.2.0-nullsafety.3',
'js': '0.6.3-nullsafety.3', 'js': '0.6.3-nullsafety.3',
'matcher': '0.12.10-nullsafety.3', 'matcher': '0.12.10-nullsafety.3',
......
...@@ -47,7 +47,7 @@ import 'package:intl/intl.dart' as intl; ...@@ -47,7 +47,7 @@ import 'package:intl/intl.dart' as intl;
/// # Internationalization support. /// # Internationalization support.
/// flutter_localizations: /// flutter_localizations:
/// sdk: flutter /// sdk: flutter
/// intl: 0.16.1 /// intl: 0.17.0-nullsafety.2
/// ///
/// # rest of dependencies /// # rest of dependencies
/// ``` /// ```
......
...@@ -20,7 +20,7 @@ dependencies: ...@@ -20,7 +20,7 @@ dependencies:
flutter_template_images: 1.0.1 flutter_template_images: 1.0.1
html: 0.14.0+4 html: 0.14.0+4
http: 0.12.2 http: 0.12.2
intl: 0.16.1 intl: 0.17.0-nullsafety.2
meta: 1.3.0-nullsafety.6 meta: 1.3.0-nullsafety.6
multicast_dns: 0.2.2 multicast_dns: 0.2.2
mustache_template: 1.0.0+1 mustache_template: 1.0.0+1
...@@ -49,7 +49,7 @@ dependencies: ...@@ -49,7 +49,7 @@ dependencies:
mime: 0.9.7 mime: 0.9.7
logging: 0.11.4 logging: 0.11.4
http_multi_server: 2.2.0 http_multi_server: 2.2.0
devtools_server: 0.9.3+4 devtools_server: 0.9.4
convert: 2.1.1 convert: 2.1.1
async: 2.5.0-nullsafety.3 async: 2.5.0-nullsafety.3
...@@ -71,8 +71,8 @@ dependencies: ...@@ -71,8 +71,8 @@ dependencies:
cli_util: 0.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" cli_util: 0.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
clock: 1.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" clock: 1.1.0-nullsafety.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
csslib: 0.16.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" csslib: 0.16.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
devtools: 0.9.3+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" devtools: 0.9.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
devtools_shared: 0.9.3+4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" devtools_shared: 0.9.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
fixnum: 0.10.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" fixnum: 0.10.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
glob: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" glob: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
http_parser: 3.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" http_parser: 3.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
...@@ -113,4 +113,4 @@ dartdoc: ...@@ -113,4 +113,4 @@ dartdoc:
# Exclude this package from the hosted API docs. # Exclude this package from the hosted API docs.
nodoc: true nodoc: true
# PUBSPEC CHECKSUM: 47dc # PUBSPEC CHECKSUM: 359a
...@@ -42,7 +42,7 @@ dependencies: ...@@ -42,7 +42,7 @@ dependencies:
sdk: flutter sdk: flutter
flutter_localizations: flutter_localizations:
sdk: flutter sdk: flutter
intl: 0.16.1 intl: 0.17.0-nullsafety.2
'''; ''';
@override @override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment