Provider function

Widget Provider({
  1. String? id,
  2. dynamic store,
  3. Map<String, dynamic>? stores,
  4. required Widget child,
})

Implementation

Widget Provider({
  String? id,
  dynamic store,
  Map<String, dynamic>? stores,
  required Widget child,
}) {
  // store requirement
  if (store == null && stores == null) {
    throw Exception('Both store and stores can not be null.');
  }

  String ns = (id ?? '') + (id != null ? '.' : '');

  Map<String, dynamic> _providedStores =
      store == null ? stores! : {'default': store};

  _providedStores.forEach((name, storeObject) {
    _stores[ns + name] = storeObject;

    try {
      storeObject!.stateId = ns + name;
    } catch (NoSuchMethodError) {}
  });

  // print('Provider: ');
  // print(_stores);

  return child;
}