首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在颤动项目中集成Shopify与Null Safety?

如何在颤动项目中集成Shopify与Null Safety?
EN

Stack Overflow用户
提问于 2021-10-01 06:54:20
回答 2查看 53关注 0票数 0

flutter Shopify:^0.0.1程序包给我异常:(操作系统错误:没有与主机名关联的地址,Errno = 7) #1

代码语言:javascript
复制
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,
          ),
        ),
      ),
    );
  }
}

我已经允许上网了,笔记本和手机上都有wifi。

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

我只是在运行给定的示例,并希望打印来自我的存储的数据

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

EN

回答 2

Stack Overflow用户

发布于 2021-10-01 11:28:34

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

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

票数 0
EN

Stack Overflow用户

发布于 2021-10-02 11:47:02

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69401687

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档