颤动更改字符串值

时间:2020-07-23 09:43:53

标签: string flutter variables

因此,我正在为Flutter重新编码媒体播放器,并提出以下问题。

我似乎无法使用以下函数运行时传递的URL更新字符串_url

runStation(urls){
     print(urls);
       _url = urls;

   }

它正在打印urls,但没有更改String _url;

完整代码

class Home extends StatefulWidget {
   @override
  State<StatefulWidget> createState() {
    return _HomeState();
  }

   String _url;
   AudioPlayer audioPlayer = AudioPlayer();  // NEW MEDIA PLAYER
   //AudioStreamPlayer player = AudioStreamPlayer();  // OLD MEDIA PLAYER
   runStation(urls){
     print(urls);
       _url = urls;

   }

   playStation(){
     print(_url);
     audioPlayer.play(_url);
   }
  stopStation(){
    print(_url);
     audioPlayer.stop();
  }

}

0 个答案:

没有答案