diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..3287bb6 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,13 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Flutter", + "request": "launch", + "type": "dart" + } + ] +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 83684f1..5e7aa6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## [0.0.5] - May 10th, 2018. +Implement flashing for duration + ## [0.0.4] - May 7th, 2018. Fix syntax error diff --git a/example/ios/Flutter/Debug.xcconfig b/example/ios/Flutter/Debug.xcconfig index 592ceee..e8efba1 100644 --- a/example/ios/Flutter/Debug.xcconfig +++ b/example/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Flutter/Release.xcconfig b/example/ios/Flutter/Release.xcconfig index 592ceee..399e934 100644 --- a/example/ios/Flutter/Release.xcconfig +++ b/example/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/example/lib/main.dart b/example/lib/main.dart index 0b462e7..6c4cdbc 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -37,7 +37,8 @@ class _MyAppState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ new Text('Device has flash: $_hasFlash\n Flash is on: $_isOn'), - new Slider(value: _intensity, onChanged: _isOn ? _intensityChanged : null) + new Slider(value: _intensity, onChanged: _isOn ? _intensityChanged : null), + new RaisedButton(onPressed: () async => await Lamp.flash(new Duration(seconds: 2)), child: new Text("Flash for 2 seconds")) ]), ), floatingActionButton: new FloatingActionButton( diff --git a/lib/lamp.dart b/lib/lamp.dart index adeb01a..20a09ae 100644 --- a/lib/lamp.dart +++ b/lib/lamp.dart @@ -5,7 +5,9 @@ import 'package:flutter/services.dart'; class Lamp { static const MethodChannel _channel = const MethodChannel('github.com/clovisnicolas/flutter_lamp'); - static Future turnOn({double intensity = 1.0}) => _channel.invokeMethod('turnOn', {"intensity" : intensity.clamp(0.01, 1.0)}); + static Future turnOn({double intensity = 1.0}) => _channel.invokeMethod('turnOn', {'intensity' : intensity.clamp(0.01, 1.0)}); static Future turnOff() => _channel.invokeMethod('turnOff'); static Future get hasLamp async => await _channel.invokeMethod('hasLamp'); + static Future flash(Duration duration) => turnOn().whenComplete(() => new Future.delayed(duration, () => turnOff())); + } diff --git a/pubspec.yaml b/pubspec.yaml index 1be0f13..2a3e012 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: lamp description: A Flutter plugin to access the device's lamp/torch on Android and iOS. -version: 0.0.4 +version: 0.0.5 author: Clovis Nicolas homepage: https://github.com/clovisnicolas/flutter_lamp