Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I increase font size in Dart

Tags:

flutter

dart

I'm new in Flutter+Dart and trying to increase font size but hard to understand documentation + implement to my work. Here is the file. How can I solve my problem?

import 'package:flutter/material.dart';

void main() => runApp(NewApp());



class NewApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('App Header'),
        ),
        body:  new Column(
          children: [
            new Container(
              margin: new EdgeInsets.all(10.0),
              child: new Card(
                child: new Column(
                  children: <Widget>[
                    new Container(
                      padding: new EdgeInsets.all(10.0),
                      child: new Text('Hello Macaw'),
                    ),
                  ],
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
like image 214
Macaw Avatar asked Oct 08 '18 21:10

Macaw


People also ask

How do I increase font size in Flutter?

, style: TextStyle(fontSize: 25), ), Change the value for fontSize to change the font size of text in Text Widget.


2 Answers

At the beginning this is hard to understand and implement. But once you understand, you will fall in love with the Flutter framework. Here is the solution:

new Text('Hello Macaw',style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold),),

After that, format the code. That's it. Let me know if it works.

like image 166
just don't be user123 Avatar answered Oct 01 '22 01:10

just don't be user123


You can use style property of Text to change some of the property of the Text.

Example:

Text(
    "Your text",
     style: TextStyle(
      fontSize: 20.0,
      color: Colors.red,
      fontWeight: FontWeight.w600,
    ),
  )

It's a good practice to use predefined style for Text which gives you standard fontSize and fontWeight for the Text.

You can use them like this

style: Theme.of(context).textTheme.XYZ

XYZ can be body1, body2, title, subhead, headline etc.

like image 23
CopsOnRoad Avatar answered Oct 01 '22 02:10

CopsOnRoad