[dart] search
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- import 'dart:io';
- import 'package:flutter/material.dart';
- import 'package:thawaf/resources/data_state/data_item_model.dart';
- import 'package:thawaf/resources/data_state/data_state.dart';
- class PanduanStateProvider with ChangeNotifier {
- bool isLoading = false;
- bool isInit = false;
- late DataState dataStatePanduan;
- List<DataItem> data = [];
- initialize() async {
- try {
- if (isInit) throw "Sudah diinit";
- if (isLoading) throw "Sedang loading, mohon tunggu";
- isInit = true;
- isLoading = true;
- refresh();
- dataStatePanduan = await DataState.create(
- "panduanHajis",
- id: "panduanHajis",
- withStream: true,
- showPrint: true,
- filters: [],
- sorts: [],
- onRefresh: () {
- refresh();
- },
- );
- dataStatePanduan.onRefresh = () async {
- data = await dataStatePanduan.find(
- sorts: [
- SortDataState(
- key: "createdAt",
- desc: true,
- )
- ],
- );
- refresh();
- };
- dataStatePanduan.refresh();
- isLoading = false;
- refresh();
- } catch (e) {}
- }
- refresh() {
- notifyListeners();
- }
- }
Editor
You can edit this paste and save as new: