flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
164.11k stars 27.05k forks source link

Docstring for `Canvas.transform` Should include a blurb on idiomatically creating matrices #83179

Open 4amVim opened 3 years ago

4amVim commented 3 years ago

Use case

Canvas.transform() accepts a 4d matrix, but doesn't indicate any way to do it. Perusing only on documentation, only route forward is with Float64List.

Creating matrices using Float64List is tedious, and it hampers code-readability. Yet, its the only way somebody just reading docs would construct a matrix for transform.

Proposal

Given the extreme utility of transform, and its indispensability, in lots of use-cases, we should indicate a convenient way to use it. Currently, the (vector_math)[https://pub.dev/packages/vector_math] package offers a great way to create Matrix4 in a variety of ways, which can then be passed to transform via .storage. Moreover the package is maintained by Google.

I'd be more than happy to submit a PR for the same.

TL;DR: Should add a mention of vector_math to the docstring of Canvas.transform, and add a simple example as well.

darshankawar commented 3 years ago

@4amVim Does this issue sound similar to your request ?

4amVim commented 3 years ago

They both are about Canvas' internal matrix yes. But this issue proposes that we should include a bit on how to use vector_math to construct a matrix. Purely documentation, so that a developer can stumble upon good practices easier.

While that issue proposes that the internal matrix be exposed. Which is additional functionality.

shtse8 commented 1 year ago

Any documentation about the transform matrix?