请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

shared_preferences 使用无法加载

老师 只要加上shared_preferences组件以后 就出错了!我已经配置了镜像 下载http组件就没有问题
packages 好像也有 shared_preferences 这个包
图片描述

正在回答 回答被采纳积分+3

3回答

CrazyCodeBoy 2019-03-26 23:13:38

从提供的代码上看是OK的,这是运行效果:

https://img1.sycdn.imooc.com//szimg/5c9a419b0001e2e600130009.jpg

你卸载APP之后重装实现呢:


0 回复 有任何疑惑可以回复我~
提问者 mengliu 2019-03-26 08:33:49

老师 不是项目代码的原因,新建的项目,如果不添加shared_preferences: ^0.5.1+2插件就运行正常,添加了这个插件就跑不起来了  报错信息:

Launching lib/main.dart on iPhone X in debug mode...

Warning: CocoaPods not installed. Skipping pod install.

  CocoaPods is used to retrieve the iOS platform side's plugin code that responds to your plugin usage on the Dart side.

  Without resolving iOS dependencies with CocoaPods, plugins will not work on iOS.

  For more info, see https://flutter.io/platform-plugins

To install:

  brew install cocoapods

  pod setup


Running Xcode build...

Xcode build done.                                           11.3s

Failed to build iOS app

Could not build the application for the simulator.

Error launching application on iPhone X.

Error output from Xcode build:

    ** BUILD FAILED **



Xcode's output:

    === BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===

    Debug.xcconfig line 1: Unable to find included file "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"

    Debug.xcconfig line 1: Unable to find included file "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"

    /Users/mengliu/AndroidStudioProjects/flutter_app/ios/Runner/GeneratedPluginRegistrant.m:6:9: fatal error: 'shared_preferences/SharedPreferencesPlugin.h' file not found

    #import <shared_preferences/SharedPreferencesPlugin.h>

            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    1 error generated.


0 回复 有任何疑惑可以回复我~
CrazyCodeBoy 2019-03-25 01:18:03

如果还没解决的话,将这个文件的完整代码提供下,我帮你看看

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信