Home Blog Page 43

How to Install Flutter in ubuntu 20.04

2
how to install flutter in ubuntu 20.04
how to install flutter in ubuntu 20.04

Hi Guys, Welcome to Proto Coders Point. In this Article we’ll learn How to install flutter in ubuntu 20.04.

Install Flutter in Ubuntu 20.04/ Linux

System Requirement to Install Flutter in ubuntu

To install and run Flutter on ubuntu, your development system environment must meet these minimum requirements:

  • Operating Systems: Linux (64-bit)
  • Disk Space: 600 MB (does not include disk space for IDE/tools).
  • Tools: Flutter depends on these command-line tools being available in your environment.
    • bash
    • curl
    • git 2.x
    • mkdir
    • rm
    • unzip
    • which
    • xz-utils

Download flutter SDK for Linux/ubuntu

Flutter_Linux_Ubuntu_v1.9.1+hotfix.4-stable.tar.xz

After Downloading flutter dart sdk from above gived button, Change your current directory using cd command where the flutter_linux_stable.tar.xz is located ( May be in Downloads Directory )

cd Downloads

After Download Complete Extract the flutter_linux_stable.tar.xz file in you selected directory using below command.

tar xf ~/Downloads/flutter_linux_v1.9.1+hotfix.4-stable.tar.xz

Add the flutter tool to your path:

 export PATH="$PATH:`pwd`/flutter/bin"

Note: Above command will sets your PATH variable for the current terminal window only. Means when you you close the terminal you no longer will be able to use flutter, to use again you need to user again and again export PATH ( above command ).

To permanently add Flutter to your path, see Update your path.

Add Flutter to environment variable in Ubuntu

Now you can add the flutter binaries to your PATH, either by running this in your terminal:

export PATH="$PATH:`pwd`/flutter/bin"

But this comment will temporary add flutter binaries in PATH variable, you can permanently add it to the configuration file of your shell permanently.

Depending on which shell you use either ~/.bashrc for bash~/.zshrc for zsh , these will typically be:

bash your can proceed steps to add flutter binaries in PATH variable

open the hidden file ~/.bashrc using command:

gedit ~/.bashrc
how to open .bashrc file for editing
open ~/.bashrc

A gedit will pop up with a window like below. just scroll down still you reach at the bottom and paste the below code.

export PATH="$PATH:/home/$USER/flutter/bin"

Adding export PATH in .bashrc file – add flutter to path ubuntu

add flutter to path ubuntu
Add this line at the bottom of .bashrc file to set flutter bin environment

You can reload your config by running:

source ~/.bashrc

Now close the current terminal or restart the terminal.

How to check if flutter is correctly installed in the system.

flutter doctor
flutter doctor
flutter doctor

Installing Flutter Plugin in android studio

Check out this post installing flutter SDK + android studio with Flutter plugin 

 

 

Android Welcome Screen Github Library

2
Android welcone screen github library
Android welcone screen github library

Hi Guys, Welcome to Proto Coders Point, here I found out a best Android Welcome Screen Github Library. That help use to integrate a customizable app intro screen in Android apps.

Android Welcome Screen Github Library

Features

  • Fully customizable.
  • RTL support ( Right to Left Support ).
  • Ability to use built in layouts or custom fragments.
  • Built in layouts support all screen sizes and orientations.

One time Intro Welcome Screen for new app user

What is a welcome screen in app?

App welcome screen is a one time screen that is been used to introduce your app to your customer, so that the user can understand your company and how to your the app. its just a introduction screen for first time app user.

Adding Welcome Screen Library to your project

To make use of this awesome intro screen android library you need to first add welcome screen github library into your android project.

Add this dependencies in Gradle Script of module level : app

implementation 'com.stephentuso:welcome:1.4.1'
add dependencies android welcome screen github library

If you use proguard, add the following to your proguard rules.

-keepclassmembers class * extends com.stephentuso.welcome.WelcomeActivity {
    public static java.lang.String welcomeKey();
}

Basic Usage to add welcome screen android library

To make use of this welcome screen android library you need to create a class that extend WelcomeActivity like this.

Just in your android project > java folder create a new class my any name “myWelcomeScreen” that should extend WelcomeActivity that came from the library we have added above.

package protocoderspoint.com.welcomescreen;

import com.stephentuso.welcome.BasicPage;
import com.stephentuso.welcome.TitlePage;
import com.stephentuso.welcome.WelcomeActivity;
import com.stephentuso.welcome.WelcomeConfiguration;

public class MyWelcomeScreen extends WelcomeActivity {
    @Override
    protected WelcomeConfiguration configuration() {
        return new WelcomeConfiguration.Builder(this)
                .defaultBackgroundColor(R.color.background)
                .page(new TitlePage(R.drawable.logo1,
                        "Title")
                )
                .page(new BasicPage(R.drawable.logo3,
                        "Header",
                        "More text.")
                        .background(R.color.colorAccent)
                )
                .page(new BasicPage(R.drawable.logo3,
                        "Lorem ipsum",
                        "dolor sit amet.")
                )
                .swipeToDismiss(true)
                .build();
    }
}

Then your need to implement one @Override method called WelcomeConfiguration configuration() and add n numbers of welcome screen you need.

You do not need to override onCreate or call setContentView.

Note: For now, defaultBackgroundColor() needs to be called before adding pages.

Add MyWelcomeScreen Activity in AndroidManifest.xml File

 <activity android:name=".MyWelcomeScreen"
            android:theme="@style/WelcomeScreenTheme"/>

Show the welcome screen Library.

Welcome screens are started with WelcomeHelperonSaveInstanceState is needed to be sure only one instance of the welcome screen is started. Add the following to the Activity you want to show the welcome screen before (probably your launcher activity):

MainActivity.java

package protocoderspoint.com.welcomescreen;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import com.stephentuso.welcome.WelcomeHelper;

public class MainActivity extends AppCompatActivity {

    WelcomeHelper welcomeScreen;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        welcomeScreen = new WelcomeHelper(this, MyWelcomeScreen.class);
        welcomeScreen.show(savedInstanceState);

    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        welcomeScreen.onSaveInstanceState(outState);
    }
}

Download Project

Download from Drive Download from Github

A vertical sequence UI progress bar Android in Github

0
Veritcal Sequence Layout UI Progress Bar
Veritcal Sequence Layout UI Progress Bar

A vertical step progress bar sequence layout UI component for Android.

The Vertical sequence layout UI android Library is used to Animates a progress bar to the first active step in the sequence and then periodically runs a pulse animation on that step.

Veritcal Sequence Layout UI Progress Bar
Veritcal Sequence Layout UI Progress Bar

How to setup Sequence layout progress bar UI in android Studio?

Add the JitPack maven repository to your root build.gradle:

allprojects {
    repositories {
      maven { url "https://jitpack.io" }
    }
}

And then the actual library dependency to your module’s build.gradle:

dependencies {
    implementation 'com.github.transferwise:sequence-layout:... // use latest version'
}

The latest version of Sequence Layout UI You can found in Github Current latest version is 1.0.11 may change.

How to Implement a vertical sequence progress bar in android.

In XML layout UI of the Sequence progress bar

You can define n number of steps in your XML layout:

<com.transferwise.sequencelayout.SequenceLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <com.transferwise.sequencelayout.SequenceStep
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:anchor="30 Nov"
        app:title="First step"/>

    <com.transferwise.sequencelayout.SequenceStep
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:title="Second step"/>

    <com.transferwise.sequencelayout.SequenceStep
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:active="true"
        app:anchor="Today"
        app:subtitle="Subtitle of this step."
        app:title="Third step"
        app:titleTextAppearance="@style/TextAppearance.AppCompat.Title"/>

    <com.transferwise.sequencelayout.SequenceStep
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:title="Fourth step"/>

    <com.transferwise.sequencelayout.SequenceStep
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:anchor="2 Dec"
        app:title="Fifth step"/>
</com.transferwise.sequencelayout.SequenceLayout>

Here com.transferwise.sequencelayout.SequenceLayout is the main Sequence Layout within which we can describe n number of Sequence Steps with com.transferwise.sequencelayout.SequenceStep.

Custom attributes for SequenceLayout:

AttributeDescription
progressForegroundColor foreground color of the progress bar
progressBackgroundColor background color of the progress bar

Custom attributes for SequenceStep:

Attribute Description
active boolean type ‘true/false’ to set the step to active or deactive state. There should only be one active step per SequenceLayout.
anchor text for the left side of the step
anchorMinWidth minimum width for the left side of the step
anchorMaxWidth maximum width for the left side of the step
anchorTextAppearance styling for the left side of the step
title title of the step
titleTextAppearance styling for the title of the step
subtitle subtitle of the step
subtitleTextAppearance styling for the subtitle of the step

Programmatically using Java code for Sequence UI Layout progress bar

MainActivity.java to handle sequence Layout Vertical progress bar.

package shri.ab.sequenceprogressbar;

import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.transferwise.sequencelayout.SequenceStep;

public class MainActivity extends AppCompatActivity {

    SequenceStep step1,step2,step3,step4,step5;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        step1=(SequenceStep)findViewById(R.id.step1);
        step3=(SequenceStep)findViewById(R.id.step3);

        //programatically activating
        step3.setActive(true);
        step3.setTitle("Active Step");
        step3.setAnchor("Date...");
        step3.setSubtitle("Subtitle of this step third.");

        //programatically seting style to Title
        step3.setTitleTextAppearance(R.style.TextAppearance_AppCompat_Title);
    }
}

OR

Programmatically using Kotlin code for Sequence UI Layout progress bar.

MainActivity.kt to handle sequence Layout Vertical progress bar.

package shri.ab.sequenceprogressbar

import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.transferwise.sequencelayout.SequenceStep

class MainActivity : AppCompatActivity() {

    internal var step1: SequenceStep? = null
    internal var step2: SequenceStep? = null
    internal var step3: SequenceStep? = null
    internal var step4: SequenceStep? = null
    internal var step5: SequenceStep? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        step1 = findViewById<View>(R.id.step1) as SequenceStep
        step3 = findViewById<View>(R.id.step3) as SequenceStep

        //programatically activating
        step3!!.setActive(true)
        step3!!.setTitle("Active Step")
        step3!!.setAnchor("Date...")
        step3!!.setSubtitle("Subtitle of this step third.")

        //programatically seting style to Title
        step3!!.setTitleTextAppearance(R.style.TextAppearance_AppCompat_Title)
    }
}

Download Project

Download from Drive Download from Github

Types Of Variables In JAVA With Example

1
variable in java

In JAVA, Variables can be Termly defined as to reserve memory space to store the values. These variables can easily be initialized at the time of declaration or later on whenever needed on the type of variable.

Types Of Variables in JAVA:

There are 3 types of variables in JAVA:

1. Local Variable
2. Instance variable
3. Class Variable/Static variable.

Local variable:

  • These are also called as a stack variable. Because they exist in computer stack memory.
  • It is mandatory to initialize the local variable. Otherwise, you will get run time error from the compiler.
  • These can be defined inside the method, constructor or also inside block.
  • The scope or lifeline of the local variable destroyed with the end of method completed, this means that local variables cannot be used outside the method or the class.

Instance variable:

  • An instance variable in java is also known as member variable or field.
  • These are associated with object creation. As the object gets created instance variable also gets created.
  • These live on heap memory. In case, if you don’t initialize instance variable with the initial value these get default value at run time implicitly. Here default value initialed to int is 0.

Class Variable/Static Variable:

  • These are loaded and initialized when class is loaded in JVM.
  • There exists only one copy of the class variable.
  • They live on heap memory. and if variables are not initialized to some default value is assigned to them implicitly.

Examples Of Variables In JAVA: With Small program

Correct Program Code With Initialization of Local Variable:

Simply just assign the initial value to local variables in the same program. The change in output will reflect automatically the importance of this change. It’s Because of only the local variables required to initialize with some value.Class/Static and instance variable implicitly assign the null /0/ false value to these particular variable.

Class/Static and instance variable implicitly assign the null /0/ false value to this particular variable.

public class Main{
	public static int staticvariable;
	int instancevariable=10;
	public void printValue(){
		int localvariable = 10;
		System.out.println("the value of static variable \t"+staticvariable);
		System.out.println("the value of instance variable\t"+instancevariable);
		System.out.println("the value of local variable \t"+localvariable);
	}
	public static void main(String args[]){
		Main object=new Main();
		object.printValue();
	}
}

OUTPUT
the value of static variable     0                                                                                             
the value of instance variable   10                                                                                            
the value of local variable      10 

Post Referred Website https://abhiandroid.com

Variables In JAVA The Complete Tutorial – With Java Example

0

Variables are something that makes the computer programs very useful for storing information in computer temp memory. When you think of variables, think of boxes that are used to store the real-world object. In the computer world, you can have hundreds, thousands n number of boxes (mean variables) each containing their own pieces of information. That box is called variables in JAVA.

While creating variables in JAVA we need to assign two things. First is the type of information we want to store and second is the name of the variable. Below is an example of a variable where int is an integer in this case and x is the name:

Eg: int n;
Here int is integer primitive data type and n is the variable.

Syntax Of Java Variables:

JAVA has its own rules for syntax of variables and we need to follow it. Syntax of variables in JAVA is divided into 3 parts:

  1. The types of data you are storing (int, char, byte, etc.)
  2. Naming (let’s say n). where you store the data information.
  3. Putting a semicolon (;) at the end. which is telling the program statement ends here.
int n;

If you want to store values into java variables directly, you can do it by using = (which is also called as assignment operator) :

int n = 10;

In the above syntax, we are storing values directly in a variable n with value initial value as 10. n = 10;

Few more Java Variables Examples:

Let us create a student variable that stores student details :

int rollno=123;
char name =”x”;

In the above example, we have defined two variables rollno and name for storing student details.

Important Note: 

char variable can only store one character. If you want to store full name then you need to use the String variable.

Defining variable for storing decimal number say 500.36

float account_balance = 1000.58;

Above Example Explanation:

  • int, char, and float are a data type that is telling the program to assign area in memory for storing integer, character or decimal number.
  • Rollno, name & account_balance are names of variables and value, 3, “Rajat” & 1000.58 is stored in them.

Types of variable in java

There are 3 types of variables in JAVA:

1. Local Variables:

 These can be defined inside the method, constructor or also inside the block. The scope or lifeline of the local variable destroyed with the end of method completion.

2. Instance variables: 

These are associated with object creation. As the object gets created instance variable also gets created.

3. Class Variable/static variables: 

These are loaded and initialized when class is loaded in JVM (java virtual machine) and there exists only one copy of the class variable.

public class DiffTypeOfVariable{
	public static int staticvariable;
	int instancevariable;
	public void printValue(){
		int localvariable;
		System.out.println("the value of static variable \t"+staticvariable);
		System.out.println("the value of instance variable\t"+instancevariable);
		System.out.println("the value of local variable \t"+localvariable);
	}
	public static void main(String args[]){
		DiffTypeOfVariable object=new DiffTypeOfVariable();
		object.printValue();
	}
}

For more details read Type Of Java Variable Tutorial With Example

How To Print Java Variable Value:

We can easily print/display java values by using a java inbuilt method System.out.print();

Here the System is a class, out is an object and print is the method to print/display values on the screen.

If you are new in java and not able to understand what is class, what os object don’t worry just remember System.out.print(); is used to print values on the screen in JAVA.

System.out.print(); will just print values without a new line, if you need to give a new line then you should use System.out.println();

Now, let us print a number 10 in JAVA. First, we will create a variable and store value 10 in it. Remember 10 is an integer so we will assign int as a data type:

int n = 10;

Now using the inbuilt JAVA method for printing it:

System.out.println(x);

Complete Java Code for printing Variable in the screen

public class Main
{
	public static void main(String[] args) {
	    int n = 10;
		System.out.println("Value of n = "+n);
	}
}

Output

Value of n = 10

Here JAVA takes a looks for the value stored in the memory of variable name n, finds it and then prints it which is 10.

Why it is important Of Variables In JAVA:

  • It makes the computer program very useful by storing information which can be easily accessed. For example, if you want to create a JAVA program that can calculate the current age based on the birthday of the person. The person will enter his birthday details which need to be stored somewhere in the computer with proper naming to make it easily accessible for calculating his age. Here you need variables to do that for you.
  • In simple words, you need variables in the program because it gives the ability to store information which can then be processed. Without variables, the computer won’t be able to process anything.

Post referred from https://abhiandroid.com