From a134a5560d029f617b45ca8b3439af5de81286ce Mon Sep 17 00:00:00 2001 From: Matteo Pietro Dazzi Date: Tue, 15 Aug 2023 10:57:43 +0200 Subject: [PATCH] fix: deprecation warning --- CHANGELOG.md | 3 ++- lib/loaders/translation_loader.dart | 5 ++--- test/flutter_i18n_test.dart | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 263bcbb..87008db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -280,4 +280,5 @@ Support for Dart 3 and Flutter 3.10 Fix for #204 ## [0.34.0] -Upgrade http@1.1.0, logging@1.2.0, xml2json@6.2.0, yaml@3.1.2, path@1.8.3 \ No newline at end of file +Upgrade http@1.1.0, logging@1.2.0, xml2json@6.2.0, yaml@3.1.2, path@1.8.3 +Fix: deprecation warnings \ No newline at end of file diff --git a/lib/loaders/translation_loader.dart b/lib/loaders/translation_loader.dart index 1ebf5b8..88f4223 100644 --- a/lib/loaders/translation_loader.dart +++ b/lib/loaders/translation_loader.dart @@ -1,5 +1,4 @@ -import 'dart:ui' as ui; - +import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_i18n/utils/message_printer.dart'; @@ -23,7 +22,7 @@ abstract class TranslationLoader { /// Return the device current locale Future findDeviceLocale() async { - final systemLocale = ui.window.locale; + final systemLocale = PlatformDispatcher.instance.locale; MessagePrinter.info("The system locale is $systemLocale"); return Future.value(systemLocale); } diff --git a/test/flutter_i18n_test.dart b/test/flutter_i18n_test.dart index 6a3b185..a8ce9fa 100644 --- a/test/flutter_i18n_test.dart +++ b/test/flutter_i18n_test.dart @@ -7,12 +7,14 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); setUp(() { - channel.setMockMethodCallHandler((MethodCall methodCall) async { + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(channel, (MethodCall methodCall) async { return '42'; }); }); tearDown(() { - channel.setMockMethodCallHandler(null); + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler(channel, null); }); }