Skip to content

Instantly share code, notes, and snippets.

View jamesdixon's full-sized avatar

James Dixon jamesdixon

View GitHub Profile
@jamesdixon
jamesdixon / dimiss-keyboard.dart
Created August 25, 2019 21:30
Flutter 360: Dismiss Keyboard
GestureDetector(
onTap: () {},
child: ...
);
@jamesdixon
jamesdixon / dimiss-keyboard-1.dart
Created August 25, 2019 21:33
Flutter 360: Dimiss Keyboard
// main.dart
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {},
// main.dart
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
// main.dart
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
// main.dart
import 'package:logs/logs.dart';
final Log httpLog = Log('http');
void main() {
httpLog.enabled = true;
}
# pubspec.yaml
dependencies:
logs:
git: https://github.com/pq/logs
// Make sure to replace <YOUR_LOCAL_IP> with
// the external IP of your computer if you're using Android.
// Note that we're using port 8888 which is Charles' default.
String proxy = Platform.isAndroid ? '<YOUR_LOCAL_IP>:8888' : 'localhost:8888';
// Create a new HttpClient instance.
HttpClient httpClient = new HttpClient();
// Hook into the findProxy callback to set
// the client's proxy.
// Make sure to replace <YOUR_LOCAL_IP> with
// the external IP of your computer if you're using Android.
// Note that we're using port 8888 which is Charles' default.
String proxy = Platform.isAndroid ? '<YOUR_LOCAL_IP>:8888' : 'localhost:8888';
// Create a new HttpClient instance.
HttpClient httpClient = new HttpClient();
// Hook into the findProxy callback to set
// the client's proxy.
// Make sure to replace <YOUR_LOCAL_IP> with
// the external IP of your computer if you're using Android.
// Note that we're using port 8888 which is Charles' default.
String proxy = Platform.isAndroid ? '<YOUR_LOCAL_IP>:8888' : 'localhost:8888';
// Create a new Dio instance.
Dio dio = Dio();
// Tap into the onHttpClientCreate callback
// to configure the proxy just as we did earlier.
import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:dart_jsona/dart_jsona.dart';
import 'package:flutter/foundation.dart';
/// Dio Transformer used to automatically serialize and
/// deserialize JSON-API payloads.
class JsonApiTransformer extends DefaultTransformer {
static const kJsonApiMimeType = 'application/vnd.api+json';