flutter Shopify:^0.0.1程序包给我异常:(操作系统错误:没有与主机名关联的地址,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,
),
),
),
);
}
}我已经允许上网了,笔记本和手机上都有wifi。
我提供了商店名称,如: verden-app.myshopify.com和storeFrontApiToken(从我创建的私人应用程序),我已经允许所有选项的read_write权限,请帮助?
我只是在运行给定的示例,并希望打印来自我的存储的数据
https://github.com/nonvanilla-shop/shopify_flutter

发布于 2021-10-01 11:28:34
您的完整错误消息指出它找不到URL "https“的地址。这并不奇怪,因为这不是一个完整的地址。您需要以有效的格式提供完整地址。
由于您还没有实际发布您的代码,我只能猜测...也许在你复制粘贴的时候,你的url的https部分后面有一个空格?或者您使用了分号而不是冒号?或者是反斜杠而不是正斜杠?
发布于 2021-10-02 11:47:02
对于那些将来可能会遇到这个错误的人。我的代码只需在商店名称中添加商店名称,即e verden-app即可成功运行
https://stackoverflow.com/questions/69401687
复制相似问题