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
Remove NoopInAppPurchase implementation
  • Loading branch information
mvanbeusekom committed Apr 22, 2021
commit a7693bd9ade48245e05ad61ee99b31a6b77e6feb
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