Skip to content

[flutter_tools] ErrorHandlingFile.readAsStringSync drops encoding parameter #196225

Closed

Description

@bkonyi

ErrorHandlingFile.readAsStringSync({Encoding encoding = utf8}) ignores its encoding parameter and calls delegate.readAsStringSync(), forcing UTF-8 decoding even when callers specify another codec (unlike readAsString, readAsLines, and readAsLinesSync, which forward encoding).

Because flutter_tools wraps LocalFileSystem in ErrorHandlingFileSystem, callers such as ScreenshotCommand.ensureOutputIsNotJsonRpcError (which passes encoding: const AsciiCodec(allowInvalid: true) when checking small screenshot files for JSON-RPC error payloads) crash with FileSystemException: Failed to decode data using encoding 'utf-8':

FileSystemException: Failed to decode data using encoding 'utf-8', path = '.../flutter_01.skp'
#0      _File._tryDecode (dart:io/file_impl.dart:704:7)
#1      _File.readAsStringSync (dart:io/file_impl.dart:715:7)
#2      ForwardingFile.readAsStringSync (package:file/src/forwarding/forwarding_file.dart:99:16)
#3      ErrorHandlingFile.readAsStringSync.<anonymous closure> (package:flutter_tools/src/base/error_handling_io.dart:258:22)
#4      _runSync (package:flutter_tools/src/base/error_handling_io.dart:1116:16)
#5      ErrorHandlingFile.readAsStringSync (package:flutter_tools/src/base/error_handling_io.dart:257:12)
#6      ScreenshotCommand.ensureOutputIsNotJsonRpcError (package:flutter_tools/src/commands/screenshot.dart:198:39)
#7      ScreenshotCommand.runSkia (package:flutter_tools/src/commands/screenshot.dart:180:5)

Activity

  1. added
    c: crashStack traces logged to the console
    toolAffects the "flutter" command-line tool. See also t: labels.
    P2Important issues not at the top of the work list
    team-toolOwned by Flutter Tool team
    triaged-toolTriaged by Flutter Tool team
    on Nov 9, 2026
  2. added a commit that references this issue on Nov 12, 2026
    0e1f50f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: crashStack traces logged to the consoleteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions