Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Modify test to set treeShakeIcons: false
  • Loading branch information
kenzieschmoll committed Oct 19, 2023
commit 19e3523a04420e3992035b74d6402a8cf145b9aa
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:web_benchmarks/client.dart';

import '../aboutpage.dart' show backKey;
import '../homepage.dart' show aboutPageKey, textKey;
import '../about_page.dart' show backKey;
import '../home_page.dart' show aboutPageKey, textKey;
import '../main.dart';

/// A recorder that measures frame building durations.
Expand Down
45 changes: 45 additions & 0 deletions packages/web_benchmarks/testing/test_app/lib/icon_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';

class IconGeneratorPage extends StatefulWidget {
const IconGeneratorPage({super.key});

static int defaultIconCodePoint = int.parse('0xf03f');

@override
State<IconGeneratorPage> createState() => _IconGeneratorPageState();
}

class _IconGeneratorPageState extends State<IconGeneratorPage> {
int iconCodePoint = IconGeneratorPage.defaultIconCodePoint;

@override
Widget build(BuildContext context) {
return Column(
children: [
TextField(
onSubmitted: (String value) {
final int codePointAsInt =
int.tryParse(value) ?? IconGeneratorPage.defaultIconCodePoint;
setState(() {
iconCodePoint = codePointAsInt;
});
},
),
const SizedBox(height: 24.0),
Icon(generateIcon(iconCodePoint)),
],
);
}

// Unless '--no-tree-shake-icons' is passed to the flutter build command,
// the presence of this method will trigger an exception due to the use of
// non-constant invocations of [IconData].
IconData generateIcon(int materialIconCodePoint) => IconData(
materialIconCodePoint,
fontFamily: 'MaterialIcons',
);
}
6 changes: 4 additions & 2 deletions packages/web_benchmarks/testing/test_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

import 'package:flutter/material.dart';

import 'aboutpage.dart';
import 'homepage.dart';
import 'about_page.dart';
import 'home_page.dart';
import 'icon_page.dart';

void main() {
runApp(const MyApp());
Expand All @@ -26,6 +27,7 @@ class MyApp extends StatelessWidget {
routes: <String, WidgetBuilder>{
'home': (_) => const HomePage(title: 'Flutter Demo Home Page'),
'about': (_) => const AboutPage(),
'icon_generator': (_) => const IconGeneratorPage(),
},
);
}
Expand Down
3 changes: 1 addition & 2 deletions packages/web_benchmarks/testing/test_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ publish_to: 'none'
version: 1.0.0+1

environment:
sdk: '>=2.17.0 <3.0.0'
sdk: '>=2.17.0 <4.0.0'

dependencies:
cupertino_icons: ^0.1.3
flutter:
sdk: flutter
flutter_test:
Expand Down
1 change: 1 addition & 0 deletions packages/web_benchmarks/testing/web_benchmarks_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Future<void> main() async {
benchmarkAppDirectory: Directory('testing/test_app'),
entryPoint: 'lib/benchmarks/runner.dart',
useCanvasKit: false,
treeShakeIcons: false,
);

for (final String benchmarkName in <String>['scroll', 'page', 'tap']) {
Expand Down