Aman-Malhotra / Volume_Flutter

Now you can change android volumes in Flutter. You can change MEDIA volume, NOTIFICATION volume, RING Volume, VOICE CALL Volume, ALARM Volume and SYSTEM Volume. This is exclusively for android right now because I don't have max to do the IOS coding and I don't have experience in IOS coding as well. Pull requests for IOS Implementation are welcome.
MIT License
23 stars 31 forks source link

Support change volume in isolate mode #13

Open Ted-chiptech opened 2 years ago

Ted-chiptech commented 2 years ago

Will get this exception if I change the volume in the isolate mode.

E/MethodChannel#volume( 7076): java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.Activity.setVolumeControlStream(int)' on a null object reference
E/MethodChannel#volume( 7076):  at com.example.volume.VolumePlugin.controlVolume(VolumePlugin.java:97)
E/MethodChannel#volume( 7076):  at com.example.volume.VolumePlugin.onMethodCall(VolumePlugin.java:80)
E/MethodChannel#volume( 7076):  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#volume( 7076):  at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:84)
E/MethodChannel#volume( 7076):  at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:865)
E/MethodChannel#volume( 7076):  at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#volume( 7076):  at android.os.MessageQueue.next(MessageQueue.java:332)
E/MethodChannel#volume( 7076):  at android.os.Looper.loop(Looper.java:168)
E/MethodChannel#volume( 7076):  at android.app.ActivityThread.main(ActivityThread.java:6878)
E/MethodChannel#volume( 7076):  at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#volume( 7076):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
E/MethodChannel#volume( 7076):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:876)
ZoltanTabi commented 2 years ago

Hi! I fixed this issue in my repo Use this in pubspec.yaml:

dependencies:
  volume:
    git:
      url: https://github.com/ZoltanTabi/Volume_Flutter
      ref: master