Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Remove NoopInAppPurchase implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanbeusekom committed Apr 7, 2021
1 parent b283153 commit 9bf96ec
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'dart:async';

import 'package:plugin_platform_interface/plugin_platform_interface.dart';

import 'noop_in_app_purchase.dart';
import 'types/types.dart';

/// The interface that implementations of in_app_purchase must implement.
Expand All @@ -22,10 +21,18 @@ abstract class InAppPurchasePlatform extends PlatformInterface {

static final Object _token = Object();

static InAppPurchasePlatform _instance = NoopInAppPurchase();
static InAppPurchasePlatform? _instance;

/// The default instance of [InAppPurchasePlatform] to use.
static InAppPurchasePlatform get instance => _instance;
static InAppPurchasePlatform get instance {
final InAppPurchasePlatform? platform = _instance;
if (platform == null) {
throw UnimplementedError(
'No platform specific implementation set. Please make sure you set the `instance` with a valid platform specific implementation of the `InAppPurchasePlatform` class.');
}

return platform;
}

/// Platform-specific plugins should set this with their own platform-specific
/// class that extends [InAppPurchasePlatform] when they register themselves.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@

import 'package:flutter_test/flutter_test.dart';
import 'package:in_app_purchase_platform_interface/in_app_purchase_platform_interface.dart';
import 'package:in_app_purchase_platform_interface/src/noop_in_app_purchase.dart';
import 'package:mockito/mockito.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';

void main() {
TestWidgetsFlutterBinding.ensureInitialized();

group('$InAppPurchasePlatform', () {
test('$NoopInAppPurchase is the default instance', () {
expect(InAppPurchasePlatform.instance, isA<NoopInAppPurchase>());
test('default instance is null and throws unimplemented exception', () {
expect(() => InAppPurchasePlatform.instance, throwsUnimplementedError);
});

test('Cannot be implemented with `implements`', () {
Expand Down

0 comments on commit 9bf96ec

Please sign in to comment.