SHARE
TWEET

Untitled

a guest Oct 22nd, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Date : 19/9/19
  2. --------------
  3.  
  4. In Dart :
  5.  
  6. Constructor :
  7.  
  8.   named constructor & unnamed constructor
  9.  
  10.  
  11. Inheritance :
  12.  
  13.   It is little bit differnt in terms of concept than c#
  14.  
  15.   There are 2 types of Class i.e abstract or concrete and implicit is bot in our hand but that is constructed already by Dart backhanded;
  16.  
  17.  
  18. Imperative code to function :
  19.  
  20.   For iterable object : eg such as fold(), map(), take(), skip(), forEach(), where()
  21.  
  22.                            map & foreach, both take function but map return same collection after applying function to all the elements whereas foreach do not.
  23.  
  24.  
  25. Future< T > & async need not to be in relation with one another, although mostly they are used for asynchronous operation :
  26.  
  27.   async - It is used to tell that method can perform async operation.
  28.  
  29.   Future<T> - It is used generally for return type of async function as they may get delayed in its return
  30.  
  31. Remember : function assigned async must have return type assigned to Future
  32.  
  33. ____________________
  34. Date : 23/9/19
  35.  
  36.  
  37. language tour
  38.  
  39.  
  40. -> all things are object.
  41.  
  42. -> const and final can be used with variable without type annotation. [ i.e without type or var ]
  43.  
  44. -> adjacent string concatenation is allowed same as python in Dart. ( eg 'Nipun' ' Shah')
  45.  
  46. -> iLiteral strings are compile-time constants, as long as any interpolated expression is a compile-time constant that evaluates to null or a numeric, string, or boolean value.
  47.  
  48. -> spread operator & null aware spread operator [ ... & ?.. ]
  49.  
  50. -> Symbols are compile time constants
  51.  
  52. -> function in Dart are objects, having types Function -> more precisely it is Closure.
  53.  
  54. -> In arrow function, only an expression can be used not a statement
  55.  
  56. -> Anonymuous functions ( nameless, lamda, closure ) can be treated as objects
  57.  
  58.     Lexical Scope : Scope of variable is defined statically.
  59.  
  60.     closure : function object -> that has access to variables in its lexical scope, even when function is used outside of its original scope.
  61.  
  62.                   Actually Functions can close over varibles from its surrounding scopes.
  63.  
  64. -> All functions returns value, ( by default return null )
  65.  
  66.     Cascade (..) : allow to make a sequence of operations on same object. avoid creating temporary variables
  67.  
  68.                        ignoring any subsequent values that might be returned.
  69.  
  70.                        Be careful to construct your cascade on a function that returns an actual object i.e Constructor
  71.  
  72.  
  73. -> for loop :
  74.  
  75.    Closures inside of Dart’s for loops capture the value of the index
  76.  
  77. -> Assert : assert( condition, optionalMessage )
  78.  
  79.    disrupt normal execution if boolean condition is false
  80.    Normally used during development
  81.  
  82.    If condition false : AssertionError is thrown
  83.  
  84. -> Exceptions :
  85.  
  86.    Something unexpected happened
  87.    Exception & Error.
  88.  
  89.    can throw any non-null object as exception, but usually types that implement Error or Exception are thrown
  90.    throwing exception -> is an expression
  91.  
  92.    Catch : stops exception from propagating ( unless exception is rethrown )
  93.  
  94.            3 types: 1) for specific type of exception - { on ExceptionTypeName }
  95.  
  96.                     2) for general Exception  - { on Exception Catch(e) }
  97.  
  98.                     3) No specified type - { catch(e) }
  99.  
  100.  
  101.            Remember : on is used when we need specific Exception
  102.  
  103.                       catch is used when we need object of that thrown exception
  104.  
  105.    rethrow : partially handle exception, and allow it to propagate
  106.  
  107.    finally : finally clause runs after any matching catch clauses
  108.  
  109.        
  110. -> Class :
  111.  
  112.           Object,
  113.  
  114.           Mixin-based inheritance - every class ( except Object ) has 1 superclass. a class body can be reused in multiple
  115.  
  116.           ?. -> instance null check before accessing property
  117.  
  118.    Constructor :
  119.  
  120.           ClassName or ClassName.Identifier  [ Named Constructor ]
  121.  
  122.           compile-time constant - constant constructors
  123.  
  124.           Remember :- Constructing two identical compile-time constants results in a single, canonical instance
  125.  
  126.                       Constructors are not inherited
  127.  
  128.                       The superclass’s constructor is called at the beginning of the constructor body
  129.  
  130.                       initializer list executes before the superclass constructor is called
  131.  
  132.                       If you don't declare any of constructor, then only default one will be provided
  133.  
  134.           Summary : Execution oreder in case of constructor :
  135.  
  136.             1) initializer list
  137.                 2) superclass’s no-arg constructor
  138.                 3) main class’s no-arg constructor
  139.  
  140.  
  141.    constant context :
  142.  
  143.           applying const in front of identifier, const context is created where rhs is alreday const without declaring const for it.
  144.  
  145.           if a const cosntructor is outside of a constant context and invoked without const, it creates a non-const object
  146.  
  147.           :- const become after occurence of constant context
  148.  
  149.    Get Type of Object :
  150.  
  151.           property - runTimeProperty -> return Type object
  152.  
  153.  
  154.    Class Implementation :
  155.  
  156.  
  157.    Instance :
  158.  
  159.           all instance variables -> implicit getter methods
  160.           non-final instance variables -> implicit setter methods
  161.  
  162.      Note : if you initialize an instance variable where it is declared (instead of in a constructor or method), the value is set when the instance is created, which is before the constructor and its initializer list execute.
  163.  
  164.                    
  165.    
  166.    Assigning Constructor Arguments to Instance variables : use syntatcic sugar approach [ i.e this ]
  167.  
  168.  
  169.    Default Constructor : also invokes the no-argument constructor in superclass.
  170.  
  171.    Name Constructor : multiple constructor for sinlge class or to provide extra clarity
  172.  
  173.  
  174.  
  175.  
  176.  
  177. ___________________
  178.  
  179. Flutter :
  180.  
  181.  
  182.   Flutter uses most of time, named parameter in function
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top