删除商品后重新计算Flutter的总价

嗨,大家好,我正在做一个食品订购应用程序,我需要一些帮助,而用户从购物车中删除了一个商品,那么如果您有任何建议,我应该自动计算价格,请让我知道谢谢 单击删除的按钮后,我已经尝试过刷新页面,但是我认为我可以执行推按钮功能

                             import 'package:flutter/material.dart';
            import 'package:http/http.dart' as http;
            import 'package:resat/BurgerListView/const/themeColor.dart';
            import 'dart:convert';
            import 'DataTableDemo.dart';
            import 'Employee.dart';
            import 'services.dart';

            class FavoritesPage extends StatefulWidget {
              @override
              FavoritesPageState createState() => FavoritesPageState();
            }

            class FavoritesPageState extends State<FavoritesPage> {
              List<Employee> _employees;

              @override
              Widget build(BuildContext context) {
                return new MaterialApp(
                  theme: new ThemeData(
                    primarySwatch: Colors.deepOrange,
                  ),
                  home: new Scaffold(
                    body: new Center(
                      //FutureBuilder is a widget that builds itself based on the latest snapshot
                      // of interaction with a Future.
                      child: new FutureBuilder<List<Employee>>(
                        future: Services.getEmployees(),
                        //we pass a BuildContext and an AsyncSnapshot object which is an
                        //Immutable representation of the most recent interaction with
                        //an asynchronous computation.
                        builder: (context, snapshot) {
                          if (snapshot.hasData) {
                            List<Employee> _employee = snapshot.data;
                            Services.getEmployees();
                            return  Scaffold(
                              body: SafeArea(
                                child: CustomListView(_employee),
                              ),
                              bottomNavigationBar: BottomBar(_employee),
                            );
                          } else if (snapshot.hasError) {
                            return Text('${snapshot.error}');
                          }
                          //return  a circular progress indicator.
                          return new CircularProgressIndicator();
                        },
                      ),
                    ),
                  ),
                );
              }
            }

            class CustomListView extends StatefulWidget {
              List<Employee> _employee;

              CustomListViewState createState() => CustomListViewState();

              CustomListView(this._employee);
            }

            class CustomListViewState extends State<CustomListView> {
              List<Employee> _employee;

              Widget build(context) {
                return ListView.builder(
                  itemCount: _employee.length,
                  itemBuilder: (context, int currentIndex) {
                    return createViewItem(_employee[currentIndex], context);
                  },
                );
              }

              @override
              void initState() {
                _employee = [];
                _getEmployees();
              }

              Widget createViewItem(Employee _employee, BuildContext context) {
                return new Card(
                    child: new Column(
                  children: <Widget>[
                    new ListTile(
                      leading: new Image.asset(_employee.path, fit: BoxFit.cover),
                      title: new Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: <Widget>[
                          Text(
                            _employee.firstName,
                            style: new TextStyle(
                              fontSize: 19.0,
                              fontWeight: FontWeight.bold,
                            ),
                          ),
                          Row(
                            children: <Widget>[
                              FlatButton(
                                child: Text('-', style: TextStyle(fontSize: 28.0)),
                                onPressed: () {},
                              ),
                              Text(_employee.quantity),
                              FlatButton(
                                child: Text(
                                  '+',
                                  style: TextStyle(fontSize: 28.0),
                                ),
                                onPressed: () {},
                              ),
                            ],
                          )
                        ],
                      ),
                      subtitle: new Column(
                          mainAxisAlignment: MainAxisAlignment.start,
                          crossAxisAlignment: CrossAxisAlignment.end,
                          children: <Widget>[
                            IconButton(
                              onPressed: () {
                                Services.deleteEmployee(_employee.id);
                                _getEmployees();

                                /*
                                Navigator.of(context).push(
                                    new MaterialPageRoute(
                                        builder: (BuildContext context){
                                          return new FavoritesPage();
                                        }
                                    )
                                );
                                */
                              },
                              icon: Icon(Icons.delete),
                            ),
                            new Text('\$' + _employee.price.toString(),
                                style: new TextStyle(
                                    fontSize: 15.0, fontWeight: FontWeight.normal)),
                          ]),

                      //trailing: ,
                      onTap: () {},
                    )
                  ],
                ));
              }

              void _getEmployees() {
                Services.getEmployees().then((employees) {
                  setState(() {
                    _employee = employees;
                  });
                  print("Length ${employees.length}");
                });
              }
            }

            class BottomBar extends StatefulWidget {
              @override
              BottomBarState createState() => BottomBarState(this._employee);

              final List<Employee> _employee;
              BottomBar(this._employee);


            }

            class BottomBarState extends State<BottomBar>{
              final List<Employee> _employee;

              BottomBarState(this._employee);

              @override
              void initState() {
                returnTotalAmount(_employee);
              }



              @override
              Widget build(BuildContext context) {
                return Container(
                  margin: EdgeInsets.only(left: 35, bottom: 25),
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: <Widget>[
                      totalAmount(_employee),
                      nextButtonBar(),
                    ],
                  ),
                );
              }

              Container totalAmount(List<Employee> _employee) {
                return Container(
                  margin: EdgeInsets.only(right: 10),
                  padding: EdgeInsets.all(5),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      Text(
                        "Total:",
                        style: TextStyle(fontSize: 25, fontWeight: FontWeight.w300),
                      ),
                      Text(
                        "\$${returnTotalAmount(_employee)}",
                        style: TextStyle(fontWeight: FontWeight.w700, fontSize: 28),
                      ),
                    ],
                  ),
                );
              }

              String returnTotalAmount(List<Employee> _employee) {
                double totalAmount = 0.0;

                for (int i = 0; i < _employee.length; i++) {
                  totalAmount = totalAmount + (double.parse(_employee[i].price)*double.parse(_employee[i].quantity));
                }
                return totalAmount.toString();

              }

              Container nextButtonBar() {
                return Container(
                  margin: EdgeInsets.only(right: 25),
                  padding: EdgeInsets.all(25),
                  decoration: BoxDecoration(
                      color: Themes.color, borderRadius: BorderRadius.circular(15)),
                  child: Row(
                    children: <Widget>[
                      Text(
                        "15-25 min",
                        style: TextStyle(
                          fontWeight: FontWeight.w800,
                          fontSize: 14,
                        ),
                      ),
                      Spacer(),
                      Text(
                        "Next",
                        style: TextStyle(
                          fontWeight: FontWeight.w900,
                          fontSize: 16,
                        ),
                      ),
                    ],
                  ),
                );
              }
            }

enter image description here