Listview 将变量添加到列表中

Listview 将变量添加到列表中,listview,variables,flutter,Listview,Variables,Flutter,我当前在列表视图中有一个百分比计数器 我试图使用一个变量使中间的文本几乎与实际的条平行地变化,因为我计划从Python中得到信息,Python与数字是很好的,那么我该怎么做才能把圆圈中间的文本变成实际的var值 var number = 0.7; class percent extends StatelessWidget { @override Widget build(BuildContext context) { // TODO: impl

我当前在列表视图中有一个百分比计数器

我试图使用一个变量使中间的文本几乎与实际的条平行地变化,因为我计划从Python中得到信息,Python与数字是很好的,那么我该怎么做才能把圆圈中间的文本变成实际的var值

  var number = 0.7;

   class percent extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        // TODO: implement build

          return Scaffold(
            appBar: new AppBar(
              title: new Text("Circular Percent Indicators"),
            ),
            body: Center(
              child: ListView(
                  children: <Widget>[


                    **new CircularPercentIndicator(
                      radius: 140.0,
                      lineWidth: 13.0,
                      animation: true,
                      percent: number,
                      **center: new Text(
                        (number),**
                        style:
                        new TextStyle(fontWeight: FontWeight.bold, fontSize: 20.0),
                      ),

                      circularStrokeCap: CircularStrokeCap.round,
                      progressColor: Colors.purple,
                    ),**

                  ]),
var数=0.7;
类百分比扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
//TODO:实现构建
返回脚手架(
appBar:新的appBar(
标题:新文本(“循环百分比指标”),
),
正文:中(
子:ListView(
儿童:[
**新型循环指示器(
半径:140.0,
线宽:13.0,
动画:没错,
百分比:数字,
**中心:新文本(
(数字)**
风格:
新的文本样式(fontWeight:fontWeight.bold,fontSize:20.0),
),
circularStrokeCap:circularStrokeCap.round,
颜色:颜色。紫色,
),**
]),
这是我所有的代码

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_rave/flutter_rave.dart';
import 'package:percent_indicator/percent_indicator.dart';

void main() => runApp(MyApp());
var number = 0.7;


class MyApp extends StatelessWidget {
  final appTitle = 'assets/logo.png';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: appTitle,
      home: MyHomePage(title: appTitle),
    );
  }
}

class FirstRoute extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Image.asset(
              'assets/ccs.png',
              fit: BoxFit.contain,
              height: 32,
            ),

          ],

        ),
      ),
      body: Center(
        child: ListView(
          // Important: Remove any padding from the ListView.
          padding: EdgeInsets.zero,
          children: <Widget>[

            ListTile(
              leading: CircleAvatar(
                backgroundImage: NetworkImage('https://www.mobilityhouse.com/media/gene-cms/c/s/css-combo-stecker-468px.png'),
              ),
              title: Text('CCS'),
              subtitle: Text('Example: Ford Fusion, Hyundai Ioniq, Volkswagen e-golf'),
              onTap: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(builder: (context) => MyHomePage()),
                );
              },
            ),
            ListTile(
              leading: CircleAvatar(
                backgroundImage: NetworkImage('https://thumbs.dreamstime.com/b/gb-t-chinese-standard-ev-charger-connector-outline-icon-electric-car-charging-plug-gb-t-china-outline-icon-124469668.jpg'),
              ),
              title: Text('GB/T'),
              subtitle: Text('Example:BYD, Chineese manufacurers'),
              onTap: () {
                return showDialog<void>(
                  context: context,
                  builder: (BuildContext context) {
                    return AlertDialog(
                      title: Text('GB/T'),
                      content: const Text('Sorry! We do not have any chargers with this charging port'),

                      actions: <Widget>[

                      ],
                    );
                  },
                );
              },
            ),
            ListTile(
              leading: CircleAvatar(
                backgroundImage: NetworkImage('https://w1.pngwave.com/png/342/73/231/electricity-symbol-electric-vehicle-chademo-battery-charger-combined-charging-system-charging-station-bmw-i3-car-png-clip-art.png'),
              ),
              title: Text('Chademo'),
              subtitle: Text('Example: Nissan Leaf, Mitsubishi Mi-ev'),
              onTap: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(builder: (context) => MyHomgePage()),
                );
              },
            ),
          ],
        ),
        ),

    );
  }
}

class SecondRoute {

}
class MyHomgePage extends StatelessWidget {
  final String title;

  MyHomgePage({Key key, this.title}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text(title)),
      body: Center(child: Text('Sorry! This Charging port is currently not supported')),
    );
  }
}
 class percent extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build

      return Scaffold(
        appBar: new AppBar(
          title: new Text("Circular Percent Indicators"),
        ),
        body: Center(
          child: ListView(
              children: <Widget>[


                new CircularPercentIndicator(
                  radius: 140.0,
                  lineWidth: 13.0,
                  animation: true,
                  percent: number,
                  **center: new Text(
                    (number),**
                    style:
                    new TextStyle(fontWeight: FontWeight.bold, fontSize: 20.0),
                  ),

                  circularStrokeCap: CircularStrokeCap.round,
                  progressColor: Colors.purple,
                ),

              ]),
        ),
      );
    }
  }




class MyHomePage extends StatelessWidget {
  final String title;

  MyHomePage({Key key, this.title}) : super(key: key);

  @override
  Widget build(BuildContext context) {

    return Scaffold(
      appBar: AppBar(title: Text(title)),

      body: Center(
        child: ListView(
            children: <Widget>[


              new CircularPercentIndicator(
                radius: 140.0,
                lineWidth: 13.0,
                animation: true,
                percent: number,
                **center: new Text(
                  print(number + "/150");
                  style:**
                  new TextStyle(fontWeight: FontWeight.bold, fontSize: 20.0),
                ),
                footer: new Text(
                  "Sales this week",
                  style:
                  new TextStyle(fontWeight: FontWeight.bold, fontSize: 17.0),
                ),
                circularStrokeCap: CircularStrokeCap.round,
                progressColor: Colors.purple,
              ),

            ]),
      ),

      drawer: Drawer(
        // Add a ListView to the drawer. This ensures the user can scroll
        // through the options in the drawer if there isn't enough vertical
        // space to fit everything.
        child: ListView(
          // Important: Remove any padding from the ListView.
          padding: EdgeInsets.zero,
          children: <Widget>[
            DrawerHeader(
              child: Text('Drawer Header'),
              decoration: BoxDecoration(
                color: Colors.blue,
              ),
            ),
            ListTile(
              title: Text('Charging Port'),
              onTap: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(builder: (context) => FirstRoute()),
                );
              },
            ),
            ListTile(
              title: Text('Item 2'),
              onTap: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(builder: (context) => percent()),
                );
              },
            ),
          ],
        ),
      ),
    );
  }
}
import'包装:flift/cupertino.dart';
进口“包装:颤振/材料.省道”;
进口“包装:颤振/颤振/颤振.飞镖”;
导入“包:百分比指示器/百分比指示器.dart”;
void main()=>runApp(MyApp());
风险值=0.7;
类MyApp扩展了无状态小部件{
最终appTitle='assets/logo.png';
@凌驾
小部件构建(构建上下文){
返回材料PP(
标题:appTitle,
主页:我的主页(标题:appTitle),
);
}
}
类FirstRoute扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
返回脚手架(
appBar:appBar(
标题:世界其他地区(
mainAxisAlignment:mainAxisAlignment.center,
儿童:[
影像资产(
“assets/ccs.png”,
适合:BoxFit.contain,
身高:32,
),
],
),
),
正文:中(
子:ListView(
//重要提示:从ListView中删除任何填充。
填充:EdgeInsets.zero,
儿童:[
列表砖(
领先:CircleAvatar(
背景图片:NetworkImage('https://www.mobilityhouse.com/media/gene-cms/c/s/css-combo-stecker-468px.png'),
),
标题:文本(“CCS”),
字幕:文本(“示例:福特Fusion、现代Ioniq、大众e-golf”),
onTap:(){
导航器。推(
上下文
MaterialPage路由(生成器:(上下文)=>MyHomePage()),
);
},
),
列表砖(
领先:CircleAvatar(
背景图片:NetworkImage('https://thumbs.dreamstime.com/b/gb-t-chinese-standard-ev-charger-connector-outline-icon-electric-car-charging-plug-gb-t-china-outline-icon-124469668.jpg'),
),
标题:文本(“GB/T”),
字幕:文本('示例:比亚迪,中国制造商'),
onTap:(){
返回显示对话框(
上下文:上下文,
生成器:(BuildContext上下文){
返回警报对话框(
标题:文本(“GB/T”),
内容:const Text('抱歉!我们没有任何带此充电端口的充电器'),
行动:[
],
);
},
);
},
),
列表砖(
领先:CircleAvatar(
背景图片:NetworkImage('https://w1.pngwave.com/png/342/73/231/electricity-symbol-electric-vehicle-chademo-battery-charger-combined-charging-system-charging-station-bmw-i3-car-png-clip-art.png'),
),
标题:文本(“Chademo”),
字幕:文本(“示例:日产Leaf,三菱Mi ev”),
onTap:(){
导航器。推(
上下文
MaterialPage路由(生成器:(上下文)=>MyHomgePage()),
);
},
),
],
),
),
);
}
}
第二类路线{
}
类MyHomgePage扩展了无状态小部件{
最后的字符串标题;
MyHomgePage({Key-Key,this.title}):super(Key:Key);
@凌驾
小部件构建(构建上下文){
返回脚手架(
appBar:appBar(标题:文本(标题)),
body:Center(子项:Text('Sorry!当前不支持此充电端口'),
);
}
}
类百分比扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
//TODO:实现构建
返回脚手架(
appBar:新的appBar(
标题:新文本(“循环百分比指标”),
),
正文:中(
子:ListView(
儿童:[
新型循环指示器(
半径:140.0,
线宽:13.0,
动画:没错,
百分比:数字,
**中心:新文本(
(数字)**
风格:
新的文本样式(fontWeight:fontWeight.bold,fontSize:20.0),
),
circularStrokeCap:circularStrokeCap.round,
颜色:颜色。紫色,
),
]),
),
);
}
}
类MyHomePage扩展了无状态小部件{
最后的字符串标题;
MyHomePage({Key,this.title}):超级(Key:Key);
@凌驾
小部件构建(构建上下文){
返回脚手架(
appBar:appBar(标题:文本(标题)),
正文:中(
setState(() {
  number +=1;
});