"Fossies" - the Fresh Open Source Software Archive

Member "flutter-1.22.4/packages/flutter/lib/src/services/system_sound.dart" (13 Nov 2020, 1560 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:async';
    7 
    8 import 'system_channels.dart';
    9 
   10 /// A sound provided by the system.
   11 ///
   12 /// These sounds may be played with [SystemSound.play].
   13 enum SystemSoundType {
   14   /// A short indication that a button was pressed.
   15   click,
   16 
   17   /// A short system alert sound indicating the need for user attention.
   18   ///
   19   /// Desktop platforms are the only platforms that support a system alert
   20   /// sound, so on mobile platforms (Android, iOS), this will be ignored. The
   21   /// web platform does not support playing any sounds, so this will be
   22   /// ignored on the web as well.
   23   alert,
   24 
   25   // If you add new values here, you also need to update the `SoundType` Java
   26   // enum in `PlatformChannel.java`.
   27 }
   28 
   29 /// Provides access to the library of short system specific sounds for common
   30 /// tasks.
   31 class SystemSound {
   32   // This class is not meant to be instantiated or extended; this constructor
   33   // prevents instantiation and extension.
   34   // ignore: unused_element
   35   SystemSound._();
   36 
   37   /// Play the specified system sound. If that sound is not present on the
   38   /// system, the call is ignored.
   39   ///
   40   /// The web platform currently does not support playing sounds, so this call
   41   /// will yield no behavior on that platform.
   42   static Future<void> play(SystemSoundType type) async {
   43     await SystemChannels.platform.invokeMethod<void>(
   44       'SystemSound.play',
   45       type.toString(),
   46     );
   47   }
   48 }