小编Awe*_*165的帖子

UIKit UIButton.ButtonType.close 是否有 SwiftUI 版本?

现在,我正在从 UIKit 转换为 SwiftUI。在 UIKit 中,有一个原生的关闭、X 样式按钮-UIButton.ButtonType.close,如下所示:

在此输入图像描述

我想在 SwiftUI 中找到与此等效的内容(如果已经内置于 SwiftUI 中)。如果苹果还没有开始构建/转换它,这是可以理解的。我在 Apple 地图应用程序中也看到了这一点,我相信它是用 SwiftUI 构建的,如下所示(在面板的右下角):

在此输入图像描述

如果没有内置的按钮样式,如何为这个关闭按钮创建一个适应浅色和深色模式的视图?太感谢了!

编辑:在 UIKIt 的故事板编辑器中,这是我正在寻找的内容:

在此输入图像描述

button uikit ios swift swiftui

4
推荐指数
3
解决办法
1571
查看次数

如何修复:在通道 plugins.flutter.io/shared_preferences 上找不到方法 getAll 的实现

我已经研究这个问题近半天了。我正在尝试使用 Flutter 的 SharedPreferences 包将键/值存储在应用程序的存储中。当我通过 新建 SharedPreferences 时await SharedPreferences.getInstance(),它会正确构建并运行,但是当应用程序到达该代码行时,它会崩溃并出现以下错误:

MissingPluginException (MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences))

我找到了其他 Stackoverflow 帖子,但它们没有帮助解决这个问题:

通过所有这些,我尝试了以下方法:

  • flutter pub get
  • io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin.registerWith(registry.registrarFor("io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin"));
  • 由于我使用的是 iOS:SharedPreferencesIOS.registerWith();
  • https://pub.dev/packages/flutter_isolate
  • flutter clean && flutter pub get
  • SharedPreferences.setMockInitialValues({});

运行/执行上述步骤后,我重新启动了编辑器(VSC)。我什至安装了带有 Flutter 扩展的 Android …

sharedpreferences dart flutter

4
推荐指数
1
解决办法
5446
查看次数

标签 统计

button ×1

dart ×1

flutter ×1

ios ×1

sharedpreferences ×1

swift ×1

swiftui ×1

uikit ×1