addNewWProfile function
Implementation
Future<bool> addNewWProfile(
BuildContext context, WidgetRef ref, String text) async {
try {
final res = await ref.read(workerKeysProvider).add(
WorkerKey.fromJson(
jsonDecode(text) as Map<String, dynamic>,
),
);
if (!res) {
showErrorNotification(
tr().cantAddDepDuplicate,
);
if (context.mounted) {
FocusScope.of(context).requestFocus(
FocusNode(),
);
}
return true;
}
} on FormatException {
showErrorNotification(
tr().cantAddDepBadFormat,
);
if (context.mounted) {
FocusScope.of(context).requestFocus(
FocusNode(),
);
}
}
return false;
}