RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-363714

Денис Акулов's questions

Martin Hope
Денис Акулов
Asked: 2020-01-21 01:15:36 +0000 UTC

Flutter 收集 Map<String, dynamic> 中的 TextField 值

  • 0

你需要为此发送一个post请求你需要收集Map中所有TextFiel的值你需要做什么TextEditingController是body测试数据,据我了解,更改字段时,你需要向地图添加一个值。如何做得更好请告诉我。

class CreateOrderWidget extends StatefulWidget {

  CreateOrderWidget({Key key}) : super(key: key);
  @override
  _CreateOrderWidgetState createState() => _CreateOrderWidgetState(); 
  }


class _CreateOrderWidgetState extends State<CreateOrderWidget> {

    final formatdate = DateFormat("dd-MM-yyyy");
    final formattime = DateFormat("HH:mm"); 


    Map<String, dynamic> body = {'title':'Hello','adress':'Hello','task':'Hello','times':'Hello','dates':'Hello','city':'Hello','views':    'Hello','status':'Hello','worker':'Hello','name':'Hello','phone': 'Hello','price': 'Hello','stavka':'Hello','userid': 'Hello'};
    // dataform = '{"title":"Hello","adress":"Hello","task":"Hello","times":"Hello","dates":"Hello","city":"Hello","views": "Hello","status":"Hello","worker":"Hello","name":"Hello","phone": "Hello","price": "Hello","stavka":"Hello","userid": "Hello"}';
    void  postApi() async {
    var   catJson = await CatAPI().addOrderApi(body);
    setState(() {
      print(catJson);  
    });
  }


  @override
  void initState() {
    super.initState();
    postApi();
  }


  @override
  Widget build(BuildContext context) {

    return Scaffold(
      extendBodyBehindAppBar: true,
      body: Container(
        decoration: BoxDecoration(
          color: Color.fromARGB(255, 255, 255, 255),
        ),
        child: Container(

        child: SingleChildScrollView(
       padding: const EdgeInsets.symmetric(horizontal: 36.0),

      child: Column(

        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: <Widget>[

        SizedBox(height: 10.0),
        Row(
        children:<Widget>[
          Text("Создание заказа" ,style: TextStyle(
                color: Color.fromARGB(255, 0, 0, 0),
                fontWeight: FontWeight.w400,
                fontSize: 23,
              ),),]),

          SizedBox(height: 18.0),
          TextFormField(
            keyboardType: TextInputType.text,
            maxLength: 10,
            decoration: const InputDecoration(
                border: OutlineInputBorder(),
                labelText: 'Название задачи',
                prefixText: '',
                suffixText: '',
                suffixStyle: TextStyle(color: Colors.green)),
            maxLines: 1,
          ),

          SizedBox(height: 18.0),
          TextFormField(
             maxLength: 200,
            decoration: const InputDecoration(
              border: OutlineInputBorder(),
              hintText: 'Опишите задачу подробно',
              helperText: 'Максимум 200 символов.',
              labelText: 'Подробное описание задачи',
            ),
            maxLines: 3,
          ),

/////////////////////////////////////////////////////////////////
              SizedBox(height: 18.0),
              DateTimeField(
              decoration: const InputDecoration(
              border: OutlineInputBorder(),
              icon: Icon(Icons.date_range),
              labelText: 'Укажите дату выполнения работ',
              prefixText: '',
              suffixText: '',
              suffixStyle: TextStyle(color: Colors.green)),
              format: formatdate,           
              onShowPicker: (context, currentValue) {
              return showDatePicker(
              context: context,
              firstDate: DateTime(1900),
              initialDate: currentValue ?? DateTime.now(),
              lastDate: DateTime(2100));
              },),

 //////////////////////////////////  
             SizedBox(height: 18.0),           
             DateTimeField(
             format: formattime,
             decoration: const InputDecoration(
              border: OutlineInputBorder(),
              icon: Icon(Icons.timer),
              labelText: 'Укажите время выполнения работ',
              prefixText: '',
              suffixText: '',
              suffixStyle: TextStyle(color: Colors.green)),
             onShowPicker: (context, currentValue) async {
             final time = await showTimePicker(
              context: context,
            initialTime: TimeOfDay.fromDateTime(currentValue ?? DateTime.now()),
             );
            return DateTimeField.convert(time);
             },
             ),
//////////////////////////////////////////////////     
          SizedBox(height: 18.0),
          TextFormField( 
              maxLength: 2,
              decoration: const InputDecoration(
              border: OutlineInputBorder(),
              icon: Icon(Icons.people),
              labelText: 'Сколько нужно человек?',
              prefixText: '',
              suffixText: '',
              suffixStyle: TextStyle(color: Colors.green)),
              keyboardType: TextInputType.number,
          ),

          SizedBox(height: 18.0),
          TextFormField(
            maxLength: 6,
            keyboardType: TextInputType.number,
            decoration: const InputDecoration(
                icon: Icon(Icons.payment),
                border: OutlineInputBorder(),
                labelText: 'Укажите оплату на человека в час',
                prefixText: '',
                suffixText: 'Руб',
                suffixStyle: TextStyle(color: Colors.green)),
                maxLines: 1,
          ),


          SizedBox(height: 18.0),
          TextFormField(
            maxLength: 30,
            keyboardType: TextInputType.text,
            decoration: const InputDecoration(
                icon: Icon(Icons.gps_fixed),
                border: OutlineInputBorder(),
                labelText: 'Адрес',
                prefixText: '',
                suffixText: '',
                suffixStyle: TextStyle(color: Colors.green)),
                maxLines: 1,
          ),

          SizedBox(height: 24.0),
           RaisedButton(
           color: Colors.blue,
           child: Text("Отправить",style: TextStyle(
                color: Colors.white,
                fontWeight: FontWeight.w400,
                fontSize: 14,
              ),),
           onPressed: (){postApi();},
           ),
        ],
      ),

         ),
        ),
      ),
       );
  }
}
listview
  • 1 个回答
  • 10 Views
Martin Hope
Денис Акулов
Asked: 2020-01-19 17:09:17 +0000 UTC

Flutter 在单独的小部件中填充列表视图项

  • 0

告诉我如何填写我在单独的小部件中拥有的项目,或者我需要在那里

Group84ItemWidget()

在此处输入图像描述

class OrderTestWidget extends StatefulWidget {

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

  final String title;
  @override
  _OrderTestWidgetState createState() => _OrderTestWidgetState();


}


class _OrderTestWidgetState extends State<OrderTestWidget> {


  var breedList = Order();
  void getCatData() async {
    var catJson = await CatAPI().getCatBreeds();
    print(catJson);
    var catMap = json.decode(catJson);
        print(catMap);
    setState(() {
      breedList = Order.fromJson(catMap);

      print(breedList.orderdata);  
    });
  }

  @override
  void initState() {
    super.initState();
    getCatData();
  }

  @override
  Widget build(BuildContext context) { 
    return Scaffold(
      extendBodyBehindAppBar: true,
      appBar: AppBar(
        title: Text(
          AppLocalizations.of(context).ordertestwidgetTitle,
          textAlign: TextAlign.center,
          style: TextStyle(
            color: AppColors.secondaryText,
            fontWeight: FontWeight.w400,
            fontSize: 21,
          ),
        ),
        automaticallyImplyLeading: false,
        backgroundColor: Color.fromARGB(255, 0, 163, 238),
      ),
      body: Container(
        constraints: BoxConstraints.expand(),
        decoration: BoxDecoration(
          color: Color.fromARGB(0, 0, 0, 0),
        ),
        child: Column(       
          crossAxisAlignment: CrossAxisAlignment.stretch,

          children: [     
            Container(
              width: MediaQuery.of(context).size.width,
              height: MediaQuery.of(context).size.height,
              child:  ListView.builder(
              itemCount: (breedList == null ||
              breedList.orderdata == null ||
              breedList.orderdata.length == 0)
              ? 0
              : breedList.orderdata.length,
              //  itemCount: 15,
              itemBuilder: (context, index) {

              return GestureDetector(

                onTap: () {
                Navigator.push(context, MaterialPageRoute(builder: (context) {
                return OrderDetaliWidget(catId: breedList.orderdata[index].id,catBreed: breedList.orderdata[index].name);
                }));},

                child: Card (child: Group84ItemWidget(),),

                );
              },
            ),
            )
          ],
        ),
      ),
    );
  }
}

模型

@JsonSerializable()
class Order {
  String apistatus;
  String apimessage;
  List<OrderData> orderdata;
  Order({this.apistatus,this.apimessage,this.orderdata});

  factory Order.fromJson(Map<String, dynamic> parsedJson) {
  var list = parsedJson['data'] as List;
   // print(list.toString());
    List<OrderData> dataList = list.map((i) => OrderData.fromJson(i)).toList();        
    return Order( 
           apistatus:parsedJson['api_status'].toString(),
           apimessage:parsedJson['api_message'],    
           orderdata: dataList
           );         
      }
}

这里的 Group84ItemWidget 只是静态填充的左侧数据,我需要从请求中用数据填充它们,而 Group84ItemWidget 也指 Group81ItemWidget 有一个 gridview with users

class Group84ItemWidget extends StatelessWidget { 
  void onButtonPressed(BuildContext context) { 
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      constraints: BoxConstraints.expand(height: 300),
      decoration: BoxDecoration(
       // color: AppColors.primaryText,
        boxShadow: [
         // Shadows.secondaryShadow,
        ],
        borderRadius: BorderRadius.all(Radius.circular(35)),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: [
          //заголовок
          Align(
            alignment: Alignment.topLeft,
            child: Container(
              margin: EdgeInsets.only(left: 11, top: 12),
              child: Text(
                AppLocalizations.of(context).group84itemwidgetTextTirleText,
                textAlign: TextAlign.left,
                style: TextStyle(
                  color: Color.fromARGB(255, 0, 0, 0),
                  fontWeight: FontWeight.w400,
                  fontSize: 16,
                ),
              ),
            ),
          ),
          Align(
            //текст описания задания
            alignment: Alignment.topLeft,
            child: Container(
              width: 350,
              height: 75,
              margin: EdgeInsets.only(left: 11, top: 5),
              child: Text(
                AppLocalizations.of(context).group84itemwidgetTextSubtitleText,
                textAlign: TextAlign.left,
                style: TextStyle(
                  color: Color.fromARGB(255, 0, 0, 0),
                  fontWeight: FontWeight.w400,
                  fontSize: 11,
                  height: 1.2,
                ),
              ),
            ),
          ),
          Container(
            height: 90,
            margin: EdgeInsets.only(left: 11, top: 8, right: 8),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.stretch,
              children: [
                //григ с воркерами
                Align(
                  alignment: Alignment.topLeft,
                  child: Container(
                    width: 300,
                    height: 90,
                    child: GridView.builder(
                      scrollDirection: Axis.horizontal,
                      gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
                        maxCrossAxisExtent: 90.42969,
                        childAspectRatio: 1.48245,
                        mainAxisSpacing: 10,
                      ),
                      itemBuilder: (context, index) => Group81ItemWidget(),
                    ),
                  ),
                ),
                Expanded(
                  flex: 1,

                  child: Align(
                    alignment: Alignment.topLeft,

                    //высота контейнера с ценой
                    child: Container(              
                     // color: AppColors.color4,
                      height: 70,
                      margin: EdgeInsets.only(left: 15, top: 0),
                      child: Column(                     
                        crossAxisAlignment: CrossAxisAlignment.stretch,
                        children: [
                          Align(
                            //текст цена за час
                            alignment: Alignment.topRight,
                            child: Container(
                              width: 68,
                              height: 30,
                              child: Text(
                                AppLocalizations.of(context).group84itemwidgetBatttonAddText,
                                textAlign: TextAlign.center,
                                style: TextStyle(
                                  color: Color.fromARGB(255, 0, 0, 0),
                                  fontWeight: FontWeight.w400,
                                  fontSize: 28,
                                ),
                              ),
                            ),
                          ),
                          //текст час или день
                          Align(
                            alignment: Alignment.center,
                            child: Container(
                              width: 50,

                              child: Text(
                                AppLocalizations.of(context).group84itemwidgetLabelText,
                                textAlign: TextAlign.center,
                                style: TextStyle(
                                  color: Color.fromARGB(255, 0, 0, 0),
                                  fontWeight: FontWeight.w400,
                                  fontSize: 24,
                                ),
                              ),
                            ),
                          ),
                        ],
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
          Expanded(
            flex: 1,
            child: Container(
              margin: EdgeInsets.only(left: 15, top: 16, right: 8, bottom: 14),
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: [
                  Align(
                    alignment: Alignment.bottomLeft,
                    child: Container(
                      width: 206,
                      height: 48,
                      margin: EdgeInsets.only(bottom: 7),
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.end,
                        crossAxisAlignment: CrossAxisAlignment.stretch,
                        children: [
                          Align(
                            alignment: Alignment.topLeft,
                            child: Container(
                              width: 206,
                              height: 20,
                              margin: EdgeInsets.only(bottom: 10),
                              child: Stack(
                                alignment: Alignment.center,
                                children: [
                                  Positioned(
                                    left: 19,
                                    bottom: 4,
                                    child: Text(
                                      AppLocalizations.of(context).group84itemwidgetTextAdressText,
                                      textAlign: TextAlign.left,
                                      style: TextStyle(
                                        color: AppColors.black,
                                        fontWeight: FontWeight.w400,
                                        fontSize: 16,
                                      ),
                                    ),
                                  ),
                                  Positioned(
                                    left: 0,
                                    bottom: 8,
                                    child: Image.asset(
                                      "assets/images/path-285.png",
                                      fit: BoxFit.none,
                                    ),
                                  ),
                                ],
                              ),
                            ),
                          ),
                          Align(
                            alignment: Alignment.topLeft,
                            child: Container(
                              width: 191,
                              height: 16,
                              margin: EdgeInsets.only(left: 3),
                              child: Row(
                                crossAxisAlignment: CrossAxisAlignment.stretch,
                                children: [
                                  Align(
                                    alignment: Alignment.bottomLeft,
                                    child: Container(
                                      width: 17,
                                      height: 17,
                                      child: Image.asset(
                                        "assets/images/path-287.png",
                                        fit: BoxFit.none,
                                      ),
                                    ),
                                  ),
                                  Align(
                                    alignment: Alignment.bottomLeft,
                                    child: Container(
                                      width: 84,
                                      height: 15,
                                      margin: EdgeInsets.only(left: 8, bottom: 1),
                                      child: Text(
                                        AppLocalizations.of(context).group84itemwidgetTextDateText,
                                        textAlign: TextAlign.left,
                                        style: TextStyle(
                                          color: AppColors.black,
                                          fontWeight: FontWeight.w400,
                                          fontSize: 15,
                                        ),
                                      ),
                                    ),
                                  ),
                                  Align(
                                    alignment: Alignment.bottomLeft,
                                    child: Container(
                                      width: 17,
                                      height: 17,
                                      margin: EdgeInsets.only(left: 14),
                                      child: Image.asset(
                                        "assets/images/time.png",
                                        fit: BoxFit.none,
                                      ),
                                    ),
                                  ),
                                  //текст время
                                  Align(
                                    alignment: Alignment.bottomLeft,
                                    child: Container(
                                      width: 45,
                                      margin: EdgeInsets.only(left: 6, bottom: 1),
                                      child: Text(
                                        AppLocalizations.of(context).group84itemwidgetTextTimeText,
                                        textAlign: TextAlign.left,
                                        style: TextStyle(
                                          color: AppColors.black,
                                          fontWeight: FontWeight.w400,
                                          fontSize: 15,
                                        ),
                                      ),
                                    ),
                                  ),
                                ],
                              ),
                            ),
                          ),
                        ],
                      ),
                    ),
                  ),
                  Spacer(),
                  Align(
                    alignment: Alignment.bottomLeft,
                    child: Container(
                      width: 55,
                      height: 55,
                      margin: EdgeInsets.only(right: 13),
                      child: Stack(
                        alignment: Alignment.center,
                        children: [
                          Positioned(
                            right: 0,
                            bottom: 0,
                            child: Container(
                              width: 55,
                              height: 55,
                              decoration: BoxDecoration(
                                boxShadow: [
                                  //тень круга с воркерами
                                  BoxShadow(
                                    color: Color.fromARGB(0, 0, 0, 0),
                                    offset: Offset(0, 0),
                                    blurRadius: 6,
                                  ),
                                ],
                              ),
                              child: Image.asset(
                                "assets/images/path-301.png",
                                fit: BoxFit.none,
                              ),
                            ),
                          ),
                          Positioned(
                            right: 16,
                            bottom: 23,
                            child: Text(
                              AppLocalizations.of(context).group84itemwidgetTextWorkerText,
                              textAlign: TextAlign.left,
                              style: TextStyle(
                                color: AppColors.primaryText,
                                fontWeight: FontWeight.w400,
                                fontSize: 24,
                              ),
                            ),
                          ),
                          Positioned(
                            right: 6,
                            bottom: 12,
                            child: Text(
                              AppLocalizations.of(context).group84itemwidgetTextWorkerCountText,
                              textAlign: TextAlign.left,
                              style: TextStyle(
                                color: AppColors.primaryText,
                                fontWeight: FontWeight.w400,
                                fontSize: 12,
                              ),
                            ),
                          ),
                        ],
                      ),
                    ),
                  ),
                  Align(
                    alignment: Alignment.topLeft,
                    child: Container(
                      width: 66,
                      height: 44,
                      margin: EdgeInsets.only(left: 13, top: 4),
                      child: FlatButton(
                        onPressed: () => this.onButtonPressed(context),
                        color: AppColors.primaryElement,
                        shape: RoundedRectangleBorder(
                          borderRadius: BorderRadius.all(Radius.circular(20)),
                        ),
                        textColor: Color.fromARGB(0, 0,0, 0),
                        padding: EdgeInsets.all(0),
                        child: Text(
                          AppLocalizations.of(context).group84itemwidgetButtonButton,
                          textAlign: TextAlign.left,
                          style: TextStyle(
                            color: Color.fromARGB(255, 255, 255, 255),
                            fontWeight: FontWeight.w400,
                            fontSize: 14,
                          ),
                        ),
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }
}
listview
  • 1 个回答
  • 10 Views
Martin Hope
Денис Акулов
Asked: 2020-01-18 11:36:43 +0000 UTC

Flutter ListView 全屏

  • 0

如何将列表视图扩展到全屏

class OrderTestWidget extends StatelessWidget { 
  @override
  Widget build(BuildContext context) { 
    return Scaffold(
      extendBodyBehindAppBar: true,
      appBar: AppBar(
        title: Text(
          AppLocalizations.of(context).ordertestwidgetTitle,
          textAlign: TextAlign.center,
          style: TextStyle(
            color: AppColors.secondaryText,
            fontWeight: FontWeight.w400,
            fontSize: 21,
          ),
        ),
        automaticallyImplyLeading: false,
        backgroundColor: Color.fromARGB(255, 0, 163, 238),
      ),
      body: Container(
        constraints: BoxConstraints.expand(),
        decoration: BoxDecoration(
          color: Color.fromARGB(0, 0, 0, 0),
        ),
        child: Column(

          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [

            Container(
              width: 363,
              height: 1000,
              child:  ListView.builder(
                itemCount: 15,
                itemBuilder: (context, index) {

                 return Card (
                 child: Group84ItemWidget(),
                 );
               },
              ),
            ),
          ],
        ),
      ),
    );
  }
}
listview
  • 1 个回答
  • 10 Views
Martin Hope
Денис Акулов
Asked: 2020-12-13 12:16:08 +0000 UTC

Javascript Array 遍历数组

  • 1

我可以动态创建组,每个组都有自己的价格。

该网站有一个表格:

在此处输入图像描述

有必要在 1-10 范围内的第一组一个价格从 10-20 另一个等。最后一组根据请求显示文本价格在最后一组字段中输入的任何文本:

在此处输入图像描述

group_count =1     
diapazon_ot[group_count] =  1;
diapazon_do[group_count] =  10;
czena_na_cheloveka[group_count] =  5;

group_count =2      
diapazon_ot[group_count] =  10;
diapazon_do[group_count] =  20;
czena_na_cheloveka[group_count] =  10;

group_count =3      
diapazon_ot[group_count] =  20;
diapazon_do[group_count] =  30;
czena_na_cheloveka[group_count] =  15;

group_count =4     
diapazon_ot[group_count] =  30;
diapazon_do[group_count] =  40;
czena_na_cheloveka[group_count] =  "Цена индивидуальна ";

最后一组没有问题,像这样可以是成年人这是来自天主教徒的形式

//выше этого индивидуально
if (adults > diapazon_do.length) {
    alert( 'Максимум' );                                          
    var  person_max = czena_na_cheloveka[diapazon_do.length];
}

在这里,据我了解,需要循环整理,但我就是不明白怎么做。

javascript
  • 2 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5