setUpMockPlugin function

  1. @visibleForTesting
MockedPlugin setUpMockPlugin(
  1. String methodChannelName, {
  2. bool shouldTearDown = true,
})

Implementation

@visibleForTesting
MockedPlugin setUpMockPlugin(
  String methodChannelName, {
  bool shouldTearDown = true,
}) {
  TestWidgetsFlutterBinding.ensureInitialized();

  // setMockMethodCallHandler for the plugin specified
  final methodChannel = MethodChannel(methodChannelName);
  final mockPlugin = MockedPlugin._(methodChannel);

  // tearDown mock plugin after test
  if (shouldTearDown) {
    addTearDown(() => mockPlugin._tearDown());
  }

  return mockPlugin;
}