Flutter Blog Chris Sells Apr 30, 2020

Modern Flutter Plugin Development

Article Summary

Chris Sells and the Flutter team just dropped a masterclass on plugin architecture. If you're still using MethodChannels the old way, you're about to feel very behind.

The Flutter team published a comprehensive guide to modern plugin development in 2020, introducing Android Plugin API 2.0, federated plugins, and a new pubspec schema. This marked a fundamental shift in how Flutter plugins are architected across multiple platforms.

Key Takeaways

Critical Insight

Flutter plugins now support proper lifecycle management, explicit platform declarations, and federated architecture that lets multiple teams contribute platform-specific implementations without bottlenecks.

The article reveals why the old MethodChannel approach was actually a hidden technical debt bomb, and how the new architecture prevents a specific class of bugs that plagued production apps.

About This Article

Problem

Flutter plugins needed to initialize statically and couldn't handle multiple FlutterEngine instances at the same time. This meant all plugins had to start up when the app launched, even if they weren't needed right away.

Solution

Chris Sells and the Flutter team built the FlutterPlugin interface with onAttachedToFlutterEngine() and onDetachedFromFlutterEngine() callbacks. Plugins could now load only when required and attach to specific engine instances.

Impact

Plugins can attach and detach multiple times as an app runs. This opened up more complex scenarios, like running several Flutter experiences at once inside a single Android application.