erluxman / pdf_flutter

Flutter Widget to display PDF
Apache License 2.0
99 stars 51 forks source link

The plugin `pdf_flutter` uses a deprecated version of the Android embedding. #41

Open MobileMon opened 2 years ago

MobileMon commented 2 years ago

To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs. If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.

kmorpex commented 2 years ago

i have this problem too

emmaweberyd commented 2 years ago

Hi @erluxman! 👋 I’m working on a project that relies on your plugin. I get this deprecation warning too, and from looking into it and reading the migration guide posted above, it looks like it might be low hanging fruit 🍌🍎🍍.



I cloned your repo, and did two things to get rid of the warnings: 

 



1. Removed the line 
android:name="io.flutter.app.FutterApplication" within the application tags in the AndroidManifest.xml for the example. 

 



 



2. In the PdfFlutterPlugin.java I made sure that PdfFlutterPlugin implements FlutterPlugin. It came out looking like this:



package com.erluxman.pdf_flutter;

import io.flutter.plugin.common.PluginRegistry.Registrar;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import androidx.annotation.NonNull;

/** PdfFlutterPlugin */
public class PdfFlutterPlugin implements FlutterPlugin {
  /**
   * Legacy method for supporting apps that have not migrated to the v2 Android embedding
   */
  public static void registerWith(@NonNull Registrar registrar) {
    registrar
            .platformViewRegistry()
            .registerViewFactory(
                    "pdf_flutter_plugin", new PdfFlutterFactory(registrar.messenger()));
  }

  @Override
  public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
    binding
            .getPlatformViewRegistry()
            .registerViewFactory(
                    "pdf_flutter_plugin", new PdfFlutterFactory(binding.getBinaryMessenger()));
  }

  @Override
  public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {

  }
}

I'm not a contributor so I can't make a pull request but I thought I could at least open up a conversation about it. Where are we with this?

akadatsky commented 2 years ago

@emmaweberyd thanks for the tip, I sent a merge request with these changes: https://github.com/erluxman/pdf_flutter/pull/46

chiragnahata commented 2 years ago

When will it get merged and the latest update arrives. Please inform me as soon as it happens. I am unable to build the app for it. So please so the needful as soon as possible.

CARocha commented 1 year ago

How to install version that have this PR that solve this problem?