Skip to content

Commit

Permalink
Made all JSON classes const
Browse files Browse the repository at this point in the history
Upgraded dependencies
  • Loading branch information
nrubin29 committed May 12, 2021
1 parent f70c488 commit 6bccf0b
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 43 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.1.2

* Made all JSON classes const.
* Upgraded dependencies.

## 0.1.1

* **BREAKING**: Refactored to be a proper library. Now, you just need to `import 'package:flutter_acrcloud/flutter_acrcloud.dart'`.
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ packages:
name: rxdart
url: "https://pub.dartlang.org"
source: hosted
version: "0.26.0"
version: "0.27.0"
sky_engine:
dependency: transitive
description: flutter
Expand Down
48 changes: 24 additions & 24 deletions lib/src/acrcloud_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ part 'acrcloud_response.g.dart';
/// The root response.
@JsonSerializable()
class ACRCloudResponse {
ACRCloudResponseStatus status;
ACRCloudResponseMetadata? metadata;
final ACRCloudResponseStatus status;
final ACRCloudResponseMetadata? metadata;

ACRCloudResponse(this.status, this.metadata);
const ACRCloudResponse(this.status, this.metadata);

factory ACRCloudResponse.fromJson(Map<String, dynamic> json) =>
_$ACRCloudResponseFromJson(json);
Expand All @@ -19,11 +19,11 @@ class ACRCloudResponse {
/// Response status, which provides information on any errors that occurred.
@JsonSerializable()
class ACRCloudResponseStatus {
String msg;
String version;
int code;
final String msg;
final String version;
final int code;

ACRCloudResponseStatus(this.msg, this.version, this.code);
const ACRCloudResponseStatus(this.msg, this.version, this.code);

factory ACRCloudResponseStatus.fromJson(Map<String, dynamic> json) =>
_$ACRCloudResponseStatusFromJson(json);
Expand All @@ -32,9 +32,9 @@ class ACRCloudResponseStatus {
/// The metadata of the response, which contains all of the matching tracks.
@JsonSerializable()
class ACRCloudResponseMetadata {
List<ACRCloudResponseMusicItem> music;
final List<ACRCloudResponseMusicItem> music;

ACRCloudResponseMetadata(this.music);
const ACRCloudResponseMetadata(this.music);

factory ACRCloudResponseMetadata.fromJson(Map<String, dynamic> json) =>
_$ACRCloudResponseMetadataFromJson(json);
Expand All @@ -43,32 +43,32 @@ class ACRCloudResponseMetadata {
/// A single matching track.
@JsonSerializable()
class ACRCloudResponseMusicItem {
String? label;
final String? label;

ACRCloudResponseAlbum album;
final ACRCloudResponseAlbum album;

List<ACRCloudResponseArtist> artists;
final List<ACRCloudResponseArtist> artists;

@JsonKey(name: 'acrid')
String acrId;
final String acrId;

@JsonKey(name: 'result_from')
int resultFrom;
final int resultFrom;

String title;
final String title;

@JsonKey(name: 'duration_ms')
int durationMs;
final int durationMs;

@JsonKey(name: 'release_date')
String releaseDate;
final String releaseDate;

int score;
final int score;

@JsonKey(name: 'play_offset_ms')
int playOffsetMs;
final int playOffsetMs;

ACRCloudResponseMusicItem(
const ACRCloudResponseMusicItem(
this.label,
this.album,
this.artists,
Expand All @@ -87,9 +87,9 @@ class ACRCloudResponseMusicItem {
/// The album of an [ACRCloudResponseMusicItem].
@JsonSerializable()
class ACRCloudResponseAlbum {
String name;
final String name;

ACRCloudResponseAlbum(this.name);
const ACRCloudResponseAlbum(this.name);

factory ACRCloudResponseAlbum.fromJson(Map<String, dynamic> json) =>
_$ACRCloudResponseAlbumFromJson(json);
Expand All @@ -98,9 +98,9 @@ class ACRCloudResponseAlbum {
/// The artist of an [ACRCloudResponseMusicItem].
@JsonSerializable()
class ACRCloudResponseArtist {
String name;
final String name;

ACRCloudResponseArtist(this.name);
const ACRCloudResponseArtist(this.name);

factory ACRCloudResponseArtist.fromJson(Map<String, dynamic> json) =>
_$ACRCloudResponseArtistFromJson(json);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/acrcloud_response.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions lib/src/flutter_acrcloud_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ import 'package:rxdart/rxdart.dart';

/// A configuration object with the values necessary to access the ACRCloud API.
class ACRCloudConfig {
String accessKey;
String accessSecret;
String host;
final String accessKey;
final String accessSecret;
final String host;

ACRCloudConfig(this.accessKey, this.accessSecret, this.host);
const ACRCloudConfig(this.accessKey, this.accessSecret, this.host);
}

/// A recording session.
class ACRCloudSession {
BehaviorSubject<ACRCloudResponse?> _result;
final BehaviorSubject<ACRCloudResponse?> _result;

/// A Stream of volume values.
BehaviorSubject<double> volume;
final BehaviorSubject<double> volume;

/// A Future which resolves to null if the session is [cancel]led, or an
/// [ACRCloudResponse] otherwise.
late Future<ACRCloudResponse?> result;
late final Future<ACRCloudResponse?> result;

ACRCloudSession()
: _result = BehaviorSubject<ACRCloudResponse?>(),
Expand All @@ -48,7 +48,7 @@ class ACRCloudSession {

/// The entry point for interacting with ACRCloud.
class ACRCloud {
static const MethodChannel _channel = const MethodChannel('flutter_acrcloud');
static const _channel = MethodChannel('flutter_acrcloud');

static var isSetUp = false;
static ACRCloudSession? _session;
Expand Down
19 changes: 13 additions & 6 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ packages:
name: build_runner
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
version: "2.0.2"
build_runner_core:
dependency: transitive
description:
Expand All @@ -91,7 +91,7 @@ packages:
name: built_value
url: "https://pub.dartlang.org"
source: hosted
version: "8.0.5"
version: "8.0.6"
characters:
dependency: transitive
description:
Expand Down Expand Up @@ -161,7 +161,7 @@ packages:
name: dart_style
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.0.1"
fake_async:
dependency: transitive
description:
Expand Down Expand Up @@ -193,6 +193,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
frontend_server_client:
dependency: transitive
description:
name: frontend_server_client
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
glob:
dependency: transitive
description:
Expand Down Expand Up @@ -325,14 +332,14 @@ packages:
name: rxdart
url: "https://pub.dartlang.org"
source: hosted
version: "0.26.0"
version: "0.27.0"
shelf:
dependency: transitive
description:
name: shelf
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
version: "1.1.2"
shelf_web_socket:
dependency: transitive
description:
Expand Down Expand Up @@ -435,7 +442,7 @@ packages:
name: web_socket_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0"
yaml:
dependency: transitive
description:
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_acrcloud
description: A Flutter plugin for the ACRCloud music recognition API. This plugin provides a simple interface for using ACRCloud to recognize music from the device's microphone
version: 0.1.1
version: 0.1.2
homepage: https://github.com/nrubin29/flutter_acrcloud

environment:
Expand All @@ -11,10 +11,10 @@ dependencies:
flutter:
sdk: flutter
json_annotation: ^4.0.1
rxdart: ^0.26.0
rxdart: ^0.27.0

dev_dependencies:
build_runner: ^2.0.1
build_runner: ^2.0.2
flutter_test:
sdk: flutter
json_serializable: ^4.1.1
Expand Down

0 comments on commit 6bccf0b

Please sign in to comment.