I'm facing an issue while doing widget testing on a widget that throws an exception during a Future.
Code to reproduce the problem
Here's a simple testwidget that reproduces the problem in a very simple way (thanks to Remi Rousselet for the simplification of the problem).
testWidgets('This test should pass but fails', (tester) async {
final future = Future<void>.error(42);
await tester.pumpWidget(FutureBuilder(
future: future,
builder: (_, snapshot) {
return Container();
},
));
});
Run Code Online (Sandbox Code Playgroud)
Expected result
我希望测试能够顺利完成。相反,它失败并显示以下错误:
??? EXCEPTION CAUGHT BY …Run Code Online (Sandbox Code Playgroud) 我在使用 Flutter web 并将图像上传到 Firestore 时遇到问题。我很确定问题出在图像选择器中,因为普通(移动)图像选择器不适用于网络。普通图像选择器返回一个文件,但替代image_picker_web返回一个图像,该图像在上传时被拒绝,因为它需要一个Future<File>.
image_picker_web有一种替代方法可以返回Uint8List我使用过的 a,然后转换为Filevia dart:html- 并正常上传,但图像已损坏且无法查看。
这是我所做的:
按下按钮 - 选择图像Uint8List> 转换为Image,存储在内存中并在屏幕上显示
onPressed: () async {
//Upload Image as Uint8List
imageBytes = await ImagePickerWeb.getImage(asUint8List: true);
//Convert Uint8List to Image
_image = Image.memory(imageBytes);
//Show new image on screen
setBottomSheetState(() {
image = _image;
});
},
Run Code Online (Sandbox Code Playgroud)
转换Uint8List为Fileusingdart:html File和 name as users UID.png (PNG Uploaded)
imageFile = html.File(imageBytes, …Run Code Online (Sandbox Code Playgroud) 我正在 GCP 上的 kubernetes 引擎上部署 Elasticsearch,但遇到了性能问题。Elasticsearch根据核心数量确定各种线程池的大小。尽管我创建了一个 32 核 VM,但线程池大小仅为 1。
我确实编写了一个测试程序来打印Runtime.getRuntime().availableProcessors(),它只是打印为 1 。
我想这与“容器优化操作系统”有关,这是使用 Kubernetes Engine 的虚拟机上允许的唯一操作系统。当我在 GCP 上创建 Debian VM 时,Runtime.getRuntime().availableProcessors()返回 8。不确定如何在 GCP kubernetes 引擎上使用 elasticsearch。欢迎任何想法或建议。
当我在没有 kubernetes 的 GCP 上创建 Debian 虚拟机时,返回Runtime.getRuntime().availableProcessors()8。
我正在使用这个命令来创建构建
flutter build apk --split-per-abi --no-sound-null-safety --no-tree-shake-icons --no-shrink -v
Run Code Online (Sandbox Code Playgroud)
我使用的是颤振版本2.5.0
我收到这个错误
Caused by: java.lang.ClassNotFoundException: com.android.tools.lint.client.api.Vendor
[ ] at com.intellij.util.lang.UrlClassLoader.findClass(UrlClassLoader.java:328)
[ ] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
[ ] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题来创建构建?
我正在尝试根据输入值将某些值分配给某些属性。该值在小部件的整个生命周期中保持不变。因此我使用了Stateless小部件。但是,我无法从构造函数中为 props 分配值。
class InOrOut extends StatelessWidget {
final Condition condition;
final bool isIconVisible;
final Color backgroudColor;
final Color foregrounndColor;
InOrOut({Key key, this.condition, this.isIconVisible}) : super(key: key) {
switch (condition) {
case Condition.IN:
backgroudColor = Colors.green[100];
foregrounndColor = Colors.green[100];
isIconVisible = false
break;
case Condition.ABSENT:
backgroudColor = Colors.grey[300];
foregrounndColor = Colors.green[100];
isIconVisible = true;
break;
case Condition.OUT:
backgroudColor = Colors.red[100];
foregrounndColor = Colors.green[100];
isIconVisible = false;
break;
default:
backgroudColor = Colors.red[100];
foregrounndColor = Colors.green[100];
isIconVisible = false;
} …Run Code Online (Sandbox Code Playgroud) 我觉得我错过了一些东西,但不能确定。我正在尝试将 codemagic 的自动代码签名功能用于 IOS 应用商店发布。
但是在构建过程中它会打印;
> /usr/local/bin/flutter build ios --release --no-codesign
Warning: Building for device with codesigning disabled. You will have to manually codesign before deploying to device.
Run Code Online (Sandbox Code Playgroud)
并在出版期间打印;
"Error Domain=ITunesSoftwareServiceErrorDomain Code=-22020 \"We are unable to create an authentication session.\" UserInfo={NSLocalizedDescription=We are unable to create an authentication session., NSLocalizedFailureReason=Unable to validate your application.}"
Run Code Online (Sandbox Code Playgroud)
我正在启用应用商店连接,选择自动代码签名并选择应用商店来配置配置文件类型。而且我确定我的 ID 和其他字段是正确的。
任何帮助,将不胜感激。
.. 我正在将 Cloud Firestore 用于我正在进行的 Flutter 项目。
上面添加的是我的数据库模型的屏幕截图。
基本上每个用户文档都有自己的个人信息字段和他/她的项目集合。
以上是两个项目展开后的截图。它具有项目的详细信息,例如其 CR、字段、成员等。
x = StreamBuilder(
stream: _projectStreamLock ? null : Firestore.instance.collection('User').document(_savedUser.user.uid).collection('Projects').snapshots(),
builder: (BuildContext context,AsyncSnapshot<QuerySnapshot> snapshots){
if(snapshots.hasData && !_projectStreamLock){
List<DocumentSnapshot> projectList = snapshots.data.documents;
_savedUser.user.projects = [];
for(int i=0;i<projectList.length;i++){
_savedUser.user.projects.add(Project(name: projectList[i].documentID,field: projectList[i].data["Field"],subField: projectList[i].data["SubField"],completionRate: projectList[i].data["CR"],members: projectList[i].data["Members"]));
}
return ListView.builder(
itemCount: snapshots.data.documents.length,
itemBuilder: (_,int index){
print(snapshots.data.documents[index].documentID + " : " + snapshots.data.documents[index].data["CR"].toString());
return ProjectCard(
globalHeight: _height,globalWidth: _width,
projectDetails: Project(
name : snapshots.data.documents[index].documentID,
completionRate: snapshots.data.documents[index].data["CR"],
field: snapshots.data.documents[index].data["Field"],
members: snapshots.data.documents[index].data["Members"],
subField: "Hello", …Run Code Online (Sandbox Code Playgroud) 我想要做的是:使用谷歌地图 api 获取数据,然后将数据传递到下一个屏幕。
有什么问题:它在 iOS 模拟器上运行良好,它设法进入下一个屏幕并用数据填充地图(打印位置、“yay”、http 状态代码和“loopyays”)。但是在 android 模拟器上,它只打印位置和“yay”,并挂在那里,不会导航到下一个屏幕。
什么地方出了错?:/ 请帮帮我..
class _LoadingScreenState extends State<LoadingScreen> {
void getUserLocation() async {
try {
Position position = await Geolocator()
.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
print(position);
Set<Marker> markers = {};
String url =
'https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=${position.latitude},${position.longitude}&maxprice=4&radius=1500&type=restaurant&keyword=cruise&key=AIzaSyDVzxxxxxxxxxxxxxxxxxxx';
print('yay');
http.Response data = await http.get(url);
print(data.statusCode);
var resultList = jsonDecode(data.body)['results'];
for (Map i in resultList) {
var coords = (i['geometry']['location']);
print('loopyay');
markers.add(Marker(
markerId: MarkerId(i['name']),
position: LatLng(coords['lat'], coords['lng'])));
}
Navigator.push(context, MaterialPageRoute(builder: (context) {
return UserLocationScreen(
userLocation: position,
markers: markers,
); …Run Code Online (Sandbox Code Playgroud) 我是 React js 的新手,我想创建一个像 typeform 这样的表单,但我没有使用 typeform。我有一个包含 5 个问题的列表,我希望在用户单击“下一步”后,它会一一出现,并具有像打字机一样的滑动效果。
这个问题也可能来自 json 数据。我刚刚使用了一种方法。
flutter ×7
dart ×3
android ×1
codemagic ×1
firebase ×1
flutter-test ×1
flutter-web ×1
http ×1
java ×1
kubernetes ×1
material-ui ×1
reactjs ×1
typeform ×1