Skip to content

Commit

Permalink
add some message tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
karansingla007 committed Oct 1, 2019
1 parent 312a2e3 commit e3b2dd5
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -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();
```
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
10 changes: 5 additions & 5 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -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());

Expand All @@ -19,8 +19,8 @@ class _MyAppState extends State<MyApp> {
}

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;
Expand All @@ -40,15 +40,15 @@ class _MyAppState extends State<MyApp> {
children: <Widget>[
new Text("Screen is kept on ? "),
new Checkbox(value: _isKeptOn, onChanged: (bool b){
Screen.keepOn(b);
FlutterScreen.keepOn(b);
setState((){_isKeptOn = b; });
})
]
),
new Text("Brightness :"),
new Slider(value : _brightness, onChanged : (double b){
setState((){_brightness = b;});
Screen.setBrightness(b);
FlutterScreen.setBrightness(b);
})
]
)
Expand Down
2 changes: 1 addition & 1 deletion ios/Classes/ScreenPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@implementation ScreenPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)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];
Expand Down
4 changes: 2 additions & 2 deletions lib/screen.dart → lib/flutter_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> get brightness async => (await _channel.invokeMethod('brightness')) as double;
static Future setBrightness(double brightness) =>_channel.invokeMethod('setBrightness',{"brightness" : brightness});
Expand Down
8 changes: 4 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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 <clovisnicolas0@gmail.com>
homepage: https://github.com/clovisnicolas/flutter_screen
version: 0.0.2
author: karan singla <karansingla120@gmail.com>
homepage: https://github.com/singlakaran/flutter_screen

environment:
sdk: '>=2.0.0 <3.0.0'
Expand Down

0 comments on commit e3b2dd5

Please sign in to comment.