title: HTTP Put request flutter
body: <p>I'm trying to perform put request to update data on the database.
  Ideally, each time I press button, I need  update status on database. Here is my put request:</p>
  <pre><code>Future&lt;DataModel&gt; submitData(String status, int testimonial_id) async {
    final response = await http.put(
        Uri.http('10.0.2.2:5001', '/update/testimony/$testimonial_id'),
        body: {
          &quot;status&quot;: status,
        });
    if (response.statusCode == 200) {
      String responseString = response.body;
      // If the server did return a 201 CREATED response,
      // then parse the JSON.
      return dataModelFromJson(responseString);
    } else {
      // If the server did not return a 201 CREATED response,
      // then throw an exception.
      throw Exception('Failed to load info');
    }
  }
  </code></pre>
  <p>Also see my button</p>
  <pre><code>Widget myLayoutWidget(int testimonial_id) {
      return Container(
        child: Row(
          children: &lt;Widget&gt;[
            ButtonTheme(
              minWidth: 4,
              child: RaisedButton(
                onPressed: () async {
                  showToastAccept();
                  String status = 'approve';
                  DataModel? data = await submitData(status, testimonial_id);
                  setState(() {
                    _dataModel = data;
                  });
                },
                child: const Text(
                  &quot;Approve&quot;,
                ),
              ),
            ),
  
  
  
  </code></pre>