我正在 flutter dart 中处理 json。
final response = http.get('url').
response.body returns this json String format: String stringJson = {"symbols_returned":147,"base":"USD","data":{"AED":"3.672940","AFN":"75.617000","ALL":"109.780000","AMD":"490.740000","ANG":"1.797350","AOA":"313.147500","ARS":"37.864500","AUD":"1.408450","AWG":"1.800000","AZN":"1.702500","BAM":"1.727050","BBD":"2.004250","BCH":"0.008196","BDT":"83.950500","BGN":"1.726900","BHD":"0.377470","BIF":"1800.000000","BMD":"1.000000","BND":"1.357650","BOB":"6.919100","BRL":"3.729400","BSD":"1.001300","BTC":"0.000278","BWP":"10.474000","BZD":"2.018350","CAD":"1.328050","CDF":"1631.000000","CHF":"1.000300","CLF":"0.025048","CLP":"658.100000","CNY":"6.746600","COP":"3121.850000","CRC":"612.970000","CUP":"1.001395","CVE":"97.373000","CZK":"22.793600","DJF":"177.720000","DKK":"6.589100","DOP":"50.646500","DZD":"118.840000","EGP":"17.609500","ETB":"28.413000","ETH":"0.008377","EUR":"0.883085","FJD":"2.125900","GBP":"0.773115","GEL":"2.645000","GHS":"5.276200","GIP":"0.770005","GMD":"49.550000","GNF":"9127.200000","GTQ":"7.765200","GYD":"209.360000","HKD":"7.846950","HNL":"24.439500"}
}
Map mapJson = json.decode(response.body) returns the following format:
{symbols_returned: 147, base: USD, data: {AED: 3.672940, AFN: 75.617000, ALL: 109.780000, AMD: 490.740000, ANG: 1.797350, AOA: 313.147500, ARS: 37.864500, AUD: 1.408450, AWG: 1.800000, AZN: 1.702500, BAM: 1.727050, BBD: 2.004250, BCH: 0.008196, BDT: 83.950500, BGN: 1.726900, BHD: 0.377470, BIF: 1800.000000, BMD: 1.000000, BND: 1.357650, BOB: 6.919100, BRL: 3.729400, BSD: 1.001300, BTC: 0.000278, BWP: …
Run Code Online (Sandbox Code Playgroud) 我正在尝试更改 flutter 中的 fontFamily 属性以显示外观不同于默认外观的文本。无论我在 flutter 中为 fontfamily 分配的字体名称如何,默认字体都不会改变(常规字体类型,如 Arial、comic san、Times New Roman、Lucida 等),这里没有任何自定义。我相信像这样微不足道的事情不应该抛出这个问题。任何帮助将不胜感激。以下是我的颤振代码:
pubspec.yaml 文件:
name: dramil
description: A new Flutter application.
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# …
Run Code Online (Sandbox Code Playgroud) 我的页面上有一个 ListView.builder 小部件。问题是小部件在显示结果时不滚动。请问我做错了什么?以下代码显示了我到目前为止所尝试的内容。
我尝试仅将 ListView.builder 小部件放在页面上,在这种情况下小部件会滚动,但是一旦我添加另一个小部件,Listview 就会停止滚动。
@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(
title: Text(widget.title,style: TextStyle(fontSize: 14),),
),
body: SingleChildScrollView(
scrollDirection: Axis.vertical,
physics: AlwaysScrollableScrollPhysics(),
child:Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
child:Expanded(
child: Image.asset("assets/images/1frenchToast.webp"),
),
// ),
),
],
),
SingleChildScrollView(
child: ListView.builder(
//scrollDirection: Axis.vertical,
physics: AlwaysScrollableScrollPhysics(),
itemCount: foodCategory != null?foodCategory.length:1,
itemBuilder: (context,index){
return ListTile(
//dense: true,
leading: Container(
margin: EdgeInsets.only(bottom: 10),
child:Image.asset('assets/images/3poached-egg.webp',),
),
title: Text(foodCategory != null?foodCategory[index].foodType:1),
onTap: (){
_navigate(dropDownSelectedItemState, foodCategory[index].foodType);
},
);
},shrinkWrap: …
Run Code Online (Sandbox Code Playgroud)