首页 > 解决方案 > Flutter widget that scales it's child before laying it out?

问题描述

I'm developing a File Manager app in Flutter, and I want to implement a feature where the user can have multiple tabs open in the app (like Chrome tabs or Tabs in ES File Explorer). For the transition animation I'm chosing to implement a scaling animation, where I scale down the current tab to reveal other open tabs in the background. To achieve this I'm using a ListView to hold the tabs and a Tansform.scale to scale down the tabs. But I'm getting an unexpected result. The pictures below show my expected vs actual result: (First one is the expected result, designed by me in Adobe XD, and the second one is the result I get)

Comparison of the results

After reading online, I learn that Transform.scale, scales it's child after laying it out, so the boundary of the page remain same even after scaling and thus, I get the 2nd result. So is there a widget that can scale it's child before laying it out, so that I get the result I want?

标签: flutteruser-interfaceflutter-layoutscale

解决方案


你的意思是,除了 https://api.flutter.dev/flutter/widgets/FittedBox-class.html是否还有一个小部件可以做你想做的事?:)

或者,如果这不是您想要的,请查看其来源并借用这些想法。FittedBox 中汇集了一些非常好的东西。


推荐阅读