flutter icon indicating copy to clipboard operation
flutter copied to clipboard

Breaking: DiagnosticsNode.toStringDeep added wrapWidth parameter

Open passsy opened this issue 3 months ago • 3 comments

PR https://github.com/flutter/flutter/pull/154752 adds a new parameter to the toStringDeep method in 3.27.0-0.0.pre

  String toStringDeep({
    String prefixLineOne = '',
    String? prefixOtherLines,
    DiagnosticLevel minLevel = DiagnosticLevel.debug,
+   int wrapWidth = 65,
  }) {

This breakes existing Widgets that override toStringDeep like this in current state Flutter 3.24.4:

class BetterContainer extends Container {
  @override
  String toStringDeep({
    String prefixLineOne = '',
    String? prefixOtherLines,
    DiagnosticLevel minLevel = DiagnosticLevel.debug,
  }) {
    return "Custom toStringDeep Representation";
  }
}
'BetterContainer. toStringDeep' ('String Function({DiagnosticLevel minLevel, String prefixLineOne, String? prefixOtherLines})') isn't a valid override of 'DiagnosticableTree. toStringDeep' ('String Function({DiagnosticLevel minLevel, String prefixLineOne, String? prefixOtherLines, int wrapWidth})'). (Documentation) 
The member being overridden (diagnostics.dart:366).

Open source packages affected by this change:

  • https://github.com/ethanblake4/flutter_eval/blob/master/lib/src/widgets/text.dart#L83
  • https://github.com/passsy/spot/blob/main/lib/src/spot/text/any_text.dart#L227

Unfortunately, I couldn't come up with any workaround that would allow supporting the new and old version at the same time.

passsy avatar Oct 29 '24 16:10 passsy