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. 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. FutureBuilder Center( child: FutureBuilder( // initialData: "加载中", // future: Future.delayed(Duration(seconds: 2), () => "123"), future: Future.delayed(Duration(seconds: 2), () => throw "网络错误error"), builder: (BuildContext context, AsyncSnap…
AnimatedSwitcher> controller.drive(Tween(begin:xxx,end:xxx)) Tween(begin:xxx,end:xxx).chain(CurveTween(curve: Curves.elasticInOut)).animate(controller) CurveTween(curve: Inteval(0.5,1.0)) 动画区间(表示从后半段才开始动画) import 'package:flutter/material.dart';…
使用 @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('title'.tr), bottom: HjtTabBar( tabs: const [Tab(text: "音乐"), Tab(text: "动态"), Tab(text: "语文")], // labelPadding: EdgeInsets.symmetric(horizontal: 8), cont…
一、初步使用-和SingleChildRenderObjectWidget类似 class CusRenderBox extends SingleChildRenderObjectWidget/MultiChildRenderObjectWidget 不同点: // 可以进行内部绘制 // class RenderCusRenderBox extends RenderBox with RenderObjectWithChildMixin{ class RenderCusRenderBox ext…
一、实现时间轴效果 // 实现时间轴效果 class CusRenderBox extends SingleChildRenderObjectWidget{ final double size; CusRenderBox({Widget child,this.size = 0}):super(child: child); @override RenderObject createRenderObject(BuildContext context) { return RenderCusRender…