【问题标题】:LateError (LateInitializationError: Field if i call function from parent widget in flutterLateError (LateInitializationError: Field 如果我在 flutter 中从父小部件调用函数
【发布时间】:2022-11-30 05:43:35
【问题描述】:

我正在使用 youtube_player_flutter

作为 youtube_player_flutter _playerController.load(videoId.toString()) 的文档,当我在同一个小部件中调用此功能时,此功能用于更改视频及其工作正常

void changeVideo(videoId) {
    this._playerController.load(videoId.toString());
  }

但是当我尝试从父小部件调用这个changeVideo

WatchState().changeVideo(video.toString());

它告诉我错误

LateError (LateInitializationError: Field '_playerController@43012897' has not been initialized.)

谢谢

【问题讨论】:

  • 你有变量_playerController吗?如果是这样,请显示该代码。

标签: flutter


【解决方案1】:

您需要在父窗口小部件中初始化 PlayerController。尝试这样做,让我知道它是否有效:)

【讨论】:

  • 并尝试将 PlayerController 作为参数注入到您的小部件中。
猜你喜欢
  • 1970-01-01
  • 2021-05-04
  • 2021-12-30
  • 2021-12-04
  • 2021-09-10
  • 2023-01-17
  • 2022-08-19
  • 2021-12-02
  • 1970-01-01
相关资源
最近更新 更多