草庐IT

dynamic-text

全部标签

flutter 从对象中获取值并显示在 Text() 中

如何从Flutter中的对象获取值?我需要在Text()中显示产品名称List_dataResponse=[{"item":"chakka"},{"item":"manga"},{"item":"thenga"},];ListView(children:_productName.map((f)=>ListTile(leading:Icon(Icons.check_circle,color:Colors.green,),title:**Text('$f["item"]')**,)).toList(),) 最佳答案 对于复杂的表达式(不

flutter - 如何在 Flutter 中为 Text Widget 添加自定义删除线

我正在寻找一种方法来向如下所示的文本小部件添加自定义删除线我查看了文本样式API,但找不到任何自定义删除线图形的选项。style:TextStyle(decoration:TextDecoration.lineThrough), 最佳答案 作为一个选项import'package:flutter/material.dart';voidmain()=>runApp(MyApp());classMyAppextendsStatelessWidget{@overrideWidgetbuild(BuildContextcontext){re

android - dart:从 firebase 数据库快照中获取类似 "%text%"的 SQL 搜索

我目前正在开发我的应用程序中的搜索功能。这会引用我的firebase数据库快照。我为此使用firebaseDatabase包。我目前正在使用它来搜索我的数据库FirebaseDatabase.instance.reference().child('products').orderByChild('title').equalTo(searchQuery)searchQuery变量是用于搜索数据库的字符串。这将返回标题等于searchQuery的产品列表。searchQuery='hello';title1='hello';title2='hellothere';目前只有searchQue

json - _InternalLinkedHashMap<String, dynamic> 类型不是 List<dynamic> 类型的子类型

我正在尝试使用网络调用实现一个简单的新闻提要应用程序,其中屏幕将在ListView中显示最新的故事。使用当前代码,我从API获得了响应(因为我在日志中看到了整个响应主体),但似乎无法在UI中显示数据。我收到此错误:type_InternalLinkedHashMapisnotsubtypeoftypeList这是JSON结构{"response":{"status":"ok","userTier":"developer","total":25095,"startIndex":1,"pageSize":10,"currentPage":1,"pages":2510,"orderBy":"

dart - 错误 : The argument type '() → Null' can't be assigned to the parameter type '(Null) → FutureOr<dynamic>'

import'package:flutter/material.dart';import'package:camera/camera.dart';classRegisterextendsStatefulWidget{Listcameras;@override_RegistercreateState(){return_Register();}Register(this.cameras);}class_RegisterextendsState{CameraControllercontroller;@overrideWidgetbuild(BuildContextcontext){retur

dart - 错误 : The argument type '(File) → Future<dynamic>' can't be assigned to the parameter type '(dynamic) → FutureOr<dynamic>'

我正在尝试编译示例:https://github.com/dart-lang/googleapis_examples/blob/master/drive_upload_download_console/bin/main.dart我得到以下Dart编译错误error:Theargumenttype'(File)→Future'can'tbeassignedtotheparametertype'(dynamic)→FutureOr'.(argument_type_not_assignableatlib/google_api_rest/main.dart:49)来自以下代码://Downlo

image - flutter 行 : Dynamic Height & Vertical Stretch

我有一个ListView项目,它具有受文本内容影响的动态高度。这是一个带有两个文本小部件的简单Column。当将Column包裹在Row中并添加Image时,我希望图像垂直扩展(但固定宽度)以匹配文本的自动高度。但是,我不能在Row上使用CrossAxisAlignment.stretch,因为它需要固定的高度。我怎样才能让我的图片根据旁边的文本内容展开/缩小? 最佳答案 Stack会自动包裹未定位的子元素。您可以利用这一优势:import'package:flutter/material.dart';voidmain()=>run

android - Flutter: InternalLinkedHashMap<String, dynamic >' has no instance method ' cast' with matching arguments

我无法从之前的问题中找到解决方案,我已将json字符串转换为map下面是我的API调用方法。FuturefetchEvent()async{//hereichangeFuturetypeStringurl='http://xxxxxxxxxxxx.tk/api/userapp/event/lists';varheaders=newMap();//hereidefinedMaptypeheaders['Auth-Key']='OCDOC@2018';headers['End-Client']='OCDOC';varbody=newMap();//hereidefinedMaptypehe

dart - 如何将 Future<dynamic> 转换/转换为图像?

我有像这样获取图像的功能dynamicimgBinary=_repository.fetchImage(productId);我想将其添加到图像列表中ListlistImages=newList();很喜欢dynamicimgBinary=_repository.fetchImage(productId);listImages.add(imgBinary);这个怎么投? 最佳答案 好的,所以你可以尝试.then方法。因为_repository.fetchImage(productId);是future。所以你可以试试-Listlis

flutter - 参数类型 'List<Iterable<DropdownMenuItem<int>>>' 无法分配给参数类型 'List<DropdownMenuItem<dynamic>>'

在flutter中,我正在使用TMDBAPI并从那里获取流派名称,并想在我的DropdownButton上显示它们,但我遇到了这个错误。TheargumenttypeList>>can'tbeassignedtotheparametertype'List>{"genres":[{"id":28,"name":"Action"},{"id":12,"name":"Adventure"},{"id":16,"name":"Animation"},.......]}这是json。returnDropdownButton(items:[snapGenre.data.genres.map((ma