From 7f9de39aa48f9a32000ca061b093ff8213cae447 Mon Sep 17 00:00:00 2001 From: Fayeed Pawaskar Date: Tue, 9 Mar 2021 12:00:34 +0530 Subject: [PATCH 1/4] Updated dependency to support null safety --- example/pubspec.lock | 139 +++++++++++++++++++++++++++++++++---------- example/pubspec.yaml | 6 +- pubspec.lock | 76 +++++++++++------------ pubspec.yaml | 4 +- 4 files changed, 150 insertions(+), 75 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 88be044..20e50b3 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,35 +7,49 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.3.0" + version: "2.5.0" audioplayers: dependency: "direct main" description: name: audioplayers url: "https://pub.dartlang.org" source: hosted - version: "0.13.2" + version: "0.17.4" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "1.2.0" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.11" + version: "1.15.0" convert: dependency: transitive description: @@ -50,13 +64,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.3" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" file: dependency: "direct main" description: name: file url: "https://pub.dartlang.org" source: hosted - version: "5.0.10" + version: "6.1.0" flutter: dependency: "direct main" description: flutter @@ -68,68 +96,101 @@ packages: path: ".." relative: true source: path - version: "0.5.3" + version: "0.5.5" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" - intl: + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + js: dependency: transitive description: - name: intl + name: js url: "https://pub.dartlang.org" source: hosted - version: "0.16.0" + version: "0.6.3" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.5" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.7" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" + version: "1.8.0" path_provider: dependency: "direct main" description: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" - pedantic: + version: "1.6.27" + path_provider_linux: dependency: transitive description: - name: pedantic + name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "1.8.0+1" + version: "0.0.1+2" + path_provider_macos: + dependency: transitive + description: + name: path_provider_macos + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.4+8" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.5" platform: dependency: transitive description: name: platform url: "https://pub.dartlang.org" source: hosted - version: "2.2.1" - quiver: + version: "3.0.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" + process: dependency: transitive description: - name: quiver + name: process url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "4.1.0" sky_engine: dependency: transitive description: flutter @@ -141,63 +202,77 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.5.5" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.5" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.3.0" uuid: dependency: transitive description: name: uuid url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.2.2" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.0" + win32: + dependency: transitive + description: + name: win32 + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.2" sdks: - dart: ">=2.2.2 <3.0.0" - flutter: ">=0.1.4 <2.0.0" + dart: ">=2.12.0-259.9.beta <3.0.0" + flutter: ">=1.20.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index c52486e..52cb246 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -8,9 +8,9 @@ environment: dependencies: flutter: sdk: flutter - path_provider: ^1.1.0 - file: ^5.0.4 - audioplayers: ^0.13.2 + path_provider: ^1.6.22 + file: ^6.1.0 + audioplayers: ^0.17.4 dev_dependencies: diff --git a/pubspec.lock b/pubspec.lock index ecd6508..053df98 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,35 +7,56 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.3.0" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "1.2.0" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.11" + version: "1.15.0" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" file: dependency: "direct main" description: name: file url: "https://pub.dartlang.org" source: hosted - version: "5.0.10" + version: "6.1.0" flutter: dependency: "direct main" description: flutter @@ -46,48 +67,27 @@ packages: description: flutter source: sdk version: "0.0.0" - intl: - dependency: transitive - description: - name: intl - url: "https://pub.dartlang.org" - source: hosted - version: "0.16.0" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.5" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.7" + version: "1.3.0" path: dependency: "direct main" description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.0+1" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.5" + version: "1.8.0" sky_engine: dependency: transitive description: flutter @@ -99,55 +99,55 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.5.5" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.5" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.0" sdks: - dart: ">=2.2.2 <3.0.0" + dart: ">=2.12.0-0.0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 1634f2d..e556d80 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,10 +10,10 @@ environment: sdk: ">=2.1.0 <3.0.0" dependencies: - path: ^1.5.1 + path: ^1.8.0 flutter: sdk: flutter - file: ^5.0.4 + file: ^6.1.0 dev_dependencies: From 3cdcc2092025768faa9cc6bce6e9025512756206 Mon Sep 17 00:00:00 2001 From: Fayeed Pawaskar Date: Tue, 9 Mar 2021 12:22:38 +0530 Subject: [PATCH 2/4] Added sound null safety support --- example/lib/main.dart | 25 ++++++--- example/pubspec.lock | 2 +- lib/flutter_audio_recorder.dart | 75 ++++++++++++++------------- pubspec.lock | 2 +- pubspec.yaml | 2 +- test/flutter_audio_recorder_test.dart | 1 - 6 files changed, 59 insertions(+), 48 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index daf13d0..4d28c9b 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -67,7 +67,7 @@ class RecorderExampleState extends State { children: [ Padding( padding: const EdgeInsets.all(8.0), - child: new FlatButton( + child: TextButton( onPressed: () { switch (_currentStatus) { case RecordingStatus.Initialized: @@ -95,24 +95,33 @@ class RecorderExampleState extends State { } }, child: _buildText(_currentStatus), - color: Colors.lightBlue, + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all( + Colors.lightBlue, + )), ), ), - new FlatButton( + new TextButton( onPressed: _currentStatus != RecordingStatus.Unset ? _stop : null, child: new Text("Stop", style: TextStyle(color: Colors.white)), - color: Colors.blueAccent.withOpacity(0.5), + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all( + Colors.blueAccent.withOpacity(0.5), + )), ), SizedBox( width: 8, ), - new FlatButton( + new TextButton( onPressed: onPlayAudio, child: new Text("Play", style: TextStyle(color: Colors.white)), - color: Colors.blueAccent.withOpacity(0.5), + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all( + Colors.blueAccent.withOpacity(0.5), + )), ), ], ), @@ -165,8 +174,8 @@ class RecorderExampleState extends State { print(_currentStatus); }); } else { - Scaffold.of(context).showSnackBar( - new SnackBar(content: new Text("You must accept permissions"))); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: new Text("You must accept permissions"))); } } catch (e) { print(e); diff --git a/example/pubspec.lock b/example/pubspec.lock index 20e50b3..4601925 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -274,5 +274,5 @@ packages: source: hosted version: "0.1.2" sdks: - dart: ">=2.12.0-259.9.beta <3.0.0" + dart: ">=2.12.0 <3.0.0" flutter: ">=1.20.0" diff --git a/lib/flutter_audio_recorder.dart b/lib/flutter_audio_recorder.dart index bdc1771..830efe6 100644 --- a/lib/flutter_audio_recorder.dart +++ b/lib/flutter_audio_recorder.dart @@ -12,22 +12,22 @@ class FlutterAudioRecorder { static const String DEFAULT_EXTENSION = '.m4a'; static LocalFileSystem fs = LocalFileSystem(); - String _path; - String _extension; - Recording _recording; - int _sampleRate; + String? _path; + String? _extension; + Recording? _recording; + int? _sampleRate; - Future _initRecorder; - Future get initialized => _initRecorder; - Recording get recording => _recording; + Future? _initRecorder; + Future? get initialized => _initRecorder; + Recording? get recording => _recording; FlutterAudioRecorder(String path, - {AudioFormat audioFormat, int sampleRate = 16000}) { + {AudioFormat? audioFormat, int sampleRate = 16000}) { _initRecorder = _init(path, audioFormat, sampleRate); } /// Initialized recorder instance - Future _init(String path, AudioFormat audioFormat, int sampleRate) async { + Future _init(String? path, AudioFormat? audioFormat, int sampleRate) async { String extension; String extensionInPath; if (path != null) { @@ -66,7 +66,7 @@ class FlutterAudioRecorder { _extension = extension; _sampleRate = sampleRate; - Map response; + late Map response; var result = await _channel.invokeMethod('init', {"path": _path, "extension": _extension, "sampleRate": _sampleRate}); @@ -75,7 +75,7 @@ class FlutterAudioRecorder { } _recording = new Recording() - ..status = _stringToRecordingStatus(response['status']) + ..status = _stringToRecordingStatus(response['status'] as String?) ..metering = new AudioMetering( averagePower: -120, peakPower: -120, isMeteringEnabled: true); @@ -103,7 +103,7 @@ class FlutterAudioRecorder { /// Request the recording to stop /// Once its stopped, the recording file will be finalized /// and will not be start, resume, pause anymore. - Future stop() async { + Future stop() async { Map response; var result = await _channel.invokeMethod('stop'); @@ -118,7 +118,7 @@ class FlutterAudioRecorder { /// Ask for current status of recording /// Returns the result of current recording status /// Metering level, Duration, Status... - Future current({int channel = 0}) async { + Future current({int channel = 0}) async { Map response; var result = await _channel.invokeMethod('current', {"channel": channel}); @@ -134,24 +134,27 @@ class FlutterAudioRecorder { /// Returns the result of record permission /// if not determined(app first launch), /// this will ask user to whether grant the permission - static Future get hasPermissions async { - bool hasPermission = await _channel.invokeMethod('hasPermissions'); + static Future get hasPermissions async { + bool? hasPermission = await _channel.invokeMethod('hasPermissions'); return hasPermission; } /// util - response msg to recording object. - void _responseToRecording(Map response) { + void _responseToRecording(Map? response) { if (response == null) return; - _recording.duration = new Duration(milliseconds: response['duration']); - _recording.path = response['path']; - _recording.audioFormat = _stringToAudioFormat(response['audioFormat']); - _recording.extension = response['audioFormat']; - _recording.metering = new AudioMetering( - peakPower: response['peakPower'], - averagePower: response['averagePower'], - isMeteringEnabled: response['isMeteringEnabled']); - _recording.status = _stringToRecordingStatus(response['status']); + _recording!.duration = + new Duration(milliseconds: response['duration'] as int); + _recording!.path = response['path'] as String?; + _recording!.audioFormat = + _stringToAudioFormat(response['audioFormat'] as String?); + _recording!.extension = response['audioFormat'] as String?; + _recording!.metering = new AudioMetering( + peakPower: response['peakPower'] as double?, + averagePower: response['averagePower'] as double?, + isMeteringEnabled: response['isMeteringEnabled'] as bool?); + _recording!.status = + _stringToRecordingStatus(response['status'] as String?); } /// util - verify if extension string is supported @@ -168,7 +171,7 @@ class FlutterAudioRecorder { } /// util - Convert String to Enum - static AudioFormat _stringToAudioFormat(String extension) { + static AudioFormat? _stringToAudioFormat(String? extension) { switch (extension) { case ".wav": return AudioFormat.WAV; @@ -194,7 +197,7 @@ class FlutterAudioRecorder { } /// util - Convert String to Enum - static RecordingStatus _stringToRecordingStatus(String status) { + static RecordingStatus _stringToRecordingStatus(String? status) { switch (status) { case "unset": return RecordingStatus.Unset; @@ -215,34 +218,34 @@ class FlutterAudioRecorder { /// Recording Object - represent a recording file class Recording { /// File path - String path; + String? path; /// Extension - String extension; + String? extension; /// Duration in milliseconds - Duration duration; + Duration? duration; /// Audio format - AudioFormat audioFormat; + AudioFormat? audioFormat; /// Metering - AudioMetering metering; + AudioMetering? metering; /// Is currently recording - RecordingStatus status; + RecordingStatus? status; } /// Audio Metering Level - describe the metering level of microphone when recording class AudioMetering { /// Represent peak level of given short duration - double peakPower; + double? peakPower; /// Represent average level of given short duration - double averagePower; + double? averagePower; /// Is metering enabled in system - bool isMeteringEnabled; + bool? isMeteringEnabled; AudioMetering({this.peakPower, this.averagePower, this.isMeteringEnabled}); } diff --git a/pubspec.lock b/pubspec.lock index 053df98..cabd773 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -150,4 +150,4 @@ packages: source: hosted version: "2.1.0" sdks: - dart: ">=2.12.0-0.0 <3.0.0" + dart: ">=2.12.0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index e556d80..41b72c5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,7 +7,7 @@ authors: homepage: https://github.com/shadow-app/flutter_audio_recorder environment: - sdk: ">=2.1.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: path: ^1.8.0 diff --git a/test/flutter_audio_recorder_test.dart b/test/flutter_audio_recorder_test.dart index 6c79261..d619e25 100644 --- a/test/flutter_audio_recorder_test.dart +++ b/test/flutter_audio_recorder_test.dart @@ -1,6 +1,5 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:flutter_audio_recorder/flutter_audio_recorder.dart'; void main() { const MethodChannel channel = MethodChannel('flutter_audio_recorder'); From ef276e06b21436a9855b93fafd108e295d0cd427 Mon Sep 17 00:00:00 2001 From: Fayeed Pawaskar Date: Tue, 9 Mar 2021 12:38:08 +0530 Subject: [PATCH 3/4] Updated android project files --- example/android/.gitignore | 11 +++++++ example/android/app/build.gradle | 16 ++++------ .../android/app/src/main/AndroidManifest.xml | 32 ++++++++++++------- .../MainActivity.java | 13 -------- .../com/example/example/MainActivity.kt | 6 ++++ .../res/drawable-v21/launch_background.xml | 12 +++++++ .../app/src/main/res/values-night/styles.xml | 18 +++++++++++ .../app/src/main/res/values/styles.xml | 10 ++++++ example/android/build.gradle | 4 ++- example/android/gradle.properties | 3 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- example/android/settings.gradle | 18 ++++------- 12 files changed, 96 insertions(+), 49 deletions(-) create mode 100644 example/android/.gitignore delete mode 100644 example/android/app/src/main/java/com/zeno/flutter_audio_recorder_example/MainActivity.java create mode 100644 example/android/app/src/main/kotlin/com/example/example/MainActivity.kt create mode 100644 example/android/app/src/main/res/drawable-v21/launch_background.xml create mode 100644 example/android/app/src/main/res/values-night/styles.xml diff --git a/example/android/.gitignore b/example/android/.gitignore new file mode 100644 index 0000000..0a741cb --- /dev/null +++ b/example/android/.gitignore @@ -0,0 +1,11 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 093d782..591c4ee 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -22,23 +22,23 @@ if (flutterVersionName == null) { } apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 28 + compileSdkVersion 30 - lintOptions { - disable 'InvalidPackage' + sourceSets { + main.java.srcDirs += 'src/main/kotlin' } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.zeno.flutter_audio_recorder_example" - minSdkVersion 16 - targetSdkVersion 28 + minSdkVersion 23 + targetSdkVersion 30 versionCode flutterVersionCode.toInteger() versionName flutterVersionName - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { @@ -55,7 +55,5 @@ flutter { } dependencies { - testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" } diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index f8c8e17..1e4dff5 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,12 +1,6 @@ - - - @@ -14,21 +8,35 @@ android:name=".MainActivity" android:launchMode="singleTop" android:theme="@style/LaunchTheme" - android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" + android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize"> - + + + + + diff --git a/example/android/app/src/main/java/com/zeno/flutter_audio_recorder_example/MainActivity.java b/example/android/app/src/main/java/com/zeno/flutter_audio_recorder_example/MainActivity.java deleted file mode 100644 index 09c7492..0000000 --- a/example/android/app/src/main/java/com/zeno/flutter_audio_recorder_example/MainActivity.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.zeno.flutter_audio_recorder_example; - -import android.os.Bundle; -import io.flutter.app.FlutterActivity; -import io.flutter.plugins.GeneratedPluginRegistrant; - -public class MainActivity extends FlutterActivity { - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - GeneratedPluginRegistrant.registerWith(this); - } -} diff --git a/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt b/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt new file mode 100644 index 0000000..439cd84 --- /dev/null +++ b/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt @@ -0,0 +1,6 @@ +package com.zeno.flutter_audio_recorder_example; + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/example/android/app/src/main/res/drawable-v21/launch_background.xml b/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/example/android/app/src/main/res/values-night/styles.xml b/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..449a9f9 --- /dev/null +++ b/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml index 00fa441..15ed0f2 100644 --- a/example/android/app/src/main/res/values/styles.xml +++ b/example/android/app/src/main/res/values/styles.xml @@ -1,8 +1,18 @@ + + + diff --git a/example/android/build.gradle b/example/android/build.gradle index bb8a303..c505a86 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,11 +1,13 @@ buildscript { + ext.kotlin_version = '1.3.50' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' + classpath 'com.android.tools.build:gradle:4.1.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/example/android/gradle.properties b/example/android/gradle.properties index 8ce44f6..94adc3a 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -1,4 +1,3 @@ org.gradle.jvmargs=-Xmx1536M -android.enableJetifier=true android.useAndroidX=true - +android.enableJetifier=true diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 2819f02..bc6a58a 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip diff --git a/example/android/settings.gradle b/example/android/settings.gradle index 5a2f14f..44e62bc 100644 --- a/example/android/settings.gradle +++ b/example/android/settings.gradle @@ -1,15 +1,11 @@ include ':app' -def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() -def plugins = new Properties() -def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') -if (pluginsFile.exists()) { - pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } -} +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } -plugins.each { name, path -> - def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() - include ":$name" - project(":$name").projectDir = pluginDirectory -} +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" From fde3668469b65c059c806c53edd561e9908006ab Mon Sep 17 00:00:00 2001 From: Fayeed Pawaskar Date: Tue, 9 Mar 2021 12:41:09 +0530 Subject: [PATCH 4/4] Updated example project --- example/lib/generated_plugin_registrant.dart | 15 +++++++++++++++ example/lib/main.dart | 1 + 2 files changed, 16 insertions(+) create mode 100644 example/lib/generated_plugin_registrant.dart diff --git a/example/lib/generated_plugin_registrant.dart b/example/lib/generated_plugin_registrant.dart new file mode 100644 index 0000000..2cdd734 --- /dev/null +++ b/example/lib/generated_plugin_registrant.dart @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// ignore_for_file: lines_longer_than_80_chars + +import 'package:audioplayers/audioplayers_web.dart'; + +import 'package:flutter_web_plugins/flutter_web_plugins.dart'; + +// ignore: public_member_api_docs +void registerPlugins(Registrar registrar) { + AudioplayersPlugin.registerWith(registrar); + registrar.registerMessageHandler(); +} diff --git a/example/lib/main.dart b/example/lib/main.dart index 4d28c9b..c570371 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -10,6 +10,7 @@ import 'package:flutter_audio_recorder/flutter_audio_recorder.dart'; import 'package:path_provider/path_provider.dart'; void main() { + WidgetsFlutterBinding.ensureInitialized(); SystemChrome.setEnabledSystemUIOverlays([]); return runApp(new MyApp()); }