创建 Flutter 购物车

发布于 2025-01-11 15:39:35 字数 1086 浏览 0 评论 0原文

我想在我的应用程序中制作一个购物车, 我可以有一些关于如何做到这一点的资源吗?

我所有的手表都是旧的,不是我想要的 这是使用 Firebase 和 Provider

这是模型:

class Summer_d {
  late String Imag;
  late String info;
  late String name;
  late int price;
  late String sub_info;
  late List<dynamic>? sub_img;

 

  Summer_d.fromMap(Map<String,dynamic>data){
    Imag = data["Imag"];
    info = data ["info"];
    name = data ["name"];
    price = data["price"];
    sub_info = data ["sub_info"];
    sub_img = data ["sub_img"];

    
    

  }
}

这是 Provider 类

class SummerNotifier with ChangeNotifier {
  List<Summer_d> _summerList = [];
  late Summer_d _currentsummer;

  int slectedIndex = 0;

  UnmodifiableListView<Summer_d> get summerList =>
      UnmodifiableListView(_summerList);

  Summer_d get currentsummer => _currentsummer;

  set summerList(List<Summer_d> summerList) {
    _summerList = summerList;
    notifyListeners();
  }

  set currentsummer(Summer_d summer_d) {
    _currentsummer = summer_d;
    notifyListeners();
  }
}

I want to make a Shopping Cart in my App ,
can i have some sources on how to do it ?

All i have watch is old and not what i want
which is to use Firebase and Provider

This is the model:

class Summer_d {
  late String Imag;
  late String info;
  late String name;
  late int price;
  late String sub_info;
  late List<dynamic>? sub_img;

 

  Summer_d.fromMap(Map<String,dynamic>data){
    Imag = data["Imag"];
    info = data ["info"];
    name = data ["name"];
    price = data["price"];
    sub_info = data ["sub_info"];
    sub_img = data ["sub_img"];

    
    

  }
}

This is the Provider class

class SummerNotifier with ChangeNotifier {
  List<Summer_d> _summerList = [];
  late Summer_d _currentsummer;

  int slectedIndex = 0;

  UnmodifiableListView<Summer_d> get summerList =>
      UnmodifiableListView(_summerList);

  Summer_d get currentsummer => _currentsummer;

  set summerList(List<Summer_d> summerList) {
    _summerList = summerList;
    notifyListeners();
  }

  set currentsummer(Summer_d summer_d) {
    _currentsummer = summer_d;
    notifyListeners();
  }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文