Last active
August 22, 2022 10:35
-
-
Save dened/4f8d597f7a22750c79440ca8569fe8ae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
class ApiProvidersScope extends InheritedWidget { | |
const ApiProvidersScope({ | |
required final this.store, | |
required super.child, | |
}); | |
final ApiProviderStore store; | |
static ApiProviderStore of(BuildContext context) { | |
final inhW = context.getElementForInheritedWidgetOfExactType<ApiProvidersScope>()?.widget; | |
return inhW is ApiProvidersScope ? inhW.store : _throwNotInitializedYet(); | |
} | |
@alwaysThrows | |
static Never _throwNotInitializedYet() => throw UnsupportedError('ApiProvidersScope not found'); | |
@override | |
bool updateShouldNotify(final ApiProvidersScope oldWidget) => false; | |
@override | |
void debugFillProperties(DiagnosticPropertiesBuilder properties) { | |
super.debugFillProperties(properties); | |
properties | |
..add(StringProperty('type', 'ApiProvidersScope')) | |
..add(DiagnosticsProperty('store', store)); | |
} | |
} | |
class ApiProviderStoreImpl with DiagnosticableTreeMixin implements ApiProviderStore { | |
ApiProviderStoreImpl({required HttpClient client}) : _client = client; | |
final HttpClient _client; | |
CandidateApiProvider? _candidate; | |
CompanyApiProvider? _company; | |
ConfigurationApiProvider? _configuration; | |
DictionaryApiProvider? _dictionary; | |
ExpeditorCarrierContractApiProvider? _expeditorCarrierContract; | |
ExpeditorContractConclusionApiProvider? _expeditorContractConclusion; | |
MessageApiProvider? _message; | |
OrderDocumentApiProvider? _orderDocument; | |
OrderDocumentPackageApiProvider? _orderDocumentPackage; | |
OrderDraftExpeditorApiProvider? _orderDraftExpeditor; | |
WorkerApiProvider? _worker; | |
@override | |
CandidateApiProvider get candidate => _candidate ??= CandidateApiProvider(_client); | |
@override | |
CompanyApiProvider get company => _company ??= CompanyApiProvider(_client); | |
@override | |
ConfigurationApiProvider get configuration => | |
_configuration ??= ConfigurationApiProvider(_client); | |
@override | |
DictionaryApiProvider get dictionary => _dictionary ??= DictionaryApiProvider(_client); | |
@override | |
ExpeditorCarrierContractApiProvider get expeditorCarrierContract => | |
_expeditorCarrierContract ??= ExpeditorCarrierContractApiProvider(_client); | |
@override | |
ExpeditorContractConclusionApiProvider get expeditorContractConclusion => | |
_expeditorContractConclusion ??= ExpeditorContractConclusionApiProvider(_client); | |
@override | |
MessageApiProvider get message => _message ??= MessageApiProvider(_client); | |
@override | |
OrderDocumentApiProvider get orderDocument => | |
_orderDocument ??= OrderDocumentApiProvider(_client); | |
@override | |
OrderDocumentPackageApiProvider get orderDocumentPackage => | |
_orderDocumentPackage ??= OrderDocumentPackageApiProvider(_client); | |
@override | |
OrderDraftExpeditorApiProvider get orderDraftExpeditor => | |
_orderDraftExpeditor ??= OrderDraftExpeditorApiProvider(_client); | |
@override | |
WorkerApiProvider get worker => _worker ??= WorkerApiProvider(_client); | |
@override | |
void debugFillProperties(DiagnosticPropertiesBuilder properties) { | |
super.debugFillProperties(properties); | |
properties | |
..add(StringProperty('type', 'ApiProviderStore')) | |
..add(DiagnosticsProperty('candidate', candidate)) | |
..add(DiagnosticsProperty('company', company)) | |
..add(DiagnosticsProperty('configuration', configuration)) | |
..add(DiagnosticsProperty('dictionary', dictionary)) | |
..add(DiagnosticsProperty('expeditorCarrierContract', expeditorCarrierContract)) | |
..add(DiagnosticsProperty('expeditorContractConclusion', expeditorContractConclusion)) | |
..add(DiagnosticsProperty('message', message)) | |
..add(DiagnosticsProperty('orderDocument', orderDocument)) | |
..add(DiagnosticsProperty('orderDocumentPackage', orderDocumentPackage)) | |
..add(DiagnosticsProperty('orderDraftExpeditor', orderDraftExpeditor)) | |
..add(DiagnosticsProperty('worker', worker)); | |
} | |
} | |
abstract class ApiProviderStore { | |
CandidateApiProvider get candidate; | |
CompanyApiProvider get company; | |
ConfigurationApiProvider get configuration; | |
DictionaryApiProvider get dictionary; | |
ExpeditorCarrierContractApiProvider get expeditorCarrierContract; | |
ExpeditorContractConclusionApiProvider get expeditorContractConclusion; | |
MessageApiProvider get message; | |
OrderDocumentApiProvider get orderDocument; | |
OrderDocumentPackageApiProvider get orderDocumentPackage; | |
OrderDraftExpeditorApiProvider get orderDraftExpeditor; | |
WorkerApiProvider get worker; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment