Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@jamesderlin
Copy link
Contributor

Make FlutterAppDelegate try to forward all unhandled messages to
its FlutterPluginAppLifeCycleDelegate so that it doesn't need to
explicitly forward for each application life cycle event (e.g.
applicationDidEnterBackground:, applicationWillEnterForeground:,
etc.).

This also greatly reduces the amount of code that should be copied
and pasted from FlutterAppDelegate if client applications cannot
directly inherit from it. Alternatively, it provides an example for
how client applications can use FlutterAppDelegate via composition
rather than inheritance (issue #20709).

(This is a scaled down version of #6086.)

…AppLifeCycleDelegate`

Make `FlutterAppDelegate` try to forward all unhandled messages to
its `FlutterPluginAppLifeCycleDelegate` so that it doesn't need to
explicitly forward for each application life cycle event (e.g.
`applicationDidEnterBackground:`, `applicationWillEnterForeground:`,
etc.).

This also greatly reduces the amount of code that should be copied
and pasted from `FlutterAppDelegate` if client applications cannot
directly inherit from it.  Alternatively, it provides an example for
how client applications can use `FlutterAppDelegate` via composition
rather than inheritance (issue #20709).
Copy link
Contributor

@chinmaygarde chinmaygarde left a comment

Choose a reason for hiding this comment

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

This seems very heavy handed and assumes that FlutterPluginAppLifeCycleDelegate can handle all unhandled (by FlutterAppDelegate) messages that are sent to it (and not just the ones it implements on its own). In general, I am always in favor of being explicit about what each class instead of adding dynamism (unless absolutely necessary). I understand that this might lead to more code in some cases.

@jamesderlin
Copy link
Contributor Author

How about if I replaced [_lifeCycleDelegate respondsToSelector:selector] with something like [_lifeCycleDelegate wantsSelector:selector] where -[FlutterPluginAppLifeCycleDelegate wantsSelector:] responds only to a hard-coded list of selectors (more like what I had in #6086)?

I know it doesn't seem like it buys us anything, but the recommendation from https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps is essentially to copy-and-paste the FlutterAppDelegate implementation if it can't be inherited from. That seems onerous, and if people actually do that, it potentially makes it harder to propagate some types of changes (such as adding some new lifecycle event, or possibly optionally hiding some to suppress warnings like flutter/flutter#9984).

@kf6gpe
Copy link
Contributor

kf6gpe commented Nov 7, 2018

@chinmaygarde --- do you have feedback on James's last comment above? Thanks!

@jamesderlin
Copy link
Contributor Author

Closing this since there's some pushback.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants