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 / pinyin_utils.dart
Created April 29, 2024 08:37
拼音模糊匹配的方法,需要导入 pinyin 库 flutter pub add pinyin
import 'package:flutter/material.dart';
import 'package:pinyin/pinyin.dart';
class PinyinCompareResult {
final bool isMatch;
final String pinyin;
final Map<int, bool> matchIndex;
PinyinCompareResult({
required this.isMatch,
@CaiJingLong
CaiJingLong / automatic_example.dart
Created April 29, 2019 09:15
AutomaticKeepAliveClientMixin for tabbar example
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 / UIHelper.dart
Last active February 29, 2024 14:09
Use Offstage widget to measure the widget size.
import 'dart:async';
import 'package:flutter/material.dart';
class MeasureWidget extends StatefulWidget {
final Widget child;
final ValueSetter<Rect> measureRect;
final BoxConstraints boxConstraints;
const MeasureWidget({
@CaiJingLong
CaiJingLong / init.gradle.kts
Last active November 22, 2023 03:48 — forked from bennyhuo/init.gradle.kts
Copy files to ~/.gradle, then change to your maven proxy url.
// Thanks to: https://gist.github.com/bennyhuo/af7c43cc4831661193605e124f539942
println("The init script init.gradle.kts is running!")
val gradleHome = System.getProperty("user.home") + "/.gradle"
apply {
val gradleVersion = gradle.gradleVersion
if (gradleVersion < "6.8") {
from(gradleHome + "/old.gradle.kts")
} else {
@CaiJingLong
CaiJingLong / add-dep.sh
Last active August 11, 2023 02:50
For umi + antd5 i18n
# Add dayjs dep first
pnpm add dayjs
@CaiJingLong
CaiJingLong / init.gradle.kts
Last active July 31, 2023 02:08 — forked from AlexV525/init.gradle.kts
Mirroring Gradle repositories
// Thanks to: https://gist.github.com/bennyhuo/af7c43cc4831661193605e124f539942
val localMavenUrl = "http://localhost:8081/repository/maven-public/"
val urlMappings = mapOf(
"https://dl.google.com/dl/android/maven2" to localMavenUrl,
"https://repo.maven.apache.org/maven2" to localMavenUrl,
"https://plugins.gradle.org/m2" to localMavenUrl,
)
@CaiJingLong
CaiJingLong / main.dart
Created January 3, 2023 04:00
vagrant-oak-1842
// 转换数字为中文大写
// 比如:123456789.12 转换为 壹亿贰仟叁佰肆拾伍万陆仟柒佰捌拾玖元壹角贰分
String convertNumberToChinese(double number) {
final numberText = number.toStringAsFixed(2);
final numberTextList = numberText.split('.');
final integerText = numberTextList[0];
final decimalText = numberTextList[1];
final integerTextList = integerText.split('');
final decimalTextList = decimalText.split('');
@CaiJingLong
CaiJingLong / build_android.sh
Last active August 12, 2022 10:15
在mac上 使用ndk r21b 编译 ffmpeg 4.3.1 的so
#!/bin/bash
NDK=/Volumes/Samsung-T5/sdk/android-ndk-r21b
TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/darwin-x86_64
API=21
function build_android() {
cd ffmpeg-4.3.1
echo "Compiling FFmpeg for $CPU"
./configure \
@CaiJingLong
CaiJingLong / build_ios.sh
Created April 9, 2020 03:10
build ios shell by @AlexVincent525
# remove iOS bitcode
flutter build ios
cd build/ios/iphoneos/Runner.app/Frameworks
cd App.framework
xcrun bitcode_strip -r app -o app
cd ..
cd Flutter.framework
xcrun bitcode_strip -r Flutter -o Flutter
cd ../../../../../../
@CaiJingLong
CaiJingLong / app.dart
Last active December 28, 2021 13:09
不随系统字体大小发生变化
import 'package:flutter/material.dart';
import 'scale_text_widget.dart';
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override