"Fossies" - the Fresh Open Source Software Archive

Member "flutter-1.22.4/packages/flutter/lib/src/semantics/binding.dart" (13 Nov 2020, 2370 Bytes) of package /linux/misc/flutter-1.22.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Dart source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 // Copyright 2014 The Flutter Authors. All rights reserved.
    2 // Use of this source code is governed by a BSD-style license that can be
    3 // found in the LICENSE file.
    4 
    5 
    6 import 'dart:ui' as ui show AccessibilityFeatures, SemanticsUpdateBuilder;
    7 
    8 import 'package:flutter/foundation.dart';
    9 
   10 import 'debug.dart';
   11 
   12 export 'dart:ui' show AccessibilityFeatures;
   13 
   14 /// The glue between the semantics layer and the Flutter engine.
   15 // TODO(jonahwilliams): move the remaining semantic related bindings here.
   16 mixin SemanticsBinding on BindingBase {
   17   /// The current [SemanticsBinding], if one has been created.
   18   static SemanticsBinding? get instance => _instance;
   19   static SemanticsBinding? _instance;
   20 
   21   @override
   22   void initInstances() {
   23     super.initInstances();
   24     _instance = this;
   25     _accessibilityFeatures = window.accessibilityFeatures;
   26   }
   27 
   28   /// Called when the platform accessibility features change.
   29   ///
   30   /// See [Window.onAccessibilityFeaturesChanged].
   31   @protected
   32   void handleAccessibilityFeaturesChanged() {
   33     _accessibilityFeatures = window.accessibilityFeatures;
   34   }
   35 
   36   /// Creates an empty semantics update builder.
   37   ///
   38   /// The caller is responsible for filling out the semantics node updates.
   39   ///
   40   /// This method is used by the [SemanticsOwner] to create builder for all its
   41   /// semantics updates.
   42   ui.SemanticsUpdateBuilder createSemanticsUpdateBuilder() {
   43     return ui.SemanticsUpdateBuilder();
   44   }
   45 
   46   /// The currently active set of [AccessibilityFeatures].
   47   ///
   48   /// This is initialized the first time [runApp] is called and updated whenever
   49   /// a flag is changed.
   50   ///
   51   /// To listen to changes to accessibility features, create a
   52   /// [WidgetsBindingObserver] and listen to
   53   /// [WidgetsBindingObserver.didChangeAccessibilityFeatures].
   54   ui.AccessibilityFeatures get accessibilityFeatures => _accessibilityFeatures;
   55   late ui.AccessibilityFeatures _accessibilityFeatures;
   56 
   57   /// The platform is requesting that animations be disabled or simplified.
   58   ///
   59   /// This setting can be overridden for testing or debugging by setting
   60   /// [debugSemanticsDisableAnimations].
   61   bool get disableAnimations {
   62     bool value = _accessibilityFeatures.disableAnimations;
   63     assert(() {
   64       if (debugSemanticsDisableAnimations != null)
   65         value = debugSemanticsDisableAnimations!;
   66       return true;
   67     }());
   68     return value;
   69   }
   70 }