I have a MaterialApp with several routes for the various section of my application.
Description
I have used the builder method of the MaterialApp class to place a single scaffold around all of my routes.
The body of this scaffold is a Row which contains a custom side menu widget, and the Widget from the MaterialApp's builder method.
Problem
Flutter is placing a shadow/gradient between my side menu (the widget from the builder method) and the main body of the application. I do not want this shadow and I do not know how to remove it.
What it looks like at the moment:
What it should look like:
This photo shows the difference between the two results (look at the right hand side of the side menus):
What is the top widget in your routes?
This looks like some default elevation is applied by material. You might (worst case) want to wrap the child within the builder method with a ClipRRect or DecoratedBox with specified clip behaviour to avoid that shadow overlaying your other widgets
Related
Looking at the Flutter Hero Transition, it appears to move the tagged Widgets to an Overlay class that exists in all Navigator Widgets but sits above the main content in the stack.
If this is correct, it allows the Hero to widgets to still respond to the Route scope and its animators but exist above the actual route content. How is this actually done efficiently? Surely this involves taking an entire Widget and storing it in a state for the duration of the animation. That Widget still has to respond to intrinsic responses from its original position such as slivers responding to active scroll actions.
Recreating this could be done with state management but I wondered how the standard hero actually does this. It seems like Widgets are effectively duplicated and then conditionally rendered on the screen defaulting to the overlay during the route animation and swapping out the original widget with an Offstage or similar. Is this how it is done?
The reason for trying to understand it is the need to replicate this behaviour in situations where Navigator is not an effective use case for a transition taking place internally on a page. I built an accordion style navigator but still want a hero transition to take place on the AppBar / NavigationBar. I know that this could be done with Navigator but it doesn't suit the use case. I could also predefine the AppBar content for each internal navigator state of the accordion but that is a lot of additional code.
I am curious if I should always use a SafeArea widget at the top level of my screen. I mean....when would I want my content blocked by things like a notch? For me it seems like the answer is never.
So should I not just use SafeArea on every page? If so, should it be above or below the Scaffold widget?
You don't have to use SafeArea on every screen. It actually depends if an AppBar is used or not, because the AppBar automatically calculates the values and adds the required padding.
If you use it above a Scaffold the area where the padding is applied would be black. On the other hand, if you use it below the Scaffold the color of the area would depend on the app theme, probably the Scaffold background color.
If you won't add an app bar or add it. if you want to adjust the screen to be responsive using MediaQuery and you don't need any scroll inside the screen use it.
Use it as the first widget in the body of the scaffold.
Google Play warns me about missing Content labeling under Accessibility tests for every page the crawler can reach.
I've tried to add a Semantics Widget to every page to surround the body element of the scaffold, I've even added an Extra Container as the first child of this Semantics widget with double.infinity as width and height.
The only other thing I can think of doing is to make it the parent of the Scaffold - but what is the correct solution?
Somewhat related: Should SafeArea be the parent or the body element of the Scaffold?
Concerning the placement of the safearea, you should always put your scaffold first. In other words, wrap the safearea with the scaffold. The content label error from play console can also be solved by specifying information such as hint text in input fields or labels for buttons where necessary.
Im trying to make an new app, and i want to display a row like this
i dont understand the concept behind it, like how can he divide the box into two type of colors, and how can the shape of the box looks like that. anyone that can teach me i will appriciated it.
This is not exactly a simple UI layout to create if you are just starting out with Flutter.
Simply put, you have to have a Row containing copies of a widget you create yourself as a stateless widget. The widget tree would look something like this.
Row
CustomWidget
CustomWidget
...
The CustomWidget is the complex part, this is a simplified example of how the Widget tree of this widget could look. Create a stateless widget and try to create it yourself.
Card
Column
Container
Row
Icon
Text
Container
Align
Text
Note you will have to set the color property of the Card and Container widgets, and add some padding certain places in the widget tree. Plus, the last container will need a width property as well.
If you need more help - show what you have attempted with code (edit your question)
Hope this helps!
I am developing an app using Flutter. If I choose MaterialApp as the parent widget of my app, all Text widgets in my app are underlined yellow. On the other hand, if I just use Material as the parent widget, no yellow lines are shown under the Text widgets.
What is the difference between Material and MaterialApp?
MaterialApp is a widget that introduces many interesting tools such as Navigator or Theme to help you develop your app.
Material is, on the other hand, a widget used to define a UI element respecting Material rules. It defines what elevation is, shape, and stuff. Then reused by many material widgets such as Appbar or Card or FloatingButton.
The yellow underlines you can find in Text is introduced by MaterialApp as a fallback Theme. It is here for debug purpose, to warn you that you need to use Material somewhere above your Text.
In short, use both. You should have a MaterialApp near the root of your app. And then use widgets that introduce a Material instance (Such a Scaffold, Appbar, Dialog, ...) when you want to use Text or InkWell.
MaterialApp : The MaterialApp configures the top-level Navigator to search for routes or to define Home.
Material : For child UI widgets rendering & effects.