controller.dart 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import 'package:get/get.dart';
  2. import 'package:url_launcher/url_launcher.dart';
  3. import '../../../../common/models/index.dart';
  4. import 'index.dart';
  5. class MeetingDetailController extends GetxController {
  6. MeetingDetailController();
  7. final state = MeetingDetailState();
  8. /// 在 widget 内存中分配后立即调用。
  9. @override
  10. void onInit() {
  11. super.onInit();
  12. }
  13. /// 在 onInit() 之后调用 1 帧。这是进入的理想场所
  14. @override
  15. void onReady() {
  16. final meeting = Get.arguments;
  17. if (meeting != null && meeting is MeetingInfoModel) {
  18. state.meetingInfo.value = meeting;
  19. }
  20. super.onReady();
  21. }
  22. /// 在 [onDelete] 方法之前调用。
  23. @override
  24. void onClose() {
  25. super.onClose();
  26. }
  27. /// dispose 释放内存
  28. @override
  29. void dispose() {
  30. super.dispose();
  31. }
  32. openOnlineRoomLink() async {
  33. if (state.meetingInfo.value?.mode == MeetingMode.online.getKey() && state.meetingInfo.value?.roomLink?.isNotEmpty == true) {
  34. Uri uri = Uri.parse(state.meetingInfo.value!.roomLink!);
  35. if (await canLaunchUrl(uri)) {
  36. await launchUrl(uri, mode: LaunchMode.externalApplication);
  37. }
  38. }
  39. }
  40. }