HomeiOS Developmentandroid - The best way to test if the supplier worth is...

android – The best way to test if the supplier worth is modified or not in flutter?


I need to test if the supplier worth is modified or not as a result of I’m calling the api within the init state and need to replace the info in accordance with filter utilizing supplier.
And I am following MVVM can anybody counsel me how can I obtain this.
That is my supplier class

import 'bundle:flutter/materials.dart';

class FilterProvider extends ChangeNotifier {
  Record<String> _filterItems = [
    "usd",
    "top100",
    "1hr",
  ];
  Record<String> get filterItems => _filterItems;
  void setPrice(String value) {
    _filterItems[0] = value;
    notifyListeners();
  }

  void setCTS(String noOfCoins) {
    _filterItems[1] = noOfCoins;
    notifyListeners();
  }

  void setPriceChange(String change) {
    _filterItems[2] = change;
    notifyListeners();
  }
}

And that is my view can anybody have an concept how can I obtain this.


class CoinsPage extends StatefulWidget {
  const CoinsPage({tremendous.key});

  @override
  State<CoinsPage> createState() => _CoinsPageState();
}

class _CoinsPageState extends State<CoinsPage> {
  late CoinsViewModel viewModel = CoinsViewModel();
  Record<CoinDetailsModel>? merchandise;

  @override
  void initState() {
    tremendous.initState();
    viewModel.loadCoinData("marketCap", "desc");
    viewModel.scrollController.addListener(viewModel.pagination);
  }

  @override
  Widget construct(BuildContext context) {
    double screenWidth = MediaQuery.of(context).measurement.width;
    double columnWidth = screenWidth / 5;
    double mar = (columnWidth / 5) + 1;
    // var margin = EdgeInsets.all(mar);
    return ChangeNotifierProvider<CoinsViewModel>(
        create: (BuildContext context) => viewModel,
        little one: Consumer2<CoinsViewModel, FilterProvider>(
          builder: (context, viewModel, filterProvider, _) {
            debugPrint("size ${viewModel.coinsModel.size}");
            merchandise = viewModel.coinsModel;
            //TODO Filter
            var usd = context.watch<FilterProvider>().filterItems[0];

            debugPrint("Filter $usd");
            return Scaffold(
              
            );
          },
        ));
  }

  
}

I’ve tried this

import 'bundle:flutter/materials.dart';
import 'bundle:supplier/supplier.dart';

class MyWidget extends StatelessWidget {
  @override
  Widget construct(BuildContext context) {
    return Shopper<MyProvider>(
      builder: (context, myProvider, little one) {
        if (myProvider.myValue == someValue) {
          // do one thing if the worth has not modified
        } else {
          // do one thing if the worth has modified
        }
        return Textual content(myProvider.myValue.toString());
      },
    );
  }
}

But when I need to return to the primary merchandise it will not replace

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments