event.dart 438 B

12345678910111213141516171819
  1. import 'dart:convert';
  2. import 'package:flutter/material.dart';
  3. void handlePluginEvent(
  4. Map<String, dynamic> evt,
  5. Function(Map<String, dynamic> e) handleMsgBox,
  6. ) {
  7. Map<String, dynamic>? content;
  8. try {
  9. content = json.decode(evt['content']);
  10. } catch (e) {
  11. debugPrint(
  12. 'Json decode plugin event content failed: $e, ${evt['content']}');
  13. }
  14. if (content?['t'] == 'MsgBox') {
  15. handleMsgBox(content?['c']);
  16. }
  17. }