Skip to content

Instantly share code, notes, and snippets.

@rubywai
rubywai / main.dart
Created October 30, 2023 13:59 — forked from Piinks/main.dart
Two Dimensional Grid in Flutter
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:math' as math;
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
@rubywai
rubywai / Variance.kt
Created December 29, 2020 13:41 — forked from tomaszpolanski/Variance.kt
Covariance vs Contravariance
package com.tomek
abstract class Animal(val size: Int)
class Dog(val cuteness: Int): Animal(100)
class Spider(val terrorFactor: Int): Animal(1)
// Covariance
@rubywai
rubywai / AnAndroidApp.kt
Last active December 24, 2020 05:39 — forked from manuelvicnt/AnAndroidApp.kt
Hilt and AssistedInject working together in Hilt v2.28-alpha times - ViewModel version
// AssistedInject and Hilt working together in v2.28-alpha times
// Example of a ViewModel using AssistedInject injected in a Fragment by Hilt
// As AssistedInject isn't part of Dagger yet, we cannot use in
// conjuction with @ViewModelInject
data class MyInitParams(private val neededId: String)
class MyViewModel @AssistedInject constructor(
... // Other dependencies injected by Hilt
// com.squareup.inject.assisted.Assisted annotation
@rubywai
rubywai / AssistedInjectModule.kt
Created December 24, 2020 05:36 — forked from adam-hurwitz/AssistedInjectModule.kt
Dagger 2 AssistedInject ViewModels
import com.squareup.inject.assisted.dagger2.AssistedModule
import dagger.Module
@AssistedModule
@Module(includes = [AssistedInject_AssistedInjectModule::class])
class AssistedInjectModule