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 'package:flutter/material.dart'; | |
| import 'package:cloud_firestore/cloud_firestore.dart'; | |
| void main() async { | |
| runApp(MyApp()); | |
| //Escrevendo dados na base de dados. | |
| //OBS: se o parametro de document() for vazio é criado um id para | |
| // o documento de forma automática. | |
| Firestore.instance.collection("mensagens").document().setData({ |
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 kotlinx.coroutines.delay | |
| import kotlinx.coroutines.flow.Flow | |
| import kotlinx.coroutines.flow.flow | |
| import kotlinx.coroutines.flow.collect | |
| import kotlinx.coroutines.runBlocking | |
| /** | |
| flow {...} - build | |
| emit(value) - transmit a value | |
| collect {...} - receive the values |
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 android.app.IntentService | |
| import android.content.Context | |
| import android.content.Intent | |
| import android.content.SharedPreferences | |
| import android.util.Log | |
| import androidx.core.content.edit | |
| import com.google.gson.Gson | |
| abstract class BaseService(val name: String) : IntentService(name) { |
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
| val verdadeiro = true | |
| val falso = false | |
| val resultado1 = verdadeiro.and(falso) //resultado1 = false | |
| val resultado2 = verdadeiro.or(falso) //resultado2 = true | |
| val resultado3 = verdadeiro.not() //resultado3 = false | |
| val resultado4 = verdadeiro.xor(falso) //resultado4 = true | |
| println("$resultado1, $resultado2, $resultado3, $resultado4") |
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
| fun check(c: Char) { | |
| if (c == 1) { //ERRO: tipos incompatíveis | |
| // ... | |
| } | |
| } |
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
| val i: Int = b.toInt() // OK: covertido explicitamente. | |
| print(i) |
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
| // Código hipotético, na verdade não compila: | |
| val a: Int? = 1 // Tipo Int (java.lang.Integer) | |
| val b: Long? = a // conversão implícita produz um Long (java.lang.Long) | |
| print (b == a) // Surpresa! Isso imprime "falso" |
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
| val umMilhao = 1_000_000 | |
| val numeroCartaoCredito = 1234_5678_9012_3456L | |
| val numeroSeguroSocial = 999_99_9999L | |
| val hexBytes = 0xFF_EC_DE_5E | |
| val bytes = 0b11010010_01101001_10010100_10010010 |
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
| val s = "abc" | |
| val str ="$s.length is ${s.length}" | |
| println(str) // imprime "abc.length is 3" |
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
| val inteiro = 10 | |
| val resultado = "inteiro = $inteiro" | |
| print(resultado) // imprime "inteiro = 10" |
NewerOlder