back_button.dart 1.12 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4 5 6 7 8 9 10 11 12 13
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// See //dev/devicelab/bin/tasks/flutter_gallery__memory_nav.dart

import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_gallery/gallery/app.dart' show GalleryApp;
import 'package:flutter_test/flutter_test.dart';

Future<void> endOfAnimation() async {
  do {
14 15
    await SchedulerBinding.instance.endOfFrame;
  } while (SchedulerBinding.instance.hasScheduledFrame);
16 17 18 19 20
}

int iteration = 0;

class LifecycleObserver extends WidgetsBindingObserver {
21 22 23 24 25
  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    debugPrint('==== MEMORY BENCHMARK ==== $state ====');
    debugPrint('This was lifecycle event number $iteration in this instance');
  }
26 27 28 29 30
}

Future<void> main() async {
  runApp(const GalleryApp());
  await endOfAnimation();
31
  await Future<void>.delayed(const Duration(milliseconds: 50));
32
  debugPrint('==== MEMORY BENCHMARK ==== READY ====');
33
  WidgetsBinding.instance.addObserver(LifecycleObserver());
34
}