Giter VIP home page Giter VIP logo

sky24n / flustars Goto Github PK

View Code? Open in Web Editor NEW
1.9K 37.0 236.0 340 KB

🔥🔥🔥 Flutter common utils library. SpUtil, ScreenUtil,WidgetUtil. 也许是目前最好用的SharedPreferences工具类。WidgetUtil 获取图片尺寸宽高, View尺寸&在屏幕上的坐标。

License: BSD 2-Clause "Simplified" License

Java 0.34% Objective-C 0.09% Dart 90.77% Ruby 7.83% Swift 0.97%
sputil screenutil dioutil dateutil directoryutil widgetutil regexutil timerutil timelineutil logutil

flustars's Introduction

Sky24n Github

Sky24n github stats

Popular repositories

azlistview    lpinyin

A GitHub client app developed with Flutter, which supports Android iOS Web.
Web :Flutter Web.

flustars's People

Contributors

sky24n avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flustars's Issues

TimelineUtil.format 总是要快8个小时

TimelineUtil.format 总是要快8个小时 , 设置了 locale:'zh', 也不行

      var t = DateTime.parse('2020-07-22 22:45:00');
      var ts = TimelineUtil.format(
        t.millisecondsSinceEpoch,
        locale: 'zh',
        dayFormat: DayFormat.Full,
      );

      print(ts);

新增对空安全支持

The library 'package:flustars/flustars.dart' is legacy, and should not be imported into a null safe library.

初始化SpUtil.getInstance后提示Unhandled Exception: Null check operator used on a null value

初始化代码

void main() {
_initApp();
runApp(const MyApp());
}

_initApp() async {
LogUtil.init(tag: GlobalAppData.appLogTag, isDebug: GlobalAppData.isDebug);
await SpUtil.getInstance();
}

错误日志

E/flutter ( 2316): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Null check operator used on a null value
E/flutter ( 2316): #0 MethodChannel.binaryMessenger (package:flutter/src/services/platform_channel.dart:142:86)
E/flutter ( 2316): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:148:36)
E/flutter ( 2316): #2 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:331:12)
E/flutter ( 2316): #3 MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:358:49)
E/flutter ( 2316): #4 MethodChannelSharedPreferencesStore.getAll (package:shared_preferences_platform_interface/method_channel_shared_preferences.dart:44:25)
E/flutter ( 2316): #5 SharedPreferences._getSharedPreferencesMap (package:shared_preferences/shared_preferences.dart:180:57)
E/flutter ( 2316): #6 SharedPreferences.getInstance (package:shared_preferences/shared_preferences.dart:56:19)
E/flutter ( 2316): #7 SpUtil._init (package:sp_util/sp_util.dart:41:38)
E/flutter ( 2316): #8 SpUtil.getInstance. (package:sp_util/sp_util.dart:30:27)
E/flutter ( 2316): #9 SpUtil.getInstance. (package:sp_util/sp_util.dart:25:32)
E/flutter ( 2316): #10 BasicLock.synchronized (package:synchronized/src/basic_lock.dart:31:24)
E/flutter ( 2316): #11 SpUtil.getInstance (package:sp_util/sp_util.dart:25:19)
E/flutter ( 2316): #12 _initApp (package:hello_flutter/main.dart:19:16)
E/flutter ( 2316): #13 main (package:hello_flutter/main.dart:11:3)
E/flutter ( 2316): #14 _runMainZoned.. (dart:ui/hooks.dart:142:25)
E/flutter ( 2316): #15 _rootRun (dart:async/zone.dart:1354:13)
E/flutter ( 2316): #16 _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter ( 2316): #17 _runZoned (dart:async/zone.dart:1789:10)
E/flutter ( 2316): #18 runZonedGuarded (dart:async/zone.dart:1777:12)
E/flutter ( 2316): #19 _runMainZoned. (dart:ui/hooks.dart:138:5)
E/flutter ( 2316): #20 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:283:19)
E/flutter ( 2316): #21 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

flustars版本 flustars: ^2.0.1

Flutter 版本

Flutter 2.2.3 • channel stable • [email protected]:mirrors/Flutter.git
Framework • revision f4abaa0735 (6 weeks ago) • 2021-07-01 12:46:11 -0700
Engine • revision 241c87ad80
Tools • Dart 2.13.4

添加flustars: ^0.2.5+1 cocoapods报错

Launching lib/main.dart on iPod touch in debug mode...

Signing iOS app for device deployment using developer identity: "iPhone Developer: li pengfei (UGQ6C8DH5Y)"

CocoaPods' output:

[!] Invalid `Podfile` file: invalid byte sequence in US-ASCII.

 #  from /Users/xuzhao/Desktop/FLutterApp测试/zxeasynet_learn/ios/Podfile:21

 #  -------------------------------------------

 #    File.foreach(file_abs_path) { |line|

 >        next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }

 #        plugin = line.split(pattern=separator)

 #  -------------------------------------------

/usr/local/lib/ruby/gems/2.5.0/gems/cocoapods-core-1.7.2/lib/cocoapods-core/podfile.rb:301:in `rescue in block in from_ruby'

/usr/local/lib/ruby/gems/2.5.0/gems/cocoapods-core-1.7.2/lib/cocoapods-core/podfile.rb:295:in `block in from_ruby'

/usr/local/lib/ruby/gems/2.5.0/gems/cocoapods-core-1.7.2/lib/cocoapods-core/podfile.rb:50:in `instance_eval'

/usr/local/lib/ruby/gems/2.5.0/gems/cocoapods-core-1.7.2/lib/cocoapods-core/podfile.rb:50:in `initialize'

/usr/local/lib/ruby/gems/2.5.0/gems/cocoapods-core-1.7.2/lib/cocoapods-core/podfile.rb:293:in `new'

/usr/local/lib/ruby/gems/2.5.0/gems/cocoapods-core-1.7.2/lib/cocoapods-core/podfile.rb:293:in `from_ruby'

/usr/local/lib/ruby/gems/2.5.0/gems/cocoapods-core-1.7.2/lib/cocoapods-core/podfile.rb:259:in `from_file'

/usr/local/lib/ruby/gems/2.5.0/gems/cocoapods-1.7.2/lib/cocoapods/config.rb:199:in `podfile'

/usr/local/lib/ruby/gems/2.5.0/gems/cocoapods-1.7.2/lib/cocoapods/command.rb:150:in `verify_podfile_exists!'

/usr/local/lib/ruby/gems/2.5.0/gems/cocoapods-1.7.2/lib/cocoapods/command/install.rb:45:in `run'

/usr/local/lib/ruby/gems/2.5.0/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'

/usr/local/lib/ruby/gems/2.5.0/gems/cocoapods-1.7.2/lib/cocoapods/command.rb:52:in `run'

/usr/local/lib/ruby/gems/2.5.0/gems/cocoapods-1.7.2/bin/pod:55:in `<top (required)>'

/usr/local/bin/pod:23:in `load'

/usr/local/bin/pod:23:in `<main>'

Error output from CocoaPods:

    WARNING: CocoaPods requires your terminal to be using UTF-8 encoding.

    Consider adding the following to ~/.profile:

    export LANG=en_US.UTF-8

Error running pod install

Exited (sigterm)

我当前的flutter版本是

localhost:~ xuzhao$ flutter --version
Flutter 1.6.3 • channel beta • https://github.com/flutter/flutter.git
Framework • revision bc7bc94083 (4 weeks ago) • 2019-05-23 10:29:07 -0700
Engine • revision 8dc3a4cde2
Tools • Dart 2.3.2 (build 2.3.2-dev.0.0 e3edfd36b2)

common_utils报异常

异常如下:

Xcode's output:
↳
    ../../../Code/flutter/.pub-cache/hosted/pub.dartlang.org/common_utils-2.0.2/lib/src/money_util.dart:87:59: Error: The method 'toInt' isn't defined for the class 'Decimal'.
     - 'Decimal' is from 'package:decimal/decimal.dart' ('../../../Code/flutter/.pub-cache/hosted/pub.dartlang.org/decimal-2.1.0/lib/decimal.dart').
    Try correcting the name to the name of an existing method, or defining a method named 'toInt'.
        return NumUtil.multiplyDecStr(yuan.toString(), '100').toInt();
                                                              ^^^^^
    ../../../Code/flutter/.pub-cache/hosted/pub.dartlang.org/common_utils-2.0.2/lib/src/num_util.dart:134:29: Error: A value of type 'Rational' can't be returned from a function with return type 'Decimal'.
     - 'Rational' is from 'package:rational/rational.dart' ('../../../Code/flutter/.pub-cache/hosted/pub.dartlang.org/rational-2.0.0/lib/rational.dart').
     - 'Decimal' is from 'package:decimal/decimal.dart' ('../../../Code/flutter/.pub-cache/hosted/pub.dartlang.org/decimal-2.1.0/lib/decimal.dart').
        return Decimal.parse(a) / Decimal.parse(b);
                                ^

Compiler ImageStreamListener error

Flutter 1.5.4-hotfix.2 • channel stable • https://github.com/flutter/flutter.git Framework • revision 7a4c33425d (7 weeks ago) • 2019-04-29 11:05:24 -0700 Engine • revision 52c7a1e849 Tools • Dart 2.3.0 (build 2.3.0-dev.0.5 a1668566e5)

Compiler message:
file:///Users/**/Documents/flutter/.pub-cache/hosted/pub.flutter-io.cn/flustars-0.2.6+1/lib/src/widget_util.dart:88:26: Error: Method not found: 'ImageStreamListener'.
        .addListener(new ImageStreamListener(
                         ^^^^^^^^^^^^^^^^^^^
file:///Users/**/Documents/flutter/.pub-cache/hosted/pub.flutter-io.cn/flustars-0.2.6+1/lib/src/widget_util.dart:88:45: Error: Too many positional arguments: 0 allowed, but 1 found.
Try removing the extra positional arguments.
        .addListener(new ImageStreamListener(
                                            ^
file:///Users/**/Documents/flutter/.pub-cache/hosted/pub.flutter-io.cn/flustars-0.2.6+1/lib/src/widget_util.dart:121:26: Error: Method not found: 'ImageStreamListener'.
        .addListener(new ImageStreamListener(
                         ^^^^^^^^^^^^^^^^^^^
file:///Users/**/Documents/flutter/.pub-cache/hosted/pub.flutter-io.cn/flustars-0.2.6+1/lib/src/widget_util.dart:121:45: Error: Too many positional arguments: 0 allowed, but 1 found.
Try removing the extra positional arguments.
        .addListener(new ImageStreamListener(
                                            ^

升级到0.2.6报错了

报错信息如下:
Compiler message:
file:///Users/zhangchangwei/Desktop/flutterWorkspace/flutter/.pub-cache/hosted/pub.flutter-io.cn/flustars-0.2.6+1/lib/src/widget_util.dart:88:26: Error: Method not found: 'ImageStreamListener'.
.addListener(new ImageStreamListener(
^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^
file:///Users/zhangchangwei/Desktop/flutterWorkspace/flutter/.pub-cache/hosted/pub.flutter-io.cn/flustars-0.2.6/lib/src/widget_util.dart:88:45: Error: Too many positional arguments: 0 allowed, but 1 found.
Try removing the extra positional arguments.
.addListener(new ImageStreamListener(

升级了Flutter,报错了。

../../../../flutterWorkspace/flutter/.pub-cache/hosted/pub.flutter-io.cn/common_utils-2.0.2/lib/src/money_util.dart:87:59: Error: The method 'toInt' isn't defined for the class 'Decimal'.

  • 'Decimal' is from 'package:decimal/decimal.dart' ('../../../../flutterWorkspace/flutter/.pub-cache/hosted/pub.flutter-io.cn/decimal-2.0.0/lib/decimal.dart').
    Try correcting the name to the name of an existing method, or defining a method named 'toInt'.
    return NumUtil.multiplyDecStr(yuan.toString(), '100').toInt();
    突然出现这种情况。。。。

The argument type 'Null Function(ImageInfo, bool)' can't be assigned to the parameter type 'ImageStreamListener'.

`Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.7.8+hotfix.3, on Mac OS X 10.14.5 18F132, locale zh-Hans-CN)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 10.1)
[✓] iOS tools - develop for iOS devices
[✓] Android Studio (version 3.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.1.1)
[✓] Connected device (1 available)

• No issues found!`

`
cached_network_image: ^1.0.0

keyboard_actions: ^2.1.1

dio: ^2.1.7

common_utils: ^1.1.1

flustars: ^0.2.6+1

sprintf: ^4.0.2

`
image

flustars 2.0.1 Error

await DirectoryUtil.getInstance();
DirectoryUtil.createStorageDirSync(category: 'apk');
String path = DirectoryUtil.getStoragePath(category: 'apk', fileName: 'pxt', format: 'apk');
print("path::::${path}");

path = null
?

flutter 1.6.3 出错

widget_util.dart:115:8: Error: No named parameter with the name 'onError'.
}, onError: (dynamic exception, StackTrace stackTrace) {
^^^^^^^
Compiler failed on /Users/unreal/Downloads/flutter/lib/main.dart
Gradle task assembleDebug failed with exit code 1

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

Flutter 1.10.14-pre.12
Dart 2.6.0

errors:

[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)
#0      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:319:7)
<asynchronous suspension>
#1      MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:349:48)
<asynchronous suspension>
#2      SharedPreferences._getSharedPreferencesMap (package:shared_preferences/shared_preferences.dart:158:25)
<asynchronous suspension>
#3      SharedPreferences.getInstance (package:shared_preferences/shared_preferences.dart:25:17)
<asynchronous suspension>
#4      SpUtil._init (package:flustars/src/sp_util.dart:40:38)
<asynchronous suspension>
#5      SpUtil.getInstance.<anonymous closure> (package:flustars/src/sp_util.dart:29:27)
<asynchronous suspension>
#6      BasicLock.synchronized (package:synchronized/src/basic_lock.dart:31:26)
<asynchronous suspension>
#7      SpUtil.getInstance (pac<…>

解决方法:

const MethodChannel('plugins.flutter.io/shared_preferences')
        .setMockMethodCallHandler((MethodCall methodCall) async {
      if (methodCall.method == 'getAll') {
        return <String, dynamic>{};
      }
      return null;
    });

await SpUtil.getInstance();

//  todo more

ScreenUtil获取的宽高不准确

我用ScreenUtil获取的宽高不准确,具体代码如下:
image

获取了appBar的高度作为shouMenu的top,但是实际位置不对:
image

ScreenUtil没做其他任何初始化。是我用的有问题吗?还是有什么其他问题呢?求解答下,多谢了

FAILURE: Build failed with an exception.

Launching lib\main.dart on Android SDK built for x86 in debug mode...
[!] Your app isn't using AndroidX.
To avoid potential build failures, you can quickly migrate your app by following the steps on https://goo.gl/CP92wY.
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.

More than one file was found with OS independent path 'META-INF/proguard/androidx-annotations.pro'

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 4s
AndroidX incompatibilities may have caused this build to fail. Please migrate your app to AndroidX. See https://goo.gl/CP92wY.
Finished with error: Gradle task assembleDebug failed with exit code 1

工具类中存在错误

  _bottomBarHeight = mediaQuery.padding.bottom;

应该为 _bottomBarHeight = kBottomNavigationBarHeight;

build failed

run is ok
build failed

Building com.mxqh.wsapp for device (ios-release)...
Automatically signing iOS for device deployment using specified developm                                                                                       ├─Building Dart code...                                    99.8s                                                                                              ├─Generating dSYM file...                                   0.5s                                                   
 ├─Stripping debug symbols...                                0.4s
 ├─Assembling Flutter resources...                           7.6s
 └─Compiling, linking and signing...                        51.5s
Xcode build done.                                           177.6s
Failed to build iOS app
Error output from Xcode build:
↳
    2019-02-22 14:22:36.891 xcodebuild[61424:5145419] [MT] PluginLoading: Required plug-in compatibility UUID D7881182-AD00-4C36-A94D-F45FC9B0CF85 for plug-in
    at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/KSImageNamed.xcplugin' not present in DVTPlugInCompatibilityUUIDs
    2019-02-22 14:22:36.892 xcodebuild[61424:5145419] [MT] PluginLoading: Required plug-in compatibility UUID D7881182-AD00-4C36-A94D-F45FC9B0CF85 for plug-in
    at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/FuzzyAutocomplete.xcplugin' not present in DVTPlugInCompatibilityUUIDs
    2019-02-22 14:22:36.892 xcodebuild[61424:5145419] [MT] PluginLoading: Required plug-in compatibility UUID D7881182-AD00-4C36-A94D-F45FC9B0CF85 for plug-in
    at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/Alcatraz.xcplugin' not present in DVTPlugInCompatibilityUUIDs
    2019-02-22 14:22:38.166 xcodebuild[61424:5145467]  DTDeviceKit: deviceType from 6070e3de45c7ad35ba42a806f80bde6f532ec9a4 was NULL
    ** BUILD FAILED **


Xcode's output:
↳
    === BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Release ===
    The use of Swift 3 @objc inference in Swift 4 mode is deprecated. Please address deprecated @objc inference warnings, test your code with “Use of
    deprecated Swift 3 @objc inference” logging enabled, and then disable inference by changing the "Swift 3 @objc Inference" build setting to "Default" for
    the "Runner" target.
    The use of Swift 3 @objc inference in Swift 4 mode is deprecated. Please address deprecated @objc inference warnings, test your code with “Use of
    deprecated Swift 3 @objc inference” logging enabled, and then disable inference by changing the "Swift 3 @objc Inference" build setting to "Default" for
    the "Runner" target.
    === BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Release ===
    Non-fat binary /Users//MEGA/Flutter/wsapp/wsapp/build/ios/Release-iphoneos/Runner.app/Frameworks/flustars.framework/flustars is not armv7. Running
    lipo -info:
    Non-fat file: /Users//MEGA/Flutter/wsapp/wsapp/build/ios/Release-iphoneos/Runner.app/Frameworks/flustars.framework/flustars is architecture: arm64
    Command /bin/sh failed with exit code 1

在模拟器Pad模式下,出现错误。模拟器版本号:iPad Air

Launching lib/main.dart on iPad Pro (12.9-inch) (3rd generation) in debug mode...
Removing obsolete reference to flutter_assets from Runner.app
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. 15.6s
Failed to build iOS app
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/anins/Documents/Project_Private_Github_Flutter/flustars/example/ios/Runner/GeneratedPluginRegistrant.m:6:9: fatal error: 'flustars/FlustarsPlugin.h' file not found
#import <flustars/FlustarsPlugin.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Could not build the application for the simulator.
Error launching application on iPad Pro (12.9-inch) (3rd generation).

错误内容如上,在执行了brew install cocoapods && pod setup 也是不行的。

但是在iPhone模式下可以,很奇怪啊。

通过实验,在terminal中通过flutter run进行运行是可以的,然后关闭这个,再次通过ide的build工具运行,虽然还是出现让 brew install cocoapods && pod setup 这个错误,但是可以进行运行起来了。

FlutterActivity.withCachedEngine("engine").build(MainActivity.this)报错

E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)
D/: addLayerName, tid:1690
W/InputMethodManager: startInputReason = 1
D/: addLayerName, tid:1690
E/ion: ioctl c0044901 failed with code -1: Invalid argument
D/ViewRootImpl[MainActivity]: surface should not be released
D/ActivityThread: Remove activity client record, r= ActivityRecord{318df9d token=android.os.BinderProxy@704ce8b {com.yunzao.sufang/com.yunzaokeji.ordertool.MainActivity}} token= android.os.BinderProxy@704ce8b
D/: setLayerData
D/: addLayerName, tid:1542
E/GED: Failed to get GED Log Buf, err(0)
D/: addLayerName, tid:1690
W/ServiceManager: Service huawei.android.security.IAppBehaviorDataAnalyzer didn't start. Returning NULL
E/[HOTFIX]: [ThreadDexHotfixMonitor]Bind hotfix monitor service fail!

在MIUI13 (Android 12)系统上工具类在Release模式下不可用

经测,在小米K40 Pro+手机(MIUI 13.0.5, Android 12)上,如使用Release模式运行:flutter run --release

screenWidth, screenHeight, statusBarHeight, bottomBarHeight, appBarHeight等基础属性全为0,间接导致几乎所有方法均返回为0,如getSp

关于SpUtil的初始化,在闪屏页延迟500毫秒就一定能加载完吗?

你好,我是flutter新手,查本地存储的时候查到的这个库。发现里面关于异步读取本地存储的代码:
Future.delayed(new Duration(milliseconds: 500), () { /// 同步使用Sp。 /// 是否显示引导页。 if (SpUtil.getBool("key_guide", defValue: true)) { SpUtil.putBool("key_guide", false); _initBanner(); } else { _initSplash(); } });

延迟500毫秒就可以确定是同步读取吗?谢谢

sp怎么和原生共享

请教个问题,Android原生可以通过设置sp库名称(FlutterSharedPreferences)来获取flutter存储的数据,而在flutter里面要通过什么方式来获取原生sp存储的数据呢。

MissingPluginException

如果用swift如果配置log啊

[VERBOSE-2:ui_dart_state.cc(166)] Unhandled Exception: MissingPluginException(No implementation found for method logD on channel x_log)
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:154:7)

SpUtil.getBool('key', defValue: true) 判断好像有误

if (SpUtil.getBool('key_test', defValue: true)) {
       SpUtil.putBool('key_test', false); //虽然设置成false ,但是下次还会执行进来
  }

看了下源码

 static bool getBool(String key, {bool defValue = false}) {
    if (_prefs == null) return defValue; 
    return _prefs.getBool(key) ?? defValue;  
  }

可能需要做以下修改

 static bool getBool(String key, {bool defValue = false}) {
    if (_prefs == null || _prefs.getBool(key) == null) return defValue; 
    return _prefs.getBool(key);
  }

iOS工程 archive 编译报错

iOS工程里引入了flutter module模块,flutter module里用到了flustars: ^0.2.6+1 插件,xcode项目编译与运行正常,当xcode执行archive的时候编译报错,报错提示在path_provider库,报错内容如下:
/////////////////////////////////////
ld: warning: Could not find or use auto-linked framework 'Flutter'
Undefined symbols for architecture armv7:
"_FlutterMethodNotImplemented", referenced from:
___47+[FLTPathProviderPlugin registerWithRegistrar:]_block_invoke in PathProviderPlugin.o
"OBJC_CLASS$_FlutterError", referenced from:
objc-class-ref in PathProviderPlugin.o
"OBJC_CLASS$_FlutterMethodChannel", referenced from:
objc-class-ref in PathProviderPlugin.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
/////////////////////////////////////

Xcode版本:11.1
flutter版本:
[✓] Flutter (Channel master, v1.10.2-pre.4, on Mac OS X 10.14.6 18G84, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 11.1)
[✓] Android Studio (version 3.4)
[✓] VS Code (version 1.39.1)
[✓] Connected device (1 available)

我看您的这个插件中有引用到path_provider这个插件库,是不是什么原因导致的这个报错呢

DioUtil问题

有一个接口使用DioUtil需要设置header,其他接口不需要,怎么设置header头的,在案例里面只有设置公共的,请求的怎么设置

SpUtil 混合开发问题

在flutter 界面后设置 key value 后 ,在跳转原生界面后 无法通过SharedPreferences 原生api 获取。

0.2.1+依赖好多

Because flutter_cache_manager 0.2.0+1 depends on shared_preferences ^0.4.0 and no versions of flutter_cache_manager match >0.2.0+1 <0.3.0, flutter_cache_manager ^0.2.0+1 requires shared_preferences ^0.4.0.
And because flustars >=0.2.1 depends on shared_preferences ^0.5.0, flustars >=0.2.1 is incompatible with flutter_cache_manager ^0.2.0+1.
And because cached_network_image 0.5.1 depends on flutter_cache_manager ^0.2.0+1 and no versions of cached_network_image match >0.5.1 <0.6.0, flustars >=0.2.1 is incompatible with cached_network_image ^0.5.1.
So, because module_flutter depends on both cached_network_image ^0.5.1 and flustars 0.2.2, version solving failed.
pub get failed (1)

降级为0.2.0版本啦

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.