Skip to content

Commit

Permalink
flutter update (#1203)
Browse files Browse the repository at this point in the history
  • Loading branch information
ksyeo1010 authored Jan 15, 2024
1 parent edd54c1 commit 0fcc1c3
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 139 deletions.
5 changes: 4 additions & 1 deletion binding/flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,7 @@
* Improved error reporting

## [3.0.1] - 2023-11-17
* Update native packages
* Update native packages

## [3.0.2] - 2024-01-15
* Address locale issue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2020-2023 Picovoice Inc.
// Copyright 2020-2024 Picovoice Inc.
//
// You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
// file accompanying this source.
Expand Down Expand Up @@ -53,7 +53,7 @@ public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBindin
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
Method method;
try {
method = Method.valueOf(call.method.toUpperCase());
method = Method.valueOf(call.method);
} catch (IllegalArgumentException e) {
result.error(
PorcupineRuntimeException.class.getSimpleName(),
Expand Down
4 changes: 2 additions & 2 deletions binding/flutter/ios/Classes/SwiftPorcupinePlugin.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2020-2023 Picovoice Inc.
// Copyright 2020-2024 Picovoice Inc.
//
// You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
// file accompanying this source.
Expand Down Expand Up @@ -33,7 +33,7 @@ public class SwiftPorcupinePlugin: NSObject, FlutterPlugin {
}

public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
guard let method = Method(rawValue: call.method.uppercased()) else {
guard let method = Method(rawValue: call.method) else {
result(errorToFlutterError(
PorcupineRuntimeError("Porcupine method '\(call.method)' is not a valid function")))
return
Expand Down
21 changes: 16 additions & 5 deletions binding/flutter/lib/porcupine.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2020-2023 Picovoice Inc.
// Copyright 2020-2024 Picovoice Inc.
//
// You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
// file accompanying this source.
Expand Down Expand Up @@ -48,6 +48,17 @@ enum BuiltInKeyword {
TERMINATOR
}

enum _NativeFunctions {
// ignore:constant_identifier_names
FROM_BUILTIN_KEYWORDS,
// ignore:constant_identifier_names
FROM_KEYWORD_PATHS,
// ignore:constant_identifier_names
PROCESS,
// ignore:constant_identifier_names
DELETE
}

class Porcupine {
static final MethodChannel _channel = MethodChannel("porcupine");

Expand Down Expand Up @@ -101,7 +112,7 @@ class Porcupine {

try {
Map<String, dynamic> result = Map<String, dynamic>.from(
await _channel.invokeMethod('from_builtin_keywords', {
await _channel.invokeMethod(_NativeFunctions.FROM_BUILTIN_KEYWORDS.name, {
'accessKey': accessKey,
'modelPath': modelPath,
'keywords': keywordValues,
Expand Down Expand Up @@ -146,7 +157,7 @@ class Porcupine {

try {
Map<String, dynamic> result = Map<String, dynamic>.from(
await _channel.invokeMethod('from_keyword_paths', {
await _channel.invokeMethod(_NativeFunctions.FROM_KEYWORD_PATHS.name, {
'accessKey': accessKey,
'modelPath': modelPath,
'keywordPaths': keywordPaths,
Expand Down Expand Up @@ -175,7 +186,7 @@ class Porcupine {
Future<int> process(List<int>? frame) async {
try {
int keywordIndex = await _channel
.invokeMethod('process', {'handle': _handle, 'frame': frame});
.invokeMethod(_NativeFunctions.PROCESS.name, {'handle': _handle, 'frame': frame});

return keywordIndex;
} on PlatformException catch (error) {
Expand All @@ -188,7 +199,7 @@ class Porcupine {
/// Frees memory that was allocated for Porcupine
Future<void> delete() async {
if (_handle != null) {
await _channel.invokeMethod('delete', {'handle': _handle});
await _channel.invokeMethod(_NativeFunctions.DELETE.name, {'handle': _handle});
_handle = null;
}
}
Expand Down
28 changes: 14 additions & 14 deletions binding/flutter/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.16.0"
version: "1.15.0"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.2.0"
ffi:
dependency: transitive
description:
Expand Down Expand Up @@ -95,13 +95,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
meta:
dependency: transitive
description:
Expand All @@ -115,7 +108,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.0"
path_provider:
dependency: "direct main"
description:
Expand Down Expand Up @@ -197,7 +190,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.2"
version: "1.8.1"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -232,14 +225,21 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.9"
version: "0.4.3"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
version: "2.1.1"
win32:
dependency: transitive
description:
Expand All @@ -255,5 +255,5 @@ packages:
source: hosted
version: "0.2.0"
sdks:
dart: ">=2.17.0-0 <3.0.0"
dart: ">=2.14.0 <3.0.0"
flutter: ">=2.8.1"
2 changes: 1 addition & 1 deletion binding/flutter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: porcupine_flutter
description: A Flutter plugin for Picovoice's Porcupine offline wake word engine.
version: 3.0.1
version: 3.0.2
homepage: https://picovoice.ai/
repository: https://github.com/Picovoice/porcupine/
documentation: https://picovoice.ai/docs/porcupine/
Expand Down
Loading

0 comments on commit 0fcc1c3

Please sign in to comment.