You can determine if the user has modified the default font size in the flutter mobile app using MediaQuery textScaleFactor.
Here is how the example works.
Here is the complete code from main.dart file.
import 'package:flutter/material.dart';
void main(List<String> args) {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@
override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
body: MyWidget(),
),
);
}
}
class MyWidget extends StatelessWidget {
const MyWidget({
super.key,
});
@
override
Widget build(BuildContext context) {
var fontScaling = MediaQuery.of(context).textScaleFactor;
return Center(
child: Text(
'$fontScaling
',
style: const TextStyle(fontSize: 50.0),
),
);
}
}
Hope this is useful to you.Thanks,
Srikanth