I have built an application for mobile screens and I now want to add Desktop and Tablet screens to it.
After a bit of googling I read about the LayoutBuilder and my question is:
What is the best Code/Project Structure to use LayoutBuilder?
Can I use it with the folder-by-feature pattern?
Should I use a Global Builder or add one into each feature?
Related
I am just learning flutter and I am wondering if it is possible to change the properties of a widget from the code.
I am familiar with WPF, where I can just access the Elements by a name that is given to them (e.g. "btnIncreaseCounter") and then say btnIncreaseCounter.Background = Colors.Orange.
Does a similar concept exist in Flutter? Or how do I modify my widgets from the code?a
You can do it in flutter using key of particular widget,
but flutter is not designed to code this way, flutter provides you with much easy and best practices to achieve the same.
In one section of a client's app an expansion panel / accordion is used to open some content. At the same time the AppBar is supposed to animated as is a new route has been pushed but the new route's content should display in the body of the expansion panel.
I have been able to implement this by creating an entirely independent Widget and using a state management library but it is not a tidy solution.
I wondered if it is possible to use the App's main Navigator but not remove the current route's body. This cannot be done with a nested navigator either as the AppBar uses Hero tags that are not reflected between Navigator's.
Is there a simple way to achieve this without using entirely customised state management.
Flutter's in built Navigator, even Navigator 2.0, is well known to not be a particularly friendly interface to use, so I'd recommend the use of a community library that makes things easier.
Auto Route is a popular solution that I use personally and can attest to its quality. For your particular problem it offers navigation observers which you can register. You could use this to trigger the animation of your app bar when the new route is pushed.
It will be a little bit of effort to replace your current navigation with a new library but I'd imagine you'll end up with a cleaner solution at the end instead of customized state management.
This is taken from the ESPN website where you can select one of the 3 options within the choice bar and it shows the information related to your choice. Is there any flutter widget for this? Choice chips are the closest one I've found but they are not connected together. Just wondering if there is a widget for this before spend the time to build one myself.
You can try something like this. https://pub.dev/packages/toggle_bar
But, IMHO, your own implementation will be more flexible.
You can use the built-in TabBar widget.
Take a look at this article:
https://flutter.dev/docs/cookbook/design/tabs
I have two questions with and "if" regarding the first question. As the title says I know it's better to have one MaterialApp in an App in Flutter and making Scaffold widgets for screens. But in a situation like this App which I followed for learning purposes and it's really written well and very clean. but it uses "TabBarView" as a default home for the entire app. So if I want to add another screen like "LoginSreen" that's not part of the "TabBarView" it's not inheriting the "MaterialApp" widget features. So I have to add a "MaterialApp" widget independently for that screen.
So the question is, is it ok to have two "MaterialApp" widgets in a situation like this?
if yes does it affect any variables that's shared among the screens like "SharedPreference"? or what does it affect?
If it's a bad behavior to have two "MaterialApp" widgets to in an App, Then how can you get rid of the "NavScreen()" and implement the TabBarView in the screens, Because I have tried many ways and looked at many of open source projects like this they have "TabBarView" widget as the body and start of the project.
yes you can definitely have two mat apps. but its not recommended.
How can I do this if I want it through XML file layout..
Perhaps you could find a way to make the widgets share an ID? Don't think you could do that from the layout however (if at all).
Is Android Widget ID persistent