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
You can also wrap the text in a Wrap, use overflow in Text(overflow: TextOverflow.Ellipsis)
https://pub.dev/packages/auto_size_text