test_vsync.dart 983 Bytes
Newer Older
1 2 3 4 5 6
// Copyright 2016 The Chromium 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/scheduler.dart';

7 8 9 10
/// A [TickerProvider] that creates a standalone ticker.
///
/// Useful in tests that create an [AnimationController] outside of the widget
/// tree.
11
class TestVSync implements TickerProvider {
12
  /// Creates a ticker provider that creates standalone tickers.
13 14 15 16 17 18 19 20 21
  const TestVSync({this.disableAnimations = false});

  /// Whether to disable the animations of tickers create from this picker.
  ///
  /// See also:
  ///
  ///   * [AccessibilityFeatures.disableAnimations], for the setting that controls this flag.
  ///   * [AnimationBehavior], for how animation controllers change when created from tickers with this flag.
  final bool disableAnimations;
22 23

  @override
24
  Ticker createTicker(TickerCallback onTick) => new Ticker(onTick)..disableAnimations = disableAnimations;
25
}