Auto-format Framework (#160545)
This auto-formats all *.dart files in the repository outside of the `engine` subdirectory and enforces that these files stay formatted with a presubmit check. **Reviewers:** Please carefully review all the commits except for the one titled "formatted". The "formatted" commit was auto-generated by running `dev/tools/format.sh -a -f`. The other commits were hand-crafted to prepare the repo for the formatting change. I recommend reviewing the commits one-by-one via the "Commits" tab and avoiding Github's "Files changed" tab as it will likely slow down your browser because of the size of this PR. --------- Co-authored-by: Kate Lovett <katelovett@google.com> Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
8e0993eda8
commit
5491c8c146
@@ -7,15 +7,11 @@ import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() {
|
||||
runApp(
|
||||
const PlatformViewApp()
|
||||
);
|
||||
runApp(const PlatformViewApp());
|
||||
}
|
||||
|
||||
class PlatformViewApp extends StatefulWidget {
|
||||
const PlatformViewApp({
|
||||
super.key,
|
||||
});
|
||||
const PlatformViewApp({super.key});
|
||||
|
||||
@override
|
||||
PlatformViewAppState createState() => PlatformViewAppState();
|
||||
@@ -33,7 +29,7 @@ class PlatformViewAppState extends State<PlatformViewApp> {
|
||||
}
|
||||
|
||||
class PlatformViewLayout extends StatelessWidget {
|
||||
const PlatformViewLayout({ super.key });
|
||||
const PlatformViewLayout({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -48,12 +44,7 @@ class PlatformViewLayout extends StatelessWidget {
|
||||
child: Material(
|
||||
elevation: (index % 5 + 1).toDouble(),
|
||||
color: Colors.white,
|
||||
child: const Stack(
|
||||
children: <Widget> [
|
||||
DummyPlatformView(),
|
||||
RotationContainer(),
|
||||
],
|
||||
),
|
||||
child: const Stack(children: <Widget>[DummyPlatformView(), RotationContainer()]),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -70,21 +61,13 @@ class DummyPlatformView extends StatelessWidget {
|
||||
const String viewType = 'benchmarks/platform_views_layout/DummyPlatformView';
|
||||
late Widget nativeView;
|
||||
if (Platform.isIOS) {
|
||||
nativeView = const UiKitView(
|
||||
viewType: viewType,
|
||||
);
|
||||
nativeView = const UiKitView(viewType: viewType);
|
||||
} else if (Platform.isAndroid) {
|
||||
nativeView = const AndroidView(
|
||||
viewType: viewType,
|
||||
);
|
||||
nativeView = const AndroidView(viewType: viewType);
|
||||
} else {
|
||||
assert(false, 'Invalid platform');
|
||||
}
|
||||
return Container(
|
||||
color: Colors.purple,
|
||||
height: 200.0,
|
||||
child: nativeView,
|
||||
);
|
||||
return Container(color: Colors.purple, height: 200.0, child: nativeView);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,8 +78,7 @@ class RotationContainer extends StatefulWidget {
|
||||
State<RotationContainer> createState() => _RotationContainerState();
|
||||
}
|
||||
|
||||
class _RotationContainerState extends State<RotationContainer>
|
||||
with SingleTickerProviderStateMixin {
|
||||
class _RotationContainerState extends State<RotationContainer> with SingleTickerProviderStateMixin {
|
||||
late AnimationController _rotationController;
|
||||
|
||||
@override
|
||||
@@ -120,11 +102,7 @@ class _RotationContainerState extends State<RotationContainer>
|
||||
Widget build(BuildContext context) {
|
||||
return RotationTransition(
|
||||
turns: Tween<double>(begin: 0.0, end: 1.0).animate(_rotationController),
|
||||
child: Container(
|
||||
color: Colors.purple,
|
||||
width: 50.0,
|
||||
height: 50.0,
|
||||
),
|
||||
child: Container(color: Colors.purple, width: 50.0, height: 50.0),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,29 +8,25 @@ import 'package:flutter/material.dart';
|
||||
import 'package:google_mobile_ads/google_mobile_ads.dart';
|
||||
|
||||
void main() {
|
||||
runApp(
|
||||
const PlatformViewApp()
|
||||
);
|
||||
runApp(const PlatformViewApp());
|
||||
}
|
||||
|
||||
class PlatformViewApp extends StatefulWidget {
|
||||
const PlatformViewApp({
|
||||
super.key,
|
||||
});
|
||||
const PlatformViewApp({super.key});
|
||||
|
||||
@override
|
||||
PlatformViewAppState createState() => PlatformViewAppState();
|
||||
}
|
||||
|
||||
class PlatformViewAppState extends State<PlatformViewApp> {
|
||||
|
||||
AdWidget _getBannerWidget() {
|
||||
// Test IDs from Admob:
|
||||
// https://developers.google.com/admob/ios/test-ads
|
||||
// https://developers.google.com/admob/android/test-ads
|
||||
final String bannerId = Platform.isAndroid
|
||||
? 'ca-app-pub-3940256099942544/6300978111'
|
||||
: 'ca-app-pub-3940256099942544/2934735716';
|
||||
final String bannerId =
|
||||
Platform.isAndroid
|
||||
? 'ca-app-pub-3940256099942544/6300978111'
|
||||
: 'ca-app-pub-3940256099942544/2934735716';
|
||||
final BannerAd bannerAd = BannerAd(
|
||||
adUnitId: bannerId,
|
||||
request: const AdRequest(),
|
||||
@@ -53,12 +49,12 @@ class PlatformViewAppState extends State<PlatformViewApp> {
|
||||
itemCount: 250,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return index.isEven
|
||||
// Use 320x50 Admob standard banner size.
|
||||
? SizedBox(width: 320, height: 50, child: _getBannerWidget())
|
||||
// Adjust the height to control number of platform views on screen.
|
||||
// TODO(hellohuanlin): Having more than 5 banners on screen causes an unknown crash.
|
||||
// See: https://github.com/flutter/flutter/issues/144339
|
||||
: const SizedBox(height: 150, child: ColoredBox(color: Colors.yellow));
|
||||
// Use 320x50 Admob standard banner size.
|
||||
? SizedBox(width: 320, height: 50, child: _getBannerWidget())
|
||||
// Adjust the height to control number of platform views on screen.
|
||||
// TODO(hellohuanlin): Having more than 5 banners on screen causes an unknown crash.
|
||||
// See: https://github.com/flutter/flutter/issues/144339
|
||||
: const SizedBox(height: 150, child: ColoredBox(color: Colors.yellow));
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
@@ -8,29 +8,25 @@ import 'package:flutter/material.dart';
|
||||
import 'package:google_mobile_ads/google_mobile_ads.dart';
|
||||
|
||||
void main() {
|
||||
runApp(
|
||||
const PlatformViewApp()
|
||||
);
|
||||
runApp(const PlatformViewApp());
|
||||
}
|
||||
|
||||
class PlatformViewApp extends StatefulWidget {
|
||||
const PlatformViewApp({
|
||||
super.key,
|
||||
});
|
||||
const PlatformViewApp({super.key});
|
||||
|
||||
@override
|
||||
PlatformViewAppState createState() => PlatformViewAppState();
|
||||
}
|
||||
|
||||
class PlatformViewAppState extends State<PlatformViewApp> {
|
||||
|
||||
Widget _getBannerWidget() {
|
||||
// Test IDs from Admob:
|
||||
// https://developers.google.com/admob/ios/test-ads
|
||||
// https://developers.google.com/admob/android/test-ads
|
||||
final String bannerId = Platform.isAndroid
|
||||
? 'ca-app-pub-3940256099942544/6300978111'
|
||||
: 'ca-app-pub-3940256099942544/2934735716';
|
||||
final String bannerId =
|
||||
Platform.isAndroid
|
||||
? 'ca-app-pub-3940256099942544/6300978111'
|
||||
: 'ca-app-pub-3940256099942544/2934735716';
|
||||
final BannerAd bannerAd = BannerAd(
|
||||
adUnitId: bannerId,
|
||||
request: const AdRequest(),
|
||||
@@ -39,13 +35,9 @@ class PlatformViewAppState extends State<PlatformViewApp> {
|
||||
);
|
||||
bannerAd.load();
|
||||
return Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
// Use 320x50 Admob standard banner size.
|
||||
child: SizedBox(
|
||||
width: 320,
|
||||
height: 50,
|
||||
child: AdWidget(ad: bannerAd),
|
||||
),
|
||||
alignment: Alignment.bottomCenter,
|
||||
// Use 320x50 Admob standard banner size.
|
||||
child: SizedBox(width: 320, height: 50, child: AdWidget(ad: bannerAd)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -67,7 +59,9 @@ class PlatformViewAppState extends State<PlatformViewApp> {
|
||||
elevation: 2,
|
||||
child: ListTile(
|
||||
title: Text('Breaking News!'),
|
||||
subtitle: Text('Huge breaking news! Here is huge and breaking news which is both huge and breaking.'),
|
||||
subtitle: Text(
|
||||
'Huge breaking news! Here is huge and breaking news which is both huge and breaking.',
|
||||
),
|
||||
leading: FlutterLogo(),
|
||||
),
|
||||
);
|
||||
@@ -75,8 +69,8 @@ class PlatformViewAppState extends State<PlatformViewApp> {
|
||||
),
|
||||
),
|
||||
_getBannerWidget(),
|
||||
]
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,15 +7,11 @@ import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() {
|
||||
runApp(
|
||||
const PlatformViewApp()
|
||||
);
|
||||
runApp(const PlatformViewApp());
|
||||
}
|
||||
|
||||
class PlatformViewApp extends StatefulWidget {
|
||||
const PlatformViewApp({
|
||||
super.key,
|
||||
});
|
||||
const PlatformViewApp({super.key});
|
||||
|
||||
@override
|
||||
PlatformViewAppState createState() => PlatformViewAppState();
|
||||
@@ -33,7 +29,7 @@ class PlatformViewAppState extends State<PlatformViewApp> {
|
||||
}
|
||||
|
||||
class PlatformViewLayout extends StatelessWidget {
|
||||
const PlatformViewLayout({ super.key });
|
||||
const PlatformViewLayout({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -48,9 +44,10 @@ class PlatformViewLayout extends StatelessWidget {
|
||||
child: Material(
|
||||
elevation: (index % 5 + 1).toDouble(),
|
||||
color: Colors.white,
|
||||
child: index.isEven
|
||||
? CustomPaint(painter: ExpensivePainter(), size: const Size(400, 200))
|
||||
: const DummyPlatformView()
|
||||
child:
|
||||
index.isEven
|
||||
? CustomPaint(painter: ExpensivePainter(), size: const Size(400, 200))
|
||||
: const DummyPlatformView(),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -67,21 +64,13 @@ class DummyPlatformView extends StatelessWidget {
|
||||
const String viewType = 'benchmarks/platform_views_layout/DummyPlatformView';
|
||||
late Widget nativeView;
|
||||
if (Platform.isIOS) {
|
||||
nativeView = const UiKitView(
|
||||
viewType: viewType,
|
||||
);
|
||||
nativeView = const UiKitView(viewType: viewType);
|
||||
} else if (Platform.isAndroid) {
|
||||
nativeView = const AndroidView(
|
||||
viewType: viewType,
|
||||
);
|
||||
nativeView = const AndroidView(viewType: viewType);
|
||||
} else {
|
||||
assert(false, 'Invalid platform');
|
||||
}
|
||||
return Container(
|
||||
color: Colors.purple,
|
||||
height: 200.0,
|
||||
child: nativeView,
|
||||
);
|
||||
return Container(color: Colors.purple, height: 200.0, child: nativeView);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,9 +82,11 @@ class ExpensivePainter extends CustomPainter {
|
||||
for (int i = 0; i < 50; i++) {
|
||||
for (int j = 0; j < 50; j++) {
|
||||
final Rect rect = Rect.fromLTWH(i * boxWidth, j * boxHeight, boxWidth, boxHeight);
|
||||
canvas.drawRect(rect, Paint()
|
||||
..style = PaintingStyle.fill
|
||||
..color = Colors.red
|
||||
canvas.drawRect(
|
||||
rect,
|
||||
Paint()
|
||||
..style = PaintingStyle.fill
|
||||
..color = Colors.red,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,5 @@ import 'package:platform_views_layout/main.dart' as app;
|
||||
|
||||
void main() {
|
||||
enableFlutterDriverExtension();
|
||||
runApp(
|
||||
const app.PlatformViewApp()
|
||||
);
|
||||
runApp(const app.PlatformViewApp());
|
||||
}
|
||||
|
||||
@@ -52,7 +52,10 @@ void main() {
|
||||
test('platform_views_scroll_perf', () async {
|
||||
// Disable frame sync, since there are ongoing animations.
|
||||
await driver.runUnsynchronized(() async {
|
||||
await testScrollPerf('platform-views-scroll', 'platform_views_scroll_perf_bottom_ad_banner');
|
||||
await testScrollPerf(
|
||||
'platform-views-scroll',
|
||||
'platform_views_scroll_perf_bottom_ad_banner',
|
||||
);
|
||||
});
|
||||
}, timeout: Timeout.none);
|
||||
});
|
||||
|
||||
@@ -54,7 +54,10 @@ void main() {
|
||||
test('platform_views_scroll_perf', () async {
|
||||
// Disable frame sync, since there are ongoing animations.
|
||||
await driver.runUnsynchronized(() async {
|
||||
await testScrollPerf('platform-views-scroll', 'platform_views_scroll_perf_non_intersecting');
|
||||
await testScrollPerf(
|
||||
'platform-views-scroll',
|
||||
'platform_views_scroll_perf_non_intersecting',
|
||||
);
|
||||
});
|
||||
}, timeout: Timeout.none);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user