diff --git a/README.md b/README.md index 295e5bb..20d65a0 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ A Flutter plugin to manage the device's screen on Android and iOS. ## Usage -To use this plugin, add `screen` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/). +To use this plugin, add `flutter_screen` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/). Make sure you add the following permissions to your Android Manifest ``` @@ -13,17 +13,20 @@ Make sure you add the following permissions to your Android Manifest ## Example ``` dart // Import package -import 'package:screen/screen.dart'; +import 'package:flutter_screen/flutter_screen.dart'; // Get the current brightness: double brightness = await Screen.brightness; // Set the brightness: -Screen.setBrightness(0.5); +FlutterScreen.setBrightness(0.5); // Check if the screen is kept on: -bool isKeptOn = await Screen.isKeptOn; +bool isKeptOn = await FlutterScreen.isKeptOn; // Prevent screen from going into sleep mode: -Screen.keepOn(true); +FlutterScreen.keepOn(true); + +//free brightness (it works only on Android): +FlutterScreen.resetBrightness(); ``` diff --git a/android/src/main/java/flutter/plugins/screen/screen/ScreenPlugin.java b/android/src/main/java/flutter/plugins/screen/screen/ScreenPlugin.java index 0c7ba43..a202d43 100644 --- a/android/src/main/java/flutter/plugins/screen/screen/ScreenPlugin.java +++ b/android/src/main/java/flutter/plugins/screen/screen/ScreenPlugin.java @@ -20,7 +20,7 @@ private ScreenPlugin(Registrar registrar){ private Registrar _registrar; public static void registerWith(Registrar registrar) { - final MethodChannel channel = new MethodChannel(registrar.messenger(), "github.com/clovisnicolas/flutter_screen"); + final MethodChannel channel = new MethodChannel(registrar.messenger(), "github.com/singlakaran/flutter_screen"); channel.setMethodCallHandler(new ScreenPlugin(registrar)); } diff --git a/example/lib/main.dart b/example/lib/main.dart index bf59225..1cf830b 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:screen/screen.dart'; +import 'package:screen/flutter_screen.dart'; void main() => runApp(new MyApp()); @@ -19,8 +19,8 @@ class _MyAppState extends State { } initPlatformState() async { - bool keptOn = await Screen.isKeptOn; - double brightness = await Screen.brightness; + bool keptOn = await FlutterScreen.isKeptOn; + double brightness = await FlutterScreen.brightness; setState((){ _isKeptOn = keptOn; _brightness = brightness; @@ -40,7 +40,7 @@ class _MyAppState extends State { children: [ new Text("Screen is kept on ? "), new Checkbox(value: _isKeptOn, onChanged: (bool b){ - Screen.keepOn(b); + FlutterScreen.keepOn(b); setState((){_isKeptOn = b; }); }) ] @@ -48,7 +48,7 @@ class _MyAppState extends State { new Text("Brightness :"), new Slider(value : _brightness, onChanged : (double b){ setState((){_brightness = b;}); - Screen.setBrightness(b); + FlutterScreen.setBrightness(b); }) ] ) diff --git a/ios/Classes/ScreenPlugin.m b/ios/Classes/ScreenPlugin.m index 0902cc1..38eb84f 100644 --- a/ios/Classes/ScreenPlugin.m +++ b/ios/Classes/ScreenPlugin.m @@ -3,7 +3,7 @@ @implementation ScreenPlugin + (void)registerWithRegistrar:(NSObject*)registrar { FlutterMethodChannel* channel = [FlutterMethodChannel - methodChannelWithName:@"github.com/clovisnicolas/flutter_screen" + methodChannelWithName:@"github.com/singlakaran/flutter_screen" binaryMessenger:[registrar messenger]]; ScreenPlugin* instance = [[ScreenPlugin alloc] init]; [registrar addMethodCallDelegate:instance channel:channel]; diff --git a/lib/screen.dart b/lib/flutter_screen.dart similarity index 91% rename from lib/screen.dart rename to lib/flutter_screen.dart index d5e993a..cd3d739 100644 --- a/lib/screen.dart +++ b/lib/flutter_screen.dart @@ -2,8 +2,8 @@ import 'dart:async'; import 'package:flutter/services.dart'; -class Screen { - static const MethodChannel _channel = const MethodChannel('github.com/clovisnicolas/flutter_screen'); +class FlutterScreen { + static const MethodChannel _channel = const MethodChannel('github.com/singlakaran/flutter_screen'); static Future get brightness async => (await _channel.invokeMethod('brightness')) as double; static Future setBrightness(double brightness) =>_channel.invokeMethod('setBrightness',{"brightness" : brightness}); diff --git a/pubspec.yaml b/pubspec.yaml index c3531d0..31c452b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,8 +1,8 @@ -name: screen +name: flutter_screen description: A Flutter plugin to manage the device's screen on Android and iOS. -version: 0.0.5 -author: Clovis Nicolas -homepage: https://github.com/clovisnicolas/flutter_screen +version: 0.0.2 +author: karan singla +homepage: https://github.com/singlakaran/flutter_screen environment: sdk: '>=2.0.0 <3.0.0'