Skip to content

initial textScaleFactor on app first run is wrong #178238

@asaarnak

Description

@asaarnak

Steps to reproduce

  1. Set your Chrome > settings > appearance > font size to Large.
  2. flutter create test_web_font_scaling --platforms=web
  3. Copy example: https://api.flutter.dev/flutter/widgets/WidgetsBindingObserver/didChangeTextScaleFactor.html
  4. Fix late init error in example.
  5. flutter run --release
  6. Copy the URL in your chrome a few times in a new tab until the "Current scale factor" is not updated.

Expected results

Should show "Current scale factor: 1.25"

Actual results

Shows "Current scale factor: 1"

Code sample

Reproducible sample
import 'package:flutter/material.dart';

void main() {
  return runApp(const MaterialApp(home: TextScaleFactorReactor()));
}

class TextScaleFactorReactor extends StatefulWidget {
  const TextScaleFactorReactor({super.key});

  @override
  State<TextScaleFactorReactor> createState() => _TextScaleFactorReactorState();
}

class _TextScaleFactorReactorState extends State<TextScaleFactorReactor>
    with WidgetsBindingObserver {
  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addObserver(this);
  }

  @override
  void dispose() {
    WidgetsBinding.instance.removeObserver(this);
    super.dispose();
  }

  double _lastTextScaleFactor =
      WidgetsBinding.instance.platformDispatcher.textScaleFactor;

  @override
  void didChangeTextScaleFactor() {
    setState(() {
      _lastTextScaleFactor =
          WidgetsBinding.instance.platformDispatcher.textScaleFactor;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Text('Current scale factor: $_lastTextScaleFactor');
  }
}

Screenshots or Video

Screenshots 1. Update font size to Large: Image

Open new tab in normal chrome until the text scale is not updated:
Image

Press refresh:
Image

Logs

Flutter Doctor output

Doctor output
flutter doctor -v
[✓] Flutter (Channel stable, 3.35.7, on Ubuntu 25.10 6.17.0-6-generic, locale en_US.UTF-8) [42ms]
    • Flutter version 3.35.7 on channel stable at /A/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision adc9010625 (3 weeks ago), 2025-10-21 14:16:03 -0400
    • Engine revision 035316565a
    • Dart version 3.9.2
    • DevTools version 2.48.0
    • Feature flags: enable-web, enable-linux-desktop, no-enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-lldb-debugging

[✓] Chrome - develop for the web [13ms]
    • Chrome at google-chrome

[✓] Connected device (3 available) [212ms]
    • Chrome (web)      • chrome      • web-javascript • Google Chrome 142.0.7444.134

[✓] Network resources [334ms]
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

Labels

f: material designflutter/packages/flutter/material repository.found in release: 3.35Found to occur in 3.35found in release: 3.38Found to occur in 3.38frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-webOwned by Web platform team

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions