Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
dd2ea7c5
Unverified
Commit
dd2ea7c5
authored
Oct 22, 2020
by
Michael Goderbauer
Committed by
GitHub
Oct 22, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate all of examples/layers to sound null safety (#68744)
parent
8273b992
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
54 additions
and
65 deletions
+54
-65
test.dart
dev/bots/test.dart
+1
-1
pubspec.yaml
examples/layers/pubspec.yaml
+1
-1
text.dart
examples/layers/raw/text.dart
+1
-1
touch_input.dart
examples/layers/raw/touch_input.dart
+1
-1
custom_coordinate_systems.dart
examples/layers/rendering/custom_coordinate_systems.dart
+0
-2
flex_layout.dart
examples/layers/rendering/flex_layout.dart
+2
-2
sector_layout.dart
examples/layers/rendering/src/sector_layout.dart
+0
-2
touch_input.dart
examples/layers/rendering/touch_input.dart
+4
-4
isolate.dart
examples/layers/services/isolate.dart
+7
-8
lifecycle.dart
examples/layers/services/lifecycle.dart
+4
-4
custom_render_box.dart
examples/layers/widgets/custom_render_box.dart
+1
-1
gestures.dart
examples/layers/widgets/gestures.dart
+15
-15
media_query.dart
examples/layers/widgets/media_query.dart
+4
-4
sectors.dart
examples/layers/widgets/sectors.dart
+2
-2
spinning_mixed.dart
examples/layers/widgets/spinning_mixed.dart
+9
-9
spinning_square.dart
examples/layers/widgets/spinning_square.dart
+1
-1
styled_text.dart
examples/layers/widgets/styled_text.dart
+1
-7
No files found.
dev/bots/test.dart
View file @
dd2ea7c5
...
...
@@ -604,7 +604,7 @@ Future<void> _runFrameworkTests() async {
await
_runFlutterTest
(
path
.
join
(
flutterRoot
,
'dev'
,
'manual_tests'
),
tableData:
bigqueryApi
?.
tabledata
);
await
_runFlutterTest
(
path
.
join
(
flutterRoot
,
'dev'
,
'tools'
,
'vitool'
),
tableData:
bigqueryApi
?.
tabledata
);
await
_runFlutterTest
(
path
.
join
(
flutterRoot
,
'examples'
,
'hello_world'
),
tableData:
bigqueryApi
?.
tabledata
);
await
_runFlutterTest
(
path
.
join
(
flutterRoot
,
'examples'
,
'layers'
),
tableData:
bigqueryApi
?.
tabledata
,
options:
mixedMode
NullSafetyOptions
);
await
_runFlutterTest
(
path
.
join
(
flutterRoot
,
'examples'
,
'layers'
),
tableData:
bigqueryApi
?.
tabledata
,
options:
sound
NullSafetyOptions
);
await
_runFlutterTest
(
path
.
join
(
flutterRoot
,
'dev'
,
'benchmarks'
,
'test_apps'
,
'stocks'
),
tableData:
bigqueryApi
?.
tabledata
);
await
_runFlutterTest
(
path
.
join
(
flutterRoot
,
'packages'
,
'flutter_driver'
),
tableData:
bigqueryApi
?.
tabledata
,
tests:
<
String
>[
path
.
join
(
'test'
,
'src'
,
'real_tests'
)]);
await
_runFlutterTest
(
path
.
join
(
flutterRoot
,
'packages'
,
'flutter_goldens'
),
tableData:
bigqueryApi
?.
tabledata
);
...
...
examples/layers/pubspec.yaml
View file @
dd2ea7c5
...
...
@@ -2,7 +2,7 @@ name: flutter_examples_layers
environment
:
# The pub client defaults to an <2.0.0 sdk constraint which we need to explicitly overwrite.
sdk
:
"
>=2.
0.0-dev.68.0
<3.0.0"
sdk
:
"
>=2.
10.0-0.0.dev
<3.0.0"
dependencies
:
flutter
:
...
...
examples/layers/raw/text.dart
View file @
dd2ea7c5
...
...
@@ -9,7 +9,7 @@ import 'dart:typed_data';
import
'dart:ui'
as
ui
;
// A paragraph represents a rectangular region that contains some text.
ui
.
Paragraph
paragraph
;
late
ui
.
Paragraph
paragraph
;
ui
.
Picture
paint
(
ui
.
Rect
paintBounds
)
{
final
ui
.
PictureRecorder
recorder
=
ui
.
PictureRecorder
();
...
...
examples/layers/raw/touch_input.dart
View file @
dd2ea7c5
...
...
@@ -8,7 +8,7 @@
import
'dart:typed_data'
;
import
'dart:ui'
as
ui
;
ui
.
Color
color
;
late
ui
.
Color
color
;
ui
.
Picture
paint
(
ui
.
Rect
paintBounds
)
{
// First we create a PictureRecorder to record the commands we're going to
...
...
examples/layers/rendering/custom_coordinate_systems.dart
View file @
dd2ea7c5
...
...
@@ -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.
...
...
examples/layers/rendering/flex_layout.dart
View file @
dd2ea7c5
...
...
@@ -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
;
}
...
...
examples/layers/rendering/src/sector_layout.dart
View file @
dd2ea7c5
...
...
@@ -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'
;
...
...
examples/layers/rendering/touch_input.dart
View file @
dd2ea7c5
...
...
@@ -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
;
...
...
examples/layers/services/isolate.dart
View file @
dd2ea7c5
...
...
@@ -5,7 +5,6 @@
import
'dart:convert'
;
import
'dart:isolate'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
...
...
@@ -17,7 +16,7 @@ typedef OnResultListener = void Function(String result);
// The choice of JSON parsing here is meant as an example that might surface
// in real-world applications.
class
Calculator
{
Calculator
({
@required
this
.
onProgressListener
,
@required
this
.
onResultListener
,
String
data
})
Calculator
({
required
this
.
onProgressListener
,
required
this
.
onResultListener
,
String
?
data
})
:
assert
(
onProgressListener
!=
null
),
assert
(
onResultListener
!=
null
),
// In order to keep the example files smaller, we "cheat" a little and
...
...
@@ -53,7 +52,7 @@ class Calculator {
}
}
static
String
_replicateJson
(
String
data
,
int
count
)
{
static
String
_replicateJson
(
String
?
data
,
int
count
)
{
final
StringBuffer
buffer
=
StringBuffer
()..
write
(
'['
);
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
buffer
.
write
(
data
);
...
...
@@ -85,7 +84,7 @@ class CalculationMessage {
// This class manages these ports and maintains state related to the
// progress of the background computation.
class
CalculationManager
{
CalculationManager
({
@required
this
.
onProgressListener
,
@
required
this
.
onResultListener
})
CalculationManager
({
required
this
.
onProgressListener
,
required
this
.
onResultListener
})
:
assert
(
onProgressListener
!=
null
),
assert
(
onResultListener
!=
null
),
_receivePort
=
ReceivePort
()
{
...
...
@@ -120,7 +119,7 @@ class CalculationManager {
if
(
isRunning
)
{
_state
=
CalculationState
.
idle
;
if
(
_isolate
!=
null
)
{
_isolate
.
kill
(
priority:
Isolate
.
immediate
);
_isolate
!
.
kill
(
priority:
Isolate
.
immediate
);
_isolate
=
null
;
_completed
=
0.0
;
_total
=
1.0
;
...
...
@@ -129,7 +128,7 @@ class CalculationManager {
}
final
ReceivePort
_receivePort
;
Isolate
_isolate
;
Isolate
?
_isolate
;
void
_runCalculation
()
{
// Load the JSON string. This is done in the main isolate because spawned
...
...
@@ -209,8 +208,8 @@ class IsolateExampleState extends State<StatefulWidget> with SingleTickerProvide
String
_label
=
'Start'
;
String
_result
=
' '
;
double
_progress
=
0.0
;
AnimationController
_animation
;
CalculationManager
_calculationManager
;
late
AnimationController
_animation
;
late
CalculationManager
_calculationManager
;
@override
void
initState
()
{
...
...
examples/layers/services/lifecycle.dart
View file @
dd2ea7c5
...
...
@@ -5,7 +5,7 @@
import
'package:flutter/widgets.dart'
;
class
LifecycleWatcher
extends
StatefulWidget
{
const
LifecycleWatcher
({
Key
key
})
:
super
(
key:
key
);
const
LifecycleWatcher
({
Key
?
key
})
:
super
(
key:
key
);
@override
_LifecycleWatcherState
createState
()
=>
_LifecycleWatcherState
();
...
...
@@ -13,17 +13,17 @@ class LifecycleWatcher extends StatefulWidget {
class
_LifecycleWatcherState
extends
State
<
LifecycleWatcher
>
with
WidgetsBindingObserver
{
AppLifecycleState
_lastLifecycleState
;
AppLifecycleState
?
_lastLifecycleState
;
@override
void
initState
()
{
super
.
initState
();
WidgetsBinding
.
instance
.
addObserver
(
this
);
WidgetsBinding
.
instance
!
.
addObserver
(
this
);
}
@override
void
dispose
()
{
WidgetsBinding
.
instance
.
removeObserver
(
this
);
WidgetsBinding
.
instance
!
.
removeObserver
(
this
);
super
.
dispose
();
}
...
...
examples/layers/widgets/custom_render_box.dart
View file @
dd2ea7c5
...
...
@@ -39,7 +39,7 @@ class RenderDots extends RenderConstrainedBox {
}
class
Dots
extends
SingleChildRenderObjectWidget
{
const
Dots
({
Key
key
,
Widget
child
})
:
super
(
key:
key
,
child:
child
);
const
Dots
({
Key
?
key
,
Widget
?
child
})
:
super
(
key:
key
,
child:
child
);
@override
RenderDots
createRenderObject
(
BuildContext
context
)
=>
RenderDots
();
...
...
examples/layers/widgets/gestures.dart
View file @
dd2ea7c5
...
...
@@ -6,14 +6,14 @@ import 'package:flutter/material.dart';
class
_GesturePainter
extends
CustomPainter
{
const
_GesturePainter
({
this
.
zoom
,
this
.
offset
,
this
.
swatch
,
this
.
forward
,
this
.
scaleEnabled
,
this
.
tapEnabled
,
this
.
doubleTapEnabled
,
this
.
longPressEnabled
,
required
this
.
zoom
,
required
this
.
offset
,
required
this
.
swatch
,
required
this
.
forward
,
required
this
.
scaleEnabled
,
required
this
.
tapEnabled
,
required
this
.
doubleTapEnabled
,
required
this
.
longPressEnabled
,
});
final
double
zoom
;
...
...
@@ -61,12 +61,12 @@ class GestureDemo extends StatefulWidget {
class
GestureDemoState
extends
State
<
GestureDemo
>
{
Offset
_startingFocalPoint
;
late
Offset
_startingFocalPoint
;
Offset
_previousOffset
;
late
Offset
_previousOffset
;
Offset
_offset
=
Offset
.
zero
;
double
_previousZoom
;
late
double
_previousZoom
;
double
_zoom
=
1.0
;
static
const
List
<
MaterialColor
>
kSwatches
=
<
MaterialColor
>[
...
...
@@ -175,7 +175,7 @@ class GestureDemoState extends State<GestureDemo> {
children:
<
Widget
>[
Checkbox
(
value:
_scaleEnabled
,
onChanged:
(
bool
value
)
{
setState
(()
{
_scaleEnabled
=
value
;
});
},
onChanged:
(
bool
?
value
)
{
setState
(()
{
_scaleEnabled
=
value
!
;
});
},
),
const
Text
(
'Scale'
),
],
...
...
@@ -184,7 +184,7 @@ class GestureDemoState extends State<GestureDemo> {
children:
<
Widget
>[
Checkbox
(
value:
_tapEnabled
,
onChanged:
(
bool
value
)
{
setState
(()
{
_tapEnabled
=
value
;
});
},
onChanged:
(
bool
?
value
)
{
setState
(()
{
_tapEnabled
=
value
!
;
});
},
),
const
Text
(
'Tap'
),
],
...
...
@@ -193,7 +193,7 @@ class GestureDemoState extends State<GestureDemo> {
children:
<
Widget
>[
Checkbox
(
value:
_doubleTapEnabled
,
onChanged:
(
bool
value
)
{
setState
(()
{
_doubleTapEnabled
=
value
;
});
},
onChanged:
(
bool
?
value
)
{
setState
(()
{
_doubleTapEnabled
=
value
!
;
});
},
),
const
Text
(
'Double Tap'
),
],
...
...
@@ -202,7 +202,7 @@ class GestureDemoState extends State<GestureDemo> {
children:
<
Widget
>[
Checkbox
(
value:
_longPressEnabled
,
onChanged:
(
bool
value
)
{
setState
(()
{
_longPressEnabled
=
value
;
});
},
onChanged:
(
bool
?
value
)
{
setState
(()
{
_longPressEnabled
=
value
!
;
});
},
),
const
Text
(
'Long Press'
),
],
...
...
examples/layers/widgets/media_query.dart
View file @
dd2ea7c5
...
...
@@ -5,7 +5,7 @@
import
'package:flutter/material.dart'
;
class
AdaptedListItem
extends
StatelessWidget
{
const
AdaptedListItem
({
Key
key
,
this
.
name
})
:
super
(
key:
key
);
const
AdaptedListItem
({
Key
?
key
,
required
this
.
name
})
:
super
(
key:
key
);
final
String
name
;
...
...
@@ -26,7 +26,7 @@ class AdaptedListItem extends StatelessWidget {
}
class
AdaptedGridItem
extends
StatelessWidget
{
const
AdaptedGridItem
({
Key
key
,
this
.
name
})
:
super
(
key:
key
);
const
AdaptedGridItem
({
Key
?
key
,
required
this
.
name
})
:
super
(
key:
key
);
final
String
name
;
...
...
@@ -65,13 +65,13 @@ const double _kMaxTileWidth = 150.0;
const
double
_kGridViewBreakpoint
=
450.0
;
class
AdaptiveContainer
extends
StatelessWidget
{
const
AdaptiveContainer
({
Key
key
,
this
.
names
})
:
super
(
key:
key
);
const
AdaptiveContainer
({
Key
?
key
,
required
this
.
names
})
:
super
(
key:
key
);
final
List
<
String
>
names
;
@override
Widget
build
(
BuildContext
context
)
{
if
(
MediaQuery
.
of
(
context
).
size
.
width
<
_kGridViewBreakpoint
)
{
if
(
MediaQuery
.
of
(
context
)
!
.
size
.
width
<
_kGridViewBreakpoint
)
{
return
ListView
(
itemExtent:
_kListItemExtent
,
children:
names
.
map
<
Widget
>((
String
name
)
=>
AdaptedListItem
(
name:
name
)).
toList
(),
...
...
examples/layers/widgets/sectors.dart
View file @
dd2ea7c5
...
...
@@ -54,9 +54,9 @@ class SectorAppState extends State<SectorApp> {
int
index
=
0
;
while
(
index
<
actualSectorSizes
.
length
&&
index
<
wantedSectorSizes
.
length
&&
actualSectorSizes
[
index
]
==
wantedSectorSizes
[
index
])
index
+=
1
;
final
RenderSectorRing
ring
=
sectors
.
child
as
RenderSectorRing
;
final
RenderSectorRing
ring
=
sectors
.
child
!
as
RenderSectorRing
;
while
(
index
<
actualSectorSizes
.
length
)
{
ring
.
remove
(
ring
.
lastChild
);
ring
.
remove
(
ring
.
lastChild
!
);
actualSectorSizes
.
removeLast
();
}
while
(
index
<
wantedSectorSizes
.
length
)
{
...
...
examples/layers/widgets/spinning_mixed.dart
View file @
dd2ea7c5
...
...
@@ -11,13 +11,13 @@ import '../rendering/src/solid_color_box.dart';
void
addFlexChildSolidColor
(
RenderFlex
parent
,
Color
backgroundColor
,
{
int
flex
=
0
})
{
final
RenderSolidColorBox
child
=
RenderSolidColorBox
(
backgroundColor
);
parent
.
add
(
child
);
final
FlexParentData
childParentData
=
child
.
parentData
as
FlexParentData
;
final
FlexParentData
childParentData
=
child
.
parentData
!
as
FlexParentData
;
childParentData
.
flex
=
flex
;
}
// Solid color, Widget version
class
Rectangle
extends
StatelessWidget
{
const
Rectangle
(
this
.
color
,
{
Key
key
})
:
super
(
key:
key
);
const
Rectangle
(
this
.
color
,
{
Key
?
key
})
:
super
(
key:
key
);
final
Color
color
;
...
...
@@ -31,8 +31,8 @@ class Rectangle extends StatelessWidget {
}
}
double
value
;
RenderObjectToWidgetElement
<
RenderBox
>
element
;
double
?
value
;
RenderObjectToWidgetElement
<
RenderBox
>
?
element
;
BuildOwner
owner
=
BuildOwner
();
void
attachWidgetTreeToRenderTree
(
RenderProxyBox
container
)
{
element
=
RenderObjectToWidgetAdapter
<
RenderBox
>(
...
...
@@ -58,7 +58,7 @@ void attachWidgetTreeToRenderTree(RenderProxyBox container) {
],
),
onPressed:
()
{
value
=
value
==
null
?
0.1
:
(
value
+
0.1
)
%
1.0
;
value
=
value
==
null
?
0.1
:
(
value
!
+
0.1
)
%
1.0
;
attachWidgetTreeToRenderTree
(
container
);
},
),
...
...
@@ -77,17 +77,17 @@ void attachWidgetTreeToRenderTree(RenderProxyBox container) {
).
attachToRenderTree
(
owner
,
element
);
}
Duration
timeBase
;
RenderTransform
transformBox
;
Duration
?
timeBase
;
late
RenderTransform
transformBox
;
void
rotate
(
Duration
timeStamp
)
{
timeBase
??=
timeStamp
;
final
double
delta
=
(
timeStamp
-
timeBase
).
inMicroseconds
.
toDouble
()
/
Duration
.
microsecondsPerSecond
;
// radians
final
double
delta
=
(
timeStamp
-
timeBase
!
).
inMicroseconds
.
toDouble
()
/
Duration
.
microsecondsPerSecond
;
// radians
transformBox
.
setIdentity
();
transformBox
.
rotateZ
(
delta
);
owner
.
buildScope
(
element
);
owner
.
buildScope
(
element
!
);
}
void
main
(
)
{
...
...
examples/layers/widgets/spinning_square.dart
View file @
dd2ea7c5
...
...
@@ -10,7 +10,7 @@ class SpinningSquare extends StatefulWidget {
}
class
_SpinningSquareState
extends
State
<
SpinningSquare
>
with
SingleTickerProviderStateMixin
{
AnimationController
_animation
;
late
AnimationController
_animation
;
@override
void
initState
()
{
...
...
examples/layers/widgets/styled_text.dart
View file @
dd2ea7c5
...
...
@@ -78,13 +78,7 @@ class StyledTextDemo extends StatefulWidget {
}
class
_StyledTextDemoState
extends
State
<
StyledTextDemo
>
{
@override
void
initState
()
{
super
.
initState
();
_toText
=
toStyledText
;
}
_TextTransformer
_toText
;
_TextTransformer
_toText
=
toStyledText
;
void
_handleTap
()
{
setState
(()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment