MissingPluginException(未在通道 com.ryanheise.just_audio.methods 上找到方法 init 的实现)

MissingPluginException(No implementation found for method init on channel com.ryanheise.just_audio.methods)

我正在使用 flutter 构建桌面应用程序,我需要从本地存储播放音频文件,为此我使用 just_audio flutter 包,因为它支持 Windows。但是我找不到 windows 的任何示例。我编写了这样的代码-

import 'package:just_audio/just_audio.dart';
...

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
  final _player = AudioPlayer();

  @override
  void initState() {
    super.initState();
    ...
    _init();
  }
   
  Future<void> _init() async {
    await _Player.setFilePath('C:/Users/Admin/Downloads/test.wav', preload: true);
  }
  ...

await 调用从未完成,我收到以下错误:

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method init on channel com.ryanheise.just_audio.methods)
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:165:7)
<asynchronous suspension>
#1      MethodChannelJustAudio.init (package:just_audio_platform_interface/method_channel_just_audio.dart:13:5)
<asynchronous suspension>
#2      AudioPlayer._setPlatformActive.setPlatform (package:just_audio/just_audio.dart:1255:13)
<asynchronous suspension>
#3      AudioPlayer.load (package:just_audio/just_audio.dart:708:26) 
<asynchronous suspension>
#4      AudioPlayer.setAudioSource (package:just_audio/just_audio.dart:683:18)
<asynchronous suspension>

您好,如果您已经使用了一些包,那么在 pub get 之后尝试重启应用程序(不是热重启,重新构建它)然后它就会工作。

just_audio 不包含 Windows 实现。由于它 says in the README,您需要包含另一个包,例如 just_audio_libwinmedia,它提供了包的 Windows 实现。