-
Notifications
You must be signed in to change notification settings - Fork 147
fix: Retire the dynamic configuration extracted from the pubspec.yaml file #340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,21 +12,19 @@ | |
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| import 'package:flutter/services.dart'; | ||
|
|
||
| import 'package:yaml/yaml.dart'; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I guess we can also remove the dependency from pubspec.yaml? |
||
| import 'package:pay_platform_interface/core/payment_configuration.dart'; | ||
| import 'package:pay_platform_interface/generated/package_info.dart'; | ||
|
|
||
| /// A utility class to handle configuration objects and metadata associated | ||
| /// with this plugin. | ||
| class Configurations { | ||
| /// Complements the payment configuration object with metadata about the | ||
| /// package. | ||
| /// | ||
| /// Takes the configuration included in [config] and returns and updated | ||
| /// version of the object wrapped in a [Future] with additional metadata. | ||
| static Future<Map<String, dynamic>> extractParameters( | ||
| Map<String, dynamic> configuration) async { | ||
| /// Takes the configuration included in [configuration] and returns an updated | ||
| /// version of the object with additional metadata. | ||
| static Map<String, dynamic> extractParameters( | ||
| Map<String, dynamic> configuration) { | ||
| PayProvider provider = | ||
| PayProviders.fromString(configuration['provider'] as String)!; | ||
| Map<String, dynamic> configurationParams = | ||
|
|
@@ -43,7 +41,7 @@ class Configurations { | |
| ...(configurationParams['merchantInfo'] ?? {}) as Map, | ||
| 'softwareInfo': { | ||
| 'id': 'flutter/pay-plugin', | ||
| 'version': (await _getPackageConfiguration())['version'] | ||
| 'version': PackageInfo.version | ||
| } | ||
| }; | ||
|
|
||
|
|
@@ -53,11 +51,4 @@ class Configurations { | |
| return updatedPaymentConfiguration; | ||
| } | ||
| } | ||
|
|
||
| /// Retrieves package information from the `pubspec.yaml` file as a [Map]. | ||
| static Future<Map<dynamic, dynamic>> _getPackageConfiguration() async { | ||
| final configurationFile = await rootBundle | ||
| .loadString('packages/pay_platform_interface/pubspec.yaml'); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: same here. pubspec.yaml can be removed from the assets entry in pubspec.yaml? |
||
| return loadYaml(configurationFile) as Map<dynamic, dynamic>; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this be a breaking change?