Skip to content

Instantly share code, notes, and snippets.

View javaherisaber's full-sized avatar

Mahdi Javaheri javaherisaber

View GitHub Profile
@javaherisaber
javaherisaber / picsum_list.json
Created April 17, 2021 02:43
List of picsum images to be used in Mockfit medium article
[
{
"id": "1016",
"author": "Andrew Ridley",
"width": 3844,
"height": 2563,
"url": "https://unsplash.com/photos/_h7aBovKia4",
"download_url": "https://picsum.photos/id/1018/3914/2935"
},
{
@javaherisaber
javaherisaber / api.kt
Created April 17, 2021 02:50
Api to picsum
interface Api {
@Mock("picsum_list.json")
@GET("list")
fun getListOfPicsums(
@Query("page") page: Int,
@Query("limit") limit: Int
): Call<List<Picsum>>
}
class RemoteDataSource(private val context: Context) {
fun api(): Api {
val mockFitInterceptor = provideMockFitInterceptor(context)
val okHttpClient = provideOkHttpClient(mockFitInterceptor)
val retrofit = provideRetrofit(okHttpClient)
return retrofit.create(Api::class.java)
}
private fun provideRetrofit(okHttpClient: OkHttpClient): Retrofit = Retrofit.Builder()
@javaherisaber
javaherisaber / bloc.dart
Last active September 18, 2022 11:09
BlocProvider
import 'package:flutter/material.dart';
import 'package:rxdart/rxdart.dart';
abstract class BlocBase {
void dispose();
}
class BlocProvider<T extends BlocBase> extends StatefulWidget {
const BlocProvider({
super.key,