Skip to content

Instantly share code, notes, and snippets.

View magicleon94's full-sized avatar

Antonello Galipò magicleon94

View GitHub Profile
@magicleon94
magicleon94 / scrolly_button.dart
Created June 27, 2019 18:15
Always up button on scroll view
//Hello Gonçalo!
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
ValueNotifier<double> _notifier;
ScrollController _controller;
double _previousOffset;
@magicleon94
magicleon94 / index.html
Created December 17, 2019 11:56
Dart streams - Flutter BLoC talk example
<!-- Copyright 2011 the Dart project authors. All rights reserved.
Use of this source code is governed by a BSD-style license
that can be found in the LICENSE file. -->
<h2>Dart streams!</h2>
<div>
<canvas id="canvas" width="300" height="300"></canvas>
</div>
@magicleon94
magicleon94 / cloudSettings
Last active July 30, 2020 07:52
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-07-30T07:52:04.215Z","extensionVersion":"v3.4.3"}
@magicleon94
magicleon94 / dependency_injector.dart
Last active July 12, 2022 18:18
Lazy dependency injection template
import 'package:dio/dio.dart';
import 'package:dio/src/dio.dart';
import 'package:my_test_app/config/application_config.dart';
import 'package:my_test_app/dependency_injection/dependency_injector_base.dart';
import 'package:my_test_app/features/login/login_bloc.dart';
import 'package:my_test_app/features/login/login_service.dart';
import 'package:my_test_app/features/splash/splash_bloc.dart';
import 'package:my_test_app/features/splash/splash_service.dart';
class DependencyInjector extends DependencyInjectorBase {
@magicleon94
magicleon94 / exclude_compile_code_example_1.dart
Last active March 26, 2020 09:26
Excluding Dart code from the release compiled executable (Medium article)
class Config {
static final bool enable = false;
}
class Features {
void runCheck() {
List<String> features = [
"feature1",
if (Config.enable) "feature2",
];
@magicleon94
magicleon94 / exclude_compile_code_example_2.dart
Last active March 26, 2020 09:26
Excluding Dart code from the release compiled executable (Medium article)
class Config {
static const bool enable = false;
}
class Features {
void runCheck() {
List<String> features = [
"feature1",
if (Config.enable) "feature2",
];
@magicleon94
magicleon94 / snapshot_helper.dart
Last active July 9, 2020 12:13
A simple helper to map states of a snapshot coming from a StreamBuilder
import 'package:flutter/material.dart';
typedef SnapshotBuilder<T> = Widget Function(AsyncSnapshot<T>);
class SnapshotHelper<T> {
final AsyncSnapshot<T> snapshot;
SnapshotHelper._(this.snapshot);
factory SnapshotHelper.of(AsyncSnapshot snapshot) =>
@magicleon94
magicleon94 / auth0_manager.js
Created July 14, 2020 14:46
Auth0 manager - js side - for medium article
function createAuth0Manager(clientParameters, onAuthenticated, onAuthError) {
return new Auth0Manager(clientParameters, onAuthenticated, onAuthError);
}
class Auth0Manager {
constructor(clientParameters, onAuthenticated, onAuthError) {
this.clientParameters = clientParameters;
this.onAuthenticated = onAuthenticated;
this.onAuthError = onAuthError;
this.auth0Client = new auth0.WebAuth({
@magicleon94
magicleon94 / auth0_manager_for_web.dart
Created July 14, 2020 14:57
Auth0 manager - dart side - for medium article
import 'dart:async';
import 'dart:convert';
import 'dart:js' as js;
import 'package:my_app/providers/user_provider/model/user.dart';
import 'package:my_app/providers/user_provider/user_provider.dart';
import 'auth_manager.dart';
void _alert(dynamic param) {
@magicleon94
magicleon94 / auth_manager.dart
Last active July 15, 2020 12:36
Abstract class for auth0 login - for medium article
abstract class AuthManager {
static AuthManager _instance;
static AuthManager get instance {
if (_instance == null) {
if (kIsWeb) {
_instance = Auth0ManagerForWeb();
} else {
_instance = Auth0Manager();
}