首页 > 解决方案 > 可以在php url中使用flutter变量吗

问题描述

我想在 PHP URL 中使用颤振变量的值。我可以做些什么来传递变量的值。

我尝试过传递值,或者可以在 web 视图中说一个 id,但它打印的是字符串而不是变量的值。

`

String url = "http://10.0.2.2/pre_beta_02/dummy.php?therapist_id=value";

class NextPage extends StatefulWidget{
  //List list;
  String value;
  //NextPage({this.value});

  NextPage({Key key,this.value}):super (key: key);

  @override
  _Nextpagestate createState() => new _Nextpagestate();

}

class _Nextpagestate extends State<NextPage>{
  @override
  Widget build(BuildContext context) {

    return WebviewScaffold(
      appBar: new AppBar(
        title: new Text('${widget.value}'),
      ),
      url: url,


    );
  }


}

`

我希望输出为“value = 5”,但实际输出为“value”

标签: androidflutterflutter-dependencies

解决方案


这应该这样做:

return WebviewScaffold(
  appBar: new AppBar(
    title: new Text('${widget.value}'),
  ),
  url: "http://10.0.2.2/pre_beta_02/dummy.php?therapist_id=${widget.value}",
);

推荐阅读