Open aytunch opened 4 years ago
Thanks! About the first question: The initial project was an exact port from Zdog to CustomPainter canvas, but I thought it would be more powerful if it could take full advantage of the Flutter framework. One of the keys is that Flutter widgets are nested and immutable. That's why I implemented this way. While this solution generates more code it comes with more benefits (eg you can more than just canvas paths, and it will only re-paint what it is needed)
To reuse part of the code, you can do it as it was a normal widget. Check the dice code for an example.
class Dot extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ZCircle(
diameter: 15,
stroke: 0,
fill: true,
color: Colors.white,
);
}
}
About the second question, the performance is not as good as I would want. I tried a ZIlustration with around 100 shapes and works good in mobile, but starts to lag in the browser. I want to work on some optimizations about how and when the z-index sorting is done. I expect to work on this later this year, as now I am focused on other projects.
I don't recommend to use ZFlutter for a production application yet, just to play with it. Also using just ZToBoxAdapters wouldn't bring you a lot of benefits; normally an app needs complex layouts as stacks, row, column, list. But with few ZToBoxAdapters
the performance should be similar to wrapping your app with a Transform widget.
Just wow, this is definitely a game changer for Flutter. The possibilities are endless and graphics look very cute. Thank you for porting Zdog.
My question is: is it better to do modelling with nesting or is it a better strategy to use Zdog
addTo:
method? I thought if we hadaddTo
, we could have the ability to reuse parts of our models instead of copy pasting code inside nested structure. I might be missing something. Please correct me if I am wrong. Keep up the great work.One last thing. How is the performance? is there a limit on maximum number of Zshapes we should use? Would it be smart to make an application fully constructed with ZFlutter using
ZToBoxAdapter
s?