Not able to get current View from Android native (Java) when used in Flutter

I have my own Android SDK/library where I get the user’s current view using _window.getDecorView() to get an image of that view using below code and it’s working fine in Android Native.

Bitmap bitmap = Bitmap.createBitmap(512, 1024, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
v.draw(canvas);

But when I use this library in a Flutter app (via a Flutter plugin), I am getting only white image.