草庐IT

last_list

全部标签

dart - Json String to Map<> or List

我有一个像下面这样存储为字符串的jsonStringjson="[{"name":"a","id",1},{"name":"b","id",2},{"name":"c","id",3}]";我的问题如何将其编码为映射或列表以访问键并使用值? 最佳答案 您需要先对值进行JSON解码import'dart:convert';finaldecoded=jsonDecode(json);print(decoded[0]['name']);//justoneexample 关于dart-JsonS

list - flutter - 设置显示List距离时的最大半径

我正在开发最近的FoodDish应用程序位置。我设法根据离用户最近的位置显示它,使用这个插件great_circle_distance我想知道如何设置最大半径?前任。这是我的代码:_foodByCategories.sort((a,b){vardistance1=newGreatCircleDistance.fromDegrees(latitude1:model.userLocation==null?0.0:model.userLocation["latitude"],longitude1:model.userLocation==null?0.0:model.userLocation[

list - 在具有动态高度的同一页面上 flutter 两个 listview.builder

我正在使用flutter。我有两个可用项目和不可用项目的动态列表。我想以一种显示完整的可用项目列表然后显示完整的不可用项目列表的方式显示这两个列表,并且flutter将动态决定长度。谢谢。 最佳答案 这是一个小示例,应该为可用项目显示红色容器,为不可用项目显示蓝色容器。Listunavailable;Listavailable;Expanded(child:CustomScrollView(slivers:[SliverList(delegate:SliverChildBuilderDelegate((BuildContextcon

list - flutter 将项目添加到列表

我想向列表中添加一个项目:voidsubmitAll()async{ListuserSearchItems=[];Firestore.instance.collection('insta_users').snapshots().listen((data)=>data.documents.forEach((doc){print(data.documents.length);Useruser=newUser.fromDocument(doc);UserSearchItemsearchItem=newUserSearchItem(user);userSearchItems.add(searc

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

list - 如何在 flutter 中制作垂直堆叠的卡片?

我正在尝试设计这种堆叠列表,但无法在flutter中进行负填充,因此我需要另一种方法来实现这种重叠效果。 最佳答案 您可以使用Stack和Positioned(知道卡片的高度)。像这样:classHomePageextendsStatelessWidget{@overrideWidgetbuild(BuildContextcontext){returnScaffold(appBar:AppBar(title:Text('Home'),),body:Stack(children:[Positioned(bottom:150.0,lef

dart - Flutter 如何在 List 映射中映射一个完成的 Future 对象

Future>>getNewsList(skipItems)async{finalresponse=awaithttp.get('https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty');if(response.statusCode==200){//Ifthecalltotheserverwassuccessful,parsetheJSONvarresponseNewsList=json.decode(response.body);newsList=responseNewsListasList;varres

android - 在 flutter 中将 List<T> 转换为 json

IhavealistofoptionwhentheattributeisselectedofaparticularoptionthenIsaveattributeobjectattheselectedpositionofoptioninthelist.现在我有一个选项列表,其中包含他们选择的属性对象。我的目标是将选项列表转换为JSON对象,但是当属性不为空时。在这种情况下,当一个人没有选择选项的属性时,Attribute对象可以为null。classOptionAttribute{String_grouprowid;String_groupname;Attribute_selected

list - 如何在 flutter 中将字符串列表转换为字符串?

我需要转换List进入String在Dart中。我想从首选项中提取列表的值。我试过这个实现,但它只给我最后一个值。Future>services=SharedPrefSignUp.getSelectedServices();services.then((onValue){ListservicesList=onValue;selectServicesText=servicesList.join(",");}); 最佳答案 如果你知道你有List那么你可以使用join()flutter提供的功能。varlist=['one','two'

listview - Flutter 类型 'List<dynamic>' 不是类型 'list<Widget>' 的子类型

我正在尝试用带有图像的卡片制作列表,想法是这些卡片在未来通过API请求动态生成,但现在我只想从图像开始,但是当我运行时出现以下错误:类型“列表”不是类型“列表”的子类型我该如何解决?请您帮忙。我的代码在一个名为的文件中:请求.dart这是我的代码:import'package:flutter/material.dart';classMyAppextendsStatelessWidget{//Thiswidgetistherootofyourapplication.@overrideWidgetbuild(BuildContextcontext){returnnewMaterialApp