- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我在 android 模拟器和 google chrome 设备中运行我的应用程序时,我遇到了一些问题。我的应用程序仅在带有 iPhone 的 IOS 中运行良好。
我想,问题出在我的下拉菜单和对我的 api 的调用上。
在 iPhone 设备中,我可以在 dropDownButton 中看到作为 API 列表的数据,但在其他设备中看不到。
这是我用来与我的 api 通信的代码的一部分:
// Creation of deviceGet object with device data
var deviceGet = new List<Device>();
Future<void> GetDevice() async {
// CHANGED
await GET.url(url1).then((response) {
//END CHANGED
setState(() {
Iterable list = json.decode(response.body);
deviceGet = list.map((model) => Device.fromJson(model)).toList();
});
});
}
Future<String> getCommands(String deviceName1, String commandName1) async {
String deviceName = deviceName1;
String commandName = commandName1;
var url = "http://localhost:48082/api/v1/device/name/" +
deviceName +
"/command/" +
commandName1;
//we have to wait to get the data so we use 'await'
http.Response response = await http.get(
//Uri.encodeFull removes all the dashes or extra characters present in our Uri
Uri.encodeFull(url),
);
//print(response.body);
final body = json.decode(response.body);
//print(body['readings'][0]['value']);
value = body['readings'][0]['value'];
}
/flutter ( 8084): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 43992
E/flutter ( 8084): #0 IOClient.send
package:http/src/io_client.dart:33
E/flutter ( 8084): <asynchronous suspension>
E/flutter ( 8084): #1 BaseClient._sendUnstreamed
package:http/src/base_client.dart:176
E/flutter ( 8084): #2 BaseClient.get
package:http/src/base_client.dart:35
E/flutter ( 8084): #3 get.<anonymous closure>
package:http/http.dart:46
E/flutter ( 8084): #4 _withClient
package:http/http.dart:166
E/flutter ( 8084): #5 get
package:http/http.dart:46
E/flutter ( 8084): #6 GET.url
package:interface_edge/Get.dart:9
E/flutter ( 8084): #7 Chart1State.GetDevice
package:interface_edge/Chart1.dart:47
E/flutter ( 8084): #8 Chart1State.wait
package:interface_edge/Chart1.dart:85
E/flutter ( 8084): #9 Chart1State.initState
package:interface_edge/Chart1.dart:91
E/flutter ( 8084): #10 StatefulElement._firstBuild
package:flutter/…/widgets/framework.dart:4428
E/flutter ( 8084): #11 ComponentElement.mount
package:flutter/…/widgets/framework.dart:4274
E/flutter ( 8084): #12 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3269
E/flutter ( 8084): #13 Element.updateChild
package:flutter/…/widgets/framework.dart:3063
E/flutter ( 8084): #14 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4316
E/flutter ( 8084): #15 Element.rebuild
E/flutter ( 8084): #21 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3269
E/flutter ( 8084): #22 Element.updateChild
package:flutter/…/widgets/framework.dart:3063
E/flutter ( 8084): #23 SingleChildRenderObjectElement.mount
package:flutter/…/widgets/framework.dart:5518
E/flutter ( 8084): #24 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3269
E/flutter ( 8084): #25 Element.updateChild
package:flutter/…/widgets/framework.dart:3063
E/flutter ( 8084): #26 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4316
E/flutter ( 8084): #27 Element.rebuild
package:flutter/…/widgets/framework.dart:4020
E/flutter ( 8084): #28 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:4279
E/flutter ( 8084): #29 ComponentElement.mount
package:flutter/…/widgets/framework.dart:4274
E/flutter ( 8084): #30 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3269
E/flutter ( 8084): #31 Element.updateChild
package:flutter/…/widgets/framework.dart:3063
E/flutter ( 8084): #32 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4316
E/flutter ( 8084): #33 Element.rebuild
package:flutter/…/widgets/framework.dart:4020
E/flutter ( 8084): #34 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:4279
E/flutter ( 8084): #35 ComponentElement.mount
E/flutter ( 8084): #36 ParentDataElement.mount
package:flutter/…/widgets/framework.dart:4690
E/flutter ( 8084): #37 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3269
E/flutter ( 8084): #38 Element.updateChild
package:flutter/…/widgets/framework.dart:3063
E/flutter ( 8084): #39 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4316
E/flutter ( 8084): #40 Element.rebuild
package:flutter/…/widgets/framework.dart:4020
E/flutter ( 8084): #41 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:4279
E/flutter ( 8084): #42 StatefulElement._firstBuild
package:flutter/…/widgets/framework.dart:4454
E/flutter ( 8084): #43 ComponentElement.mount
package:flutter/…/widgets/framework.dart:4274
E/flutter ( 8084): #44 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3269
E/flutter ( 8084): #45 Element.updateChild
package:flutter/…/widgets/framework.dart:3063
E/flutter ( 8084): #46 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4316
E/flutter ( 8084): #47 Element.rebuild
package:flutter/…/widgets/framework.dart:4020
E/flutter ( 8084): #48 ComponentEle
Analyzing chat...
info • Name types using UpperCamelCase • lib/commandsData.dart:1:7 • camel_case_types
info • Name types using UpperCamelCase • lib/deviceData.dart:1:7 • camel_case_types
info • This function has a return type of 'Future<String>', but doesn't end with a return statement •
lib/getterMarche.dart:25:18 • missing_return
info • Name non-constant identifiers using lowerCamelCase • lib/main.dart:62:16 •
non_constant_identifier_names
info • This function has a return type of 'Future<String>', but doesn't end with a return statement •
lib/main.dart:73:18 • missing_return
info • The value of the local variable 'commandName' isn't used • lib/main.dart:75:12 •
unused_local_variable
info • This function has a return type of 'List<String>', but doesn't end with a return statement •
lib/main.dart:94:16 • missing_return
7 issues found. (ran in 6.5s)
This is the flutter doctor -v
[✓] Flutter (Channel dev, v1.13.5, on Mac OS X 10.15.1 19B88, locale fr-FR)
• Flutter version 1.13.5 at /Users/wassimbenjabria/flutter
• Framework revision 41a911099b (9 weeks ago), 2019-12-19 13:48:02 -0800
• Engine revision 0f90e6546b
• Dart version 2.8.0 (build 2.8.0-dev.0.0 aa6709974d)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/wassimbenjabria/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3, Build version 11C29
• CocoaPods version 1.8.4
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin installed
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] VS Code (version 1.42.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.8.1
[✓] Connected device (3 available)
• AOSP on IA Emulator • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
• Chrome • chrome • web-javascript • Google Chrome 79.0.3945.130
• Web Server • web-server • web-javascript • Flutter Tools
• No issues found!
import 'dart:convert';
import 'package:flutter/material.dart';
import 'Get.dart';
import 'Device.dart';
import 'deviceData.dart';
var url1 = "http://localhost:48082/api/v1/device";
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
build(context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'My App',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyListScreen(),
);
}
}
class MyListScreen extends StatefulWidget {
@override
createState() => _MyListScreenState();
}
class _MyListScreenState extends State {
List<deviceData> dataDevice = deviceData.getDevicesData();
List<DropdownMenuItem<deviceData>> listDropDevice;
deviceData deviceSelection;
// Creation of deviceGet object with device data
var deviceGet = new List<Device>();
Future<void> GetDevice() async {
// CHANGED
await GET.url(url1).then((response) {
//END CHANGED
setState(() {
Iterable list = json.decode(response.body);
deviceGet = list.map((model) => Device.fromJson(model)).toList();
});
});
}
Future<void> wait() async {
await GetDevice();
}
initState() {
super.initState();
wait().then((result) {
var nbrDevice = deviceGet.length;
for (int i = 0; i < nbrDevice;) {
dataDevice.add(deviceData(deviceGet[i].name, i));
i = i + 1;
}
listDropDevice = buildDropdownMenuItems(dataDevice);
});
}
List<DropdownMenuItem<deviceData>> buildDropdownMenuItems(List devices) {
List<DropdownMenuItem<deviceData>> items = List();
for (deviceData device1 in devices) {
items.add(
DropdownMenuItem(
value: device1,
child: Text(device1.name),
),
);
}
return items;
}
onChange(deviceData selectionUtilisateur) {
setState(() {
deviceSelection = selectionUtilisateur;
});
}
@override
build(context) {
return Scaffold(
appBar: AppBar(
title: Text("Device List"),
),
body: Column(children: <Widget>[
Center(child: Text("")),
DropdownButton(
value: deviceSelection,
items: listDropDevice,
onChanged: onChange,
hint: Text("Select the device")),
]));
}
}
最佳答案
这似乎是 Android 模拟器连接到远程服务器的问题。您可以查看 Stack Overflow post有关此问题的解决方法。
关于android - E/flutter (8084): [ERROR:flutter/lib/ui/ui_dart_state. cc(157)]未处理的异常:SocketException:操作系统错误:连接被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60372466/
我试图找到使用这行代码的原因 var cc = cc = cc || {}; 在 Cocos2D JavaScript 库中,例如 this地方,但我找不到任何合理的理由。就设置默认值而言,单一赋值是
我的 make 文件中有这些行: ifeq ($(SYSTEM),SOLARIS) # SUN Solaris 8 no c99 ifeq ($(OSVER),510)
服务器详细信息 MySQL 5.6.22 256GB 内存 4TB 固态硬盘 32 核 背景信息 有一个删除进程,每秒大约执行 3 次删除。每秒 2-3k QPS。主要是 SELECT。没有长时间运行
我正在 Spring 的帮助下发送邮件,其中我想要 CC 中的多个电子邮件 ID,所有人都会收到邮件,但问题是当他们在rackspace(apps.rackspace.com)中打开电子邮件时,它只显
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
我有一个生成文件。当我在 Unix 上运行它时,我得到这个错误: cc -I/opt/oracle/product/9.2.0/rdbms/demo -I/opt/oracle/product/9.2
直观的逻辑,具有 build 性,是函数式编程中类型系统的基础。经典逻辑不是 build 性的,尤其是排中律 A ∨ ¬A(或其等价物,例如 double negation elimination 或
我必须使用我之前创建的列表文件在 C++ 中编写一个队列,并且我很难编译所有内容。 我目前遇到的问题是,当我编译时出现错误: Queue.h:7:2: 错误:'List' 没有命名类型 如何正确连接队
使用支持延续的语言,例如Scheme、Ruby 和 Haskell,假设有一个函数 cc' 不带参数并返回当前延续,以便通过调用 cc' 获得延续的调用者然后可以随心所欲地在任何地方调用延续。 cc'
我有一个 InDesign 文档,其中包含不同宽度尺寸的页面。现在我想用 JS 脚本添加垂直指南。因此我必须添加 pageWidth + pageWidth (特定页面的)。 但我只知道如何获取文档尺
像这样,我有一个对象: { 'person': { 'like': { 'color': 'red', 'food': 'rice' }, 'nam
我知道我可以用: string input = "AA,BB,CC"; string output = ""; foreach (var item in
我正在尝试使用我使用 Label-img 标记的样本来训练对象检测算法。我的图像尺寸为 1100 x 1100 像素。我使用的算法是在 TensorFlow 2 Detection Model Zoo
我正在尝试学习 C,并且刚刚开始阅读“艰难地学习 C”这本书。在第二课中,作者提到了 Makefiles,并指出当使用命令“make example.c”时,“make”会自动调用 cc 来构建 .c
在我的主要方法的一开始,我就有了 main(int argc, char *argv[]){ if(argc!=2){ printf("not enough arguments"); ex
因此,我有一个 c 模块,其中我修改了两件事:向函数添加了一个参数,向结构体添加了一个参数。 问题是,当使用 cc 进行编译时(从我继承的脚本),无论我的更改在哪里,我都会收到错误消息(抱歉,如果翻译
我浪费了很多时间来弄清楚为什么一种算法应该比另一种算法更有效,然而,就速度而言,另一种算法却完全相同。我做了这些操作:我在一个单独的终端窗口中编译了第一个源代码;而第二个源代码在另一个窗口中。我只是用
多次按 Tab 不会将文本向右移动。有没有办法让它表现得像 Visual Studio 的智能缩进?第一个制表符缩进,随后的制表符将文本移动到下一个制表位。谢谢你。 最佳答案 像这样的东西? (def
如果我使用 C 编译器 cc,则命令行完成不起作用。如果我输入 cc dig + press tab 那么什么都不会发生,但是如果我用 cc digenv.c 编译程序,那么它就可以工作。为什么 cc
有人对它的工作原理有很好的指导吗?带有视觉辅助的东西会很好,我遇到的每个指南似乎都在说我需要重新尝试的同一件事。 最佳答案 这是留在CS实验室白板上的图。因此,您将要获取一些苹果,然后在开始操作之前先
我是一名优秀的程序员,十分优秀!