Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

209 строки
7.6 KiB

  1. // Copyright 2013 The Flutter Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. // Autogenerated from Pigeon (v22.6.4), do not edit directly.
  5. // See also: https://pub.dev/packages/pigeon
  6. // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers
  7. import 'dart:async';
  8. import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
  9. import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;
  10. import 'package:flutter/services.dart';
  11. PlatformException _createConnectionError(String channelName) {
  12. return PlatformException(
  13. code: 'channel-error',
  14. message: 'Unable to establish connection on channel: "$channelName".',
  15. );
  16. }
  17. /// Possible outcomes of launching a URL.
  18. enum LaunchResult {
  19. /// The URL was successfully launched (or could be, for `canLaunchUrl`).
  20. success,
  21. /// There was no handler available for the URL.
  22. failure,
  23. /// The URL could not be launched because it is invalid.
  24. invalidUrl,
  25. }
  26. /// Possible outcomes of handling a URL within the application.
  27. enum InAppLoadResult {
  28. /// The URL was successfully loaded.
  29. success,
  30. /// The URL did not load successfully.
  31. failedToLoad,
  32. /// The URL could not be launched because it is invalid.
  33. invalidUrl,
  34. }
  35. class _PigeonCodec extends StandardMessageCodec {
  36. const _PigeonCodec();
  37. @override
  38. void writeValue(WriteBuffer buffer, Object? value) {
  39. if (value is int) {
  40. buffer.putUint8(4);
  41. buffer.putInt64(value);
  42. } else if (value is LaunchResult) {
  43. buffer.putUint8(129);
  44. writeValue(buffer, value.index);
  45. } else if (value is InAppLoadResult) {
  46. buffer.putUint8(130);
  47. writeValue(buffer, value.index);
  48. } else {
  49. super.writeValue(buffer, value);
  50. }
  51. }
  52. @override
  53. Object? readValueOfType(int type, ReadBuffer buffer) {
  54. switch (type) {
  55. case 129:
  56. final int? value = readValue(buffer) as int?;
  57. return value == null ? null : LaunchResult.values[value];
  58. case 130:
  59. final int? value = readValue(buffer) as int?;
  60. return value == null ? null : InAppLoadResult.values[value];
  61. default:
  62. return super.readValueOfType(type, buffer);
  63. }
  64. }
  65. }
  66. class UrlLauncherApi {
  67. /// Constructor for [UrlLauncherApi]. The [binaryMessenger] named argument is
  68. /// available for dependency injection. If it is left null, the default
  69. /// BinaryMessenger will be used which routes to the host platform.
  70. UrlLauncherApi(
  71. {BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''})
  72. : pigeonVar_binaryMessenger = binaryMessenger,
  73. pigeonVar_messageChannelSuffix =
  74. messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
  75. final BinaryMessenger? pigeonVar_binaryMessenger;
  76. static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();
  77. final String pigeonVar_messageChannelSuffix;
  78. /// Checks whether a URL can be loaded.
  79. Future<LaunchResult> canLaunchUrl(String url) async {
  80. final String pigeonVar_channelName =
  81. 'dev.flutter.pigeon.url_launcher_ios.UrlLauncherApi.canLaunchUrl$pigeonVar_messageChannelSuffix';
  82. final BasicMessageChannel<Object?> pigeonVar_channel =
  83. BasicMessageChannel<Object?>(
  84. pigeonVar_channelName,
  85. pigeonChannelCodec,
  86. binaryMessenger: pigeonVar_binaryMessenger,
  87. );
  88. final List<Object?>? pigeonVar_replyList =
  89. await pigeonVar_channel.send(<Object?>[url]) as List<Object?>?;
  90. if (pigeonVar_replyList == null) {
  91. throw _createConnectionError(pigeonVar_channelName);
  92. } else if (pigeonVar_replyList.length > 1) {
  93. throw PlatformException(
  94. code: pigeonVar_replyList[0]! as String,
  95. message: pigeonVar_replyList[1] as String?,
  96. details: pigeonVar_replyList[2],
  97. );
  98. } else if (pigeonVar_replyList[0] == null) {
  99. throw PlatformException(
  100. code: 'null-error',
  101. message: 'Host platform returned null value for non-null return value.',
  102. );
  103. } else {
  104. return (pigeonVar_replyList[0] as LaunchResult?)!;
  105. }
  106. }
  107. /// Opens the URL externally, returning the status of launching it.
  108. Future<LaunchResult> launchUrl(String url, bool universalLinksOnly) async {
  109. final String pigeonVar_channelName =
  110. 'dev.flutter.pigeon.url_launcher_ios.UrlLauncherApi.launchUrl$pigeonVar_messageChannelSuffix';
  111. final BasicMessageChannel<Object?> pigeonVar_channel =
  112. BasicMessageChannel<Object?>(
  113. pigeonVar_channelName,
  114. pigeonChannelCodec,
  115. binaryMessenger: pigeonVar_binaryMessenger,
  116. );
  117. final List<Object?>? pigeonVar_replyList = await pigeonVar_channel
  118. .send(<Object?>[url, universalLinksOnly]) as List<Object?>?;
  119. if (pigeonVar_replyList == null) {
  120. throw _createConnectionError(pigeonVar_channelName);
  121. } else if (pigeonVar_replyList.length > 1) {
  122. throw PlatformException(
  123. code: pigeonVar_replyList[0]! as String,
  124. message: pigeonVar_replyList[1] as String?,
  125. details: pigeonVar_replyList[2],
  126. );
  127. } else if (pigeonVar_replyList[0] == null) {
  128. throw PlatformException(
  129. code: 'null-error',
  130. message: 'Host platform returned null value for non-null return value.',
  131. );
  132. } else {
  133. return (pigeonVar_replyList[0] as LaunchResult?)!;
  134. }
  135. }
  136. /// Opens the URL in an in-app SFSafariViewController, returning the results
  137. /// of loading it.
  138. Future<InAppLoadResult> openUrlInSafariViewController(String url) async {
  139. final String pigeonVar_channelName =
  140. 'dev.flutter.pigeon.url_launcher_ios.UrlLauncherApi.openUrlInSafariViewController$pigeonVar_messageChannelSuffix';
  141. final BasicMessageChannel<Object?> pigeonVar_channel =
  142. BasicMessageChannel<Object?>(
  143. pigeonVar_channelName,
  144. pigeonChannelCodec,
  145. binaryMessenger: pigeonVar_binaryMessenger,
  146. );
  147. final List<Object?>? pigeonVar_replyList =
  148. await pigeonVar_channel.send(<Object?>[url]) as List<Object?>?;
  149. if (pigeonVar_replyList == null) {
  150. throw _createConnectionError(pigeonVar_channelName);
  151. } else if (pigeonVar_replyList.length > 1) {
  152. throw PlatformException(
  153. code: pigeonVar_replyList[0]! as String,
  154. message: pigeonVar_replyList[1] as String?,
  155. details: pigeonVar_replyList[2],
  156. );
  157. } else if (pigeonVar_replyList[0] == null) {
  158. throw PlatformException(
  159. code: 'null-error',
  160. message: 'Host platform returned null value for non-null return value.',
  161. );
  162. } else {
  163. return (pigeonVar_replyList[0] as InAppLoadResult?)!;
  164. }
  165. }
  166. /// Closes the view controller opened by [openUrlInSafariViewController].
  167. Future<void> closeSafariViewController() async {
  168. final String pigeonVar_channelName =
  169. 'dev.flutter.pigeon.url_launcher_ios.UrlLauncherApi.closeSafariViewController$pigeonVar_messageChannelSuffix';
  170. final BasicMessageChannel<Object?> pigeonVar_channel =
  171. BasicMessageChannel<Object?>(
  172. pigeonVar_channelName,
  173. pigeonChannelCodec,
  174. binaryMessenger: pigeonVar_binaryMessenger,
  175. );
  176. final List<Object?>? pigeonVar_replyList =
  177. await pigeonVar_channel.send(null) as List<Object?>?;
  178. if (pigeonVar_replyList == null) {
  179. throw _createConnectionError(pigeonVar_channelName);
  180. } else if (pigeonVar_replyList.length > 1) {
  181. throw PlatformException(
  182. code: pigeonVar_replyList[0]! as String,
  183. message: pigeonVar_replyList[1] as String?,
  184. details: pigeonVar_replyList[2],
  185. );
  186. } else {
  187. return;
  188. }
  189. }
  190. }