分帧build、layout、paint小部件封装。
- DelayBuildWidget控制builder返回的widget分帧创建。
- DelayLayoutAndPaintWidget控制child的layout和paint分帧进行。 例如:假设多个DelayBuildWidget的buildManager相同,则每帧进行一个DelayBuildWidget的builder调用并显示builder返回的widget。 DelayLayoutAndPaintWidget的原理类似,不过分帧处理的是child的layout和paint。
DelayManager manager = DelayManager(reverse: true);
DelayBuildWidget(
delayManager: manager,
builder: (_){
//return your widget
},
)
DelayManager manager = DelayManager();
DelayLayoutAndPaintWidget(
height: height,
width: width,
delayManager: manager,
child: Text('hello'),
)
DelayManager manager = DelayManager(reverse: true);
DelayManager managerTwo = DelayManager(reverse: true);
//managerTwo会等manager执行完后才会执行。如果manager有新任务,则会暂停managerTwo,等manager执行完所有任务在重启managerTwo
DelayManager managerTwo.dependentOn(manager);
DelayLayoutAndPaintWidget(
height: height,
width: width,
delayManager: manager,
child: Text('helloA'),
)
DelayLayoutAndPaintWidget(
height: height,
width: width,
delayManager: managerTwo,
child: Text('helloB'),
)