user17970363
user17970363

Reputation:

The named parameter 'fontSize' isn't defined. in flutter code

want to add 5 box containers display xs, s, m, l, xl sizes. but the code throwing errors. where should I correct this? please refer to the image here. I add a container to create those. I'm new to flutter and can anyone please help image of error how can I fix this.

error >> The named parameter 'fontSize' isn't defined. in flutter code error>> The named parameter 'fontWeight' isn't defined.

 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*.8,
          padding: EdgeInsets.all(10.0),

          decoration: const BoxDecoration(
            image: DecorationImage(
              image: AssetImage("assets/images/image23.png"),
              //fit: BoxFit.fitHeight,

            ),
          ),

        ),

          ),
                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: const [
                        Padding(
                       padding: const EdgeInsets.fromLTRB(10, 40, 100, 40),
                              child: Text(
                       "Summer  Collections",
                      style: TextStyle(
                          fontSize: 24,
                   color: Color(0xff262626),
                       fontWeight: FontWeight.w700),
                          textAlign: TextAlign.left,
    ),
    ),
                        Padding(
                          padding: const EdgeInsets.fromLTRB(0, 0, 270, 100),
                          child: Text(
                            "Sizes",
                            style: TextStyle(
                                fontSize: 12,
                                color: Color(0xff262626),
                                fontWeight: FontWeight.w700),
                            textAlign: TextAlign.left,
                          ),
                        ),
                            ],
                          ),
                        )

                    Container(
                        child: Row(
                          children: [
                            Container(
                                height:49, width: 49,
                                decoration: BoxDecoration(
                                    color: Color.fromRGBO(228, 228, 228, 1),
                                    borderRadius: BorderRadius.circular(10)
                                ),
                                child:const Center(
                                  child:Text("xs",
                                      fontSize:20,
                                      fontWeight:FontWeight.bold

                                  ),
                                ),
                            )

    ],




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



               ]
                    ),

                  ],
                ),



    );
  }
}

Upvotes: 7

Views: 2095

Answers (7)

Kaushik Ghori
Kaushik Ghori

Reputation: 11

used this:-

Center(
  child: Text(
    "xs",
    style: TextStyle(
      fontSize: 20,
      fontWeight: FontWeight.bold,
    ),
  ),
), 

Upvotes: 0

Masum Billah Sanjid
Masum Billah Sanjid

Reputation: 1189

This is the correct way to use TextStyle. reference.

Text(
    'text',
     style: TextStyle(
             fontSize: 20,
             fontWeight: FontWeight.bold),
     ),

Upvotes: 3

Major Akash
Major Akash

Reputation: 209

This is the props of textStyle of Text widget, So first you have to give textstyle of Text widget, then set this.

 Text(
"Helo world",
style: TextStyle(
  fontSize: 30,
  fontWeight: FontWeight.normal,
)),

Upvotes: 0

Navid Shokoufeh
Navid Shokoufeh

Reputation: 569

You should use TextStyle :

Text(
   "your text here" , 
    style: TextStyle(
        fontsize: ,
        fontWeight: 
         ),
     )

Upvotes: 2

Put the text styles in a TextStyle widget.

The problem here is pretty simple. The text widget does not have any attribute fontSize or font weight. Instead, it is the TextStyle widge.

This is how it works

const Center(
  child: Text("xs",
  style: TextStyle(
    fontSize: 22,
    fontWeight: FontWight.bold
  
  )
)

Upvotes: 0

Ravindra S. Patil
Ravindra S. Patil

Reputation: 14775

You have wrote a wrong code,Try below code hope its helpful to you.

Refer Text Class here

Refer TextStyle here

 Center(
  child: Text(
    "xs",
    style: TextStyle(
      fontSize: 20,
      fontWeight: FontWeight.bold,
    ),
  ),
),

Your Reslt Screen-> image

Upvotes: 0

Ferenc Orosi
Ferenc Orosi

Reputation: 265

You need TextStyle to change fontSize, color, fontWeight etc.

child: Text("xs", style: TextStyle(
    fontSize: 20,
    fontWeight: FontWeight.bold
  ),
),

Upvotes: 0

Related Questions