Breaking change 52444: Make dart:io Platform abstract

93 views
Skip to first unread message

Brian Quinlan

unread,
May 18, 2023, 7:41:47 PM5/18/23
to anno...@dartlang.org
See discussion on breaking change: https://github.com/dart-lang/sdk/issues/52444

Change Intent

Add the abstract class modifier to the dart:io Platform class.

Justification

Platform only has static properties so there is no reason to make instances of it.

Impact

All code that constructs Platform (i.e. Platform()) will break. There is one known pattern where this is done: package:dcli implements a non-static extension on Platform to allow users to get the line ending for the platform i.e.

Platform().eol;

Mitigation

In Dart 3.1:

  • The constructor for Platform is deprecated.
  • Platform contains a lineTerminator property that obviates the need for the extension in package:dcli.

Before we mark Platform as abstract, I will remove the extension from package:dcli and give users some time to update their dependencies. Making the change in Dart 3.2 would give users an approximately 6 week period to update their dependencies and code.

Reply all
Reply to author
Forward
0 new messages