小编Lab*_*Lab的帖子

Flutter:不推荐使用“UIAlertView”:在 iOS 9.0 中首次不推荐使用

我收到以下错误:

/Users/flo/.pub-cache/hosted/pub.dartlang.org/image_picker-0.6.7+12/ios/Classes/FLTImagePickerPlugin.m:1
    49:20: warning: 'UIAlertView' is deprecated: first deprecated in iOS 9.0 - UIAlertView is deprecated.
    Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead
    [-Wdeprecated-declarations]
        [[[UIAlertView alloc] initWithTitle:@"Error"
Run Code Online (Sandbox Code Playgroud)

我已经尝试做:

flutter pub cache repair

rm .pub-cache/hosted/pub.dartlang.org 目录

rm podfile.lock 和 Pods 文件夹

但还是同样的问题。有任何想法吗 ?我只为 Swift 发现了这样的问题,但与 Flutter 无关。

ios flutter

7
推荐指数
1
解决办法
2405
查看次数

IOS 上的颤动:致命错误:未找到模块“cloud_firestore”

在 github 和 stack 上搜索了很长时间以查找类似错误后,没有一个建议的解决方案帮助我解决此错误。

我尝试了很多东西(有点乱):

  • 删除IOS派生数据
  • 更改 Firestore 软件包版本
  • 扑干净
  • rm -Rf ios/Pods
  • rm -Rf ios/.symlinks
  • rm -Rf ios/Flutter/Flutter.framework
  • rm -Rf ios/Flutter/Flutter.podspec
  • rm -rf ios/Podfile ios/Podfile.lock ios/Pods ios/Runner.xcworkspace
  • pod init、安装和更新
  • 取消注释平台:ios,来自 podfile 的“9.0”(可能与此问题无关)

这是错误:

    ** BUILD FAILED **


Xcode's output:
?
    /Users/flo/Mobile/we_ll_see/ios/Runner/GeneratedPluginRegistrant.m:10:9: fatal error: module
    'cloud_firestore' not found
    @import cloud_firestore;
     ~~~~~~~^~~~~~~~~~~~~~~
    1 error generated.
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description
Run Code Online (Sandbox Code Playgroud)

需要一些帮助的家伙

ios firebase flutter google-cloud-firestore

5
推荐指数
4
解决办法
9992
查看次数

Stripe - 转账时从哪里获取 source_transaction id?

我想从用户卡直接转账到关联帐户。为此,我必须指示 source_transaction 字段。

await stripe.transfers.create({
          amount: amount,
          currency: "eur",
          destination: "{connected_account1}",
          transfer_group: "{ORDER1}",
          source_transaction: // How to get this information ?
        });
Run Code Online (Sandbox Code Playgroud)

这是我从我的应用程序(PaymentMethod)获得的信息:

付款方式对象

我需要做什么才能获取source_transaction我在 PaymentMethod 对象上获得的信息?

node.js stripe-payments flutter

5
推荐指数
1
解决办法
1271
查看次数

如何在 Flutter 中测试(单元测试)BehaviorSubject?

我想测试管理我的表单的控制器流。在这里,我尝试测试连接到验证器的电子邮件控制器。

我设法通过接收器方法添加控制器值并通过流方法恢复。

宣言

  final emailController = BehaviorSubject<String>();

  Stream<String> get email => emailController.stream.transform(validateEmail);

  Function(String) get changeEmail => emailController.sink.add;

Run Code Online (Sandbox Code Playgroud)

验证器进行测试

final validateEmail =
      StreamTransformer<String, String>.fromHandlers(handleData: (email, sink) {
    final emailRegExp = new RegExp(
      r"^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,253}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,253}[a-zA-Z0-9])?)*$",
      caseSensitive: false,
      multiLine: false,
    );

    emailRegExp.hasMatch(email).toString();
    if (email.contains('@')) {
      sink.add(email);
    } else {
      sink.addError('Enter a valid email');
    }
  });
Run Code Online (Sandbox Code Playgroud)

单元测试

void main() {
  UserProfilEditBloc userProfilEditBloc = new UserProfilEditBloc();

  test('Email check BehaviorSubject', () {
    userProfilEditBloc.changeEmail('testtest'); //Expected @

    expect(userProfilEditBloc.email, emits('Enter a valid email'));
  });
}
Run Code Online (Sandbox Code Playgroud)

错误信息

00:02 +0 -1: Email …
Run Code Online (Sandbox Code Playgroud)

unit-testing dart behaviorsubject flutter

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

AnimationController:我们可以将 TickerProvider vsync 传递给其他类吗?

我在 Flutter 中开发了一个应用程序,其中有很多不同的动画。我想通过分离视图、逻辑(模型 BLoC)和动画来构建我的代码。对于这个问题,我尝试为 StatefulWidget 的不同类中的按钮声明多次相同的动画。

但是,我陷入困境,因为我必须将 TickerProvider 传递给我的动画类,而我没有以正确的方式执行此操作。

构造函数动画类

AppBloc(TickerProvider tickerProvider) {
    banimationController = AnimationController(
      vsync: tickerProvider,
      duration: Duration(milliseconds: 100),
      lowerBound: 0,
      upperBound: 0.05,
    );
}
Run Code Online (Sandbox Code Playgroud)

宣言

AppBloc(this);
Run Code Online (Sandbox Code Playgroud)

我知道这可能不是正确的方法,我编写了这段代码来说明我的问题。

我只想将我的动画声明分离到另一个文件中。

animation ticker flutter

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

Flutter 2 升级:CocoaPods 未安装或未处于有效状态

更新 Flutter 2 后,我无法再在 IOS 上部署应用程序:

\n
Warning: CocoaPods minimum required version 1.9.0 or greater not installed.\nSkipping pod install.\n  CocoaPods is used to retrieve the iOS and macOS platform side\'s plugin code\n  that responds to your plugin usage on the Dart side.\n  Without CocoaPods, plugins will not work on iOS or macOS.\n  For more info, see https://flutter.dev/platform-plugins\nTo upgrade see\nhttps://guides.cocoapods.org/using/getting-started.html#installation for\ninstructions.\n\nCocoaPods not installed or not in valid state.\nError launching application on iPhone 11.\n
Run Code Online (Sandbox Code Playgroud)\n

到目前为止我已经尝试过:

\n
    \n
  • 因为我使用 Flavors:方法
  • \n …

xcode ios cocoapods flutter

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

Flutter Firebase Cloud 功能:无法读取数据,因为格式不正确

我尝试使用 Flutter 项目中的 cloud_functions 插件调用我的云函数,代码如下:

\n
final HttpsCallable callable = new CloudFunctions(region: "europe-west3")\n        .getHttpsCallable(functionName: 'helloWorld');\n\ndynamic resp = await callable.call(<String, dynamic>{'id': id, 'chatId': chat.chatId});\n
Run Code Online (Sandbox Code Playgroud)\n

并得到以下错误:

\n
ERROR: PlatformException(3840, The data couldn\xe2\x80\x99t be read because it isn\xe2\x80\x99t in the correct format., null)\n
Run Code Online (Sandbox Code Playgroud)\n

通过我的研究,我发现当您忘记将区域放在服务器和客户端上时,可能会出现问题,但错误仍然存​​在。

\n

我还尝试传递成功的 http 请求:

\n
var parameters = {'id': id, 'chatId': chat.chatId};\nvar url = "https://europe-west3-{MY_DOMAIN}.cloudfunctions.net/helloWorld";\nawait http.post(url, body: parameters).then((res) {...}\n
Run Code Online (Sandbox Code Playgroud)\n

所以我认为问题出在插件上,我可能忘记了一些东西。有任何想法吗 ?

\n

云功能(测试):

\n
exports.helloWorld = functions\n  .region('europe-west3')\n  .https.onRequest((request, response) => {\n    try {\n      response.send('Hello from …
Run Code Online (Sandbox Code Playgroud)

firebase flutter google-cloud-functions

3
推荐指数
1
解决办法
2058
查看次数

尝试通过 Firebase Cloud 函数将 DateTime 对象发送到 Firestore

通过将 DateTime 对象从应用程序直接发送到 Firebase,会自动转换为 TimeStamp 格式。但是,如果我通过云函数发送相同的对象,我将收到以下错误:

Invalid argument: Instance of 'DateTime'
Run Code Online (Sandbox Code Playgroud)

我尝试使用该toString()方法传递对象并通过运行 Date.parse 进行后端转换Date.parse(data["birth_date"])。但在 Firestore 上,数据记录为数字而不是时间戳。

颤振代码:

//final DateTime birthDate; -> To show you the type
final HttpsCallable callable =
          CloudFunctions(region: "europe-west3").getHttpsCallable(
        functionName: 'userFunctions-editUser',
      );
      HttpsCallableResult httpsCallableResult =
          await callable.call({"birth_date": birthDate});
Run Code Online (Sandbox Code Playgroud)

服务器端代码:

exports.addUser = functions
  .region("europe-west3")
  .https.onCall((data, context) => {
    const userUid = data["userUid"];
    const docRef = admin.firestore().doc(`/users_profils/${userUid}`);

    return docRef.set({
      ...
      birth_date: Date.parse(data["birth_date"]),
      ...
    });
  });
Run Code Online (Sandbox Code Playgroud)

如何使用云函数将 DateTime 对象转换为 TimeStamp ?

firebase flutter google-cloud-functions google-cloud-firestore

0
推荐指数
1
解决办法
1160
查看次数