【问题标题】:How to integrate Shopify in the flutter project with Null Safety Please?如何将 Shopify 与 Null Safety Please 集成到颤振项目中?
【发布时间】:2021-10-01 06:54:19
【问题描述】:

flutter Shopify: ^0.0.1 package 给我一个例外:(OS Error: No address associated with hostname, Errno = 7) #1

import 'package:flutter/material.dart';
import 'package:shopify/shopify.dart';

void main() {
  Shopify.create(
    shop: 'shop-name',
    storeFrontApiToken: 'your-api-key',
  );

  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Shopify Example',
      theme: ThemeData(primaryColor: Colors.redAccent),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({Key? key}) : super(key: key);

  Future<void> getData() async {
    final shopify = Shopify.instance;
    final data = await shopify.runQuery([
      ShopifyQuery.products()
        ..withFields(
          availableForSale: true,
          compareAtPriceRange: ShopifyProductPriceRange()
            ..withFields(
              maxVariantPrice: ShopifyMoney()
                ..withFields(
                  amount: true,
                ),
            ),
          createdAt: true,
          description: true,
          descriptionHtml: true,
          handle: true,
          id: true,
          onlineStoreUrl: true,
          options: ShopifyProductOptions()
            ..by(first: 5)
            ..withFields(
              id: true,
              name: true,
              values: true,
            ),
          priceRange: ShopifyProductPriceRange()
            ..withFields(
              maxVariantPrice: ShopifyMoney()
                ..withFields(
                  amount: true,
                ),
            ),
          productType: true,
          publishedAt: true,
          requiresSellingPlan: true,
          seo: ShopifySeo()
            ..withFields(
              description: true,
              title: true,
            ),
          tags: true,
          title: true,
          totalInventory: true,
          updatedAt: true,
          variantBySelectedOptions: ShopifyProductVariant()
            ..withFields(
              weight: true,
            ),
          // selectedOptions: true,
          vendor: true,
        )
        ..by(first: 4)
      // ..as(Article.fromJson),
    ]);

    // print(data);
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Center(
        child: GestureDetector(
          onTap: getData,
          child: Container(
            width: 100,
            height: 100,
            color: Colors.red,
          ),
        ),
      ),
    );
  }
}

我已经允许上网了,lapy和手机上的wifi都打开了

我提供的商店名称如:verden-app.myshopify.com 和 storeFrontApiToken(来自我创建的私有应用程序),我也允许所有选项的 read_write 权限,请帮忙?

我只是在运行给定的示例并想从我的商店打印数据

https://github.com/nonvanilla-shop/shopify_flutter

【问题讨论】:

  • 所以?问题是什么?如果您不描述您遇到的问题,我们将无法帮助您。它不编译吗?你有错误吗?运行时有什么异常吗?
  • 我正在尝试运行上面链接的代码,并得到一个错误(上面更新的问题)
  • 哪一行给出了这个错误?您正在运行的代码是什么?我们不是魔术师,我们无法神奇地知道您在屏幕上做错了什么。您需要分享这些信息。
  • 先生,我已经清楚地提到了问题所在,请您打开GitHub链接,这是flutter插件的repo:Shopify 1.0.0,我正在运行给定的代码链接,它给了我一个编译时错误:(操作系统错误:没有与主机名关联的地址,Errno = 7):我将再次编辑问题

标签: flutter api dart shopify


【解决方案1】:

您的完整错误消息显示找不到 URL“https”的地址。这并不奇怪,因为这不是一个完整的地址。您需要提供有效格式的完整地址。

由于您实际上还没有发布您的代码,我只能猜测......也许在您复制和粘贴它的时候,您的网址的 https 部分后面有一个空格?或者,也许您使用了分号而不是冒号?或者也许是反斜杠而不是正斜杠?

【讨论】:

    【解决方案2】:

    对于你们这些将来可能会遇到此错误的人。我的代码只需添加商店名称即可成功运行,即仅在商店名称中添加 verden-app

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-07
      • 2020-09-29
      • 2021-08-27
      • 1970-01-01
      • 2019-06-10
      • 1970-01-01
      相关资源
      最近更新 更多