Issue : Cant resolve symbol 'firebasemessaging' - flutter

I am using Firebase Cloud Messaging for getting notifications. I was getting proper notifications when my app was running but when my app was in background, I used to get this exception on arrival of the notification :
After some digging I got a solution for this where they performed the following changes :
My MyActivity.java :
package ......; /* Package Name*/
import android.os.Bundle;
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;
public class MainActivity extends FlutterActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
}
}
Application.java :
GeneratedPluginRegistrant.java
And I changed the 'android:name' of tag form "io.flutter.app.FlutterApplication" to ".Application" accordingly :
Now as you can see in the screenshots provided above ..... I am getting errors saying cannot revolves symbol 'Firebasemesseging' etc. (Same 'Cannot resolve' everywhere). Can anyone please help me to fix this error. I am a bit new to Flutter hence I am not sure how to solve this.
Thanks a lot in advance for the help.

Related

How do I use local auth and bar code scanner in the same flutter project?

I building a flutter app that scans bar codes and also uses biometric auth in it. The problem is for package local_auth
MainActivity.kt should be like
import io.flutter.embedding.android.FlutterFragmentActivity;
public class MainActivity extends FlutterFragmentActivity {
// ...
}
but for scaning bar codes MainActivity.kt should be like
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
}
else it don't work. How do I use them both in the same project?
Currently you have to replace FlutterActivity with FlutterFragmentActivity yourself in FlutterBarcodeScannerPlugin.java (like this).
So you would want to use a fork of the flutter_barcode_scanner plugin where FlutterFragmentActivity is used or you use some other barcode scanner plugin.

User isn't a type so it can't be used as a type argument

Recently i tried to develop some flutter apps using firebase, and i follow along the tutorial on the youtube how to make connection with it, but i got trouble when in the video, the person hover his cursor to some word, and it showed option for correction and add some library in it, and in my case, there's no option for adding the library, but to make some class or mixin.
Here's mine
And This is the tutorial
import 'package:firebase_auth/firebase_auth.dart';
import 'package:get/get.dart';
class AuthController extends GetxController{
static AuthController instance = Get.find();
Rx<User?> _user;
FirebaseAuth auth = FirebaseAuth.instance;
#override
void onReady(){
super.onReady();
_user = Rx<User?>(auth.currentUser)
}
}
The problem was in Rx<User?>, i already add the library manually, but still have the same error message
The name 'User' isn't a type so it can't be used as a type argument.
Android studio needs to re index the dependencies.
have a look at the solution here (similar case):
https://stackoverflow.com/a/24406882/11914081

Disable screenshot in flutter

How to disable screenshot in flutter? I have Kotlin file instead of MainActivity.java file. Please suggest full code with path where I need to change for disable screenshot in my app.
package com.quotster.untitled
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
}
If you want to do that in Android only you can use flutter_windowmanager and add FLAG_SECURE.
await FlutterWindowManager.addFlags(FlutterWindowManager.FLAG_SECURE);

In flutter how to prevent screenshot to secure my app for android part in kotlin

In my flutter app, it supports the kotlin for android part. i can't find a code to prevent the screeenshot in app which is written in kotlin language. I searched over the google then i found the code that is written in java language but i require the kotlin code to prevent the screenshot.
package com.example.schoolbells
import io.flutter.embedding.android.FlutterActivity
import android.os.Bundle;
import androidx.annotation.NonNull;
import io.flutter.embedding.engine.FlutterEngine;
import android.view.WindowManager.LayoutParams;
class MainActivity: FlutterActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,WindowManager.LayoutParams.FLAG_SECURE);
}
}
getting this error in onCreate method
[ERROR] :Unresolved reference: WindowManagerkotlin(UNRESOLVED_REFERENCE)
I tried this code in kotlin but getting error.
Is there any other way to prevent screenshot in flutter?

ui4j - Possible to screenshot the whole page?

I would like to capture a screenshot of a website including content that you can only see if you scrolled down.
Is that possible?
EDIT:
I already tried https://github.com/ui4j/ui4j/blob/master/ui4j-sample/src/main/java/com/ui4j/sample/ScreenCapture.java, but it did not capture the whole page, just the visible portion(inside my monitor's viewport).
page.show(true);
page.captureScreen(new FileOutputStream(file));
Yes, you could capture screenshot of the whole page with ui4j. Sample code:
package com.ui4j.sample;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import com.ui4j.api.browser.BrowserFactory;
import com.ui4j.api.browser.Page;
public class ScreenCapture {
public static void main(String[] args) throws FileNotFoundException {
Page page = BrowserFactory.getWebKit().navigate("https://www.google.com");
page.show(true);
page.captureScreen(new FileOutputStream(new File("google.png")));
}
}
Alternative solution:
I highly recommend to use cdp4j library for full page screen capture. Its a Java library which help to automate Chrome/Chromium based browser. Here is the sample code.