import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';

class BaseController extends GetxController {
  Map? parameters;

  @override
  void onInit() {
    super.onInit();
    _initParameters();
  }

  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();
    }
  }
}