Line data Source code
1 : // You have generated a new plugin project without 2 : // specifying the `--platforms` flag. A plugin project supports no platforms is generated. 3 : // To add platforms, run `flutter create -t plugin --platforms <platforms> .` under the same 4 : // directory. You can also find a detailed instruction on how to add platforms in the `pubspec.yaml` at https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms. 5 : 6 : import 'package:plugin_platform_interface/plugin_platform_interface.dart'; 7 : 8 : import 'method_channel_screen_brightness.dart'; 9 : 10 : /// Screen brightness platform interface which is implemented with 11 : /// [federated plugins](flutter.dev/go/federated-plugins) 12 : abstract class ScreenBrightnessPlatform extends PlatformInterface { 13 : /// Default constructor for [ScreenBrightnessPlatform] 14 3 : ScreenBrightnessPlatform() : super(token: _token); 15 : 16 : /// The token which [PlatformInterface.verifyToken] needs to be verify 17 3 : static final Object _token = Object(); 18 : 19 : /// Private instance which will be only create once 20 0 : static ScreenBrightnessPlatform _instance = MethodChannelScreenBrightness(); 21 : 22 : /// The default instance of [ScreenBrightnessPlatform] to use. 23 : /// 24 : /// Defaults to [MethodChannelScreenBrightness]. 25 0 : static ScreenBrightnessPlatform get instance => _instance; 26 : 27 : /// Platform-specific plugins should set this with their own platform-specific 28 : /// class that extends [ScreenBrightnessPlatform] when they register themselves. 29 0 : static set instance(ScreenBrightnessPlatform instance) { 30 0 : PlatformInterface.verifyToken(instance, _token); 31 : _instance = instance; 32 : } 33 : 34 : /// Returns system screen brightness which is set when application is started. 35 : /// 36 : /// The value should be within 0.0 - 1.0. Otherwise, [RangeError.range] will 37 : /// be throw. 38 : /// 39 : /// This parameter is useful for user to get screen brightness value after 40 : /// calling [resetScreenBrightness] 41 1 : Future<double> get system async { 42 1 : throw UnimplementedError('system brightness has not been implemented.'); 43 : } 44 : 45 : /// Returns current screen brightness which is current screen brightness value. 46 : /// 47 : /// The value should be within 0.0 - 1.0. Otherwise, [RangeError.range] will 48 : /// be throw. 49 : /// 50 : /// This parameter is useful for user to get screen brightness value after 51 : /// calling [setScreenBrightness] 52 1 : Future<double> get current async { 53 1 : throw UnimplementedError('current brightness has not been implemented.'); 54 : } 55 : 56 : /// Set screen brightness with double value. 57 : /// 58 : /// The value should be within 0.0 - 1.0. Otherwise, [RangeError.range] will 59 : /// be throw. 60 : /// 61 : /// This method is useful for user to change screen brightness. 62 1 : Future<void> setScreenBrightness(double brightness) async { 63 1 : throw UnimplementedError( 64 : 'setScreenBrightness(brightness) has not been implemented.'); 65 : } 66 : 67 : /// Reset screen brightness with (Android)-1 or (iOS)system brightness value. 68 : /// 69 : /// This method is useful for user to reset screen brightness when user leave 70 : /// the page which has change the brightness value. 71 1 : Future<void> resetScreenBrightness() async { 72 1 : throw UnimplementedError( 73 : 'resetScreenBrightness() has not been implemented.'); 74 : } 75 : 76 : /// A stream return with screen brightness changes including 77 : /// [ScreenBrightness.setScreenBrightness], 78 : /// [ScreenBrightness.resetScreenBrightness], system control center or system 79 : /// setting. 80 : /// 81 : /// This stream is useful for user to listen to brightness changes. 82 1 : Stream<double> get onCurrentBrightnessChanged { 83 1 : throw UnimplementedError( 84 : 'get onCurrentBrightnessChanged has not been implemented.'); 85 : } 86 : }