main.dart 7.11 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
import 'src/fullscreenTextField.dart';
16 17 18
import 'src/heavy_grid_view.dart';
import 'src/large_image_changer.dart';
import 'src/large_images.dart';
19
import 'src/multi_widget_construction.dart';
20
import 'src/picture_cache.dart';
21
import 'src/post_backdrop_filter.dart';
22
import 'src/simple_animation.dart';
23
import 'src/simple_scroll.dart';
24
import 'src/text.dart';
25

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

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

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

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

  final String initialRoute;
62 63 64 65 66 67 68 69
}

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