Skip to content

Instantly share code, notes, and snippets.

View temoki's full-sized avatar
🐢

Tomoki Kobayashi temoki

🐢
View GitHub Profile
//================================================================================
// Flutter State Management Guide (2)
//
// 前回の続き
// https://gist.github.com/temoki/0e9acedbfa2b6ebe424f7e856dc2f5f3
//================================================================================
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
//================================================================================
// Flutter State Management Guide (1)
//
// f(State) = UI
//
// It means the UI is a function of the current state.
// When the state changes, the UI automatically updates to reflect it.
//================================================================================
import 'package:flutter/material.dart';
import 'package:provider/provider.dart' as provider;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@temoki
temoki / main.dart
Created December 26, 2022 23:49
[Flutter tips] Themeで囲ってデフォルトのアイコンサイズを変える
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return MaterialApp(
title: 'Test',
@temoki
temoki / All_POSIXErrorCode.swift
Created July 21, 2020 06:56
All POSIXErrorCode
import Foundation
let allCodes: [(POSIXErrorCode, String)] = [
(.E2BIG,"E2BIG"),
(.EACCES,"EACCES"),
(.EADDRINUSE,"EADDRINUSE"),
(.EADDRNOTAVAIL,"EADDRNOTAVAIL"),
(.EAFNOSUPPORT,"EAFNOSUPPORT"),
(.EAGAIN,"EAGAIN"),
(.EALREADY,"EALREADY"),
@temoki
temoki / All_NSCocoaErrorDomain.swift
Created July 21, 2020 06:31
All NSCocoaErrorDomain
import Foundation
let allCodes: [(Int, String)] = [
(NSFileNoSuchFileError,"NSFileNoSuchFileError"),
(NSFileLockingError,"NSFileLockingError"),
(NSFileReadUnknownError,"NSFileReadUnknownError"),
(NSFileReadNoPermissionError,"NSFileReadNoPermissionError"),
(NSFileReadInvalidFileNameError,"NSFileReadInvalidFileNameError"),
(NSFileReadCorruptFileError,"NSFileReadCorruptFileError"),
(NSFileReadNoSuchFileError,"NSFileReadNoSuchFileError"),
@temoki
temoki / All_OSStatus.swift
Last active July 21, 2020 06:17
All OSStatus in Security.framework
import Foundation
let statuses: [(OSStatus, String)] = [
(errSecSuccess,"errSecSuccess"),
(errSecUnimplemented,"errSecUnimplemented"),
(errSecDiskFull,"errSecDiskFull"),
// (errSecDskFull,"errSecDskFull"), // Deprecated
(errSecIO,"errSecIO"),
(errSecOpWr,"errSecOpWr"),
(errSecParam,"errSecParam"),
@temoki
temoki / Error_as_NSError.swift
Last active July 21, 2020 05:56
Error as NSError
import Foundation
struct StructError: Error {
var localizedDescription: String { "StructError.localizedDescription" }
}
class ClassError: Error {
var localizedDescription: String { "ClassError.localizedDescription" }
}
@temoki
temoki / SendSynchronously.swift
Last active January 26, 2018 15:25
Execute `APIKit.Session.send(_:callbackQueue:handler:)` synchronously.
import APIKit
import Result
extension APIKit.Session {
class func sendSynchronous<Request>(_ request: Request) -> Result<Request.Response, APIKit.SessionTaskError> where Request: APIKit.Request {
return shared.sendSynchronous(request)
}
/// Execute `send(_:callbackQueue:handler:)` synchronously.
@temoki
temoki / UIImage+Extension.swift
Created October 23, 2017 02:17
UIImage+Extension
extension UIImage {
public func cropped(to rect: CGRect) -> UIImage? {
UIGraphicsBeginImageContextWithOptions(rect.size, true, scale)
draw(at: rect.origin.applying(CGAffineTransform(scaleX: -1, y: -1)))
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return image
}