import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:get/get_connect/sockets/src/socket_notifier.dart';

class BaseController extends GetxController {
  Map? parameters;

  @override
  void onInit() {
    debugPrint('BaseController $runtimeType onInit');
    super.onInit();
    _initParameters();
  }

  @override
  void onReady() {
    debugPrint('BaseController $runtimeType onReady');
    super.onReady();
  }

  @override
  void onClose() {
    debugPrint('BaseController $runtimeType onClose');
    super.onClose();
  }
  void _initParameters() {
    var getParameters = Get.parameters;
    var getArguments = Get.arguments;
    parameters ??= <dynamic, dynamic>{};
    parameters?.addAll(getParameters);
    if (getArguments != null && getArguments is Map) {
      parameters?.addAll(getArguments);
    }
  }

  /// 隐藏键盘
  void hideKeyboard(BuildContext context) {
    FocusScopeNode currentFocus = FocusScope.of(context);
    if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) {
      FocusManager.instance.primaryFocus!.unfocus();
    }
  }
}
