小编Jag*_*esh的帖子

How to convert map to string?

my obj is:

Map myJSON = {
  "name": {"first":"foo","last":"bar"}, 
  "age":31, "city":"New York"
}; 
Run Code Online (Sandbox Code Playgroud)

I want to replace it with the new output Ex:

String myJSON = '{"name":{"first":"foo","last":"bar"}, "age":31, "city":"New York"}';
Run Code Online (Sandbox Code Playgroud)

dart flutter

8
推荐指数
2
解决办法
8058
查看次数

设备后退按钮在抖动中不起作用

在我的应用程序中,当我单击设备的后退按钮时,它正在关闭应用程序。我使用了 Willpopscope 但它不起作用。但是当我创建一个示例项目时它正在工作。任何人都可以解释一下为什么它在现有应用程序中不起作用。我分享了我的代码。(在应用栏中后退箭头工作正常,但问题在于设备后退按钮)

    Future<bool> _onWillPop() {
    return showDialog(
          context: context,
          builder: (context) => new AlertDialog(
                title: new Text('Are you sure?'),
                content: new Text('Unsaved data will be lost.'),
                actions: <Widget>[
                  new FlatButton(
                    onPressed: () => Navigator.of(context).pop(false),
                    child: new Text('No'),
                  ),
                  new FlatButton(
                    onPressed: () => Navigator.of(context).pop(true),
                    child: new Text('Yes'),
                  ),
                ],
              ),
        ) ??
        false;
  }

@override
  Widget build(BuildContext context) {
    return new WillPopScope(
      onWillPop: _onWillPop,
      child: new Scaffold(
        appBar: new AppBar(
          title: new Text(
            "On Back pressed", 
            style: new TextStyle(color: …
Run Code Online (Sandbox Code Playgroud)

dart flutter

6
推荐指数
1
解决办法
6515
查看次数

标签 统计

dart ×2

flutter ×2