#ifndef FLUTTER_INAPPWEBVIEW_PLUGIN_UTIL_H_ #define FLUTTER_INAPPWEBVIEW_PLUGIN_UTIL_H_ #include #include namespace flutter_inappwebview_plugin { template static inline std::optional make_pointer_optional(const T* value) { return value == nullptr ? std::nullopt : std::make_optional(*value); } template static inline T get_flutter_value(const flutter::EncodableMap map, const char* string) { return std::get(map.at(flutter::EncodableValue(string))); } template static inline std::optional get_optional_flutter_value(const flutter::EncodableMap map, const char* string) { return make_pointer_optional(std::get_if(&map.at(flutter::EncodableValue(string)))); } static inline std::string variant_to_string(std::variant var) { return std::visit([](auto&& arg) { using T = std::decay_t; if constexpr (std::is_same_v) return arg; else if constexpr (std::is_arithmetic_v) return std::to_string(arg); else static_assert(always_false_v, "non-exhaustive visitor!"); }, var); } } #endif //FLUTTER_INAPPWEBVIEW_PLUGIN_UTIL_H_