Tuesday, 23 February 2021

Flutter Database Connection Using Dart, Android Studio & SQFLITE | Copy-Paste Code



You can download project from : 
https://unpossiblepog.com/codes/DART+FLUTTER/Flutter-And-Dart-Convert-SQFLITE-Data-Into-Map-And-Display-That-Data-In-Table-UI


Note : Watch the video if you are confused to you want to see the practical approach of instructions which are given below.

########## START ##########

 1. In “pubspec.yaml” file, inside “dependencies”, after “flutter”, paste the following code (make sure that following code should be at the same level as “flutter”):


sqflite: any #stable version at the time of publishing this article

path_provider: any #stable version at the time of publishing this article

intl: ^0.15.7

--------------------------

2. Create “database_connector.dart” file at the level of "main.dart" (or at any place which contains dart files )

Then paste the following code in “database_connector.dart” file:


import 'package:sqflite/sqflite.dart';

import 'dart:async';

import 'dart:io';

import 'package:path_provider/path_provider.dart';


class DatabaseConnect{

static Database _database;


Future<Database> get database async {


if (_database == null) {

_database = await initializeDatabase();

}

return _database;

}


Future<Database> initializeDatabase() async {

Directory directory = await getApplicationDocumentsDirectory();

String path = directory.path + 'tutorialdb.db';


var notesDatabase = await openDatabase(path, version: 1, onCreate: createTable);

return notesDatabase;

}


void createTable(Database db, int newVersion) async {


await db.execute('CREATE TABLE employee(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, address TEXT)');

}


Future<int> insertStatic() async {

Database db = await this.database;

var result = await db.rawInsert("INSERT INTO employee(name,address) VALUES('steve rogers','brooklyn')");

return result;

}


Future<List<Map<String, dynamic>>> getList() async {

Database db = await this.database;

var result = await db.rawQuery('SELECT * FROM employee order by id ASC');

return result;

}


}


--------------------------

3. Then in "main.dart" file, paste the following at top of page below other imports:


import 'dart:async';

import 'package:<your_app_name+path_if_database_connector_is_inside_folder>/database_connector.dart';

import 'package:sqflite/sqflite.dart';

--------------------------


4. Then in “main.dart” file, just above the end bracket of class (which extends state), paste the following code:



void JustPrint()

{

print('wow');

}


void DBConInsert(){

DatabaseConnect con = DatabaseConnect();


final Future<Database> dbFuture = con.initializeDatabase();

dbFuture.then((database) {

Future<int> noteListFutureInsert = con.insertStatic();

noteListFutureInsert.then((noteList) {

print(noteList);

});

});


}

void DBConDisplay(){

DatabaseConnect con = DatabaseConnect();


List<Map<String, dynamic>> list=[];

final Future<Database> dbFuture = con.initializeDatabase();

dbFuture.then((database) {


Future<List<Map<String, dynamic>>> noteListFuture = con.getList();

noteListFuture.then((emp_data) {


for(var i=0;i<emp_data.length;i++)

{

Map m=emp_data[i];

m.forEach((k,v) => print('${k}: ${v}'));

}


});

});


}



--------------------------


5. If you have a button, then it is good, otherwise add the button. And onPressed of that button, add “JustPrint”

(JustPrint is a normal/temporary function which we pasted in main.dart file, it only prints ‘wow’ in console)


--------------------------


6. Then open the console in ANDROID STUDIO (4. Run), run the project and click on button.

If you see ‘wow’ in console, then it is good. Otherwise, check the process again to see if any step is missing.


--------------------------


7. If it is displaying ‘wow’, remove the ‘JustPrint’ after ‘onPressed’, and add ‘DBConInsert’ instead.

Save it. Refresh the project. Then click on button only once.

It will insert a new row in database table and display id in console.


--------------------------


8. If above step works, remove ‘DBConInsert’ and add ‘DBConDisplay’, then again click on button.

Save it. Refresh the project. Then click on button.

It will display data columnwise.


########## END ##########


IGNORE THE INFORMATION GIVEN BELOW WHICH IS MORE DETAILED VERSION OF ABOVE INSTRUCTIONS.

Subscribe my Channel:- http://www.youtube.com/user/SanketRooney?sub_confirmation=1


Facebook Page:- https://www.facebook.com/UnpossibleNS


Twitter Account:- https://twitter.com/UnpossiblePOG


Blog :- https://unpossiblepog.blogspot.in/


Hey guys, now we shall be connecting the flutter app with database and Insert data. Also we shall display a data but only in console as our main aim is to connect database on SQFLITE.

Now, I created a blog which contains steps & code. Link is given in the description. Then you just have to follow my steps as per the video.


First, we shall create a new flutter application. I am using Android studio.


Observe that in project explorer, there is a “lib” folder and inside it is a dart file.


Now, the first step is to copy code from 1st point and open “pubspec.yaml” and paste code inside dependencies but at the same level as flutter text.


Then a bulb symbol will appear. Click on “pub get”. It shall download dependencies.

Or you can click on the link which appeared at the top side of window.


Lets run an ANDROID SIMULATOR and RUN the project. It will take several minutes to run the project first time.


Once ran, click on the bottom button which increases the CLICK COUNT and displays on screen.


In second step, we have to create a dart file with any name. I would prefer database_connector.dart. Make sure that it should be created inside “LIB” folder.

If you so desire, you can create a package folder and add that file inside it just like I am doing in this video.


Copy-paste the whole code from point 2 and paste it in database_connector.dart file.


In third step, you have to import that file & other libraries.

So paste the code at the top of main.dart file.


Then you need to give specific location of database_connector file. That is, your project name which in my case is “”tutorial1, then /, then package name if you database connector file is inside it, then /, then database connector file name.


Copy the code from 4th point,

Go to the ending curly bracket of class which is extending STATE class.

Paste the code just above the ending curly bracket.


5th point is to call a simple function called JustPrint on press of a button.

SAVE all files, Refresh the app. Or enable the HOT RELOAD.

The navigator for RUN Console is available at the bottom of android studio. As you can see that this function is only printing the text in RUN CONSOLE.


6th point is just that.


Now in 7th point, we have to call DBConInsert on button’s press event. That function will create a database, an employee table and insert one row.


SAVE IT and DO REFRESH if you don’t have HOT RELOAD.


Once clicked on button, it will display a new ID’s value in console.


Sometimes you may get this error. Just simply close SIMULATOR and ANDROID STUDIO OR VISUAL STUDIO CODE and restart them. And do this step again.


Now,, if you get an ID on click of button, go to 8th and last step. And copy DBCONDISPLAY function and paste it at on press event of button.


Click on button and you will get all the data in console. Lets insert new row. And display them again to confirm.


Now you can play around with code and you can figure out how the code works.


So that is it, thanks for watching. Like share and subscribe.



Tuesday, 5 January 2021

Filmora X : Download Free Effects From Filmstock | For Licensed User Only



Filmstock link : https://filmstock.wondershare.com/


-------------------------------
Subscribe my Channel:- http://www.youtube.com/user/SanketRooney?sub_confirmation=1


Facebook Page:- https://www.facebook.com/UnpossibleNS


Twitter Account:- https://twitter.com/UnpossiblePOG


Blog :- https://unpossiblepog.blogspot.in/

-------------------------------
Hey guys, in this video, we are going to download some free effects in WONDERSHARE Filmora X. Before I start, one thing to let you know is that this video is only for those who purchased a license for this product. Means it is not for CRACKED VERSION.


I have 1 clip and there are some effects already present however you can download some extras legally.

Open the browser and search filmstock wondershare.

Go to filmstock.wondershare.com link.

Now click on JOIN FREE.

Click on “CREATE ACCOUNT” on free column.

You can register and you may get verification email.

However I already created one account so I shall click on login.

I don’t know why they ask you to login twice but any ways.

Login and then click on effects menu.

You can see the green circle which means that effect is free.

I shall find other one because I already downloaded it.

Here is one called 2D Business Pack.

You will see FREE DOWNLOAD button. Click on it.

Then click on OPEN of popup button. Some browsers may show different text instead of OPEN, so click on button other than CLOSE.

It will open filmora’s window and it will start downloading.

It says there are 9 title, 20 elements, 3transitions and 5 overlays.

After that, close this window.

Now if you check EFFECTS tab, you will see a new menu called 2D Business pack.

You can drag-and-drop those effects.

Also in TITLES tab, click on newly downloaded menu, and put any one on video.

Same goes for TRANSITIONS and ELEMENTS.


So that is it, thanks for watching.

Sunday, 8 November 2020

Mysql | Order By Comparing Multiple Columns & Ignore Specific Value While Sorting | Greatest & Least



> SELECT *,greatest(maturity,death) as insurance_date FROM `insurance` order by insurance_date DESC

> SELECT *,least(maturity,if(death='0000-00-00 00:00:00',maturity,death)) as insurance_date FROM `insurance` order by insurance_date DESC


In MYSQL, GREATEST and LEAST are the functions which compares columns columns rather than rows. Best example is an Insurance company’s data where admins want to figure out the day a customer gets his/her money by comparing which date comes first, a maturity date or death date.


Subscribe my Channel:-

http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-

https://www.facebook.com/UnpossibleNS

Twitter Account:-

https://twitter.com/UnpossiblePOG

Blog :-

https://unpossiblepog.blogspot.in/

------------------------------------------------

Hey guys, in this video I am going to sort the table by comparing multiple columns.

For example, I have an insurance table, and two columns, maturity and death have the date-time as data-type.

First we shall sort it by the maximum date among maturity and death, so we shall use the GREATEST function and add columns which will be compared.

We give that value of function as “insurance_date” and then use the  ORDER BY clause.

Now as you can see, it gives the output based on which date is maximum and sort accordingly.

However in insurance, the lowest date matters because company has to give money based on which date occurs first.

So for that we are going to use LEAST function.

But the problem is, if a person is not died then, of course the date field will be empty so the output is incorrect.

To fix that, we have to overwrite the the death date. We are going to use the IF condition inside LEAST function, and if death date is zero, we overwrite it with a maturity date. Also, Maturity Date shouldn’t be empty in any case.

And now we got the output we wanted.

Query link is given in the description.

Don’t forget to like, share and subscribe.Thanks for watching.

Thursday, 15 October 2020

Use Hash Value As Different Page For Navigation Like Angular JS | Hashtag | Javascript | Jquery | Ajax




You can download code from: https://unpossiblepog.com/codes/JAVASCRIPT+AJAX-JQUERY/Use-Hash-Value-As-Different-Page-For-Navigation-Like-Angular-JS-Using-Javascript-Jquery-And-Ajax

Code :-

product.php

------------------------------------------

<!DOCTYPE html>

<html lang="en">

<head>

  <title>Bootstrap Example</title>

  <meta charset="utf-8">

  <meta name="viewport" content="width=device-width, initial-scale=1">

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>

</head>

<body>

<script type="text/javascript">

  loc = (window.location).toString();

  res = loc.split("#");

</script>

<div class="container">

  <h2>&nbsp;</h2>



  <div class="row">

    <center>

    <div class="col-md-4">

    

      <a onclick="showDataAjax('#Linux');history.pushState({},'','#Linux');">

        <button type="button" class="btn btn-info btn-lg">Linux</button>  

      </a>

    </div>



    <div class="col-md-4">

      <a onclick="showDataAjax('#Microsoft');history.pushState({},'','#Microsoft');">

        <button type="button" class="btn btn-info btn-lg">Microsoft</button>  

      </a>

    </div>



    <div class="col-md-4">

      <a onclick="showDataAjax('#Apple');history.pushState({},'','#Apple');">

        <button type="button" class="btn btn-info btn-lg">Apple</button>  

      </a>

    </div>

    <center>

  </div>



  <div class="row">

    <div class="col-md-12" id="show-data" style="background-color: #fff68d;margin-top: 15px;height: 100px;">

    

    </div>

  </div>



  <div class="row">

    <center>

    <div class="col-md-12">

      <a  class="btn btn-info btn-lg" style="margin-top: 15px;"

      onclick="history.pushState({},'',res[0]);">Refresh</a>

    </div>

    </center>

  </div>



</div>



<script type="text/javascript">

  function showDataAjax(company)

  {

    $.ajax({

      url: "read_data.php",

      method: "POST",

      data:{company:company},

      beforeSend : function()

      {

      },

      success: function(ajax_data)

      {

        $("#show-data").html(ajax_data);

      }

    });

  }

 

  window.onpopstate = function(event){

    var hash = location.hash;

    showDataAjax(hash);

  };



  function runHash()

  {

    var hash = location.hash;

    if(hash!=="")

    {

      showDataAjax(hash);

    }

  }

  runHash();

</script>



</body>

</html>



------------------------------------------

read_data.php



<center>

<h1>

<?php

echo str_replace(array("#","%20"), array(""," "), $_POST['company']);

?>   

</h1>

</center>





------------------------------------------



This video is about how to dynamically navigate on browser using hashtag and display data based on hash values with the help of ajax jquery & javascript.

For example, when I click on buttons, I am displaying the data using AJAX, but at the same time I am also manipulating the url.

Not only that, when I click on back and forth buttons, the data changes respectively.
Also if I directly open with hash value, it shows the data.
You can also remove the hash value by clicking on refresh button.


Lets start building code from the scratch.


Here is the page design, I using PHP language but you can use any backend language.

I have including a header file, which has JQUERY and boostrap links.


In our main page, I added onclick event and “showDataAjax” function on each button.
I added them statically just to avoid backend language,
Notice that I added hashtag before each value which is important.

And here is the ajax code which shows data in ID.

You can remove hashtag from post data using your backend language.

Lets add history.pushState function with 3 arguments.

1st will be empty array, 2nd will be empty string and the will be the hash value.
Copy paste them and add values respectively.


Notice that your URL hash is also changing.
Now next problem is when I click on back button, it doesn’t change the ajax value.

So for that, add a javascript code.
we shall get the hashvalue and call the function.
Now lets check.
Now, next challenge is what do when when user applies URL with hashvalue.
For that we shall add similar code.

Lets check the direct URL.
As you can see, its working, now to remove hash value, create the script tag at the top of page.

You can also add in common header file but I don’t want to confuse viewers, so I am writing on same page.

On click of refresh page, paste that code, and use array’s first element.
As you can see, this button wipes out the hash value.

Create a function.

Run that function after it’s declaration.


Don’t forget to like, share and subscribe.

Thanks for watching.

Monday, 28 September 2020

JQUERY Tutorial | Hide Collapsible Navbar When Clicked Outside It | Bootstrap




You can now download a code from : 
https://unpossiblepog.com/codes/javascript+jquery+bootstrap/Hide-Collapsible-Navbar-When-Clicked-Outside


In this video, I shall create a code in JQUERY to hide bootstrap’s responsive navbar when user clicks outside that navbar.


I have created one bootstrap page.
When I convert User Interface from desktop to mobile version, and click on hamburger icon, the menu appears and same button is used for hiding it.
Lets create a script tag.
Write a function which shall run as soon as the whole page load.
And first we are going to check if jquery is working or not.
Lets refresh. When I click, it shows the alert message.
Now comment it just for now.
Now we have to observe which one is the main class which shows the navbar,
As there different types of navbar for each version of bootstrap,  only the classes names will differ from me but overall the process will be same.
When I toggle, this part is the topmost part which is changing it’s class.
So have to copy the classes of both toggle button and navbar division.
Now we have to find out the class name where user clicks.
As there are different JQUERY versions, one of them is applicable for your version.
For me the second one works so I am going to comment the first one.
Now we are getting the class name of elements where we clicked.
We shall use the IF-ELSE statements and check if the class is same as navbar’s class or not.
However there are some classes which are inside the navbar, So to find out if we click inside navbar too, we shall use this code in alert box.
Now if we click outside navabar, it shall give 0, but if we click inside navbar it shall give 1.
So we shall also use it inside our IF-ELSE statement.
We shall put if statement empty and use the ELSE part.
Here, if we check, when the navbar is expanded, there is an “IN” class present with it.
So in code, we have to find out if that NAVBAR class have “IN” class with it.
If yes, then we shall auto-click the toggle button.
Lets refresh.
It is not hiding when I click inside the navbar, but is hiding when I click outside.
Don’t forget to like, share and subscribe.Thanks for watching.

Sunday, 13 September 2020

JQUERY Tutorial | Add Unique Count On Repeated HTML Elements Without Bac...



Automatically add count in repeated elements using only JQUERY.

Boostrap code with JQUERY link:-
https://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_default&stacked=h

Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/
------------------------------------------------

In this video, I am going to show how to add count in incrementing order in elements.
I created an empty html page as you can see.
I am lazy so I am going to copy some html code from w3schools. Link in the description.
In that code, they manually added 1,2,3. Which might take a lot of time if you add one by one.
Let me just remove Order and add LIST in h3 tag.

Now, they already provided one jquery link which is necessary.
Now create a script tag, make sure that it is below those repeated elements.
Create a random function, and call it.

Now, as soon as page loads, it will show an alert message.
After that, remove alert.
If you observe the pattern, H3 tag comes after the class called “col-sm-4”.

So, we shall now call then one by one using jquery.
We have to append the number, so we shall need an integer and increase it by 1 each time.

Don’t forget to like, share and subscribe.
Thanks for watching.