Skip to content

Commit

Permalink
doc:comment why not use const constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedAlaaInstabug committed Oct 31, 2024
1 parent 7414132 commit 476c29e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
import io.flutter.embedding.engine.renderer.FlutterRenderer;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.PluginRegistry;

public class InstabugFlutterPlugin implements FlutterPlugin, ActivityAware {
private static final String TAG = InstabugFlutterPlugin.class.getName();
Expand All @@ -39,6 +40,15 @@ public class InstabugFlutterPlugin implements FlutterPlugin, ActivityAware {

PrivateViewManager privateViewManager;

/**
* Embedding v1
*/
@SuppressWarnings("deprecation")
public static void registerWith(PluginRegistry.Registrar registrar) {
activity = registrar.activity();
register(registrar.context().getApplicationContext(), registrar.messenger(), (FlutterRenderer) registrar.textures());
}


@Override
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
Expand Down Expand Up @@ -69,7 +79,6 @@ public void onDetachedFromActivityForConfigChanges() {
@Override
public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) {
activity = binding.getActivity();

privateViewManager.setActivity(activity);

}
Expand All @@ -81,7 +90,7 @@ public void onDetachedFromActivity() {

}

private void register(Context context, BinaryMessenger messenger, FlutterRenderer renderer) {
private static void register(Context context, BinaryMessenger messenger, FlutterRenderer renderer) {
ApmApi.init(messenger);
BugReportingApi.init(messenger);
CrashReportingApi.init(messenger);
Expand All @@ -94,19 +103,4 @@ private void register(Context context, BinaryMessenger messenger, FlutterRendere
SurveysApi.init(messenger);
}

@Nullable
private static Bitmap takeScreenshot(FlutterRenderer renderer) {
try {
final View view = activity.getWindow().getDecorView().getRootView();

view.setDrawingCacheEnabled(true);
final Bitmap bitmap = renderer.getBitmap();
view.setDrawingCacheEnabled(false);

return bitmap;
} catch (Exception e) {
Log.e(TAG, "Failed to take screenshot using " + renderer.toString() + ". Cause: " + e);
return null;
}
}
}
1 change: 1 addition & 0 deletions lib/src/utils/private_views/instabug_private_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:instabug_flutter/src/utils/private_views/visibility_detector/vis
class InstabugPrivateView extends StatefulWidget {
final Widget child;

// Making the constructor const prevents the VisibilityDetector from detecting changes in the view,
// ignore: prefer_const_constructors_in_immutables
InstabugPrivateView({required this.child}) : super(key: null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:instabug_flutter/src/utils/private_views/visibility_detector/sli
class InstabugSliverPrivateView extends StatefulWidget {
final Widget sliver;

// Making the constructor const prevents the VisibilityDetector from detecting changes in the view,
// ignore: prefer_const_constructors_in_immutables
InstabugSliverPrivateView({Key? key, required this.sliver}) : super(key: key);

Expand Down

0 comments on commit 476c29e

Please sign in to comment.