1. 定义NotificationListener Widget wrapWithNotify(Widget child){ return NotificationListener<ScrollNotification>( child: child, onNotification: handleNotification, ); } 2. 具体处理 bool handleNotification(ScrollNotification notification){ final Scrol…
import 'package:flutter/material.dart'; class CalendarWidget extends StatefulWidget { // 选择器范围 DateTime startTime; DateTime endTime; // 日期文本字体大小 TextStyle? style; // 头部 周文本样式 TextStyle? headerStyle; // 日期容器大小 double? size; // 选择器高度 double? height; //…
1. 调用处 import 'dart:async'; import 'package:flutter/material.dart'; import 'package:plano_flutter/helpers/router/flutter_binding.dart'; import 'package:plano_flutter/models/event_bus.dart'; import 'package:plano_flutter/modules/home/models/week_slide…
1. FlutterBoost源码 FlutterBoostApp->pop方法 Future<bool> pop( {String? uniqueId, Object? result, bool onBackPressed = false}) async { BoostContainer? container; if (uniqueId != null) { container = _findContainerByUniqueId(uniqueId); if (container …
1. physics方式 ClampingScrollPhysics() 强制将滚动距离限制最大可滑动 2. 自定义ScrollBehavior class NoScrollBehaviorWidget extends ScrollBehavior { @override Widget buildViewportChrome(BuildContext context, Widget child, AxisDirection axisDirection) { switch (getPlatform…
1. FractionallySizedBox 通过更改width/heightFactor来实现类似滚动进度条 Row( children: [ Flexible( child: FractionallySizedBox( widthFactor: 1.0, child: Container( width: 20, height: 20, color: Colors.red, ), ), ), Container( width: 20, height: 20, color: Colors.bl…
1. Scroller public void fling(int startX, int startY, int velocityX, int velocityY, int minX, int maxX, int minY, int maxY) {} public void startScrollBy(int dx,int dy) { mScroller.forceFinished(true); int startX = getScrollX(); int startY = getScroll…
// val h = (img.width * 1.0f / img.drawable.intrinsicWidth * img.drawable.intrinsicHeight).toInt() // val animator = ValueAnimator.ofInt(img.height,h) public class LiveImageView extends AppCompatImageView { private int mDx; private int mMinDx; public…
public class CustomImageView extends AppCompatImageView implements View.OnTouchListener { private float lastX, lastY; private int screenWidth, screenHeight; private int imageWidth, imageHeight; private float translationX, translationY; public CustomI…
1. 单行文本 FontMetrics.ascent 或 Paint.ascent 注意这些都是间距 ascent = ascent线的y坐标 - baseline线的y坐标; // 为负值 descent = descent线的y坐标 - baseline线的y坐标; top = top线的y坐标 - baseline线的y坐标; bottom = bottom线的y坐标 - baseline线的y坐标; center先计算 float centerY = (fontmetrics.desce…