Skip to content

Commit

Permalink
fix the issue with dynamic property of Chapa instance
Browse files Browse the repository at this point in the history
  • Loading branch information
mrnpro committed Feb 24, 2024
1 parent a37ec0c commit 1c23e37
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/src/chapa.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ class Chapa {
Chapa._internal(this._initilizeUsecase, this._verifyUsecase);

/// Returns the singleton instance of Chapa.
static Chapa get getInstance => _instance;
static Chapa get getInstance {
if (_instance == null) {
throw const AuthException(
msg:
'Please configure the API key before getting chapa instance.Please refer to the documentation: [https://pub.dev/packages/chapa_unofficial]');
}
return _instance!;
}

/// Sets up the Chapa singleton instance and other dependenciy
/// injections with the provided [privateKey]
Expand Down Expand Up @@ -101,7 +108,6 @@ class Chapa {
throw const AuthException(
msg:
'Please configure the API key before starting the payment. Refer to the documentation: [https://pub.dev/packages/chapa_unofficial]');

}

// intialize on the server
Expand Down

0 comments on commit 1c23e37

Please sign in to comment.