我正在使用Awesome_notifications库,并防止它在 AppDelegate 中使用,例如MissingPluginException(在通道 plugins.flutter.io/shared_preferences 上找不到方法 getAll 的实现) :
SwiftAwesomeNotificationsPlugin.setPluginRegistrantCallback { registry in
SwiftAwesomeNotificationsPlugin.register(
with: registry.registrar(forPlugin: "io.flutter.plugins.awesomenotifications.AwesomeNotificationsPlugin")!)
FLTSharedPreferencesPlugin.register(
with: registry.registrar(forPlugin: "io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin")!)
}
Run Code Online (Sandbox Code Playgroud)
但我的自定义通道仍然有错误: 未处理的异常:MissingPluginException(在通道 it.example.watch 上找不到方法 flutterToWatch 的实现) 而且我不知道如何像 Awesome_notifications 那样在后台注册它。
我的频道:
private func initFlutterChannel() {
if let controller = window?.rootViewController as? FlutterViewController {
let channel = FlutterMethodChannel(
name: "it.example.watch",
binaryMessenger: controller.binaryMessenger)
channel.setMethodCallHandler({ [weak self] (
call: FlutterMethodCall,
result: @escaping FlutterResult) -> Void in
switch call.method {
case "flutterToWatch":
guard let watchSession = self?.session, watchSession.isPaired, watchSession.isReachable, let methodData …Run Code Online (Sandbox Code Playgroud) 今天我在我所有的片段中发现了这个警告:
警告:(45, 12) 'onCreateView' 总是返回非空类型
onCreateView:
override fun onCreateView(inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?): View? {
...
}
Run Code Online (Sandbox Code Playgroud)
问题是,发生了什么变化,为什么?
Android Studio 版本 - 4.1.1。