How to dynamically resize text in Flutter?

后端 未结 7 1667
梦如初夏
梦如初夏 2021-01-31 06:53

I retrieve a piece of text from an API. I want to allot a set amount of space to it (say a max Container with width: 300.0 and height: 100.0). Sometimes, the piece of text fits

7条回答
  •  清歌不尽
    2021-01-31 07:48

    Responsive_Flutter, I had the same issues since reading your problem. I found it Works every time using this package to resize your fonts.

    This Flutter package is for scaling the size your apps UI and fontSize across different sized devices. (The example shows the top text using the Responsive_Flutter package and the bottom text without plugin.

    https://github.com/layounisl/responsive_flutter

    You can install in 30 seconds - 3 Steps

    1. Add dependencies to yaml file "responsive_flutter: ^0.0.4"
    2. import 'package:responsive_flutter/responsive_flutter.dart';
    3. child: Text("Responsive flutter", style: TextStyle(fontSize: ResponsiveFlutter.of(context).fontSize(3)),

提交回复
热议问题