繁体   English   中英

如何使用 flutter 创建一个原始按钮

[英]How to create a button raw using flutter

我想在卡片中创建 3 个与“crop top”字词对齐的按钮。 但我创建的按钮会引发错误。 我怎样才能正确解决这个问题? 我想正确放置它。 有人可以帮我更正我的代码吗?

错误>>未定义的名称“孩子”。

错误>>没有为“DetailsScreen”类型定义方法“Raw”

. 在此处输入图像描述

import 'package:flutter/material.dart';

class DetailsScreen extends StatelessWidget {
  const DetailsScreen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        backgroundColor: Colors.pinkAccent,


      ),
      body: Column(
        children: <Widget>[
          Expanded(
            child: Container(
              height: MediaQuery.of(context).size.height,
              width : MediaQuery.of(context).size.width,
              padding: const EdgeInsets.only(left:20),
              decoration: const BoxDecoration(
                image: DecorationImage(
                  image: AssetImage("assets/images/image23.png"),
                  fit: BoxFit.contain,
                ),
              ),
            ),
          ),


          Stack(
            alignment: Alignment.bottomRight,
            children: <Widget>[
              // Max Size
              Container(
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(30.0),
                  color: Colors.red.shade50,
                ),
                alignment: const Alignment(1, 1),
                height: 400,
                width: 350,
                child: Column(
                  children: [
                    Padding(
                      padding: const EdgeInsets.fromLTRB(0, 40, 200, 40),
                      child: Text(
                        "Crop Top",
                        style: TextStyle(
                            fontSize: 24,
                            color: Color(0xff262626),
                            fontWeight: FontWeight.w700),
                        textAlign: TextAlign.left,
                      ),
                    ),

                   child Raw (
                    Padding(
                      padding: const EdgeInsets.only(left: 275, right: 0 ),
                      child: SizedBox(
                        width: 25,
                        height: 25,
                        child: FloatingActionButton(
                            onPressed: () {},
                            backgroundColor: Colors.amber.shade100,
                            child: null),
                      ),
                    ),
                    Padding(
                      padding: const EdgeInsets.only(left: 250, right: 30,),
                      child: SizedBox(
                        width: 25,
                        height: 25,
                        child: FloatingActionButton(
                            onPressed: () {},
                            backgroundColor: Colors.purple,
                            child: null),
                      ),
                    ),
                    Padding(
                      padding: const EdgeInsets.only(left: 5, right: 0),
                      child: SizedBox(
                        width: 25,
                        height: 25,
                        child: FloatingActionButton(
                            onPressed: () {},
                            backgroundColor: Colors.red.shade300,
                            child: null),
                      ),
                    ),
                    ),
                    Padding(
                      padding: const EdgeInsets.fromLTRB(0, 0, 270, 10),
                      child: Text(
                        "Sizes",
                        style: TextStyle(
                            fontSize: 16,
                            color: Color(0xff262626),
                            fontWeight: FontWeight.w700),
                        textAlign: TextAlign.left,
                      ),
                    ),
                    // SizedBox(
                    //   height: 30,
                    // ),


                    Row(

                      mainAxisAlignment: MainAxisAlignment.spaceEvenly,

                      children: [
                        TextButton(
                          style: TextButton.styleFrom(
                            side: BorderSide(
                              color: Colors.black,
                            ),
                          ),
                          onPressed: () {
                            print('XS');
                          },
                          child: Text('XS'),
                        ),
                        TextButton(
                          style: TextButton.styleFrom(
                            side: BorderSide(
                              color: Colors.black,
                            ),
                          ),
                          onPressed: () {
                            print('X');
                          },
                          child: Text('S'),
                        ),
                        TextButton(
                          style: TextButton.styleFrom(
                            side: BorderSide(
                              color: Colors.black,
                            ),
                          ),
                          onPressed: () {
                            print('M');
                          },
                          child: Text('M'),
                        ),
                        TextButton(
                          style: TextButton.styleFrom(
                            side: BorderSide(
                              color: Colors.black,
                            ),
                          ),
                          onPressed: () {
                            print('L');
                          },
                          child: Text('L'),
                        ),
                        TextButton(
                          style: TextButton.styleFrom(
                            side: BorderSide(
                              color: Colors.black,
                            ),
                          ),
                          onPressed: () {
                            print('XL');
                          },
                          child: Text('XL'),
                        ),
                      ],
                    ),

                    SizedBox(
                      height: 30,
                    ),

                    Row(
                      children: [
                        Padding(
                          padding: const EdgeInsets.all(8.0),
                          child: Text(
                            "30% off",
                            style: TextStyle(
                                fontSize: 25,
                                color: Colors.purple,
                                fontWeight: FontWeight.w700),
                          ),
                        ),
                      ],

                    ),
                    SizedBox(
                      height: 30,
                    ),

                    Row(
                      children: const [
                        Padding(
                          padding: const EdgeInsets.all(8.0),
                          child: Text(
                            "Rs.2950",
                            style: TextStyle(
                                fontSize: 18,
                                color: Color(0xff8399A9),
                                fontWeight: FontWeight.w700,
                                decoration: TextDecoration.lineThrough),
                          ),
                        ),


                        Text(
                          "Rs.2750",
                          style: TextStyle(
                            fontSize: 24,
                            color: Color(0xff0DA75F),
                            fontWeight: FontWeight.w700,
                          ),
                        ),
                      ],
                    ),
                  ],
                ),


              ),





              Padding(
                padding: const EdgeInsets.fromLTRB(230, 110, 0, 40),
                child: ElevatedButton(
                  onPressed: () {},
                  child: const Text(
                    "Add to Cart ",
                  ),
                  style: ElevatedButton.styleFrom(
                    primary: Colors.pinkAccent,
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.only(
                        topLeft: Radius.circular(30),
                        bottomRight: Radius.circular(20),
                      ),
                    ),
                    padding: const EdgeInsets.all(28),
                  ),
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}

列表children:[]接受小部件。 Raw前面的child这个词没有意义。

因此'child' is not defined

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM