Migrate all of examples/layers to sound null safety (#68744)
This commit is contained in:
committed by
GitHub
parent
8273b99294
commit
dd2ea7c503
@@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.10
|
||||
|
||||
// This example shows how to build a render tree with a non-cartesian coordinate
|
||||
// system. Most of the guts of this examples are in src/sector_layout.dart.
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ void main() {
|
||||
subrow.add(RenderSolidColorBox(const Color(0x7FCCFFFF), desiredSize: const Size(30.0, 40.0)));
|
||||
row.add(subrow);
|
||||
table.add(row);
|
||||
final FlexParentData rowParentData = row.parentData as FlexParentData;
|
||||
final FlexParentData rowParentData = row.parentData! as FlexParentData;
|
||||
rowParentData.flex = 1;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ void main() {
|
||||
row.add(RenderSolidColorBox(const Color(0xFFCCCCFF), desiredSize: const Size(160.0, 60.0)));
|
||||
row.mainAxisAlignment = justify;
|
||||
table.add(row);
|
||||
final FlexParentData rowParentData = row.parentData as FlexParentData;
|
||||
final FlexParentData rowParentData = row.parentData! as FlexParentData;
|
||||
rowParentData.flex = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.10
|
||||
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
@@ -20,7 +20,7 @@ List<Color> _kColors = <Color>[
|
||||
|
||||
/// A simple model object for a dot that reacts to pointer pressure.
|
||||
class Dot {
|
||||
Dot({ Color color }) : _paint = Paint()..color = color;
|
||||
Dot({ required Color color }) : _paint = Paint()..color = color;
|
||||
|
||||
final Paint _paint;
|
||||
Offset position = Offset.zero;
|
||||
@@ -65,7 +65,7 @@ class RenderDots extends RenderBox {
|
||||
@override
|
||||
void handleEvent(PointerEvent event, BoxHitTestEntry entry) {
|
||||
if (event is PointerDownEvent) {
|
||||
final Color color = _kColors[event.pointer.remainder(_kColors.length) as int];
|
||||
final Color color = _kColors[event.pointer.remainder(_kColors.length)];
|
||||
_dots[event.pointer] = Dot(color: color)..update(event);
|
||||
// We call markNeedsPaint to indicate that our painting commands have
|
||||
// changed and that paint needs to be called before displaying a new frame
|
||||
@@ -76,7 +76,7 @@ class RenderDots extends RenderBox {
|
||||
_dots.remove(event.pointer);
|
||||
markNeedsPaint();
|
||||
} else if (event is PointerMoveEvent) {
|
||||
_dots[event.pointer].update(event);
|
||||
_dots[event.pointer]!.update(event);
|
||||
markNeedsPaint();
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ void main() {
|
||||
//
|
||||
// We use the StackParentData of the paragraph to position the text in the top
|
||||
// left corner of the screen.
|
||||
final StackParentData paragraphParentData = paragraph.parentData as StackParentData;
|
||||
final StackParentData paragraphParentData = paragraph.parentData! as StackParentData;
|
||||
paragraphParentData
|
||||
..top = 40.0
|
||||
..left = 20.0;
|
||||
|
||||
Reference in New Issue
Block a user