Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Document the addition functionality in README
  • Loading branch information
mvanbeusekom committed Apr 22, 2021
commit 9eb358fee78102af78685b38da1a486861b1332c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ platform-specific behavior, and when you register your plugin, set the default
`InAppPurchasePlatform` by calling
`InAppPurchasePlatform.setInstance(MyPlatformInAppPurchase())`.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add doc for how to add additional features in a platform

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

To implement functionality that is specific to the platform and is not covered
by the [`InAppPurchasePlatform`][2] idiomatic API, extend
[`InAppPurchasePlatformAddition`][3] with the platform-specific functionality,
and when the plugin is registered, set the addition instance by calling the
`InAppPurchasePlatformAddition.instance = MyPlatformInAppPurchaseAddition()`.

# Note on breaking changes

Strongly prefer non-breaking changes (such as adding a method to the interface)
Expand All @@ -23,4 +29,5 @@ See https://flutter.dev/go/platform-interface-breaking-changes for a discussion
on why a less-clean interface is preferable to a breaking change.

[1]: ../in_app_purchase
[2]: lib/in_app_purchase_platform_interface.dart
[2]: lib/in_app_purchase_platform_interface.dart
[3]: lib/in_app_purchase_platform_addition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

export 'src/in_app_purchase_addition.dart';
export 'src/in_app_purchase_addition_provider.dart';
export 'src/in_app_purchase_platform.dart';
export 'src/in_app_purchase_platform_addition.dart';
export 'src/in_app_purchase_platform_addition_provider.dart';
export 'src/types/types.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ignore: avoid_classes_with_only_static_members
/// The interface that platform implementations must implement when they want to
/// provide platform specific in_app_purchase features.
abstract class InAppPurchaseAddition {
abstract class InAppPurchasePlatformAddition {
/// The instance containing the platform specific in_app_purchase features.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a code example of how a platform can add "Addition".
Something like:

class InAppPurchaseSomeStoreAddition extends InAppPurchaseAddition {
    void someMethod() {}
}

class InAppPurchaseSomeStorePluginWeb {
    static void registerWith() {
         InAppPurchaseAddition = InAppPurchaseSomePlatformAddition();
     }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

static InAppPurchaseAddition? instance;
static InAppPurchasePlatformAddition? instance;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:in_app_purchase_platform_interface/src/in_app_purchase_addition.dart';
import 'package:in_app_purchase_platform_interface/src/in_app_purchase_platform_addition.dart';

/// The [InAppPurchaseAdditionProvider] is responsible for providing
/// a platform specific [InAppPurchaseAddition].
/// The [InAppPurchasePlatformAdditionProvider] is responsible for providing
/// a platform specific [InAppPurchasePlatformAddition].
///
/// [InAppPurchaseAddition] implementation contain platform specific
/// [InAppPurchasePlatformAddition] implementation contain platform specific
/// features that are not available from the platform idiomatic
/// [InAppPurchasePlatform] API.
abstract class InAppPurchaseAdditionProvider {
/// Provides a platform specific implementation of the [InAppPurchaseAddition]
abstract class InAppPurchasePlatformAdditionProvider {
/// Provides a platform specific implementation of the [InAppPurchasePlatformAddition]
/// class.
T getPlatformAddition<T extends InAppPurchaseAddition>();
T getPlatformAddition<T extends InAppPurchasePlatformAddition>();
}