withProvider method
Adds config, or replaces the entry with the same id. The first
provider added becomes the selected one.
Implementation
ModelSettings withProvider(ProviderConfig config) {
final index = providers.indexWhere((p) => p.id == config.id);
final next = [...providers];
if (index < 0) {
next.add(config);
} else {
next[index] = config;
}
return ModelSettings(
useThirdParty: useThirdParty,
providers: List.unmodifiable(next),
selectedProviderId: selectedProviderId ?? config.id,
);
}