This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Person{ | |
| String firstName; | |
| int age; | |
| Person(this.firstName,this.age); | |
| printName(){ | |
| print(firstName); | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Deck{ | |
| List<Card> cards = new List<Card>(); | |
| Deck(){ | |
| var ranks = ['Ace','Two','Three','Four','Five']; | |
| var suits = ['Diamonds','Hearts','Clubs','Spades']; | |
| for(var suit in suits){ | |
| for(var rank in ranks){ | |
| var card = new Card(rank:rank, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'dart:convert'; | |
| class ImageModel{ | |
| int id; | |
| String url; | |
| ImageModel(this.id,this.url); | |
| ImageModel.fromJson(parsedJson){ | |
| this.id = parsedJson['id']; | |
| this.url = parsedJson['url']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'dart:async'; | |
| main() async{ | |
| /*print('About to fetch the data'); | |
| get('http:/dkjsbkdsjbdl') | |
| .then((result){ | |
| print(result); | |
| }); | |
| */ | |
| // Async Await Syntax: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'dart:html'; | |
| void main(){ | |
| final ButtonElement button = querySelector('button'); | |
| // Game: Click the button atleast once in a second otherwise you lose it | |
| button.onClick | |
| .timeout( | |
| new Duration(seconds: 1), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Model a Chocolate Cake factory using Streams | |
| import 'dart:async'; | |
| void main(){ | |
| final controller = new StreamController(); | |
| /*once the controller is created, it gets 2 attributes | |
| 1. Sink - The order taker | |
| 2. Factory - Where the processing is done*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'dart:html'; | |
| import 'dart:async'; | |
| void main(){ | |
| final InputElement input = querySelector('input'); | |
| final DivElement div = querySelector('div'); | |
| final validator = new StreamTransformer.fromHandlers( | |
| handleData: (inputValue,sink){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data class UserModel( | |
| val userName : String?, | |
| val userEmailId: String?, | |
| val uuid: String?, | |
| val accountCreatedAt: String?, | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dependencies{ | |
| /* YOUR EXISTING DEPENDENCIES */ | |
| implementation 'com.squareup.retrofit2:retrofit:2.6.2' | |
| implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5' | |
| implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.5' | |
| implementation 'com.squareup.retrofit2:converter-gson:2.3.0' | |
| implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.3.0-alpha01" | |
| implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' | |
| implementation 'androidx.core:core-ktx:1.2.0' | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface ApiInterface { | |
| @GET("/api/") | |
| suspend fun getPhotos() : Photos | |
| } |
OlderNewer