This file contains 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
Future<http.Response> fetchAlbum() { | |
return http.get(Uri.parse('https://jsonplaceholder.typicode.com/albums/1')); | |
} |
This file contains 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
var nome = 'Ulisses' | |
var sobrenome = 'Hen'; | |
var idade = 29; | |
console.log('Meu nome é ' + nome + ' ' + sobrenome + ' e tenho ' + idade + ' anos.'); | |
// exibe: Meu nome é Ulisses Hen e tenho 29 anos. |
This file contains 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
Future<Album> fetchAlbum() async { | |
final response = await http | |
.get(Uri.parse('https://jsonplaceholder.typicode.com/albums/1')); | |
if (response.statusCode == 200) { | |
// Se o servidor retornou uma resposta 200 OK, | |
// então analisa o JSON. | |
return Album.fromJson(jsonDecode(response.body)); | |
} else { | |
// Se o servidor não retornou uma resposta 200 OK, | |
// então lança uma exceção. |
This file contains 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
FutureBuilder<Album>( | |
future: futureAlbum, | |
builder: (context, snapshot) { | |
if (snapshot.hasData) { | |
return Text(snapshot.data!.title); | |
} else if (snapshot.hasError) { | |
return Text('${snapshot.error}'); | |
} | |
// By default, show a loading spinner. | |
return const CircularProgressIndicator(); |
This file contains 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'; | |
import 'dart:convert'; | |
import 'package:flutter/material.dart'; | |
import 'package:http/http.dart' as http; | |
Future<Album> fetchAlbum() async { | |
final response = await http | |
.get(Uri.parse('https://jsonplaceholder.typicode.com/albums/1')); | |
if (response.statusCode == 200) { | |
// If the server did return a 200 OK response, | |
// then parse the JSON. |
This file contains 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 _MyAppState extends State<MyApp> { | |
late Future<Album> futureAlbum; | |
@override | |
void initState() { | |
super.initState(); | |
futureAlbum = fetchAlbum(); | |
} | |
// ··· | |
} |
This file contains 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
void main() { | |
int idadePessoa = trazerIdadeDaTela(); | |
// valor da direita para a esquerda | |
// variavel <<< valor | |
String nome = trazerNomeDaTela(); | |
double salario = trazerSalarioDaTela(); | |
This file contains 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
void main() { | |
List<int> numeros = pegarNumerosNoBackEnd(); | |
print(numeros[0]); | |
print(numeros[1]); | |
print(numeros[2]); | |
print(numeros[3]); | |
List<String> nomes = pegarNomesDePessoasNoBancoDeDados(); | |
print(nomes.length); |
This file contains 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
void main() { | |
List<int> numeros = pegarNumerosNoBackEnd(); | |
print(numeros[0]); | |
print(numeros[1]); | |
print(numeros[2]); | |
print(numeros[3]); | |
List<String> nomes = pegarNomesDePessoasNoBancoDeDados(); | |
print(nomes.length); |
This file contains 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
void main() { | |
for (int i = -2; i < 5; i++) { | |
if(i > 3){ | |
print("indice maior que 3"); | |
} | |
if(i <= 3){ | |
print("indice menor que 3"); | |
} | |
if(i != 3){ | |
print("indice diferente de 3"); |
OlderNewer