如何在 Flutter 中获取 src 值?

How to get src value in Flutter?

我正在使用 Laravel Passport 从 REST API 中提取数据,数据有一个嵌入代码,我需要播放视频,为此我必须使用 ext_video_player,我如何从这样的嵌入代码中获取 src 值:

<iframe width="560" height="315" src="https://www.youtube.com/embed/fUv9gO8t8b4" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

我需要获取src的值。

我不知道它是不是字符串,但如果是字符串,你可以这样获取 src:

  const str = '<iframe width="560" height="315" src="https://www.youtube.com/embed/fUv9gO8t8b4" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>';
  const start = 'src="';
  const end = '" frameborder';

  final startIndex = str.indexOf(start);
  final endIndex = str.indexOf(end, startIndex + start.length);

  print(str.substring(startIndex + start.length, endIndex)); // https://www.youtube.com/embed/fUv9gO8t8b4