title: Error in flutter : <asynchronous suspension>
body: <p>I want to show a dialog box after product add successfully but when I clicking on Add To Cart Button then I am getting that type of error which is in image.</p>
  <p>This dialog box want to show using httpException, in product_detailpage.dart  page where i use this httpExcetion there are i use dotted line.</p>
  <p><a href="https://i.stack.imgur.com/qSHWq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qSHWq.png" alt="enter image description here" /></a>
  This is my cart_api.dart page</p>
  <pre><code>
  import 'dart:convert';
  
  import 'package:hospital/CartPage/Cart_Api/cart_http_exception.dart';
  import 'package:hospital/customApiVariable.dart';
  import 'package:http/http.dart' as http;
  
  Future add_to_cart_fn(
      String quantity, String plistId, String uid, String sid) async {
    var url = Uri.parse(
        '$ecommerceBaseUrl/addToCartApi.php?a2rTokenKey=$a2rTokenKey&amp;action=addToCart&amp;uid=60daaedd3b9f8751161');
    print('add_to_cart_url:' + url.toString());
    final response = await http.post(url, headers: {
      &quot;Accept&quot;: &quot;Application/json&quot;
    }, body: {
      &quot;quantity&quot;: quantity,
      &quot;plistId&quot;: plistId,
      &quot;uid&quot;: uid,
      &quot;sid&quot;: sid,
    });
    print(&quot;ae&quot; + response.body);
  
    final convertderDatatoJson = jsonDecode(response.body);
    try {
      if (convertderDatatoJson['status'] == &quot;true&quot;) {
        print('status' + convertderDatatoJson['status']);
        print('msg' + convertderDatatoJson['msg']);
        throw HttpException(convertderDatatoJson['msg']);
      }
    } catch (e) {
      throw e;
    }
  
    return convertderDatatoJson;
  }
  
  </code></pre>
  <p>this is my httpException.dart page</p>
  <pre><code>class HttpException implements Exception {
    final msg;
  
    HttpException(this.msg);
  
    @override
    String toString() {
      // TODO: implement toString
      return msg;
    }
  }
  
  
  </code></pre>
  <p>This is my product_detailPage.dart page,</p>
  <pre><code>import 'dart:convert';
  
  import 'package:carousel_pro/carousel_pro.dart';
  import 'package:flutter/material.dart';
  import 'package:hospital/CartPage/Cart_Api/cart_api.dart';
  import 'package:hospital/CartPage/Cart_Api/cart_http_exception.dart';
  import 'package:hospital/CartPage/pages/cartPage.dart';
  import 'package:hospital/Drawer/dropdown_menu.dart';
  import 'package:hospital/ProductDetailsPage/product_detailPage.dart';
  import 'package:hospital/ProductDetailsPage/related_product_page.dart';
  import 'package:hospital/SecondSection/Medicine/medicine_page.dart';
  import 'package:hospital/constant.dart';
  import 'package:hospital/customApiVariable.dart';
  import 'package:http/http.dart' as http;
  import 'package:line_icons/line_icons.dart';
  import 'package:provider/provider.dart';
  
  class DetailPage extends StatefulWidget {
    final plistId;
  
    const DetailPage({Key key, this.plistId}) : super(key: key);
    @override
    _DetailPageState createState() =&gt; _DetailPageState();
  }
  
  class _DetailPageState extends State&lt;DetailPage&gt; {
    final GlobalKey&lt;FormState&gt; _formKey = GlobalKey();
    int quantity = 1;
    var response;
  
    var detailPageApi;
  
    @override
    void initState() {
  
      super.initState();
  
      fetchData(widget.plistId);
    }
  
    fetchData(var consultWithDoctor) async {
  a2rTokenKey=carpet1234');
  
      var api = Uri.parse(
          '$ecommerceBaseUrl/productListApi.php?a2rTokenKey=$a2rTokenKey&amp;plistId=${widget.plistId}');
  
      response = await http.get(
        api,
      );
      print(&quot;detailPageApi &quot; + api.toString());
      print(&quot;detailPageBody &quot; + response.body);
  
      // in double quotes drink is key value of json
  
      detailPageApi = jsonDecode(response.body);
  
      print(&quot;detailPagelist &quot; + detailPageApi.toString());
      // return doctorDetailsApi;
      setState(() {});
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          backgroundColor: kGreen,
          title: Text(
            &quot;Details&quot;,
            style: TextStyle(fontStyle: FontStyle.italic),
          ),
          actions: [
            IconButton(
              icon: Icon(Icons.shopping_cart),
              // onPressed: () =&gt; print(&quot;open cart&quot;),
              onPressed: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(builder: (context) =&gt; Cartpage()),
                );
              },
            ),
            DropDownMenu(),
          ],
        ),
        body: Container(
          child: response != null
              ? ListView.builder(
                  // itemCount: categoryApi.length.clamp(0, 3),//THis is for showed minimun length of item listview.builder flutter
                  itemCount: detailPageApi.length.clamp(0, 1),
                  scrollDirection: Axis.vertical,
                  physics: ScrollPhysics(),
                  shrinkWrap: true,
                  itemBuilder: (context, index) {
                    var details = detailPageApi[index];
                    if (details['num'] == 0) {
                      return Center(
                        child: CircularProgressIndicator(
                          backgroundColor: Colors.white,
                        ),
                      );
                    }
                    return Column(
                      children: &lt;Widget&gt;[
                        Hero(
  
                          tag: &quot;1&quot;,
                          child: SizedBox(
                            height: 300.0,
                            width: 300.0,
                            child: Carousel(
                              boxFit: BoxFit.cover,
                              autoplay: false,
                              animationCurve: Curves.fastOutSlowIn,
                              animationDuration: Duration(milliseconds: 800),
                              dotSize: 6.0,
                              dotIncreasedColor: Colors.black,
                              dotBgColor: Colors.transparent,
                              // dotPosition: DotPosition.topRight,
                              dotVerticalPadding: 10.0,
                              showIndicator: true,
                              indicatorBgPadding: 7.0,
                              images: [
                                NetworkImage(details['pImgImg']),
                                
                              ],
                            ),
                          ),
                        ),
                        SizedBox(
                          height: 50,
                        ),
                        Padding(
                          padding: const EdgeInsets.only(left: 20, right: 20),
                          child: Row(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: &lt;Widget&gt;[
                              Text(
                                &quot;Name :&quot;,
                                style: TextStyle(
                                    fontSize: 18,
                                    height: 1.5,
                                    fontWeight: FontWeight.w500),
                              ),
                              SizedBox(
                                width: 20,
                              ),
                              Flexible(
                                child: Text(
                                  // widget.details,
                                  details['productName'],
                                  style: TextStyle(
                                      fontSize: 17,
                                      height: 1.5,
                                      fontWeight: FontWeight.w500),
                                ),
                              ),
                            ],
                          ),
                        ),
                        SizedBox(
                          height: 20,
                        ),
                        Padding(
                          padding: const EdgeInsets.only(left: 20, right: 20),
                          child: Row(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: &lt;Widget&gt;[
                              Text(
                                &quot;Details :&quot;,
                                style: TextStyle(
                                    fontSize: 18,
                                    height: 1.5,
                                    fontWeight: FontWeight.w500),
                              ),
                              SizedBox(
                                width: 20,
                              ),
                              Flexible(
                                child: Text(
                                  // widget.details,
                                  details['productDescription'],
                                  style: TextStyle(
                                      fontSize: 17,
                                      height: 1.5,
                                      fontWeight: FontWeight.w500),
                                ),
                              ),
                            ],
                          ),
                        ),
                        SizedBox(
                          height: 20,
                        ),
                        Padding(
                          padding: const EdgeInsets.only(left: 20, right: 20),
                          child: Row(
                            children: &lt;Widget&gt;[
                              Text(
                                &quot;Price :&quot;,
                                style: TextStyle(
                                    fontSize: 18, fontWeight: FontWeight.w500),
                              ),
                              SizedBox(
                                width: 20,
                              ),
                              Row(
                                children: &lt;Widget&gt;[
                                  Text(
                                    // &quot;Rs &quot; + widget.pPromotionPrice,
                                    &quot;Rs 55.0&quot;,
                                    style: TextStyle(
                                        fontSize: 17,
                                        fontWeight: FontWeight.w500),
                                  ),
                                  SizedBox(
                                    width: 20,
                                  ),
                                  Text(
                                    // &quot;Rs &quot; + widget.pPrice,
                                    &quot;Rs 100&quot;,
                                    style: TextStyle(
                                        fontSize: 18,
                                        fontWeight: FontWeight.w500,
                                        // color: warning,
                                        decoration: TextDecoration.lineThrough),
                                  )
                                ],
                              )
                            ],
                          ),
                        ),
                        SizedBox(
                          height: 25,
                        ),
                        
                        Padding(
                          padding: const EdgeInsets.only(right: 20, left: 20),
                          child: Row(
                            children: &lt;Widget&gt;[
                              Text(
                                &quot;Qty :&quot;,
                                style: TextStyle(
                                    fontSize: 17, fontWeight: FontWeight.w500),
                              ),
                              SizedBox(
                                width: 20,
                              ),
                              Row(
                                children: &lt;Widget&gt;[
                                  InkWell(
                                    onTap: () {
                                      if (quantity &gt; 1) {
                                        setState(() {
                                          quantity = --quantity;
                                        });
                                      }
  
                                      // minus here
                                    },
                                    child: Container(
                                      width: 25,
                                      height: 25,
                                      decoration: BoxDecoration(
                                          // border: Border.all(color: primary),
                                          shape: BoxShape.circle),
                                      child: Icon(
                                        LineIcons.minus,
                                        size: 15,
                                      ),
                                    ),
                                  ),
                                  SizedBox(
                                    width: 15,
                                  ),
                                  Text(
                                    quantity.toString(),
                                    style: TextStyle(fontSize: 16),
                                  ),
                                  SizedBox(
                                    width: 15,
                                  ),
                                  InkWell(
                                    onTap: () {
                                      setState(() {
                                        quantity = ++quantity;
                                      });
                                      // minus here
                                    },
                                    child: Container(
                                      width: 25,
                                      height: 25,
                                      decoration: BoxDecoration(
                                          // border: Border.all(color: primary),
                                          shape: BoxShape.circle),
                                      child: Icon(
                                        LineIcons.plus,
                                        size: 15,
                                      ),
                                    ),
                                  ),
                                ],
                              )
                            ],
                          ),
                        ),
                        SizedBox(
                          height: 50,
                        ),
                        InkWell(
                          onTap: () async {
                     ---------------------------------------------
                       //here show my msg using dialog box
                            try {} on HttpException catch (e) {
                              print('hiii');
                             
                              var errorMessage = 'Authentication Failed';
                              if (e.toString().contains(
                                  'Product Succesfully Added to Cart')) {
                                errorMessage =
                                    'Product Succesfully Added to Cart';
                                print(errorMessage);
                                _showerrorDialog(errorMessage);
                              }
                            } catch (error) {
                              var errorMessage = 'Please try again later';
                              _showerrorDialog(errorMessage);
                            }
                           ------------------------------------------------
                            var qty = quantity.toString();
                            var plistId = widget.plistId;
                            print('pplistid' + plistId);
  
                            var uid = var_uid.toString();
                            var sid = var_sid.toString();
                            print('uuid' + uid);
                            print('ssid' + sid);
  
                            var response =
                                await add_to_cart_fn(qty, plistId, uid, sid);
  
                            print(&quot;rsp: &quot; + response['status']);
                          },
                          // },
                          child: Padding(
                            padding: EdgeInsets.only(left: 20, right: 20),
                            child: Container(
                              height: 45,
                              width: double.infinity,
                              decoration: BoxDecoration(
                                  color: kGreen,
                                  borderRadius: BorderRadius.circular(30)),
                              child: Center(
                                child: Text(
                                  &quot;ADD TO CART&quot;,
                                  style: TextStyle(
                                    color: kWhite,
                                    fontSize: 20,
                                  ),
                                ),
                              ),
                            ),
                          ),
                        ),
  
                        SizedBox(height: 20.0),
                        // SomeMedicinePage(),
                        RelatedProductPage(plistId: widget.plistId)
                      ],
                    );
                  })
              : Center(
                  child: CircularProgressIndicator(
                    backgroundColor: Colors.white,
                  ),
                ),
        ),
      );
    }
  
    void _showerrorDialog(String message) {
      showDialog(
        context: context,
        builder: (ctx) =&gt; AlertDialog(
          title: Text(
            'An Error Occurs',
            style: TextStyle(color: Colors.blue),
          ),
          content: Text(message),
          actions: &lt;Widget&gt;[
            FlatButton(
                child: Text('Okay'),
                onPressed: () =&gt; Navigator.of(context, rootNavigator: true).pop())
          ],
        ),
      );
    }
  }
  
  </code></pre>