Skip to content

Instantly share code, notes, and snippets.

View ulisseshen's full-sized avatar
🏠
Working from home

🧙‍♂️ O Mago do Flutter 🪄 ulisseshen

🏠
Working from home
View GitHub Profile
Future<http.Response> fetchAlbum() {
return http.get(Uri.parse('https://jsonplaceholder.typicode.com/albums/1'));
}
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.
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.
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();
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.
class _MyAppState extends State<MyApp> {
late Future<Album> futureAlbum;
@override
void initState() {
super.initState();
futureAlbum = fetchAlbum();
}
// ···
}
@ulisseshen
ulisseshen / Aula 1 - main.dart
Last active February 28, 2023 00:31
[mobile_dev] Aula 1 - Dart variáveis, tipagem, funções e print
void main() {
int idadePessoa = trazerIdadeDaTela();
// valor da direita para a esquerda
// variavel <<< valor
String nome = trazerNomeDaTela();
double salario = trazerSalarioDaTela();
@ulisseshen
ulisseshen / main.dart
Last active February 8, 2023 18:10
[mobile_dev] Aula 2 - Dart listas, índices, concatenação e interpolação de String, for e for-in
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);
@ulisseshen
ulisseshen / main.dart
Created February 9, 2023 02:09
[mobile_dev] Aula 3 - Dart tipos booleanos, estrutura if - else if - else, break e continue no for
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);
@ulisseshen
ulisseshen / main.dart
Last active February 10, 2023 13:03
[mobile_dev] Aula 4 - Dart operadors lógicos, relacionais e matemático - menor igual, negação, ou
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");