This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class AnimatedSizeAndFade extends StatelessWidget { | |
/// 每当Child内容发送改变,就会产生动画 | |
/// | |
/// * 大小发送改变,会有边界变换效果 | |
/// * 内容变化,会有淡出淡入效果(和大小变化不一样,内容变化是通过[child]的类型或者key识别) | |
/// * 可以指定变化时,组件对齐的位置,比如一个上下展开收起效果的组件,那么它的[alignment]应该传[Alignment.topCenter] | |
const AnimatedSizeAndFade({ | |
super.key, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 这里通过mixin给ProviderNotifier添加一些常用操作 | |
// ignore_for_file: invalid_use_of_internal_member | |
library provider.notiifer; | |
import 'dart:async'; | |
import 'package:flutter/cupertino.dart'; | |
import 'package:freezed_annotation/freezed_annotation.dart'; | |
import 'package:riverpod/riverpod.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
Widget _defaultAnimationWidgetBuilder( | |
BuildContext context, | |
Animation<double> animation, | |
Widget? child, | |
) { | |
return SizeTransition( | |
axis: Axis.horizontal, | |
sizeFactor: animation, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 对象状态[T]的历史堆栈,可以推入或者弹出 | |
class HistoryStack<T> { | |
/// 最大索引的数据,即为最新的状态 | |
final _store = <T>[]; | |
/// 读取内容,用于保存的数据 | |
({ | |
List<T> store, | |
int step, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 修改应用图标 | |
# 1. 添加依赖 | |
# flutter pub add dev:flutter_launcher_icons | |
# 2. 运行 | |
# flutter pub run flutter_launcher_icons | |
flutter_launcher_icons: | |
android: "launcher_icon" | |
ios: true | |
macos: | |
generate: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
func hexCharAsNumber(_ char: String) -> Int64 { | |
assert(char.count == 1) | |
let c = Int64((char as NSString).character(at: 0)) | |
if c >= Int(("a" as NSString).character(at: 0)) { | |
return c - 87 | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.List; | |
public class TKCalculateUtils { | |
public static long hexCharAsNumber(char c) { | |
if (c >= 'a') { | |
return c - 87; | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Activity; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.graphics.Color; | |
import android.os.Build; | |
import android.os.Bundle; | |
import android.support.annotation.Nullable; | |
import android.support.v4.app.Fragment; | |
import android.view.Gravity; | |
import android.view.View; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static LifecycleOwner mockLifecycleOwner() { | |
LifecycleOwner owner = mock(LifecycleOwner.class); | |
LifecycleRegistry lifecycle = new LifecycleRegistry(owner); | |
lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_RESUME); | |
when(owner.getLifecycle()).thenReturn(lifecycle); | |
return owner; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.arch.lifecycle.LiveData; | |
import android.arch.lifecycle.MutableLiveData; | |
import android.arch.lifecycle.Transformations; | |
/** | |
* 每当输入一个参数{@link #input(Object)},就回调{@link OnGetLiveData},生成一个LiveData | |
*/ | |
public class ActionLiveData<InputType, ResultType> { | |
private MutableLiveData<InputType> mInput = new EventMutableLiveData<>(); |
NewerOlder