Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Andrew Chen yongjhih

🏠
Working from home
Block or report user

Report or block yongjhih

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View InstabugHttpOverrides.dart
import 'dart:io';
import 'package:instabug_flutter/NetworkLogger.dart';
import 'package:instabug_flutter/models/network_data.dart';
class InstabugIoHttpClient implements HttpClient {
final HttpClient client;
InstabugIoHttpClient({HttpClient client}) : client = client ?? HttpClient();
View SimpleHttpClientRequest.dart
class SimpleHttpClientRequest extends HttpClientRequest {
SimpleHttpClientRequest(this.request);
final http.Request request;
@override
Encoding encoding;
@override
void add(List<int> data) {
// TODO: implement add
View SimpleInstabugHttpClient.dart
class SimpleInstabugHttpClient extends InstabugHttpClient {
@override
Future<http.StreamedResponse> send(http.BaseRequest request) {
final startTime = DateTime.now();
return client.send(request).then((response) {
logHttpBaseResponse(response, startTime: startTime);
return response;
});
}
View Singleton.kt
open class Singleton<in T, out R>(private val creator: (T) -> R) {
@Volatile private var instance: R? = null
fun of(context: T): R {
return instance ?: synchronized(this) {
val i = instance
if (i != null) {
i
} else {
val i2 = creator(context)
View AnalyticsClientKtx.kt
fun AnalyticsClient.submitEvents(func: AnalyticsClient.() -> Unit) {
func()
submitEvents()
}
fun TargetingClient.updateEndpointProfile(func: TargetingClient.() -> Unit) {
func()
updateEndpointProfile()
}
View MethodCallKtx.kt
fun <T> MethodCall.argumentOrNull(key: String): T? = try { argument(key) } catch (e: Throwable) { null }
fun <T> MethodCall.argumentsOrNull(): T? = arguments() as? T?
//fun <T> MethodCall.argument(key: String): T? = try { argument(key) } catch (e: Throwable) { null }
//fun <T> MethodCall.arguments(): T? = arguments() as? T?
//@JvmOverloads
//fun Result.success(result: Any? = null): Unit = success(result)
fun Result.success(): Unit = success(null) // avoid shadow
fun Result.errors(code: String, message: String? = null, details: Any? = null): Unit = error(code, message, details)
fun Result.error(e: Throwable): Unit = errors(e.cause.toString(), e.message, e.stackTrace)
View PinpointInitLazy.kt
val pinpoint: PinpointManager by lazy {
PinpointManager(PinpointConfiguration(
context,
awsClient,
awsConfig))
}
val awsConfig: AWSConfiguration by lazy { AWSConfiguration(context) }
val awsClient: AWSMobileClient by lazy {
View PinpointInit.kt
fun init() {
val awsConfig: AWSConfiguration = AWSConfiguration(this)
AWSMobileClient.getInstance().initializes(this, awsConfig) {
onResult {
Log.d("MainActivity", "${it.userState}")
}
onError { e ->
e.printStackTrace()
}
View InstabugTree.dart
class InstabugTree extends LogTree {
static const V = "V";
static const D = "D";
static const I = "I";
static const W = "W";
static const E = "E";
static const List<String> DEFAULT = [V, D, I, W, E];
List<String> logLevels;
InstabugTree({this.logLevels = DEFAULT});
View ioHttp2http.dart
class SimpleHttpClientRequest extends HttpClientRequest {
SimpleHttpClientRequest(this.request);
final http.Request request;
@override
Encoding encoding;
@override
void add(List<int> data) {
// TODO: implement add
You can’t perform that action at this time.