显示错误(未为类型“Uri”定义运算符“+”。尝试定义运算符“+”.dart (undefined_operator))

时间:2021-06-02 17:54:31

标签: flutter dart operator-keyword

这是我的代码 这是用于将数据存储到 Google 电子表格中的应用。
// 在 plus OPERATOR '+' 下显示红线 在线

import 'dart:convert' as convert;
import 'package:store_data/models/update.dart';
import 'package:http/http.dart' as http;


class FormController {
  // Callback function to give response of status of current request.
  final void Function(String) callback;

  var url = Uri.parse('https://script.google.com/macros/s/AKfycbzFd5Cw0itASDzFgIrdr97j8PbfWHw1iVcoJWhbChPKfO2c2sA/exec');
  static const STATUS_SUCCESS = "SUCCESS";

  FormController(this.callback);

  void submitForm(Update update) async{
    try{
      await http.get(
        url + update.toParams()).then(
          (response){
            callback(convert.jsonDecode(response.body)['status']);
          });
    } catch(e){
      print(e);
    }
  }
}'

1 个答案:

答案 0 :(得分:1)

我不确定。试试

var url ='...';

然后

void submitForm(Update update) async{
url+=update.toParams();
Uri uri = Uri.paste(url);
try{
  await http.get(
    uri).then(
      (response){
        callback(convert.jsonDecode(response.body)['status']);
      });
} catch(e){
  print(e);
}