save method

Future<bool> save(
  1. NUIMiniProgramModule module
)

Save miniprogram

Implementation

Future<bool> save(NUIMiniProgramModule module) async{
  final currentMiniApps = await getMiniApps();
  final isExisting = currentMiniApps.where((element) => element.id == module.id).isNotEmpty;
  if(isExisting){
    final updated = currentMiniApps.map((value){
      if(value.id == module.id) return module;
      return value;
    }).toList();
    return saveMiniApps(updated);
  }
  else{
    currentMiniApps.add(module);
    return saveMiniApps(currentMiniApps);
  }
}