Skip to content

Instantly share code, notes, and snippets.

View Navigator flutter
import 'package:flutter/material.dart';
void main() {
runApp(const MaterialApp(
title: 'Navigation Basics',
home: FirstRoute(),
));
}
class FirstRoute extends StatelessWidget {
View gist:7bf185b718b7445a859b96ccf27f34d8
import 'dart:async';
import 'package:flutter/widgets.dart';
import 'package:path/path.dart';
import 'package:sqflite/sqflite.dart';
void main() async {
// Avoid errors caused by flutter upgrade.
// Importing 'package:flutter/widgets.dart' is required.
WidgetsFlutterBinding.ensureInitialized();
View gist:2cadcbba5f44df61698bd94c3e4b79de
import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
Future<Album> createAlbum(String title) async {
final response = await http.post(
Uri.parse('https://jsonplaceholder.typicode.com/albums'),
headers: <String, String>{
View gist:5f59d6b9cd27cbf9c276fd4dc22abd37
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'));
View Github Actions
name: Android CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
View ItemContentProvider
public class ItemContentProvider extends ContentProvider {
@Override
public boolean onCreate() { return true; }
@Nullable
@Override
View Coroutine
GlobalScope
coroutineScope
runBlocking
runBlocking 2
Job
Récupérer la valeur d'un Job
Exception
===============================
GlobalScope
===============================
View Mockito
Dans Unit Test
============================================
Database
============================================
public class Database {
public boolean isAvailable() {
// currently not implemented, as this is just demo used in a software test
return false;
}
View Network
Sans runTime permission
===================================
Gradle
===================================
implementation 'com.android.volley:volley:1.2.1'
===================================
Manifest
View Espresso Test
========================================================
layout activity
========================================================
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">