import 'package:flutter/services.dart'; class PlatformUtil { static PlatformUtil? _instance; static const MethodChannel _channel = const MethodChannel( 'com.pichillilorenzo/flutter_inappwebview_platformutil'); static PlatformUtil instance() { return (_instance != null) ? _instance! : _init(); } static PlatformUtil _init() { _channel.setMethodCallHandler(_handleMethod); _instance = PlatformUtil(); return _instance!; } static Future _handleMethod(MethodCall call) async {} String? _cachedSystemVersion; Future getSystemVersion() async { if (_cachedSystemVersion != null) { return _cachedSystemVersion!; } Map args = {}; _cachedSystemVersion = await _channel.invokeMethod('getSystemVersion', args); return _cachedSystemVersion!; } Future formatDate( {required DateTime date, required String format, String locale = "en_US", String timezone = "UTC"}) async { Map args = {}; args.putIfAbsent('date', () => date.millisecondsSinceEpoch); args.putIfAbsent('format', () => format); args.putIfAbsent('locale', () => locale); args.putIfAbsent('timezone', () => timezone); return await _channel.invokeMethod('formatDate', args); } }