Skip to content

Instantly share code, notes, and snippets.

View CaiJingLong's full-sized avatar
💭
I may be slow to respond.

Caijinglong CaiJingLong

💭
I may be slow to respond.
View GitHub Profile
@CaiJingLong
CaiJingLong / count_timer_button.dart
Last active October 10, 2018 09:26
flutter 倒计时按钮 代码片段
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:meta/meta.dart';
typedef String TextMaker(int time);
class CountTimerButton extends StatefulWidget {
final Function onTap;
final TextMaker textMaker;
@CaiJingLong
CaiJingLong / upload_file.go
Created November 8, 2018 10:05
upload file
package main
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"os"
@CaiJingLong
CaiJingLong / receive_file_spring_boot.kt
Created November 8, 2018 10:07
receive file success
package com.kikt.demo
import org.springframework.web.bind.annotation.RequestMapping
import java.io.IOException
import com.sun.tools.corba.se.idl.toJavaPortable.Util.mkdir
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.multipart.MultipartFile
import java.io.File
@CaiJingLong
CaiJingLong / material_tap.dart
Last active November 13, 2018 08:34
Wrap your widget, and you will get a clickable Widget.
import 'package:flutter/material.dart';
class MaterialTapWidget extends StatelessWidget {
final double radius;
final Function onTap;
final Widget child;
final double elevation;
final Color backgroundColor;
final Color splashColor;
final Function onLongTap;
@CaiJingLong
CaiJingLong / chinese_cupertino_delegate.dart
Created November 14, 2018 03:00
chinese_cupertino_delegate.dart
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
class ChineseCupertinoLocalizations implements CupertinoLocalizations {
final materialDelegate = GlobalMaterialLocalizations.delegate;
final widgetsDelegate = GlobalWidgetsLocalizations.delegate;
final local = const Locale('zh');
@CaiJingLong
CaiJingLong / overlay_demo.dart
Created November 20, 2018 07:28
overlay_demo.dart
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
@CaiJingLong
CaiJingLong / custom_list.dart
Created November 21, 2018 08:14
一个自定义的dart list 示例
import 'dart:collection';
class MyList<E> extends Object with ListMixin<E> implements List<E> {
var _array = <E>[];
@override
int get length => _array.length;
@override
void set length(int newLength) => _array.length = newLength;
@CaiJingLong
CaiJingLong / antd_color.dart
Last active November 26, 2018 07:30
ant design v3 颜色转换函数
Color calcAntdColor(Color color, int index) {
var helper = _AntdColorHelper.instance;
var isLight = index <= 6;
var hsv = HSVColor.fromColor(color);
int i = isLight
? _AntdColorHelper.lightColorCount + 1 - index
: index - _AntdColorHelper.lightColorCount - 1;
return HSVColor.fromAHSV(
color.opacity,
@CaiJingLong
CaiJingLong / ui_helper.dart
Created November 28, 2018 13:42
ui_helper
import 'package:flutter/widgets.dart';
class UIHelper {
static Rect findGlobalRect(GlobalKey key) {
RenderBox renderObject = key.currentContext?.findRenderObject();
if (renderObject == null) {
return null;
}
var globalOffset = renderObject?.localToGlobal(Offset.zero);
import 'dart:math' as math;
import 'package:flutter/material.dart';
class SkipCircleButton extends StatefulWidget {
final String title;
final VoidCallback onTap;
final Duration duration;
final double size;