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