Skip to content

Commit

Permalink
applied dart fix, updated flutter versions, and switch flutter_picker…
Browse files Browse the repository at this point in the history
… to flutter_picker_plus
  • Loading branch information
matt200-ok committed Jun 27, 2024
1 parent 4836b89 commit 6dd66c7
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/flutter-codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Install Flutter 2.8.1
- name: Install Flutter 3.22.2
uses: subosito/flutter-action@v2
with:
flutter-version: 2.8.1
flutter-version: 3.22.2

- name: Run Binding Analyzer
run: flutter analyze --no-fatal-infos --no-fatal-warnings
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/flutter-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
flutter-version: ['2.8.1', '3.0.4']
flutter-version: ['3.3.0', '3.22.2']

steps:
- uses: actions/checkout@v3
Expand All @@ -52,10 +52,10 @@ jobs:

build-ios:
name: Build iOS demo
runs-on: macos-11
runs-on: macos-12
strategy:
matrix:
flutter-version: ['2.8.1', '3.0.4']
flutter-version: ['3.3.0', '3.22.2']

steps:
- uses: actions/checkout@v3
Expand Down
22 changes: 11 additions & 11 deletions demo/flutter/integration_test/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ void main() {
String keyword = testData['tests']['singleKeyword'][t]['wakeword'];

String keywordPath =
"assets/test_resources/keyword_files/${keyword}_${platform}.ppn";
"assets/test_resources/keyword_files/${keyword}_$platform.ppn";
String modelPath =
"assets/test_resources/model_files/porcupine_params${language != "en" ? "_${language}" : ""}.pv";
"assets/test_resources/model_files/porcupine_params${language != "en" ? "_$language" : ""}.pv";

Porcupine porcupine;
try {
porcupine = await Porcupine.fromKeywordPaths(accessKey, [keywordPath],
modelPath: modelPath);
} on PorcupineException catch (ex) {
expect(ex, equals(null),
reason: "Failed to initialize Porcupine for ${language}: ${ex}");
reason: "Failed to initialize Porcupine for $language: $ex");
return;
}

Expand All @@ -74,10 +74,10 @@ void main() {
porcupine.delete();
expect(detections.length, equals(1),
reason:
"Number of detections for ${language} ${keyword} was incorrect");
"Number of detections for $language $keyword was incorrect");
expect(detections[0], equals(0),
reason:
"Porcupine returned wrong keyword index for ${language} ${keyword}");
"Porcupine returned wrong keyword index for $language $keyword");
}
});

Expand All @@ -90,23 +90,23 @@ void main() {
testData['tests']['multipleKeyword'][t]['groundTruth']);

List<String> keywordPaths = keywords.map((keyword) {
return "assets/test_resources/keyword_files/${keyword}_${platform}.ppn";
return "assets/test_resources/keyword_files/${keyword}_$platform.ppn";
}).toList();
String modelPath =
"assets/test_resources/model_files/porcupine_params${language != "en" ? "_${language}" : ""}.pv";
"assets/test_resources/model_files/porcupine_params${language != "en" ? "_$language" : ""}.pv";

Porcupine porcupine;
try {
porcupine = await Porcupine.fromKeywordPaths(accessKey, keywordPaths,
modelPath: modelPath);
} on PorcupineException catch (ex) {
expect(ex, equals(null),
reason: "Failed to initialize Porcupine for ${language}: ${ex}");
reason: "Failed to initialize Porcupine for $language: $ex");
return;
}

String audioPath =
"assets/test_resources/audio_samples/multiple_keywords${language != "en" ? "_${language}" : ""}.wav";
"assets/test_resources/audio_samples/multiple_keywords${language != "en" ? "_$language" : ""}.wav";
List<int> pcm = await loadAudioFile(audioPath);

List<int> detections = [];
Expand All @@ -121,9 +121,9 @@ void main() {

porcupine.delete();
expect(detections.length, equals(groundTruth.length),
reason: "Number of detections for ${language} was incorrect");
reason: "Number of detections for $language was incorrect");
expect(detections, equals(groundTruth),
reason: "Porcupine detections don't match truth for ${language}");
reason: "Porcupine detections don't match truth for $language");
}
});
});
Expand Down
8 changes: 4 additions & 4 deletions demo/flutter/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:convert';

import 'package:flutter_picker/flutter_picker.dart';
import 'package:flutter_picker_plus/flutter_picker_plus.dart';
import 'package:porcupine_flutter/porcupine.dart';
import 'package:porcupine_flutter/porcupine_manager.dart';
import 'package:porcupine_flutter/porcupine_error.dart';
Expand Down Expand Up @@ -56,15 +56,15 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
isButtonDisabled = true;
backgroundColour = defaultColour;
});
WidgetsBinding.instance?.addObserver(this);
WidgetsBinding.instance.addObserver(this);

_initializeKeywordMap();
_loadParams();
}

@override
void dispose() {
WidgetsBinding.instance?.removeObserver(this);
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}

Expand Down Expand Up @@ -278,7 +278,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {

buildStartButton(BuildContext context) {
final ButtonStyle buttonStyle = ElevatedButton.styleFrom(
primary: picoBlue,
backgroundColor: picoBlue,
shape: CircleBorder(),
textStyle: TextStyle(color: Colors.white));

Expand Down
6 changes: 3 additions & 3 deletions demo/flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ publish_to: 'none'
version: 1.0.0

environment:
sdk: ">=2.15.0 <4.0.0"
flutter: ">=2.8.1"
sdk: ">=2.18.0 <4.0.0"
flutter: ">=3.3.0"

dependencies:
flutter:
sdk: flutter

flutter_picker: ^2.0.1
flutter_picker_plus: ^1.3.0
porcupine_flutter: ^3.0.3
path: ^1.8.0

Expand Down
2 changes: 1 addition & 1 deletion demo/flutter/scripts/prepare_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void main(List<String> arguments) async {
}
modelDir.createSync(recursive: true);

var params = Map();
var params = {};
params["language"] = language;
params["keywords"] = [];

Expand Down

0 comments on commit 6dd66c7

Please sign in to comment.