Flutter otp 在手机中发送 OTP 时不起作用

问题描述

我正在尝试使用 Flutter OTP https://pub.dev/packages/flutter_otp 发送 otp。而且我不期待使用 Firebase Auth 发送 OTP。当用户通过我的应用程序传递电话号码时,我想发送一个 OTP 并验证它。但是我遇到了这个 Flutter_otp,它不需要 firebase,它的依赖项是 https://pub.dev/packages/smsFlutter only。这是我想测试是否发送 OTP 的代码片段。

import 'package:Flutter/material.dart';
import 'package:Flutter_otp/Flutter_otp.dart';

class MyAppextends StatefulWidget {

  @override
  _MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
  const MyPailaApp({Key key}) : super(key: key);
  TextEditingController _controller = new TextEditingController();
  FlutterOtp otpsender = new FlutterOtp();

  @override
  void dispose() {
     super.dispose();
    _controller.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 16.0),child: TextField(
          cursorColor: Colors.black,controller: _controller,decoration: Inputdecoration(
            hintText: 'Tap to type',suffixIcon: IconButton(
              icon: Icon(Icons.send,color: Colors.black,),onpressed: (){
                setState(() {
                  otpsender.sendOtp(_controller.text,'OTP is : pass the generated otp here ',100000,999999,'+977');
                  _controller.clear();
                });
              },);
  }
}

但是在单击文本字段中的图标后,我收到以下错误并且未发送 OTP。

Running with unsound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety
Debug service listening on ws://127.0.0.1:57564/Qnt0yPHy_eA=/ws
Error: MissingPluginException(No implementation found for method sendSMS on channel plugins.babariviere.com/sendSMS)
    at Object.throw_ [as throw] (http://localhost:58819/dart_sdk.js:5348:11)
    at MethodChannel._invokeMethod (http://localhost:58819/packages/Flutter/src/services/system_channels.dart.lib.js:962:21)
    at _invokeMethod.next (<anonymous>)
    at http://localhost:58819/dart_sdk.js:39230:33
    at _RootZone.runUnary (http://localhost:58819/dart_sdk.js:39087:58)
    at _FutureListener.thenAwait.handleValue (http://localhost:58819/dart_sdk.js:34073:29)
    at handleValueCallback (http://localhost:58819/dart_sdk.js:34633:49)
    at Function._propagatetoListeners (http://localhost:58819/dart_sdk.js:34671:17)
    at _Future.new.[_completeWithValue] (http://localhost:58819/dart_sdk.js:34513:23)
    at async._AsyncCallbackEntry.new.callback (http://localhost:58819/dart_sdk.js:34536:35)
    at Object._microtaskLoop (http://localhost:58819/dart_sdk.js:39374:13)
    at _startMicrotaskLoop (http://localhost:58819/dart_sdk.js:39380:13)
    at http://localhost:58819/dart_sdk.js:34887:9

======== Exception caught by services library ======================================================
The following MissingPluginException was thrown while activating platform stream on channel plugins.babariviere.com/statusSMS:
MissingPluginException(No implementation found for method listen on channel plugins.babariviere.com/statusSMS)

When the exception was thrown,this was the stack: 
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 236:49  throw_
packages/Flutter/src/services/platform_channel.dart 156:7                                                                  _invokeMethod
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50            <fn>
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/zone.dart 1613:54                                          runUnary
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 155:18                                    handleValue
...
====================================================================================================

请帮我解决这个问题。

解决方法

网络不支持您使用的软件包。

同样的方法只适用于 Android 和 iOS。

错误消息 public String updateAndReturn(int field1,int field2) { String query = "UPDATE my_table SET field1 = ? WHERE field2 = ? LIMIT 1"; Connection connection = DbConnectionManager.getInstance().getConnection(); PreparedStatement preparedStatement = connection.prepareStatement(query); preparedStatement.setInt(1,field1); preparedStatement.setInt(2,field2); executeUpdate(preparedStatement); return field3; // How? } 试图传达这一点。

如我们所见,pub.dev 上的所有插件均显示其支持的平台,您要使用的插件均不受 Web 支持,仅适用于 iOS 和 Android

enter image description here enter image description here