Hi Guys, Welcome to Proto Coders Point. So once i was trying to implement programmatically taking screenshot in android ap development and I faced a problem while saving the captured screenshot to gallery, & this is the error i got FileNotFoundException: open failed: EPERM (Operation not permitted), After lot’s of trial & error, finally got the solution to solve EPERM issue in android while saving file in android.
Let’s start to solve operation not permitted issue in android
How To Solve FileNotFoundException open failed: EPERM (Operation not permitted) Error
Here is a very simple soltion to easily solve FileNotFoundException open Failed: EPERM: You have to has a permission where you are allowing you android appliation to access External Storage, add it.
To add requestLegacyExternalStorage, just go to AndroidManifest.xml
Project > app > manifest > AndroidManifest.xml
Open it, then inside application tag add
android:requestLegacyExternalStorage=”true”
For Reference image:
make legacy extenal storage to true
Now, just Uninstall app and reinstall app it again & you will see your eror got successfully solved.
Hi Guys, Welcome to Proto Coders Point, In this flutter article will learn how can we programmatically take a screenshot in flutter. Add this feature into your flutter app so that users can take screenshot of the app screen when they want to, just by clicking a button.
Let’s get started – Taking Screenshot in flutter app
To capture our app screen will make use of flutter inBuilt widget i.e. RepaintBoundry.
Using RepaintBoundry widget
RePaintBoundry widget in flutter will capture the view of the child it wrapped with, For Example: if you wrap RepaintBoundry with Container Widget then your app will only capture that widget, suppose if you want to take screenshot of complete app screen then you need to wrap RePaintBoundry to Scaffold widget as done in below complete code. Then attach a GlobalKey to RepaintBoundry. Next, by using GlobalKey currentContext we can use .findRenderObject() method helps us in finding current render object. Next, will use toImage() method to convert render object to image. then, will convert image into byteData which will again get converted to asUint8List(). Next, will use the Uint8List format to save the screenshot by using ImageGallerySaver package.
Below method take screenshowt and save it.
void _CaptureScreenShot() async{
//get paint bound of your app screen or the widget which is wrapped with RepaintBoundary.
RenderRepaintBoundary bound = _key.currentContext!.findRenderObject() as RenderRepaintBoundary;
if(bound.debugNeedsPaint){
Timer(Duration(seconds: 1),()=>_CaptureScreenShot());
return null;
}
ui.Image image = await bound.toImage();
ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png);
// this will save image screenshot in gallery
if(byteData != null ){
Uint8List pngBytes = byteData.buffer.asUint8List();
final resultsave = await ImageGallerySaver.saveImage(Uint8List.fromList(pngBytes),quality: 90,name: 'screenshot-${DateTime.now()}.png');
print(resultsave);
}
}
Programmatically take screenshot in flutter
Complete Code implement to take screenshot in flutter in step
Step 1: Add ImageGallerySaver
In your flutter project, open pubspec.yaml file and under dependencies section add the image gallery saver flutter library.
dependencies:
image_gallery_saver: '^1.7.1'
Step 2: Add Permission to save image in galery
Android External Storage permission
Open manifest file, and under application tag add:
Hi Guys, Welcome to Proto Coders point. Here is a quick step by step guide to update nodejs in ubuntu OS.
Time needed: 3 minutes
update node version
use n module
To upgrade node version in ubuntu will make use of n module from npm package.
Install n module
Firstly install n module using npm run below command. sudo npm cache clean -f sudo npm install -g n sudo n stable …so now we have successfully install n module of npm package.
update node version ubuntu to latest
Now simply run below command, to upgrade nodejs and to update npm version. sudo n latest Note: this will update your nodejs and npm version to latest version(not to stable current version).
If node --version showing you old version still then simply, close and re-open new terminal and run node --version to check nodejs version updated or no.
The Cascade operator notation in flutter dart (..) is two dots, using cascade in dart we can make a sequence of operation using same object & we can even call a function & easily access field or parameter value. By using dart cascade notation (..) we can keep dart code neat & clean as it removes unnecessary temporary variable creation to store data.
Video Tutorial on Flutter Cascade Operator
Cascade Operator in dart example code
In below example We have created a class by name Person which has 2 variable and 1 method to print on console:
int? age;
String? name;
printDetails()
class person
class Person{
int? age;
String? name;
void printDetails(){
print("$name age is $age");
}
}
In Below Code,
Line No: 3 – > Create an object of Person as p1.
void main(){
Person p1 = Person(); // object creation
p1..name = "Rajat Palankar"..age = 26 ..printDetails();
// using cascade, initialize the value and call print function
}
Then, In line No: 5 -> using object, initialize the value to class variable and call printDetails method of Person Class.
In this Article will learn how to show git branch name with color in terminal (ubuntu)
Open bashrc file
Firstly open bashrc file by below cmd. gedit ~/.bashrc
Comment old color prompt
In ~/.bashrc file, you will find a code starting with if[“$color_prompt = yes”] and end’s with fi, just comment this like as shown in below screenshot for reference.
if [ "$color_prompt" = yes ]; then PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ ' else PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ ' fi
Reference Screenshot
Final done
Here is how your terminal shows branch name when you are into git repository project folder, In below screenshot as you can see we can easily get to know on which github branch we are working on(No need to keep on checking git branch -a).
Hi Guys, Welcome to Proto Coders Point, In this Article will learn how to connect to debian ubuntu server with “SSH connectioncommand” using local terminal.
Let’s get started, Follow below Steps for ubuntu ssh login.
How to login using ssh command in ubuntu terminal using pem file
If you have .pem file then jump to step 3, else you need to convert ppk to pem follow all steps as below:
Step 1: Install putty tools on Debian ubuntu
Open Terminal in your computer, and install putty, as it is needed to convert ppk to pem in step 2.
sudo apt-get install putty-tools
Step 2: Convert ppk to pem using putty
Now, once you have successfully installed putty on your ubuntu local system, let’s convert ppk file to pem by using below cmd:
The above cmd, will create pem file, for better understanding check out below screenshot.
convert ppk to pem file
Here micro_key.pem is the file that got generated successfully.
Step 3: change permission of pem file
You need to change the permission of the file to 400, means “user” with read only permission (4) and “group” & “other” with no permission (0). to use pem file.
change file access permission by below command:
chmod 400 <pemFileName>.pem
Step 4: ssh connect using pem file
Now connect to the ubuntu server using ssh with pem file, by using following command: