My old Flutter app has been complaining I need to do this migration for a while. Today I finally decided to do it.

flutter/flutter
Flutter makes it easy and fast to build beautiful apps for mobile and beyond. - flutter/flutter

Based on the criteria listed in the documentation, I determined that I should follow step 1b. However, the snippet was in Java, and my MainActivity was written in Kotlin.

I'm useless at Kotlin and the doc doesn't include a snippet in that language. Luckily someone else posted the corresponding snippet on a GitHub ticket.

Java snippet:

@Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
    GeneratedPluginRegistrant.registerWith(flutterEngine);
    new MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(), CHANNEL)
            .setMethodCallHandler(
                (call, result) -> {
                    // Your existing code
            }
    );
}

The Kotlin equivalent:

public class MainActivity extends FlutterActivity {
  @Override
  public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
    GeneratedPluginRegistrant.registerWith(flutterEngine);
  }
}

I tried it in my app and it worked fine.

And I filed this ticket so that the Flutter team can include the snippet in their official documentation.