Skip to content

Convert Diagnosticable to a mixin#51495

Merged
gspencergoog merged 4 commits intoflutter:masterfrom
gspencergoog:remove_diagnosticable
Mar 11, 2020
Merged

Convert Diagnosticable to a mixin#51495
gspencergoog merged 4 commits intoflutter:masterfrom
gspencergoog:remove_diagnosticable

Conversation

@gspencergoog
Copy link
Copy Markdown
Contributor

@gspencergoog gspencergoog commented Feb 26, 2020

Description

This converts Diagnosticable to be a mixin instead of an abstract class, so that it can be used to add diagnostics to classes which already have a base class.

It leaves in place the DiagnosticableMixin mixin, since there are some plugins that are still using it, and removing it would mean that those plugins wouldn't work with master branch Flutter anymore. DiagnosticableMixin will be removed once this mixin version of Diagnosticable makes its way to the stable branch.

Related Issues

Tests

  • No tests are needed, since we're just changing from a class to a mixin: the implementation stays the same.

Breaking Change

  • No, this is not a breaking change, since no submitted customer tests use Diagnosticable.

@fluttergithubbot fluttergithubbot added a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Feb 26, 2020
@gspencergoog gspencergoog requested review from darrenaustin and removed request for HansMuller March 10, 2020 19:51
Copy link
Copy Markdown
Contributor

@darrenaustin darrenaustin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Too bad we can't compose mixins, as that would have removed some duplication between Diagnosticable and DiagnosticableMixin.

Otherwise, it LGTM.

const Diagnosticable();
/// _This mixin is exists only to support plugins that require older Flutter
/// versions: Use the identical mixin [Diagnosticable] instead for most code._
mixin DiagnosticableMixin implements Diagnosticable {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we intend to remove this, should it be marked as deprecated?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I definitely considered that, but mainly, I didn't want a plugin that wants to work with both master and stable to start throwing deprecation warnings on master: some projects would consider that an error and so they could no longer use that plugin on master, and the plugin author couldn't do anything about it until this change hit stable. So I decided to wait to deprecate it until the change reached stable.

@gspencergoog gspencergoog merged commit 210f4d8 into flutter:master Mar 11, 2020
@gspencergoog gspencergoog deleted the remove_diagnosticable branch March 11, 2020 17:03
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this change!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a trailing _ here. Also: "most code" could probably use some clarification.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's no trailing _, that's the end of the italics for the paragraph.

@HansMuller
Copy link
Copy Markdown
Contributor

I'd starting reviewing this some time ago and then neglected to even submit what I'd written. So FWIW, now that it's too late :-)

@gspencergoog
Copy link
Copy Markdown
Contributor Author

Did your writings uncover anything I should change?

@gspencergoog
Copy link
Copy Markdown
Contributor Author

(Oh, I had to refresh GitHub to see them)

@HansMuller
Copy link
Copy Markdown
Contributor

The point about "most code" might be worth considering. I suppose youu mean all new code? https://github.com/flutter/flutter/pull/51495/files/baa502ed72e8ebdb12ba13d5687ee37d7d03f9c0#diff-e656bb511c2aa740e42637a30e61aabc

@gspencergoog
Copy link
Copy Markdown
Contributor Author

The only code that needs to use that is plugin/package code that needs to work on stable. I'll clarify that, though.

@gspencergoog gspencergoog mentioned this pull request Mar 11, 2020
gspencergoog added a commit that referenced this pull request Mar 11, 2020
Just some very minor doc changes: an adjustment of my comments in #51495, and a typo fix.
@Zazo032
Copy link
Copy Markdown
Contributor

Zazo032 commented Mar 12, 2020

@gspencergoog this is breaking builds for apps that use this plugin: https://github.com/Realank/flutter_datetime_picker

Is there any migration guide to update the plugin?

@gspencergoog
Copy link
Copy Markdown
Contributor Author

gspencergoog commented Mar 12, 2020

@Zazo032 Sorry about that. There's no migration guide yet, but I'll make one today.

It's pretty straightforward, though:

If the plugin should be compatible with the stable channel and master channel, it should convert from this:

class MyClass extends Diagnosticable { ...

to this:

class MyClass with DiagnosticableMixin { ...

At a future time (once this change lands in stable), DiagnosticableMixin will be deprecated in favor of Diagnosticable and removed, however, so if the plugin only needs to be compatible with master, it can move directly to:

class MyClass with Diagnosticable { ...

and avoid the churn.

On the up side, this change also decreased code size by 1.3%...

@Zazo032
Copy link
Copy Markdown
Contributor

Zazo032 commented Mar 12, 2020

No problem, I filled a PR to fix the plugin. Thanks for the size reduction! It was 0.2mb on our appbundle 🔥

@lock
Copy link
Copy Markdown

lock Bot commented Apr 2, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@lock lock Bot locked and limited conversation to collaborators Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants