Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR DART

flutter auto size text

add the flutter_screenutil package: https://pub.dev/packages/flutter_screenutil

then add .sp to the fontSize property of your text as follows:

import 'package:flutter_screenutil/flutter_screenutil.dart';

Center(
  child: Text(
   "Salty beans!",
   style: TextStyle(
     color: Colors.black,
     fontSize: 18.sp, // add .sp here
   ),
  )
)

the package also lets you auto size the height, width, radius of your widgets and also screenWidth/Height of your device:
use .h for height
use .w for width
use .r for radius
use .sw for screen-width
use .sh for screen-height
 
PREVIOUS NEXT
Tagged: #flutter #auto #size #text
ADD COMMENT
Topic
Name
4+3 =