Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Christopher N. KATOYI Christopher2K

🎯
Focusing
View GitHub Profile
@Christopher2K
Christopher2K / code.js
Created Jul 15, 2020
Arrays with Javascript code snippets
View code.js
// Snippets de code utilisés dans l'article
// 1.
let myArray = [];
// 2.
let myArray = [];
myArray.push("hello");
myArray.push("world");
myArray.push("today", "is", "a", "beautiful", "day", 44);
@Christopher2K
Christopher2K / list_view_with_extra_elements.dart
Created Mar 9, 2020
Allow ListView.builder() to have leading / trailling elements
View list_view_with_extra_elements.dart
import 'package:flutter/material.dart';
class ListViewWithExtraElements<T> extends StatelessWidget {
final List<T> elements;
final List<Widget> leadingElements;
final List<Widget> trailingElements;
final Widget Function(BuildContext context, T element) itemBuilder;
ListViewWithExtraElements({
this.leadingElements = const [],
@Christopher2K
Christopher2K / widget.dart
Last active Feb 7, 2020
[Programmatically open drawer from scaffold directly] How to open scaffold's drawer with code #flutter #dart
View widget.dart
class Widget extends StatelessWidget {
final GlobalKey<ScaffoldState> _drawerKey = GlobalKey();
void _openDrawer () {
_drawerKey.currentState.openDrawer();
}
@override
Widget build(BuildContext context) {
return Scaffold(
@Christopher2K
Christopher2K / widget.dart
Last active Jan 26, 2020
[Transparent App Bar] How to get a transparent app bar #flutter #dart
View widget.dart
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
title: const Text('Hello !'),
),
extendBodyBehindAppBar: true,
@Christopher2K
Christopher2K / widget.dart
Created Jan 25, 2020
[Clear the stack and push a new screen] How to reset the stack and push a new screen a flutter to avoid the back behaviour #flutter #dart
View widget.dart
class MyWidget extends StatelessWidget {
void _clearStackAndPush (BuildContext context) {
Navigator.of(context).pushNamedAndRemoveUntil(
'/screen-name',
() => false,
);
}
@override
Widget build(BuildContext context) {
View keybase.md

Keybase proof

I hereby claim:

  • I am christopher2k on github.
  • I am christopher2k (https://keybase.io/christopher2k) on keybase.
  • I have a public key ASBbLb-XbTgjxD_4tBXA5mbRgFfx4b7rGzk3BaomHEsllgo

To claim this, I am signing this object:

View http-rx-dom-multiple.js
// with rx-dom@7.0.3 & rxjs@5.5.6
import { combineLatest } from 'rxjs/observable/combineLatest';
import { ajax } from 'rxjs/observable/dom/ajax';
import { tap, map } from 'rxjs/operators';
const BASE_URL = 'http://myurl.com';
// Retour un observable AJAX formé par un argument
function loginUserAccordingToData({ someDataThis }) {
return ajax.post(`${BASE_URL}/data`, { someDataThis })
View http-rx-dom.js
// with rx-dom@7.0.3 & rxjs@5.5.6
import { ajax } from 'rxjs/observable/dom/ajax';
import { tap } from 'rxjs/operators';
const request = ajax.getJSON('http://myurl.com/data')
.pipe(
tap((jsonData) => console.log(jsonData))
);
// Appel HTTP
View fetch.js
const url = 'http://myurl.com';
const options = { method: 'GET' };
// Appel de l'API Fetch
fetch(url, options)
.then((response) => response.json()) // Récupération des données
.then((data) => { // Callback de succès
window.alert('SUCCESS');
console.log(data);
})
View xhr.js
// Initialisation de la requête XHR
const request = new window.XMLHttpRequest();
// Options de la requête
const options = {
method: 'GET',
url: 'http://myurl.com',
async: true
};