implicit-casts:false in examples (#45805)
This commit is contained in:
committed by
GitHub
parent
c6fe7bb9e1
commit
ec0842e0d3
@@ -64,7 +64,7 @@ class _RenderStatusBarPaddingSliver extends RenderSliver {
|
||||
|
||||
@override
|
||||
void performLayout() {
|
||||
final double height = (maxHeight - constraints.scrollOffset / scrollFactor).clamp(0.0, maxHeight);
|
||||
final double height = (maxHeight - constraints.scrollOffset / scrollFactor).clamp(0.0, maxHeight) as double;
|
||||
geometry = SliverGeometry(
|
||||
paintExtent: math.min(height, constraints.remainingPaintExtent),
|
||||
scrollExtent: maxHeight,
|
||||
@@ -285,7 +285,7 @@ class _AllSectionsView extends AnimatedWidget {
|
||||
final List<Widget> sectionCards;
|
||||
|
||||
double _selectedIndexDelta(int index) {
|
||||
return (index.toDouble() - selectedIndex.value).abs().clamp(0.0, 1.0);
|
||||
return (index.toDouble() - selectedIndex.value).abs().clamp(0.0, 1.0) as double;
|
||||
}
|
||||
|
||||
Widget _build(BuildContext context, BoxConstraints constraints) {
|
||||
@@ -498,7 +498,7 @@ class _AnimationDemoHomeState extends State<AnimationDemoHome> {
|
||||
return ListTile.divideTiles(context: context, tiles: detailItems);
|
||||
}
|
||||
|
||||
Iterable<Widget> _allHeadingItems(double maxHeight, double midScrollOffset) {
|
||||
List<Widget> _allHeadingItems(double maxHeight, double midScrollOffset) {
|
||||
final List<Widget> sectionCards = <Widget>[];
|
||||
for (int index = 0; index < allSections.length; index++) {
|
||||
sectionCards.add(LayoutId(
|
||||
|
||||
@@ -44,10 +44,8 @@ class Section {
|
||||
|
||||
@override
|
||||
bool operator==(Object other) {
|
||||
if (other is! Section)
|
||||
return false;
|
||||
final Section otherSection = other;
|
||||
return title == otherSection.title;
|
||||
return other is Section
|
||||
&& other.title == title;
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -287,7 +287,7 @@ class CalcExpression {
|
||||
// multiplication or division symbols.
|
||||
num currentTermValue = removeNextTerm(list);
|
||||
while (list.isNotEmpty) {
|
||||
final OperationToken opToken = list.removeAt(0);
|
||||
final OperationToken opToken = list.removeAt(0) as OperationToken;
|
||||
final num nextTermValue = removeNextTerm(list);
|
||||
switch (opToken.operation) {
|
||||
case Operation.Addition:
|
||||
@@ -313,11 +313,11 @@ class CalcExpression {
|
||||
/// and division symbols.
|
||||
static num removeNextTerm(List<ExpressionToken> list) {
|
||||
assert(list != null && list.isNotEmpty);
|
||||
final NumberToken firstNumToken = list.removeAt(0);
|
||||
final NumberToken firstNumToken = list.removeAt(0) as NumberToken;
|
||||
num currentValue = firstNumToken.number;
|
||||
while (list.isNotEmpty) {
|
||||
bool isDivision = false;
|
||||
final OperationToken nextOpToken = list.first;
|
||||
final OperationToken nextOpToken = list.first as OperationToken;
|
||||
switch (nextOpToken.operation) {
|
||||
case Operation.Addition:
|
||||
case Operation.Subtraction:
|
||||
@@ -331,7 +331,7 @@ class CalcExpression {
|
||||
// Remove the operation token.
|
||||
list.removeAt(0);
|
||||
// Remove the next number token.
|
||||
final NumberToken nextNumToken = list.removeAt(0);
|
||||
final NumberToken nextNumToken = list.removeAt(0) as NumberToken;
|
||||
final num nextNumber = nextNumToken.number;
|
||||
if (isDivision)
|
||||
currentValue /= nextNumber;
|
||||
|
||||
@@ -293,9 +293,9 @@ class Tab1ItemPageState extends State<Tab1ItemPage> {
|
||||
final math.Random random = math.Random();
|
||||
return Color.fromARGB(
|
||||
255,
|
||||
(widget.color.red + random.nextInt(100) - 50).clamp(0, 255),
|
||||
(widget.color.green + random.nextInt(100) - 50).clamp(0, 255),
|
||||
(widget.color.blue + random.nextInt(100) - 50).clamp(0, 255),
|
||||
(widget.color.red + random.nextInt(100) - 50).clamp(0, 255) as int,
|
||||
(widget.color.green + random.nextInt(100) - 50).clamp(0, 255) as int,
|
||||
(widget.color.blue + random.nextInt(100) - 50).clamp(0, 255) as int,
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -635,9 +635,9 @@ class Tab2ConversationAvatar extends StatelessWidget {
|
||||
color,
|
||||
Color.fromARGB(
|
||||
color.alpha,
|
||||
(color.red - 60).clamp(0, 255),
|
||||
(color.green - 60).clamp(0, 255),
|
||||
(color.blue - 60).clamp(0, 255),
|
||||
(color.red - 60).clamp(0, 255) as int,
|
||||
(color.green - 60).clamp(0, 255) as int,
|
||||
(color.blue - 60).clamp(0, 255) as int,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -205,12 +205,12 @@ class BackdropPanel extends StatelessWidget {
|
||||
class BackdropTitle extends AnimatedWidget {
|
||||
const BackdropTitle({
|
||||
Key key,
|
||||
Listenable listenable,
|
||||
Animation<double> listenable,
|
||||
}) : super(key: key, listenable: listenable);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Animation<double> animation = listenable;
|
||||
final Animation<double> animation = listenable as Animation<double>;
|
||||
return DefaultTextStyle(
|
||||
style: Theme.of(context).primaryTextTheme.title,
|
||||
softWrap: false,
|
||||
@@ -283,7 +283,7 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt
|
||||
}
|
||||
|
||||
double get _backdropHeight {
|
||||
final RenderBox renderBox = _backdropKey.currentContext.findRenderObject();
|
||||
final RenderBox renderBox = _backdropKey.currentContext.findRenderObject() as RenderBox;
|
||||
return renderBox.size.height;
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,10 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv
|
||||
Offset _clampOffset(Offset offset) {
|
||||
final Size size = context.size;
|
||||
final Offset minOffset = Offset(size.width, size.height) * (1.0 - _scale);
|
||||
return Offset(offset.dx.clamp(minOffset.dx, 0.0), offset.dy.clamp(minOffset.dy, 0.0));
|
||||
return Offset(
|
||||
offset.dx.clamp(minOffset.dx, 0.0) as double,
|
||||
offset.dy.clamp(minOffset.dy, 0.0) as double,
|
||||
);
|
||||
}
|
||||
|
||||
void _handleFlingAnimation() {
|
||||
@@ -107,7 +110,7 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv
|
||||
|
||||
void _handleOnScaleUpdate(ScaleUpdateDetails details) {
|
||||
setState(() {
|
||||
_scale = (_previousScale * details.scale).clamp(1.0, 4.0);
|
||||
_scale = (_previousScale * details.scale).clamp(1.0, 4.0) as double;
|
||||
// Ensure that image location under the focal point stays in the same place despite scaling.
|
||||
_offset = _clampOffset(details.focalPoint - _normalizedOffset * _scale);
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@ class _PageSelector extends StatelessWidget {
|
||||
void _handleArrowButtonPress(BuildContext context, int delta) {
|
||||
final TabController controller = DefaultTabController.of(context);
|
||||
if (!controller.indexIsChanging)
|
||||
controller.animateTo((controller.index + delta).clamp(0, icons.length - 1));
|
||||
controller.animateTo((controller.index + delta).clamp(0, icons.length - 1) as int);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -257,7 +257,7 @@ class _SlidersState extends State<_Sliders> {
|
||||
final double newValue = double.tryParse(value);
|
||||
if (newValue != null && newValue != _continuousValue) {
|
||||
setState(() {
|
||||
_continuousValue = newValue.clamp(0, 100);
|
||||
_continuousValue = newValue.clamp(0.0, 100.0) as double;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@@ -129,7 +129,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
|
||||
bottom: extraPadding,
|
||||
),
|
||||
child: Center(
|
||||
child: PestoLogo(height: logoHeight, t: t.clamp(0.0, 1.0)),
|
||||
child: PestoLogo(height: logoHeight, t: t.clamp(0.0, 1.0) as double),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -111,7 +111,7 @@ class _FrontLayer extends StatelessWidget {
|
||||
class _BackdropTitle extends AnimatedWidget {
|
||||
const _BackdropTitle({
|
||||
Key key,
|
||||
Listenable listenable,
|
||||
Animation<double> listenable,
|
||||
this.onPress,
|
||||
@required this.frontTitle,
|
||||
@required this.backTitle,
|
||||
@@ -119,14 +119,14 @@ class _BackdropTitle extends AnimatedWidget {
|
||||
assert(backTitle != null),
|
||||
super(key: key, listenable: listenable);
|
||||
|
||||
final Function onPress;
|
||||
final void Function() onPress;
|
||||
final Widget frontTitle;
|
||||
final Widget backTitle;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Animation<double> animation = CurvedAnimation(
|
||||
parent: listenable,
|
||||
parent: listenable as Animation<double>,
|
||||
curve: const Interval(0.0, 0.78),
|
||||
);
|
||||
|
||||
|
||||
@@ -604,7 +604,7 @@ class _ListModel {
|
||||
_items = initialItems?.toList() ?? <int>[];
|
||||
|
||||
final GlobalKey<AnimatedListState> listKey;
|
||||
final dynamic removedItemBuilder;
|
||||
final Widget Function(int item, BuildContext context, Animation<double> animation) removedItemBuilder;
|
||||
final List<int> _items;
|
||||
|
||||
AnimatedListState get _animatedList => listKey.currentState;
|
||||
|
||||
@@ -270,8 +270,9 @@ class BoardPoint {
|
||||
if (other.runtimeType != runtimeType) {
|
||||
return false;
|
||||
}
|
||||
final BoardPoint boardPoint = other;
|
||||
return boardPoint.q == q && boardPoint.r == r;
|
||||
return other is BoardPoint
|
||||
&& other.q == q
|
||||
&& other.r == r;
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -183,7 +183,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker
|
||||
// Get the offset of the current widget from the global screen coordinates.
|
||||
// TODO(justinmc): Protect against calling this during first build.
|
||||
static Offset getOffset(BuildContext context) {
|
||||
final RenderBox renderObject = context.findRenderObject();
|
||||
final RenderBox renderObject = context.findRenderObject() as RenderBox;
|
||||
return renderObject.localToGlobal(Offset.zero);
|
||||
}
|
||||
|
||||
@@ -377,7 +377,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker
|
||||
final double clampedTotalScale = totalScale.clamp(
|
||||
widget.minScale,
|
||||
widget.maxScale,
|
||||
);
|
||||
) as double;
|
||||
final double clampedScale = clampedTotalScale / currentScale;
|
||||
return matrix..scale(clampedScale);
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ class _ConnectivityOverlayState extends State<ConnectivityOverlay> {
|
||||
StreamSubscription<ConnectivityResult> connectivitySubscription;
|
||||
bool connected = true;
|
||||
|
||||
static const Widget errorSnackBar = SnackBar(
|
||||
static const SnackBar errorSnackBar = SnackBar(
|
||||
backgroundColor: Colors.red,
|
||||
content: ListTile(
|
||||
title: Text('No network'),
|
||||
|
||||
@@ -53,8 +53,8 @@ class _GalleryAppState extends State<GalleryApp> {
|
||||
// https://docs.flutter.io/flutter/widgets/Navigator-class.html
|
||||
return Map<String, WidgetBuilder>.fromIterable(
|
||||
kAllGalleryDemos,
|
||||
key: (dynamic demo) => '${demo.routeName}',
|
||||
value: (dynamic demo) => demo.buildRoute,
|
||||
key: (dynamic demo) => '${(demo as GalleryDemo).routeName}',
|
||||
value: (dynamic demo) => (demo as GalleryDemo).buildRoute,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ class _CrossFadeTransition extends AnimatedWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Animation<double> progress = listenable;
|
||||
final Animation<double> progress = listenable as Animation<double>;
|
||||
|
||||
final double opacity1 = CurvedAnimation(
|
||||
parent: ReverseAnimation(progress),
|
||||
@@ -227,7 +227,7 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
|
||||
double get _backdropHeight {
|
||||
// Warning: this can be safely called from the event handlers but it may
|
||||
// not be called at build time.
|
||||
final RenderBox renderBox = _backdropKey.currentContext.findRenderObject();
|
||||
final RenderBox renderBox = _backdropKey.currentContext.findRenderObject() as RenderBox;
|
||||
return math.max(0.0, renderBox.size.height - _kBackAppBarHeight - _kFrontClosedHeight);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,10 +31,10 @@ class ComponentDemoTabData {
|
||||
bool operator==(Object other) {
|
||||
if (other.runtimeType != runtimeType)
|
||||
return false;
|
||||
final ComponentDemoTabData typedOther = other;
|
||||
return typedOther.tabName == tabName
|
||||
&& typedOther.description == description
|
||||
&& typedOther.documentationUrl == documentationUrl;
|
||||
return other is ComponentDemoTabData
|
||||
&& other.tabName == tabName
|
||||
&& other.description == description
|
||||
&& other.documentationUrl == documentationUrl;
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -22,8 +22,8 @@ class GalleryDemoCategory {
|
||||
return true;
|
||||
if (runtimeType != other.runtimeType)
|
||||
return false;
|
||||
final GalleryDemoCategory typedOther = other;
|
||||
return typedOther.name == name && typedOther.icon == icon;
|
||||
return other is GalleryDemoCategory
|
||||
&& other.name == name && other.icon == icon;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -582,6 +582,6 @@ final Map<GalleryDemoCategory, List<GalleryDemo>> kGalleryCategoryToDemos =
|
||||
final Map<String, String> kDemoDocumentationUrl =
|
||||
Map<String, String>.fromIterable(
|
||||
kAllGalleryDemos.where((GalleryDemo demo) => demo.documentationUrl != null),
|
||||
key: (dynamic demo) => demo.routeName,
|
||||
value: (dynamic demo) => demo.documentationUrl,
|
||||
key: (dynamic demo) => (demo as GalleryDemo).routeName,
|
||||
value: (dynamic demo) => (demo as GalleryDemo).documentationUrl,
|
||||
);
|
||||
|
||||
@@ -134,7 +134,7 @@ class _CategoriesPage extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: List<Widget>.generate(rowCount, (int rowIndex) {
|
||||
final int columnCountForRow = rowIndex == rowCount - 1
|
||||
? categories.length - columnCount * math.max(0, rowCount - 1)
|
||||
? categories.length - columnCount * math.max<int>(0, rowCount - 1)
|
||||
: columnCount;
|
||||
|
||||
return Row(
|
||||
|
||||
@@ -54,14 +54,14 @@ class GalleryOptions {
|
||||
bool operator ==(dynamic other) {
|
||||
if (runtimeType != other.runtimeType)
|
||||
return false;
|
||||
final GalleryOptions typedOther = other;
|
||||
return themeMode == typedOther.themeMode
|
||||
&& textScaleFactor == typedOther.textScaleFactor
|
||||
&& textDirection == typedOther.textDirection
|
||||
&& platform == typedOther.platform
|
||||
&& showPerformanceOverlay == typedOther.showPerformanceOverlay
|
||||
&& showRasterCacheImagesCheckerboard == typedOther.showRasterCacheImagesCheckerboard
|
||||
&& showOffscreenLayersCheckerboard == typedOther.showRasterCacheImagesCheckerboard;
|
||||
return other is GalleryOptions
|
||||
&& other.themeMode == themeMode
|
||||
&& other.textScaleFactor == textScaleFactor
|
||||
&& other.textDirection == textDirection
|
||||
&& other.platform == platform
|
||||
&& other.showPerformanceOverlay == showPerformanceOverlay
|
||||
&& other.showRasterCacheImagesCheckerboard == showRasterCacheImagesCheckerboard
|
||||
&& other.showOffscreenLayersCheckerboard == showRasterCacheImagesCheckerboard;
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -14,8 +14,9 @@ class GalleryTextScaleValue {
|
||||
bool operator ==(dynamic other) {
|
||||
if (runtimeType != other.runtimeType)
|
||||
return false;
|
||||
final GalleryTextScaleValue typedOther = other;
|
||||
return scale == typedOther.scale && label == typedOther.label;
|
||||
return other is GalleryTextScaleValue
|
||||
&& other.scale == scale
|
||||
&& other.label == label;
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:flutter_gallery/demo/calculator_demo.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding;
|
||||
if (binding is LiveTestWidgetsFlutterBinding)
|
||||
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter_gallery/gallery/app.dart';
|
||||
|
||||
void main() {
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding;
|
||||
if (binding is LiveTestWidgetsFlutterBinding)
|
||||
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
|
||||
|
||||
@@ -31,7 +31,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Verify theme settings
|
||||
MaterialApp app = find.byType(MaterialApp).evaluate().first.widget;
|
||||
MaterialApp app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp;
|
||||
expect(app.theme.brightness, equals(Brightness.light));
|
||||
expect(app.darkTheme.brightness, equals(Brightness.dark));
|
||||
|
||||
@@ -40,7 +40,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Dark'));
|
||||
await tester.pumpAndSettle();
|
||||
app = find.byType(MaterialApp).evaluate().first.widget;
|
||||
app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp;
|
||||
expect(app.themeMode, ThemeMode.dark);
|
||||
|
||||
// Switch to the light theme: first menu button, choose 'Light'
|
||||
@@ -48,7 +48,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Light'));
|
||||
await tester.pumpAndSettle();
|
||||
app = find.byType(MaterialApp).evaluate().first.widget;
|
||||
app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp;
|
||||
expect(app.themeMode, ThemeMode.light);
|
||||
|
||||
// Switch back to system theme setting: first menu button, choose 'System Default'
|
||||
@@ -56,7 +56,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('System Default').at(1));
|
||||
await tester.pumpAndSettle();
|
||||
app = find.byType(MaterialApp).evaluate().first.widget;
|
||||
app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp;
|
||||
expect(app.themeMode, ThemeMode.system);
|
||||
|
||||
// Verify platform settings
|
||||
@@ -67,7 +67,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Cupertino').at(1));
|
||||
await tester.pumpAndSettle();
|
||||
app = find.byType(MaterialApp).evaluate().first.widget;
|
||||
app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp;
|
||||
expect(app.theme.platform, equals(TargetPlatform.iOS));
|
||||
|
||||
// Verify the font scale.
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:flutter_gallery/gallery/app.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding;
|
||||
if (binding is LiveTestWidgetsFlutterBinding)
|
||||
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter_gallery/gallery/app.dart';
|
||||
|
||||
void main() {
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding;
|
||||
if (binding is LiveTestWidgetsFlutterBinding)
|
||||
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter_gallery/gallery/app.dart' show GalleryApp;
|
||||
|
||||
void main() {
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding;
|
||||
if (binding is LiveTestWidgetsFlutterBinding)
|
||||
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ Future<String> mockUpdateUrlFetcher() {
|
||||
}
|
||||
|
||||
void main() {
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
|
||||
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding;
|
||||
if (binding is LiveTestWidgetsFlutterBinding)
|
||||
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert' show JsonEncoder, JsonDecoder;
|
||||
import 'dart:convert' show JsonEncoder, json;
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:file/local.dart';
|
||||
@@ -69,14 +69,14 @@ Future<void> saveDurationsHistogram(List<Map<String, dynamic>> events, String ou
|
||||
|
||||
// Save the duration of the first frame after each 'Start Transition' event.
|
||||
for (Map<String, dynamic> event in events) {
|
||||
final String eventName = event['name'];
|
||||
final String eventName = event['name'] as String;
|
||||
if (eventName == 'Start Transition') {
|
||||
assert(startEvent == null);
|
||||
startEvent = event;
|
||||
} else if (startEvent != null && eventName == 'Frame') {
|
||||
final String routeName = startEvent['args']['to'];
|
||||
final String routeName = startEvent['args']['to'] as String;
|
||||
durations[routeName] ??= <int>[];
|
||||
durations[routeName].add(event['dur']);
|
||||
durations[routeName].add(event['dur'] as int);
|
||||
startEvent = null;
|
||||
}
|
||||
}
|
||||
@@ -101,13 +101,13 @@ Future<void> saveDurationsHistogram(List<Map<String, dynamic>> events, String ou
|
||||
String lastEventName = '';
|
||||
String lastRouteName = '';
|
||||
while (eventIter.moveNext()) {
|
||||
final String eventName = eventIter.current['name'];
|
||||
final String eventName = eventIter.current['name'] as String;
|
||||
|
||||
if (!<String>['Start Transition', 'Frame'].contains(eventName))
|
||||
continue;
|
||||
|
||||
final String routeName = eventName == 'Start Transition'
|
||||
? eventIter.current['args']['to']
|
||||
? eventIter.current['args']['to'] as String
|
||||
: '';
|
||||
|
||||
if (eventName == lastEventName && routeName == lastRouteName) {
|
||||
@@ -192,7 +192,7 @@ void main([List<String> args = const <String>[]]) {
|
||||
}
|
||||
|
||||
// See _handleMessages() in transitions_perf.dart.
|
||||
_allDemos = List<String>.from(const JsonDecoder().convert(await driver.requestData('demoNames')));
|
||||
_allDemos = List<String>.from(json.decode(await driver.requestData('demoNames')) as List<dynamic>);
|
||||
if (_allDemos.isEmpty)
|
||||
throw 'no demo names found';
|
||||
});
|
||||
@@ -221,7 +221,7 @@ void main([List<String> args = const <String>[]]) {
|
||||
await summary.writeSummaryToFile('transitions', pretty: true);
|
||||
final String histogramPath = path.join(testOutputsDirectory, 'transition_durations.timeline.json');
|
||||
await saveDurationsHistogram(
|
||||
List<Map<String, dynamic>>.from(timeline.json['traceEvents']),
|
||||
List<Map<String, dynamic>>.from(timeline.json['traceEvents'] as List<dynamic>),
|
||||
histogramPath);
|
||||
|
||||
// Execute the remaining tests.
|
||||
|
||||
Reference in New Issue
Block a user