Home Blog Page 37

How to Create a Flutter Project in Visual Studio Code Editor

0
How to Create new Flutter Project in VSCODE EDITOR

Hi Guys, Welcome to Proto Coders Point. In this Flutter Article let’s Learn how to create a flutter project in VSCode.

Below are the requirement to create flutter project.

  1. VSCode IDE
  2. Dart SDK been downloaded and setuped.
  3. Flutter SDK been downloaded and setuped.

How to check Dart and Flutter are installed or no

Just Open Cmd prompt & enter below cmds.

dart --version

flutter --version

check if dart & flutter are instaled or not

If not setuped download it from below links

How to Download Dart SDK

How to Download Flutter SDK


How to create flutter project in vs code

Below are steps to create new flutter project in Visual Studio Code (IDE).

Step 1: Open VSCode & Install Dart & Flutter Extensions

In VsCode Editor, drawer at left you will find a extension page, search for dart & flutter extensions and install them both.

installing dart & flutter in vscode editor
dart & flutter extensions installed

Step 2: Creating flutter project in vscode editor

In vscode, Open command palette to do so, In menu bar > views > Command Palette or Ctrl _Shift + P.

Now Search for flutter project.

Then, here select Applcation.

generate a flutter application vscode

then, Now give name to your flutter_app

Now you need to just wait for it project creation process, it will just take 1 min or less.

then finally, our flutter project was successfully been create.

flutter project got successfully created in VSCode editor

Step 4: How to running flutter project on mobile device

Then, Once our flutter project is ready, To run it on physical device:

Connect the device through USB (make sure you have turned on USB Debugging Mode) or Wirelessly through TCP ID.

Run below cmd on VSCode Terminal to run flutter app :-

flutter run

cmd running flutter app in vscode
cmd running flutter app in vscode .JPG

App Running on my Mobile Device

How to install ubuntu on windows using WSL

0
How to Install ubuntu on Windows using WSL

Hi Guys, Welcome to Proto Coders Point. In this Article let’s Install ubuntu on windows by using Windows Subsystem for Linux (WSL).

So basically WSL will install the complete Ubuntu Linux Terminal envirnoment into your windows Operation System as a subsystem.

By installing WSL you can access Linux terminal & it’s file system on Windows and develop cross platform application without leaving windows.

Time needed: 2 minutes

Below are the Step to use WSL to Install ubuntu Terminal in Windows.

  1. Windows OS Requirement to install WSL

    To use WSL and install ubuntu, you need to first check your system OS specification
    1. OS – Windows 10 & above.
    2. Wins Build version should be 19041 and higher.

  2. Update Windows

    If installed version of Windows is less then 19041 then you need to update Windows, So To update to latest windows version -> In Search box search for Windows Update, open it and Check for Update.

  3. Open command Prompt

    Now Open cmd, and make sure you run it as adminstration.

  4. Install Ubuntu on Windows

    Now, In cmd prompt, you just need to type below WSL command.

    wsl --install

    This will Download and Install virtual machine with ubuntu on windows

  5. Restart your Computer

    Now, Once ubuntu is been installed in windows, To affect the changed you need to restart your Computer.

  6. Ubuntu setup on windows

    Then, After restarting, a ubuntu cmd will get opened automatically, On that window it will say “Installing ubuntu, Please wait for few minutes”. Once it get completed…
    It will ask you to enter username & password.
    Now you have successfully installed Ubuntu on Windows using WSL.WSL install windows

Video Tutorial on WSL

How to Install Redis on Windows & Ubuntu – Redis Installer .msi

0
install redis on windows
let install redis on windows

Hi Guys, Welcome to Proto Coders Point. This Article is on how to download and install redis on windows, I found out redis windows installer a .msi file by which, in just one click “install redis”.

Video Guide


What is Redis

Redis stands for “Remote Directory Server”, It’s an open source & fastest in-memory data storage CLI + Server, basically we can store data in redis in key-value pair, and is used by many developers to manage database, cache message broker & streaming engine.

When should we use Redis

Most of the time redis is used as an caching layer, As it’s an in-memory DB, That means, It keep the given data in-memory & is much faster if compared with MYSQL or NOSQL (Mongodb) query executions.

Redis can’t be used to store large data then 1/3 of RAM size, So it’s better not to use it to store huge data collections.

Can data Stored in Redis get lost

Yes, Data stored in Redis can get deleted but only when server instance is rebooted or terminated and in local PC if you shutdown you system.

Learn more about Redis on Official site


How to Install Redis on Windows

Below are the steps to install redis.

Step 1: Download redis .msi installer file

Offically, Redis not provide any direct installer file to install it on windows operating system but Microsoft has build a installer version of redis by which windows users can easily install redis on windows with just one click.

From above download link download .msi file.

redis windows installer

Step 2: Install redis using .msi installer

Start the installer by click on Redis-x64-3.0.504.msi

Don’t Forget to check tick box “add Redis installation foler to PATH envirnoment variable”
By Default, Redis run on port number 6379, Can it if you need some other port number for redis to run
Increase Redit max memory storage capacity, default is 100 MB.
Therefore, Redis is been successfully installed on Windows operating system.

Step 3: Start using Redis using CMD

On Windows, When you start your system, redis-server.exe will automatically get started and will be running in background.

To get connected to redis server and store some data in it, you can make use of redis-cli.

Just open CMD prompt and type “redis-cli”.

Here is a small example: storing data is redis memory by using set and get command.

Hope, This easiest method to install redis on win10 successfully worked for you.


How to Install Redis on Ubuntu

To Install latest stable version on Redis all you need to do is run below provided commands into Ubuntu/Linux Terminal one by one.

sudo apt install lsb-release
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
sudo apt-get update
sudo apt-get install redis

OR

If above Steps don’t work, Then you can Install Redis into Ubuntu system using Snapcraft

Install Redis via snap:

sudo snap install redis

How to give Borders to images in flutter

0
How to Add Border to images in flutter

Hi Guy’s Welcome to Proto Coders Point. In this flutter Article let’s learn how to add border to images in flutter.

In this Article will cover 4 example:

  • Flutter image with Border all side.
  • Flutter Image with rounded/circular borders
  • Flutter Image with one side border
  • Different border color at each side

As you all know to display Image in flutter we make use of Image Widget, But Flutter Image widget do not provide any properties to set a border to a image. To achieve border to any widget we can use Container widget in which we use decoration properties to set border.

Video Tutorial

Giving Border to Image in flutter

Example:

Container(
          decoration: BoxDecoration(
              // add border
              border: Border.all(/*  widget, color,..etc */),     
          // add image
          child: Image.asset(/* ..path to image. */),
),

In Detail Complete Code Example below.

Flutter Image with Border on all side – Example 1

This Example will create a Border around Image widget by using container, Inside container widget I have used decoration properties with BoxDecoration which has border property and then set Border on all the sides on child widget.

flutter image border code example

Source Code

body: SingleChildScrollView(
        child: Center(
          child: Column(
            children: [
              SizedBox(height: 10,),
              Container(
                width: 150,
                height: 220,
                decoration: BoxDecoration(
                  border: Border.all(width: 5,color: Colors.orange)
                ),
                  child: Image.asset('assets/img1.jpg',fit: BoxFit.fill,)
              ),
              
            ],
          ),
        ),
      ),

Flutter image with rounded border or circular borders

The Below Example will clip the edge of a image, To do so we make use of ClipRRect widget with borderRadius property.

ClipRRect(
                borderRadius: BorderRadius.circular(/*..20.*/),
                child: Image.asset(/* ... */),
),

Then to add border color, Container widget is been used with decoration as BoxDecoration.

flutter circular radius border

Source Code

body: SingleChildScrollView(
        child: Center(
          child: Column(
            children: [

              SizedBox(height: 10,),
              Container(
                decoration: BoxDecoration(
                  border: Border.all(width: 5,color: Colors.redAccent),
                  borderRadius: BorderRadius.circular(20)
                ),
                child: ClipRRect(
                  borderRadius: BorderRadius.circular(15),
                    child: Image.asset('assets/img2.jpg')
                ),
              ),
              SizedBox(height: 10,),
            
            ],
          ),
        ),
      ),

Flutter Image with one side border

Some time in flutter ui designing you may need border to be set only on one side of a widget, In that case you can make border set like this:

Container(
                  decoration: BoxDecoration(
                    border: Border(
                      left: BorderSide(width: 10,color: Colors.blue),
                      // Here use border properties left, right, top, bottom
                    )
                  ),
                    child: Image.asset('assets/img3.jpg')),

Here in border use properties like left, right, top, bottom.

flutter one side border

Source Code

body: SingleChildScrollView(
        child: Center(
          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.all(25.0),
                child: Container(
                  decoration: BoxDecoration(
                    border: Border(
                      left: BorderSide(width: 10,color: Colors.blue),
                      // Here you can make use of border properties left, right, top, bottom
                    )
                  ),
                    child: Image.asset('assets/img3.jpg')),
              ),
            ],
          ),
        ),
      ),

Flutter Different color border on each side

Flutter Different color border on each side

Source Code

body: SingleChildScrollView(
        child: Center(
          child: Column(
            children: [
              SizedBox(height: 10,),
              Padding(
                padding: const EdgeInsets.all(25.0),
                child: Container(
                  decoration: BoxDecoration(
                    border: Border(
                      left: BorderSide(width: 10,color: Colors.blue),
                      right: BorderSide(width: 10,color: Colors.redAccent),
                      bottom: BorderSide(width: 10,color: Colors.green),
                      top: BorderSide(width: 10,color: Colors.orange),
                    )
                  ),
                    child: Image.asset('assets/img3.jpg')),
              ),
            ],
          ),
        ),
      ),

How to Recover Access to AWS server if you lost the private key | AWS TUTORIAL

0
How to Recover Access to AWS server if you lost the private key | AWS TUTORIAL

Hi Guys, Welcome to Proto Coders Point. In this AWS tutorial let check how to get access to aws server instance if you have lost the private key (ppk file).

Amazon Web Services never keep copy of your private key on their end, If you lost the private there was no way to recover it. But now I have found out the way to access ec2 instance without using pem file and recover/regain access to your EC2 instance server from amazon instance dashboad itself.

How to access aws instance without key pair (PEM/PPK)

Video Tutorial


Time needed: 2 minutes

How To Connect To An AWS EC2 Instance Without Key Pair

  1. Login into Amazon Web Service Dashboad

  2. Select the AWS ec2 instance

    Now on AWS dashboard, navigate to EC2 and then select a instance.

    aws EC2 instance connect

  3. Click on AWS ‘Connect’ button

  4. EC2 instance Connect

    On selected instance page, you will get a Connect button, Use it to Connect to your instance, It will open a terminal, by which you can play with you server.
    aws EC2 instance connect

  5. Connected to instance ternimal through browser itself

    Now you have successfully connected to AWS service instance without using any PEM/PPK.
    Directly access instance terminal from AWS console itself.


How to change key pair to access AWS instance

discontinue old pem file and replace it with new one

discontinue pem/ppk file to access aws server – change key pair

0
discontinue a pem or ppk file to connect to server - PEM PPK file access removal

Hi Guys, Welcome to Proto Coders Point. In this AWS article let’s learn how to discontinue a PEM/PPK file by which a user can connect to server – basically remove access for using a particular PEM/PPK file (aws instance change key pair).

Why and when you should stop using old PEM/PPK file

Assume you work as a full stack developer in a startup company along with a colleague on a project where you both manage a server. Both you and your colleague are now given a pem or ppk to connect to an AWS server.

After 1-2 years of working in the same company, your colleague may resign or be fired by the company CEO.

Now your manager has asked you to collect all of the necessary documents, such as a pem or ppk file, from colleague who has a pem file and can access the server instance.

The pem file copies can be made right, and anyone with a pem/ppk file can easily gain access to and hijack your server instance.

As a result, it is preferable to phase out the old pem/ppk file (change key pair).

Now, let’s remove the old pem/ppk key file to gain access to the server by following the procedures below.

In AWS, How do I delete/deactivate the existing PEM file and generate a new one

Video Tutorial


Replace public key from aws server / change key pair ec2 Instance

Here is a simple Solution

On your server EC2 instance inside authorized_keys file the public_key is been stored, all you need to do is simply replace the existing public key with new key pair.

To do so, find the authorized_keys file in this path (/home/ubuntu/.ssh/authorized_keys) for ubuntu instance and (/home/ec2-user/.ssh/authorized_keys) for Amazon Linux instance.


Step by Step Guide to change key pair of aws server instance

Step 1: Login into AWS dashboard

Login from here – > https://aws.amazon.com/


Step 2: Create a fresh new key pair (pem)

Now, as we are discontinuing using old pem or ppk file to connect to server file system, we need to create a pem file on aws server.

In amazon dashboard, goto key Pairs page , on the left side you may see Network & Security - > Key Pair.

Create a new key pair on your amazon account

As you can see in above image, I have 2 key pair i.e PEM file, One is Old Pem file and one is newly created pem file.

This are two pem file downloaded, by which I can connect to server.


Step 3: Create a public key using puttyGen

Open PuttyGen, Click on Load button and browse to newly created pem file.

load a get public key from pem file
select the newly created pem file to create a public key

Now we have successfully got pubic key from freshly created PEM file.


Step 4: Open the public key and copy the openssh key

Now as you have the public key file created in above step using puttygen.

Open the file in any editor

Convert this key text into a single line and Copy the marked key character.

We need copy this key in authorized_keys file on server .ssh folder.


Step 5: Replacing old PEM key with new PEM key

Now the final step.

Using FileZilla or Winscp tools to connect to server.

We have to edit/replace old public key with new public in authorized_keys, To do so navigate to /home/ubuntu/.ssh in .ssh folder you will find authorized_keys file Open it in any editor or using putty terminal (vim or gedit).

Open authorized key file in any editor

Then in authorized_keys file, you have to add new public key that you create by pem key pair using puttygen in above steps.

This is the format to ssh-rsa <public key>.

In above image, you see I have old key, down of it I added new public. (Note: you can add as many as ssh-rsa public key you want).

Here I my case I want to discontinue usage of old pem/ppk file to access server. Therefore from above image I have to remove old public key from authorized_keys file from server.

Now save the file.

Warning: Before removing old ssh-rsa public key from authorized_key file, make sure that the newly added ssh-rsa public key(.pem key pair) is working and giving you access to the server.

Step 6: Verify that is new .pem is working

Now, you have added newly created pem file public key in authorized key file, It’s time verify if new .pem key is working or no.

Therefore, We have successfully removed old pem/ppk file authority to access AWS server and created a new pem file to access the same server instance.