Giter VIP home page Giter VIP logo

Comments (2)

goderbauer avatar goderbauer commented on May 12, 2024

I am confused about what this is asking for. Some questions/comments inline:

The wrong way is easy to use and hard to catch in code review because of the similarity.

This could be resolved with a lint, for which there's already a request: dart-lang/linter#4448

In contrast if you want a widget to branch on the space available then LayoutBuilder's api works well.

If you want to branch on "space available" LayoutBuilder is the right choice. MediaQuery will always give you the size of the screen, which is often NOT the available space.

This proposal suggest adding a sibling object to the existing builder of LayoutBuilder

How does adding something new that nobody know about solve the discoverability problem mentioned in the first paragraph?

that under the hood uses MediaQuery.sizeof and then converts that data into a boxConstraints

Why would you want to do that? What is the use case here? If you want to build a UI based on the available space you should NOT use MediaQuery.sizeOf. Instead, the existing LayoutBuilder (or some custom RenderObject) is the way to go.

It took me a long time to discover Dialog.fullscreen

How does Dialog.fullscreen relate to this discussion? That seems to be a different API for something different?

from flutter.

reidbaker avatar reidbaker commented on May 12, 2024

I am confused about what this is asking for. Some questions/comments inline:

The wrong way is easy to use and hard to catch in code review because of the similarity.

This could be resolved with a lint, for which there's already a request: dart-lang/linter#4448

Yes lint might be the easiest way to catch this class of error.

In contrast if you want a widget to branch on the space available then LayoutBuilder's api works well.

If you want to branch on "space available" LayoutBuilder is the right choice. MediaQuery will always give you the size of the screen, which is often NOT the available space.

kind of, but the spirit of this proposal is to have layout builder give you either the size of the app (what media query does) or the size of the available space. Media query does not give the size of the screen as I understand screen it gives the size of the app's drawing window which is a subset of the Display. Display maps more closely to screen in my mind.

This proposal suggest adding a sibling object to the existing builder of LayoutBuilder

How does adding something new that nobody know about solve the discoverability problem mentioned in the first paragraph?

If we had LayoutBuilder.localBuilder and LayoutBuilder.appBuilder then when you used (or searched for how to fork widgets based on space) one you could find the other more easily than having to know (or search) about different classes.

that under the hood uses MediaQuery.sizeof and then converts that data into a boxConstraints

Why would you want to do that? What is the use case here? If you want to build a UI based on the available space you should NOT use MediaQuery.sizeOf. Instead, the existing LayoutBuilder (or some custom RenderObject) is the way to go.

This question makes me think I did a poor job of explaining the proposal. I know when to use MediaQuery.sizeOf and when to use LayoutBuilder. The proposal is to use layout builder to do both jobs.

It took me a long time to discover Dialog.fullscreen

How does Dialog.fullscreen relate to this discussion? That seems to be a different API for something different?

This is an example of the issue of default constructors mixed with named constructors making natural discoverability more difficult. Natural in this case means finding functionality while writing code.

from flutter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.