main.dart 6.75 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6 7
import 'package:flutter/material.dart';

import 'common.dart';
8

Dan Field's avatar
Dan Field committed
9
import 'src/animated_placeholder.dart';
10
import 'src/backdrop_filter.dart';
11
import 'src/color_filter_and_fade.dart';
12
import 'src/cubic_bezier.dart';
13
import 'src/cull_opacity.dart';
14
import 'src/filtered_child_animation.dart';
15 16 17
import 'src/heavy_grid_view.dart';
import 'src/large_image_changer.dart';
import 'src/large_images.dart';
18
import 'src/multi_widget_construction.dart';
19
import 'src/picture_cache.dart';
20
import 'src/post_backdrop_filter.dart';
21
import 'src/simple_animation.dart';
22
import 'src/simple_scroll.dart';
23
import 'src/text.dart';
24

Dan Field's avatar
Dan Field committed
25
const String kMacrobenchmarks = 'Macrobenchmarks';
26

27
void main() => runApp(const MacrobenchmarksApp());
28 29

class MacrobenchmarksApp extends StatelessWidget {
30 31
  const MacrobenchmarksApp({this.initialRoute = '/'});

32 33 34 35
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: kMacrobenchmarks,
36
      initialRoute: initialRoute,
37 38 39
      routes: <String, WidgetBuilder>{
        '/': (BuildContext context) => HomePage(),
        kCullOpacityRouteName: (BuildContext context) => CullOpacityPage(),
40
        kCubicBezierRouteName: (BuildContext context) => CubicBezierPage(),
41
        kBackdropFilterRouteName: (BuildContext context) => BackdropFilterPage(),
42
        kPostBackdropFilterRouteName: (BuildContext context) => PostBackdropFilterPage(),
43
        kSimpleAnimationRouteName: (BuildContext context) => SimpleAnimationPage(),
44
        kPictureCacheRouteName: (BuildContext context) => PictureCachePage(),
45
        kLargeImageChangerRouteName: (BuildContext context) => LargeImageChangerPage(),
46
        kLargeImagesRouteName: (BuildContext context) => LargeImagesPage(),
47
        kTextRouteName: (BuildContext context) => TextPage(),
Dan Field's avatar
Dan Field committed
48
        kAnimatedPlaceholderRouteName: (BuildContext context) => AnimatedPlaceholderPage(),
49
        kColorFilterAndFadeRouteName: (BuildContext context) => ColorFilterAndFadePage(),
50
        kFadingChildAnimationRouteName: (BuildContext context) => const FilteredChildAnimationPage(FilterType.opacity),
51
        kImageFilteredTransformAnimationRouteName: (BuildContext context) => const FilteredChildAnimationPage(FilterType.rotateFilter),
52
        kMultiWidgetConstructionRouteName: (BuildContext context) => const MultiWidgetConstructTable(10, 20),
53
        kHeavyGridViewRouteName: (BuildContext context) => HeavyGridViewPage(),
54
        kSimpleScrollRouteName: (BuildContext context) => SimpleScroll(),
55 56 57
      },
    );
  }
58 59

  final String initialRoute;
60 61 62 63 64 65 66 67
}

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text(kMacrobenchmarks)),
      body: ListView(
68
        key: const Key(kScrollableName),
69
        children: <Widget>[
70
          ElevatedButton(
71 72
            key: const Key(kCullOpacityRouteName),
            child: const Text('Cull opacity'),
73
            onPressed: () {
74 75
              Navigator.pushNamed(context, kCullOpacityRouteName);
            },
76
          ),
77
          ElevatedButton(
78 79
            key: const Key(kCubicBezierRouteName),
            child: const Text('Cubic Bezier'),
80
            onPressed: () {
81 82
              Navigator.pushNamed(context, kCubicBezierRouteName);
            },
83
          ),
84
          ElevatedButton(
85 86
            key: const Key(kBackdropFilterRouteName),
            child: const Text('Backdrop Filter'),
87
            onPressed: () {
88 89 90
              Navigator.pushNamed(context, kBackdropFilterRouteName);
            },
          ),
91
          ElevatedButton(
92 93 94 95 96 97
            key: const Key(kPostBackdropFilterRouteName),
            child: const Text('Post Backdrop Filter'),
            onPressed: () {
              Navigator.pushNamed(context, kPostBackdropFilterRouteName);
            },
          ),
98
          ElevatedButton(
99 100 101 102 103 104
            key: const Key(kSimpleAnimationRouteName),
            child: const Text('Simple Animation'),
            onPressed: () {
              Navigator.pushNamed(context, kSimpleAnimationRouteName);
            },
          ),
105
          ElevatedButton(
106 107 108 109 110 111
            key: const Key(kPictureCacheRouteName),
            child: const Text('Picture Cache'),
            onPressed: () {
              Navigator.pushNamed(context, kPictureCacheRouteName);
            },
          ),
112
          ElevatedButton(
113 114 115 116 117 118
            key: const Key(kLargeImagesRouteName),
            child: const Text('Large Images'),
            onPressed: () {
              Navigator.pushNamed(context, kLargeImagesRouteName);
            },
          ),
119
          ElevatedButton(
120 121 122 123 124 125
            key: const Key(kTextRouteName),
            child: const Text('Text'),
            onPressed: () {
              Navigator.pushNamed(context, kTextRouteName);
            },
          ),
126
          ElevatedButton(
Dan Field's avatar
Dan Field committed
127 128 129 130 131 132
            key: const Key(kAnimatedPlaceholderRouteName),
            child: const Text('Animated Placeholder'),
            onPressed: () {
              Navigator.pushNamed(context, kAnimatedPlaceholderRouteName);
            },
          ),
133
          ElevatedButton(
134 135 136 137 138 139
            key: const Key(kColorFilterAndFadeRouteName),
            child: const Text('Color Filter and Fade'),
            onPressed: () {
              Navigator.pushNamed(context, kColorFilterAndFadeRouteName);
            },
          ),
140
          ElevatedButton(
141 142 143 144 145 146
            key: const Key(kFadingChildAnimationRouteName),
            child: const Text('Fading Child Animation'),
            onPressed: () {
              Navigator.pushNamed(context, kFadingChildAnimationRouteName);
            },
          ),
147
          ElevatedButton(
148 149 150 151 152 153
            key: const Key(kImageFilteredTransformAnimationRouteName),
            child: const Text('ImageFiltered Transform Animation'),
            onPressed: () {
              Navigator.pushNamed(context, kImageFilteredTransformAnimationRouteName);
            },
          ),
154
          ElevatedButton(
155 156
            key: const Key(kMultiWidgetConstructionRouteName),
            child: const Text('Widget Construction and Destruction'),
157
            onPressed: () {
158
              Navigator.pushNamed(context, kMultiWidgetConstructionRouteName);
159 160
            },
          ),
161
          ElevatedButton(
162 163 164 165 166 167
            key: const Key(kHeavyGridViewRouteName),
            child: const Text('Heavy Grid View'),
            onPressed: () {
              Navigator.pushNamed(context, kHeavyGridViewRouteName);
            },
          ),
168
          ElevatedButton(
169 170 171 172 173 174
            key: const Key(kLargeImageChangerRouteName),
            child: const Text('Large Image Changer'),
            onPressed: () {
              Navigator.pushNamed(context, kLargeImageChangerRouteName);
            },
          ),
175 176 177 178 179
        ],
      ),
    );
  }
}