broadcast.dart 968 B

1234567891011121314151617181920212223242526272829303132
  1. import 'dart:async';
  2. import 'package:flutter/services.dart';
  3. class Broadcast {
  4. static const MethodChannel _channel =
  5. const MethodChannel('broadcast');
  6. static const EventChannel _eventChannel = EventChannel('broadcast_event');
  7. static Stream<dynamic> get eventStream {
  8. return _eventChannel.receiveBroadcastStream();
  9. }
  10. static Future<String> get platformVersion async {
  11. final String version = await _channel.invokeMethod('getPlatformVersion');
  12. return version;
  13. }
  14. static Future<bool> broadcast(String action, {Map args}) async {
  15. final bool result = await _channel.invokeMethod('broadcast', {'action': action, 'args': args});
  16. return result;
  17. }
  18. static Future<bool> isLocationEnabled() async {
  19. final bool result = await _channel.invokeMethod('isLocationEnabled');
  20. return result;
  21. }
  22. static Future<bool> openSetting() async {
  23. final bool result = await _channel.invokeMethod('openSetting');
  24. return result;
  25. }
  26. }