Skip to content

Instantly share code, notes, and snippets.

@nick45chen
nick45chen / router_delegate.dart
Created June 30, 2022 06:22 — forked from Ivy-Walobwa/router_delegate.dart
Code snippets implementing RouteDelegate, RouteInformationParser and defining user data-types. Full repo here: https://github.com/Ivy-Walobwa/flutter_declarative_navigation
import 'package:flutter/material.dart';
import 'routes_config.dart';
import '../presentation/screens.dart';
import '../constants.dart';
class ShopListRouterDelegate extends RouterDelegate<ShopListRouteConfig>
with ChangeNotifier, PopNavigatorRouterDelegateMixin<ShopListRouteConfig> {
@override
final GlobalKey<NavigatorState> navigatorKey;
@nick45chen
nick45chen / EasyWS.kt
Created October 17, 2021 04:48 — forked from omarmiatello/EasyWS.kt
First experiment with WebSocket and Kotlin Coroutine
import kotlinx.coroutines.experimental.CommonPool
import kotlinx.coroutines.experimental.channels.Channel
import kotlinx.coroutines.experimental.launch
import okhttp3.*
import okio.ByteString
import kotlin.coroutines.experimental.suspendCoroutine
/**
* Created by omarmiatello on 17/06/17.
*/
@nick45chen
nick45chen / Connectivity.java
Created August 2, 2021 03:35 — forked from emil2k/Connectivity.java
Android utility class for checking device's network connectivity and speed.
/*
* Copyright (c) 2017 Emil Davtyan
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
@nick45chen
nick45chen / snapping_list_view.dart
Created December 21, 2020 08:11 — forked from yunyu/snapping_list_view.dart
A Flutter PageView replacement/snapping ListView for fixed-extent items
import "package:flutter/widgets.dart";
import "dart:math";
class SnappingListView extends StatefulWidget {
final Axis scrollDirection;
final ScrollController controller;
final IndexedWidgetBuilder itemBuilder;
final List<Widget> children;
final int itemCount;
@nick45chen
nick45chen / snapping_list_view.dart
Created December 21, 2020 08:11 — forked from yunyu/snapping_list_view.dart
A Flutter PageView replacement/snapping ListView for fixed-extent items
import "package:flutter/widgets.dart";
import "dart:math";
class SnappingListView extends StatefulWidget {
final Axis scrollDirection;
final ScrollController controller;
final IndexedWidgetBuilder itemBuilder;
final List<Widget> children;
final int itemCount;
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- google's material design colours from
http://www.google.com/design/spec/style/color.html#color-ui-color-palette -->
<!--reds-->
<color name="md_red_50">#FFEBEE</color>
<color name="md_red_100">#FFCDD2</color>
<color name="md_red_200">#EF9A9A</color>