R
R
Roman Sergeevich2021-07-04 16:53:19
Android
Roman Sergeevich, 2021-07-04 16:53:19

How to call RefreshIndicator from code?

How to call RefreshIndicator from code on startup or button click?
I am using Provider to manage application state

@override
  Widget build(BuildContext context) {
    context.read<Data>().httpRequest();

    return RefreshIndicator(
      onRefresh: () {
        return context.read<Data>().httpRequest();
      },
      child: Column(
        children: [
          DropdownButton<int>(
            hint: Hint(),
            items: loansServicecList(context),
            onChanged: (int value) {
              if (value != context.read<Data>().i) {
                context.read<Data>().i = value;
                context.read<Data>().httpRequest();
              }
            },
          ),
          Flexible(
            child: ServicesList(),
          ),
        ],
      ),
    );
  }

the httpRequest() method loads the data, but the RefreshIndicator naturally does not work in this situation

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question