Posts

Map_(Collection)_Dart

  import 'dart:ffi' ; ///Introduction to the Dart Map type /// Map type allows you to manage a collection of key/value pairs. The Map type is /// similar to the Dictionary type in other programming languages. /// In a map, keys are unique. Each key has an associated value. Unlike keys, values can /// be duplicated. Generally, you cannot add or remove keys while performing an /// operation on the map ///CREATING A MAP void main () { var fruits = { "apple" : 1 , "banana" : 2 , "orange" : 3 , "pineapple" : 4 , "pomegranate" : 5 , "coconut" : 6 , "mango" : 7 , "grapes" : 8 , "papaya" : 9 , "watermelon" : 10 , "kiwi" : 11 , "Lemon" : 12 , "cherry" : 13 , "strawberry" : 14 , "blueberry" : 15 , "pear" : 16 } ; // print(fruits); // print("\n"); /...

List_Example_Dart

  import "dart:io" ; import "dart:core" ; // void main() // { // var accountHolder = []; // print("Enter the Account holder Name : "); // var a = stdin.readLineSync(); // print("Enter the Account holder phone no : "); // var b = int.parse(stdin.readLineSync()!); // print("Enter the Account holder address : "); // var c = stdin.readLineSync(); // print("Enter the Account holder age : "); // var d = int.parse(stdin.readLineSync()!); // print("Enter the Account Type : "); // var account_type = stdin.readLineSync(); // print("Enter the Account Number : "); // var f = int.parse(stdin.readLineSync()!); // print("Enter the Deposit Amount : "); // var deposit = int.parse(stdin.readLineSync()!); // print("Enter the days : "); // var days = int.parse(stdin.readLineSync()!); // print("Are You want to Sure ?"); // var surety = stdin.readLineSync(); // ...

List_(Collection)_Dart

  import "dart:core" ; //A very commonly used collection in programming is an array. Dart represents arrays in the // form of List objects. A List is simply an ordered group of objects. The dart:core library // provides the List class that enables creation and manipulation of lists void main () { var play = [ "apple" , "mango" , "watermelon" , true, 32 , 11 , 80.12 , 31.82 , false ] ; print(play) ; //Add Element play.add( "coconut" ) ; print( "Add : ${play} " ) ; //addAll() Insert the multiple values to the given List, and each value is // separated by the commas and enclosed with a square bracket ([]) play.addAll([ 32 , "pomegranate" , true ]) ; print( "addAll() : ${play} " ) ; //Creating New List var play1 = [ 52 , 96 , 36 , 10 , 74 , 55 , 14 , 39 , 64 , 25 , 75 , 31 , 54 , 61 , 85 , 59 ] ; //sort element play1.sort() ; print( "sort element : ${play1} " ) ; //print ...

Concurrency_(Thread)_Dart

  import "dart:isolate" ; ///Concurrency - (Thread) in Dart Programming //Concurrency is the execution of several instruction sequences at the same time. It involves performing more // than one task simultaneously. Dart uses Isolates as a tool for doing works in parallel. // The dart:isolate package is Dart’s solution to taking single-threaded Dart code and // allowing the application to make greater use of the hard-ware available. // Isolates, as the name suggests, are isolated units of running code. // The only way to send data between them is by passing messages, like the way you pass messages // between the client and the server. An isolate helps the program to take advantage of multicore // microprocessors out of the box. ///Multithreading in Flutter using Dart isolates /// ● Method 1: Using compute /// ● Method 2: Using Isolate.spawn ///What are isolates? //An isolate is an abstraction on top of threads. It is similar to an // event loop, with a few differences: // ● An...

File_Read_Dart

  import "dart:io" ; void main () { /// READ FILE IN DART File fileObject = File ( "myFile.txt" ) ; /// READ FILE var data = fileObject.readAsStringSync() ; /// PRINT FILE print(data) ; print( "File Path : ${fileObject. path } " ) ; /// GET ABSOLUTE PATH print( "File Absolute Path : ${fileObject. absolute } " ) ; print( "File Absolute Path : ${fileObject. absolute . path } " ) ; /// GET FILE SIZE print( "File Size : ${fileObject.lengthSync()} bytes" ) ; /// GET LAST MODIFIED TIME print( "Last Modified : ${fileObject.lastModified()} " ) ; /// READ CSV FILE IN DART File fileObject1 = File ( "myFile.csv" ) ; /// READ FILE String contents = fileObject1.readAsStringSync() ; /// SPLIT FILE USING NEW LINE List<String> lines = contents.split( " \n " ) ; /// PRINT FILE print( "*****************************************" ) ; for ( var a in lines)...

File_Write(Create)_Dart

  import "dart:io" ; ///NOTE : //File handling is an important part of any programming language //While programming, you might run into some sort of situation, // where you need to work on a file stored at a specific location, // maybe write something on it, read it or anything else. Dart supports // working with files as well. // In order to start working, first of all we need to import dart’s inbuilt // io (input output) library. // import 'dart:io'; // This library gives us access to a large number of classes, methods // and properties which we can use to perform various operations. In // current situation, we need to work with files, hence, we need to // create an instance of the File class void main () { /// WRITE FILE IN DART ///CREATING ONE (DOC) FILE File fileObject = new File ( "myFile.doc" ) ; fileObject.writeAsString( "Hello, I am Student of PraxWare Technology" ) ; print( "File Created!" ) ; ///CREATING SECOND (TXT...

Abstraction_Dart

import 'dart:io' ; /// Data Abstraction : show only functionality and hiding background details this called /// data abstraction. // Abstract class abstract class A { // Abstract Method void getData () ; // Abstract Method void showData () ; } // Calling Abstract class class B extends A { @override void getData () { print( "Call from getData" ) ; } @override void showData () { print( "Call from showData" ) ; } } void main () { B object = new B () ; object.getData() ; object.showData() ; } ///You can create an object of concrete classes, but you cannot create an object of abstract classes. ///Abstract Class: /// Abstract classes are classes that cannot be initialized. It is used to define the behavior /// of a class that can be inherited by other classes. An abstract class is declared using /// the keyword abstract. /// Syntax: // abstract class ClassName { // //Body of abstract class // // method1(); // method2(); ...