Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Date : 19/9/19
- --------------
- In Dart :
- Constructor :
- named constructor & unnamed constructor
- Inheritance :
- It is little bit differnt in terms of concept than c#
- 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;
- Imperative code to function :
- For iterable object : eg such as fold(), map(), take(), skip(), forEach(), where()
- map & foreach, both take function but map return same collection after applying function to all the elements whereas foreach do not.
- Future< T > & async need not to be in relation with one another, although mostly they are used for asynchronous operation :
- async - It is used to tell that method can perform async operation.
- Future<T> - It is used generally for return type of async function as they may get delayed in its return
- Remember : function assigned async must have return type assigned to Future
- ____________________
- Date : 23/9/19
- language tour
- -> all things are object.
- -> const and final can be used with variable without type annotation. [ i.e without type or var ]
- -> adjacent string concatenation is allowed same as python in Dart. ( eg 'Nipun' ' Shah')
- -> 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.
- -> spread operator & null aware spread operator [ ... & ?.. ]
- -> Symbols are compile time constants
- -> function in Dart are objects, having types Function -> more precisely it is Closure.
- -> In arrow function, only an expression can be used not a statement
- -> Anonymuous functions ( nameless, lamda, closure ) can be treated as objects
- Lexical Scope : Scope of variable is defined statically.
- closure : function object -> that has access to variables in its lexical scope, even when function is used outside of its original scope.
- Actually Functions can close over varibles from its surrounding scopes.
- -> All functions returns value, ( by default return null )
- Cascade (..) : allow to make a sequence of operations on same object. avoid creating temporary variables
- ignoring any subsequent values that might be returned.
- Be careful to construct your cascade on a function that returns an actual object i.e Constructor
- -> for loop :
- Closures inside of Dart’s for loops capture the value of the index
- -> Assert : assert( condition, optionalMessage )
- disrupt normal execution if boolean condition is false
- Normally used during development
- If condition false : AssertionError is thrown
- -> Exceptions :
- Something unexpected happened
- Exception & Error.
- can throw any non-null object as exception, but usually types that implement Error or Exception are thrown
- throwing exception -> is an expression
- Catch : stops exception from propagating ( unless exception is rethrown )
- 3 types: 1) for specific type of exception - { on ExceptionTypeName }
- 2) for general Exception - { on Exception Catch(e) }
- 3) No specified type - { catch(e) }
- Remember : on is used when we need specific Exception
- catch is used when we need object of that thrown exception
- rethrow : partially handle exception, and allow it to propagate
- finally : finally clause runs after any matching catch clauses
- -> Class :
- Object,
- Mixin-based inheritance - every class ( except Object ) has 1 superclass. a class body can be reused in multiple
- ?. -> instance null check before accessing property
- Constructor :
- ClassName or ClassName.Identifier [ Named Constructor ]
- compile-time constant - constant constructors
- Remember :- Constructing two identical compile-time constants results in a single, canonical instance
- Constructors are not inherited
- The superclass’s constructor is called at the beginning of the constructor body
- initializer list executes before the superclass constructor is called
- If you don't declare any of constructor, then only default one will be provided
- Summary : Execution oreder in case of constructor :
- 1) initializer list
- 2) superclass’s no-arg constructor
- 3) main class’s no-arg constructor
- constant context :
- applying const in front of identifier, const context is created where rhs is alreday const without declaring const for it.
- if a const cosntructor is outside of a constant context and invoked without const, it creates a non-const object
- :- const become after occurence of constant context
- Get Type of Object :
- property - runTimeProperty -> return Type object
- Class Implementation :
- Instance :
- all instance variables -> implicit getter methods
- non-final instance variables -> implicit setter methods
- 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.
- Assigning Constructor Arguments to Instance variables : use syntatcic sugar approach [ i.e this ]
- Default Constructor : also invokes the no-argument constructor in superclass.
- Name Constructor : multiple constructor for sinlge class or to provide extra clarity
- ___________________
- Flutter :
- Flutter uses most of time, named parameter in function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement