小编Chr*_*ris的帖子

在 Web 上运行的 Flutter 应用程序失败并出现错误:只有 JS 互操作成员可能是“外部”

我正在尝试让我当前的 Flutter 应用程序在网络上运行。我打了电话flutter create .,但如果我尝试在 Chrome 中运行它,我会收到大约 10000 条错误消息的提示,这些消息都如下所示:

尝试删除“external”关键字或添加 JS 互操作注释。外部 ffi.Pointer<OBX_id_array> 删除;^

../../flutter/.pub-cache/hosted/pub.dartlang.org/objectbox-1.1.0/lib/src/native/bindings/objectbox-c.dart:6289:41:错误:仅JS互操作成员可能是“外部”的。尝试删除“external”关键字或添加 JS 互操作注释。外部 ffi.Pointer<OBX_sync_change> 列表;^

../../flutter/.pub-cache/hosted/pub.dartlang.org/objectbox-1.1.0/lib/src/native/bindings/objectbox-c.dart:6292:16:错误:仅JS互操作成员可能是“外部”的。尝试删除“external”关键字或添加 JS 互操作注释。外部整数计数;^

无法编译应用程序。

我尝试用谷歌搜索,但找不到任何关于此的信息。有谁知道这是什么以及我该如何适应它?

javascript dart flutter-web flutter-objectbox

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

Swift 显示应用内购买的促销代码视图不执行任何操作

我尝试添加促销代码功能,这样我就可以免费为一些用户提供一些东西。

我在App Store Connect中创建了一个促销代码,这是我打开以下内容的函数PromoCodeView

@objc func promoCodeButtonTapped() {
    let paymentQueue = SKPaymentQueue.default()
    if #available(iOS 14.0, *) {
        paymentQueue.presentCodeRedemptionSheet()
    }
}
Run Code Online (Sandbox Code Playgroud)

视图正确呈现。但是我在那里无能为力。我可以输入代码或取消,但无法确认或执行任何操作。我在这里缺少什么?顺便说一句,我正在实时版本上运行它。我知道我无法在开发中测试它。

该应用程序已上线!如果你想自己测试一下:

https://apps.apple.com/de/app/wishlists-einfach-w%C3%BCnschen/id1503912334

为应用内购买生成的促销代码:

HE9T64F74JHT

如果有人能成功,他可以使用此代码免费获得我的应用程序的高级版:D(个人资料 -> 高级会员 -> 促销代码)

在此输入图像描述

in-app-purchase ios promotion-code swift

2
推荐指数
1
解决办法
3022
查看次数

像iOS 13模态全屏一样的Flutter过渡

我想要 iOS-Modal-Transition,其中新屏幕从底部开始动画,而旧屏幕被推到后面。我发现这个非常有前途的包:

模态底部表

这是我用来显示模态的函数:

showCupertinoModalBottomSheet(
                  expand: true,
                  context: context,
                  builder: (context) => Container(
                    color: AppColors.blue,
                  ),
                );
Run Code Online (Sandbox Code Playgroud)

然而,这并不能 100% 正确地工作,因为后面的视图没有被推到后面。

我在这里缺少什么?如果有任何不清楚的地方请告诉我!

这是我的更多代码:

这是我的整个页面,我想从这里进行转换:

    class _MonthPageState extends State<MonthPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: AppColors.secondary,
      body: SafeArea(
        child: Stack(
          children: [
            ...
            Positioned(
              bottom: 10,
              right: 20,
              child: Hero(
                tag: widget.month.name + 'icon',
                child: AddButton(
                  onTapped: () {
                    showCupertinoModalBottomSheet(
                      expand: true,
                      context: context,
                      builder: (context) => Container(
                        color: AppColors.blue,
                      ),
                    );
                  },
                ),
              ),
            ),
          ],
        ),
      ), …
Run Code Online (Sandbox Code Playgroud)

router transition modal-dialog dart flutter

2
推荐指数
1
解决办法
2962
查看次数

颤振显示从图库中选取的图像

我只是想选择一个图像并将其显示在我的应用程序中。为此,我使用Flutter Image Picker。我添加了所有依赖项,我可以选择图像,但无法显示它......

这是我尝试过的:

class _AddMemoryPageState extends State<AddMemoryPage> {
  final picker = ImagePicker();
  late Future<PickedFile?> pickedFile;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: AppColors.secondary,
      body: SafeArea(
        child: Column(
          children: [
            Row(
              children: [
                Padding(
                  padding: EdgeInsets.only(
                    top: 15,
                    left: 25,
                  ),
                  child: IconButtonWithExpandedTouchTarget(
                    onTapped: () {
                      Navigator.pop(context);
                    },
                    svgPath: 'assets/icons/down.svg',
                  ),
                ),
              ],
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                IconButtonWithExpandedTouchTarget(
                  onTapped: () async {
                    pickedFile = picker
                        .getImage(
                          source: ImageSource.camera,
                        )
                        .whenComplete(() => {setState(() {})});
                  },
                  svgPath: …
Run Code Online (Sandbox Code Playgroud)

image-gallery dart flutter imagepicker flutter-futurebuilder

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

从列表中删除项目后,Flutter Slidable 保持打开状态

我在 ListView 中使用 Slidable,这样我就可以删除项目。问题是,如果我从列表中删除一个项目,新项目将可滑动打开。这显然不是理想的行为。这是一个屏幕视频,以便更好地理解。

\n

我的列表是一个 AnimatedList:

\n
\n`                       child: AnimatedList(\n                            padding: EdgeInsets.zero,\n                            shrinkWrap: true,\n                            key: listKey,\n                            initialItemCount: widget.month.memories.length,\n                            itemBuilder: (context, index, animation) {\n                              return slideIt(\n                                context,\n                                widget.month.memories[index],\n                                index,\n                                animation,\n                              );\n                            },\n                          ),`\n
Run Code Online (Sandbox Code Playgroud)\n

这是我的滑动:

\n
` Widget slideIt(\n    BuildContext context,\n    Memory memory,\n    int index,\n    animation,\n  ) {\n    return SlideTransition(\n      position: Tween<Offset>(\n        begin: const Offset(-1, 0),\n        end: Offset(0, 0),\n      ).animate(\n        CurvedAnimation(\n          parent: animation,\n          curve: Curves.easeIn,\n          reverseCurve: Curves.easeOut,\n        ),\n      ),\n      child: Slidable(\n        actionPane: SlidableDrawerActionPane(),\n        actionExtentRatio: 0.25,\n        movementDuration: Duration(milliseconds: 400),\n …
Run Code Online (Sandbox Code Playgroud)

indexing listview dart flutter flutter-animatedlist

2
推荐指数
1
解决办法
3111
查看次数

如果在另一个列内的列中使用间隔器,则会出现颤动无界高度错误

我被困住了......这是我的代码分解:

 Column(
    children: [
      Column(
        children: [
          Text('Whyy'),
          Spacer(),
          Text('crash?'),
        ],
      ),
      Text('ok'),
    ],
  ),
Run Code Online (Sandbox Code Playgroud)

这会因错误而崩溃:

RenderFlex 子级具有非零弯曲,但传入的高度约束是无界的。

当列位于不提供有限高度约束的父列中时(例如,如果它位于垂直可滚动列中),它将尝试沿垂直轴收缩包裹其子列。在子项上设置 Flex(例如使用 Expanded)表示子项将扩展以填充垂直方向上的剩余空间。这两个指令是互斥的。如果父级要收缩其子级,则子级不能同时扩展以适合其父级。

但为什么?到底为什么会崩溃?位于sParent-Column内。Scaffoldbody

我在这里缺少什么?

如果您需要更多信息,请告诉我!

dart flutter flutter-layout flutter-column

2
推荐指数
1
解决办法
2308
查看次数

Swift - 动态更改 UIImageView 的图像

我有一张普通图像UIImage和一张list图像。我的目标是每隔几秒图像就会自动改变一次,并通过我的imageList.

这是我的清单:

let images: [UIImage] = [
        UIImage(named: "avocadoImage")!,
        UIImage(named: "beerImage")!,
        UIImage(named: "bikeImage")!,
        UIImage(named: "christmasImage")!,
        UIImage(named: "dressImage")!,
        UIImage(named: "giftImage")!,
        UIImage(named: "goalImage")!,
        UIImage(named: "rollerImage")!,
        UIImage(named: "shirtImage")!,
        UIImage(named: "shoeImage")!,
        UIImage(named: "travelImage")!,     
    ]
Run Code Online (Sandbox Code Playgroud)

我试过这个:

 NSTimer(timeInterval: 0.5, target: self, selector: "ChangeImage", userInfo: nil, repeats: true)
Run Code Online (Sandbox Code Playgroud)

但我不知道如何一遍又一遍地循环我的数组。

uiimageview uiimage ios swift

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

Swift - 从随机创建的文档 ID (Firestore) 中获取字段

在我的应用程序中,用户可以注册,这样我也可以保存firstname,lastnameuid.

这是 Firestore-Database 的样子:

在此处输入图片说明

我想访问用户,lastname但我不知道如何访问,因为Document-ID在注册过程中会随机创建。

Auth.auth().createUser(withEmail: email, password: password) { (result, err) in

            //check for errors
            if let err = err {
                self.view.endEditing(true)
                self.showError(err.localizedDescription)

            }else {

                //user was created successfully; store first and last name
                let db = Firestore.firestore()

                db.collection("users").addDocument(data: ["firstname":firstName, "lastname": lastName, "uid": result!.user.uid]) { (error) in

                    if error != nil {
                        self.showError("Error saving user data")
                    }
                }

                //transition to home
                self.transitionToHome()
            }
Run Code Online (Sandbox Code Playgroud)

ios firebase swift google-cloud-firestore

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

检查当前设备在扩展中是否有缺口

我的应用程序有一个ShareExtension,我需要知道当前设备是否有缺口。

该函数适用于正常应用:

var hasBottomNotch: Bool {
    if #available(iOS 11.0, tvOS 11.0, *) {
        return UIApplication.shared.delegate?.window??.safeAreaInsets.bottom ?? 0 > 20
    }
    return false
}
Run Code Online (Sandbox Code Playgroud)

不幸的是我不能在我的扩展中使用它:

“共享”在 iOS 的应用程序扩展中不可用:在适当的情况下使用基于视图控制器的解决方案。

有什么解决方法吗?

layout ios swift

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

Flutter 填充值的常量值无效

我有一个Widget包裹在Padding. 我想分别了解rightPadding当前width设备的。这是我尝试过的:

  child: Padding(
    padding: const EdgeInsets.only(
        top: 8,
        bottom: 8,
        right: MediaQuery.of(context).size.width / 30), // -> error
    child: Image.asset('assets/images/person.png'),
  ),
Run Code Online (Sandbox Code Playgroud)

但我收到错误:

无效常量值

这是为什么?我该如何解决这个问题?

widget padding dart flutter flutter-layout

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

Flutter 字段在 Stateful widget 中不能是最终字段

Flutter 正在抱怨 ,_isSelected因为它不是final。问题是这是must not最终的,因为它是在buttonPressed......

class SelectionButton extends StatefulWidget {
  final String title;
  final Function(String) onSelectionButtonTap;
  bool isSelected;

  SelectionButton({
    required this.title,
    required this.onSelectionButtonTap,
    required this.isSelected,
  });
  @override
  _SelectionButtonState createState() => _SelectionButtonState();
}

class _SelectionButtonState extends State<SelectionButton> {
  @override
  Widget build(BuildContext context) {
    return Expanded(
      child: GestureDetector(
        onTap: () {
          setState(() {
            widget.onSelectionButtonTap(widget.title);
            widget.isSelected = !widget.isSelected;
          });
        },
        child: Container(
          decoration: BoxDecoration(
            color: widget.isSelected ? AppColors.primary : AppColors.white,
            borderRadius: BorderRadius.circular(
              scaleWidth(10),
            ),
          ),
          child: …
Run Code Online (Sandbox Code Playgroud)

final widget stateful dart flutter

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

Swift 中 Lottie 动画的闭包函数

有没有办法知道什么时候Lottie animation完成?我需要delete 一个tableViewCell 但只有在animation 完成之后。这是animation

设置:

    //MARK: setup Loading-Animation
func setupLoadingAnimation(){

    successAnimation.translatesAutoresizingMaskIntoConstraints = false
    self.contentView.addSubview(successAnimation)

    successAnimation.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: -30).isActive = true
    successAnimation.centerYAnchor.constraint(equalTo: contentView.centerYAnchor).isActive = true
    successAnimation.widthAnchor.constraint(equalToConstant: 160).isActive = true
    successAnimation.heightAnchor.constraint(equalToConstant: 160).isActive = true

    successAnimation.isHidden = true
    successAnimation.loopMode = .playOnce
}
Run Code Online (Sandbox Code Playgroud)

行动:

@objc func checkButtonTapped(){
    self.deleteWishCallback?()
    self.successAnimation.isHidden = false
    self.successAnimation.play()
}
Run Code Online (Sandbox Code Playgroud)

我想要实现的是能够self.deleteWishCallback?()self.successAnimation.play(). 有没有办法做到这一点?找不到任何关于此的信息!

closures ios swift lottie

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

将两个具有相同名称的单独文档上传到 Firebase

我希望能够在 Firebase 中添加两个具有相同名称的不同文档。现在,如果我尝试这样做,第一个文档就会被覆盖。这些文档具有不同的值。这就是我现在添加的方式:

\n
let batch = db.batch()\n\n// update listCounter\nlet userRef = Firestore.firestore().collection("users").document(userID)\nbatch.updateData(["wishCounter": counter + 1], forDocument: userRef)\n\n// save wishlist with properties\nlet wishRef = db.collection("users").document(userID).collection("wishlists").document(wishListName).collection("w\xc3\xbcnsche").document(wish.name)\n\nbatch.setData(["name": wish.name, "link": wish.link, "price": wish.price, "note": wish.note, "wishlistIDX": selectedWishlistIdx, "wishCounter": counter, "imageUrl": ""], forDocument: wishRef)\nbatch.commit { (error) in\n    if let error = error {\n        Utilities.showErrorPopUp(labelContent: "Wunsch konnte nicht gespeichert werden", description: error.localizedDescription)\n    }\n}\n
Run Code Online (Sandbox Code Playgroud)\n

wishName应该始终被创建。我不知道更多代码在这里是否有帮助,但如果有的话请告诉我。找不到任何关于此的信息,所以我对每一个帮助都很满意!

\n

ios firebase swift google-cloud-firestore

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