Problem with update total amount in cart in realtime

Hi.
I have problem with update/setstate total amount text in textspan. When I swipe product, total amount should be change in a cart in real time.

This is my code:

file : body.dart

import 'package:dobrastylowa_app/pages/cart.dart';
import 'package:flutter/material.dart';
import 'package:dobrastylowa_app/models/Cart.dart';
import 'package:dobrastylowa_app/componets/size_config.dart';

import 'cart_item_card.dart';

class Body extends StatefulWidget {

  const Body({Key? key}) : super(key: key);

  @override
  State<Body> createState() => _BodyState();
}

class _BodyState extends State<Body> {
  double counter = 0;

  @override
  Widget build(BuildContext context) {
    SiceConfig().init(context);
    return Padding(
      padding: EdgeInsets.symmetric(horizontal: getProportionateScreenWidth(20)),
      child: ListView.builder(
          itemCount: listaKoszyku.length,
          itemBuilder: (context, index) => Padding(
            padding: const EdgeInsets.symmetric(vertical: 1),
            child: Dismissible(
                  key: Key(listaKoszyku[index].product.id.toString()),
                  direction: DismissDirection.endToStart,
                  background: Container(
                    padding: const EdgeInsets.symmetric(horizontal: 20),
                    decoration: BoxDecoration(
                      color: const Color(0xFFFFE6E6),
                      borderRadius: BorderRadius.circular(15),
                    ),
                    child: Row(
                      children: const [
                        Spacer(),
                        Icon(Icons.delete),
                      ],
                    ),
                  ),
                  onDismissed: (direction){
                    setState(() {
                      listaKoszyku.removeAt(index);
                      print(total(counter, listaKoszyku));
                      Koszyk(wynik: total(counter, listaKoszyku),);
                    });
                  },
                  child: CartItemCard(cart: listaKoszyku[index]),
                ),
          ),
      ),
    );
  }
}
double total(licz, index){
  for (var element in index) {
    licz = (licz + (element.product.price * element.numOfItems));
  }
  return licz;
}

file cart.dart

import 'dart:async';

import 'package:dobrastylowa_app/models/Cart.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:dobrastylowa_app/componets/body.dart';
import 'package:dobrastylowa_app/componets/size_config.dart';
import 'package:intl/intl.dart';

class Koszyk extends StatefulWidget {

  const Koszyk({
    Key? key,
    required this.wynik,
  }) : super(key: key);

  final double wynik;

  @override
  _KoszykState createState() => _KoszykState();
}

class _KoszykState extends State<Koszyk> {
  static String routeName = "/cart";

  @override
  Widget build(BuildContext context) {
    SiceConfig().init(context);

    return Scaffold(
      appBar: buildAppBar(context),
      body: Body(),
      bottomNavigationBar: Container(
        padding: EdgeInsets.symmetric(
          vertical: getProportionateScreenWidth(15),
          horizontal: getProportionateScreenWidth(30),
        ),
        height: 174,
        decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: const BorderRadius.only(
                topLeft: Radius.circular(30),
                topRight: Radius.circular(30)
            ),
            boxShadow: [
              BoxShadow(
                offset: const Offset(0, -15),
                blurRadius: 20,
                color: const Color(0xFFDADADA).withOpacity(0.15),
              ),
            ],
        ),
        child: Column(
          children: [
            Row(
              children: [
                Container(
                  height: getProportionateScreenWidth(40),
                  width: getProportionateScreenWidth(40),
                  child: Image.asset("assets/voucher.png"),
                ),
                const Spacer(),
                const Text("Dodaj kod rabatowy"),
                const SizedBox(width: 10,),
                const Icon(Icons.arrow_forward_ios, size: 12, color: Colors.grey,)
              ],
            ),
            SizedBox(height: getProportionateScreenWidth(20),),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text.rich(
                    TextSpan(
                        text: "Razem:\n",
                        children: [
                          TextSpan(
                            text: NumberFormat.currency(locale: 'pl').format(widget.wynik),
                            style: const TextStyle(fontSize: 16, color: Colors.black, fontWeight: FontWeight.bold),
                          ),
                        ],
                    ),
                ),
                SizedBox(
                  width: getProportionateScreenWidth(150),
                  child: ElevatedButton(
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: const <Widget>[
                        Padding(
                          padding: EdgeInsets.fromLTRB(0,15,0,15),
                          child: Text("Zamawiam"),
                        ),
                      ],
                    ),
                    style: ButtonStyle(
                        foregroundColor: MaterialStateProperty.all<Color>(Colors.white),
                        backgroundColor: MaterialStateProperty.all<Color>(const Color(
                            0xff6acb03)),
                        shape: MaterialStateProperty.all<RoundedRectangleBorder>(
                            RoundedRectangleBorder(
                                borderRadius: BorderRadius.circular(50.0),
                                side: const BorderSide(color: Color(0xff6acb03))
                            )
                        )
                    ),
                    onPressed: () {
                      setState(() {
                        print(widget.wynik);
                      });
                    },
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }

  AppBar buildAppBar(context){
    return AppBar(
      leading: IconButton(
        icon: const Icon(Icons.arrow_back_ios),
        iconSize: 20.0,
        onPressed: () {
          Navigator.pop(context);
        },
      ),
      title: Column(
        children: [
          const Text(
            "Koszyk",
            style: TextStyle(color: Colors.white),
          ),
          Text(
            "${listaKoszyku.length} produkty", style: Theme.of(context).textTheme.caption!.merge(const TextStyle(color: Colors.white)),
          ),
        ],
      ),
    );
  }
}


Hi.
I found resolution.
I just add this code to onDismissed: in file body.dart

onDismissed: (direction){
                    setState(() {
                      listaKoszyku.removeAt(index);
                      Navigator.pushReplacement(
                        context,
                        PageRouteBuilder(
                          pageBuilder: (_, __, ___) => Koszyk(wynik: total(counter, listaKoszyku),),
                          transitionDuration: Duration(seconds: 0),
                        ),
                      );
                    });
                  },