Spaces:
Runtime error
Runtime error
| import 'dart:js' as js; | |
| class Vibration{ | |
| static void vibrate({List<int> pattern=const [100],int repeat=-1}){ | |
| pattern=[1]+pattern; // to change it match vibrating pattern of android which is (off,on,off,on,off,...) | |
| var jsArray = js.JsObject.jsify(pattern); | |
| if(repeat==-1){ | |
| //on,off,on,off,on | |
| js.context.callMethod('vibrate', [jsArray]); | |
| } | |
| else{ | |
| js.context.callMethod('peristentVibrate', [jsArray]); | |
| } | |
| } | |
| static Future<bool> hasVibrator(){ | |
| return Future(() => true); | |
| } | |
| static void cancel(){ | |
| js.context.callMethod('vibrate', [0]); | |
| } | |
| } |