Skip to content

Commit ff20b35

Browse files
authored
flutter locale issue fix (#668)
1 parent 8889b40 commit ff20b35

File tree

8 files changed

+146
-148
lines changed

8 files changed

+146
-148
lines changed

binding/flutter/CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,7 @@
5353
* Added reset function
5454

5555
## [3.0.1] - 2023-11-17
56-
* Update native packages
56+
* Update native packages
57+
58+
## [3.0.2] - 2024-01-15
59+
* Address locale issue

binding/flutter/android/src/main/java/ai/picovoice/flutter/rhino/RhinoPlugin.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2021-2023 Picovoice Inc.
2+
// Copyright 2021-2024 Picovoice Inc.
33
//
44
// You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
55
// file accompanying this source.
@@ -52,7 +52,7 @@ public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBindin
5252
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
5353
Method method;
5454
try {
55-
method = Method.valueOf(call.method.toUpperCase());
55+
method = Method.valueOf(call.method);
5656
} catch (IllegalArgumentException e) {
5757
result.error(
5858
RhinoRuntimeException.class.getSimpleName(),

binding/flutter/ios/Classes/SwiftRhinoPlugin.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2021-2023 Picovoice Inc.
2+
// Copyright 2021-2024 Picovoice Inc.
33
//
44
// You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
55
// file accompanying this source.
@@ -33,7 +33,7 @@ public class SwiftRhinoPlugin: NSObject, FlutterPlugin {
3333
}
3434

3535
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
36-
guard let method = Method(rawValue: call.method.uppercased()) else {
36+
guard let method = Method(rawValue: call.method) else {
3737
result(errorToFlutterError(RhinoRuntimeError("Rhino method '\(call.method)' is not a valid function")))
3838
return
3939
}

binding/flutter/lib/rhino.dart

+16-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2021-2022 Picovoice Inc.
2+
// Copyright 2021-2024 Picovoice Inc.
33
//
44
// You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
55
// file accompanying this source.
@@ -16,6 +16,17 @@ import 'package:flutter/services.dart';
1616
import 'package:path_provider/path_provider.dart';
1717
import 'package:rhino_flutter/rhino_error.dart';
1818

19+
enum _NativeFunctions {
20+
// ignore:constant_identifier_names
21+
CREATE,
22+
// ignore:constant_identifier_names
23+
PROCESS,
24+
// ignore:constant_identifier_names
25+
RESET,
26+
// ignore:constant_identifier_names
27+
DELETE
28+
}
29+
1930
class RhinoInference {
2031
final bool _isFinalized;
2132
final bool? _isUnderstood;
@@ -113,7 +124,7 @@ class Rhino {
113124

114125
try {
115126
Map<String, dynamic> result =
116-
Map<String, dynamic>.from(await _channel.invokeMethod('create', {
127+
Map<String, dynamic>.from(await _channel.invokeMethod(_NativeFunctions.CREATE.name, {
117128
'accessKey': accessKey,
118129
'contextPath': contextPath,
119130
'modelPath': modelPath,
@@ -149,7 +160,7 @@ class Rhino {
149160

150161
try {
151162
Map<String, dynamic> inference = Map<String, dynamic>.from(await _channel
152-
.invokeMethod('process', {'handle': _handle, 'frame': frame}));
163+
.invokeMethod(_NativeFunctions.PROCESS.name, {'handle': _handle, 'frame': frame}));
153164

154165
if (inference['isFinalized'] == null) {
155166
throw RhinoInvalidStateException(
@@ -179,7 +190,7 @@ class Rhino {
179190
"Unable to reset Rhino - resources have already been released");
180191
}
181192
try {
182-
await _channel.invokeMethod('reset', {'handle': _handle});
193+
await _channel.invokeMethod(_NativeFunctions.RESET.name, {'handle': _handle});
183194
} on PlatformException catch (error) {
184195
throw rhinoStatusToException(error.code, error.message);
185196
}
@@ -188,7 +199,7 @@ class Rhino {
188199
/// Frees memory that was allocated for Rhino
189200
Future<void> delete() async {
190201
if (_handle != null) {
191-
await _channel.invokeMethod('delete', {'handle': _handle});
202+
await _channel.invokeMethod(_NativeFunctions.DELETE.name, {'handle': _handle});
192203
_handle = null;
193204
}
194205
}

binding/flutter/pubspec.lock

+14-14
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ packages:
4242
name: collection
4343
url: "https://pub.dartlang.org"
4444
source: hosted
45-
version: "1.16.0"
45+
version: "1.15.0"
4646
fake_async:
4747
dependency: transitive
4848
description:
4949
name: fake_async
5050
url: "https://pub.dartlang.org"
5151
source: hosted
52-
version: "1.3.0"
52+
version: "1.2.0"
5353
ffi:
5454
dependency: transitive
5555
description:
@@ -95,13 +95,6 @@ packages:
9595
url: "https://pub.dartlang.org"
9696
source: hosted
9797
version: "0.12.11"
98-
material_color_utilities:
99-
dependency: transitive
100-
description:
101-
name: material_color_utilities
102-
url: "https://pub.dartlang.org"
103-
source: hosted
104-
version: "0.1.4"
10598
meta:
10699
dependency: transitive
107100
description:
@@ -115,7 +108,7 @@ packages:
115108
name: path
116109
url: "https://pub.dartlang.org"
117110
source: hosted
118-
version: "1.8.1"
111+
version: "1.8.0"
119112
path_provider:
120113
dependency: "direct main"
121114
description:
@@ -197,7 +190,7 @@ packages:
197190
name: source_span
198191
url: "https://pub.dartlang.org"
199192
source: hosted
200-
version: "1.8.2"
193+
version: "1.8.1"
201194
stack_trace:
202195
dependency: transitive
203196
description:
@@ -232,14 +225,21 @@ packages:
232225
name: test_api
233226
url: "https://pub.dartlang.org"
234227
source: hosted
235-
version: "0.4.9"
228+
version: "0.4.3"
229+
typed_data:
230+
dependency: transitive
231+
description:
232+
name: typed_data
233+
url: "https://pub.dartlang.org"
234+
source: hosted
235+
version: "1.3.0"
236236
vector_math:
237237
dependency: transitive
238238
description:
239239
name: vector_math
240240
url: "https://pub.dartlang.org"
241241
source: hosted
242-
version: "2.1.2"
242+
version: "2.1.1"
243243
win32:
244244
dependency: transitive
245245
description:
@@ -255,5 +255,5 @@ packages:
255255
source: hosted
256256
version: "0.2.0"
257257
sdks:
258-
dart: ">=2.17.0-0 <3.0.0"
258+
dart: ">=2.14.0 <3.0.0"
259259
flutter: ">=2.8.1"

binding/flutter/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: rhino_flutter
22
description: A Flutter plugin for Picovoice's Rhino Speech-to-Intent engine
3-
version: 3.0.1
3+
version: 3.0.2
44
homepage: https://picovoice.ai/
55
repository: https://github.com/Picovoice/rhino/
66
documentation: https://picovoice.ai/docs/rhino/

0 commit comments

Comments
 (0)