简体   繁体   中英

Text widget is clipping (Flutter)

I'm designing a website using Flutter and the "Y" in my text is clipped. Here is a screenshot of my website: 剪切 Y

This happens at all aspect ratios and on all browsers. Here is my main.dart:

import 'package:flutter/material.dart';
import 'package:website/github_icon_icons.dart';
import 'package:url_launcher/url_launcher.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(brightness: Brightness.dark),
      home: Scaffold(
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              FittedBox(
                child: Text(
                  "James Harvey",
                  style: TextStyle(fontSize: 72),
                ),
              ),
              ButtonBar(
                //mainAxisAlignment: MainAxisAlignment.center,
                //crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisSize: MainAxisSize.min,
                children: <Widget>[
                  RaisedButton.icon(
                    icon: Icon(GithubIcon.github),
                    label: Text("Github"),
                    onPressed: () =>
                        launch("https://www.github.com/UnicornsOnLSD"),
                  ),
                  RaisedButton.icon(
                    icon: Icon(Icons.email),
                    label: Text("Email"),
                    onPressed: () => launch("mailto:jmsharvey771@gmail.com"),
                  )
                ],
              )
            ],
          ),
        ),
      ),
    );
  }
}

How could I ensure that my text properly fits without being clipped?

EDIT: I think this is a bug with Flutter since the website displays fine on Chrome but not Firefox. I've made an issue here: https://github.com/flutter/flutter/issues/49946

FittedBox class can take fit as Propertie try using it!

Try this:

FittedBox(
    fit: <select_fit_you_want>,
    child: Text('James Harvey', style: TextStyle(fontSize: 72),
    ),
),

Hope this helped!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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