I have some troubles in my applications since I'm using different animated widget in combination of Future Builder (I think this is the problem).
For example when I perform a navigation to another page and in this page I retrieve data with future builder, the page transitions lag. This is an example:
As you can see the animation is lagging at the end. But I'm not sure that is a problem with Future Builder and the transitions.
This example was made on a release application on iOS, so not in debug mode.
Related
I have an architectural question.
First of all, I understand that Navigator 2.0 enables updating the URL path of the app. For Flutter web applications and for deep linking on iOS and Android, this can obviously be very important in certain situations. However, most applications probably don't need the amount of complexity involved in implementing URL sync with Navigator 2.0.
So, that brings us back to navigation with Navigator 1.0. The issue I have with the approach they require is that implementation is like the opposite of what you'd achieve from dependency injection in terms of how it affects life cycle management and control flow. By forcing construction of objects (in this case widgets) to occur deep in your code, it sort of convolutes your architecture... For example, instead of having an easy to follow hierarchy, you now have much greater cyclomatic complexity as you also need to worry about managing navigation state and controlling application flow from a second dimension (instead of just leveraging the hierarchy.) To me, it seems like it would violate SOLID to allow a deeply nested child to change which extended relatives are displayed because it seems like that relative's rendering behavior should be controlled by its parent, not some random other widget in some unknown part of the hierarchy. As an analogy, that would be like my child calling their second cousin to take them out of school instead of that decision (for the cousin to go to school or not) being made by the cousin's parent.
In contrast, by leveraging stateful widgets, screens and child widgets can be conditionally displayed without relying on Navigation. This approach makes the hierarchy clean and easy to read and follow. If you need to troubleshoot the display of a widget, you only need to walk up the hierarchy (and occasionally back down to a sibling, depending on how you're propagating state.) By using the Provider architecture (like StreamProvider and ChangeNotifier), state and changes can be gracefully propagated throughout the application. So, a child deep in the hierarchy could use a model class to propagate a state change to an observer that conditionally displays child widgets in a reactive manner. (Going back to the analogy, that would be like my child broadcasting that there was a family emergency, and their second cousin's parent reacts to that by pulling their child out of school that day.)
This reactive design allows cleaner separation of concerns because a descendent never needs to worry about how some extended relative wants to react to a state change (such as by displaying a different screen.) It also makes debugging and testing a lot simpler.
With all that said, it does appear that Navigation is required to get proper behavior of the back button on a device. Is that the only redeeming value of using Navigation? Can someone please help me understand if I'm missing something?
Also, if that's the main purpose of using Navigation, is there a principle I can follow to use it without turning my control flow into a spaghetti mess?
In my app I navigation to a page with a fullscreen map. Currently I've implemented a FutureBuilder to render the map or else a progressindicator is displayed. From initState I request UserLocation (lastknown or current) and the maps navigates to the location. The issue is that the page navigation is not smooth after I added the map. I'm looking for a way to make the page complete its navigation before the map is rendered. I've searched but haven't found a working solution yet. Any good ideas on how to make this?
Happy Flutter day :)
Use Isolates to do any intensive work. An Isolate is essentially a new thread so that the main thread is freed up to continue doing UI work.
from https://flutter.io/docs/resources/faq#how-do-i-write-parallel-andor-concurrent-apps-for-flutter
How do I write parallel and/or concurrent apps for Flutter? Flutter
supports isolates. Isolates are separate heaps in Flutter’s VM, and
they are able to run in parallel (usually implemented as separate
threads). Isolates communicate by sending and receiving asynchronous
messages. Flutter does not currently have a shared-memory parallelism
solution, although we are evaluating solutions for this.
Check out an example of using isolates with Flutter.
Can someone please point me in the right direction to achieving this effect in both Android and iOS application, https://www.cocoacontrols.com/controls/pinterestanimator. Not necessarily this effect, but you will notice that the transition between two screens (list and details) is animated in non standard way (image enlarges).
The idea is to execute an animation between two screens, so that upon animation finish, the route is changed, backend service kicks in, etc. Not sure if I am expressing myself right, but how do I "swap" native screens transitions, with a custom animation? And doing this on case by case basis, not as a general rule to all transitions.
I am using Angular2 and Nativescript.
--
Edit: It is fine if the solution above seems like a hack, it doesn't have to be supported out of the box. To clarify, is it anyhow possible to:
capture and prevent default click action, thus preventing the native transition
animate the view
update the route programatically
execute the previously prevented action (call ngOnInit, or similar)
The page transitions can not be fully customized and currenтly you can only apply native transitions as the following listed in this API reference
curl (same as curlUp) (iOS only)
curlUp (iOS only)
curlDown (iOS only)
explode (Android Lollipop(21) and up only)
fade
flip (same as flipRight)
flipRight
flipLeft
slide (same as slideLeft)
slideLeft
slideRight
slideTop
slideBottom
Notice that some of the transitions (like curl) are supported only by iOS and others (like explode) are supported only by Android. Here is the documentation article about page transitions in Angular enabled application.
I want my view controller to display different views based on a condition that depends on some runtime checks (lets say a uiwebview at even hours and a form on odd hours).
What is the best pattern to achieve it in iphone project? Maybe I can hide controls based on aforementioned condition or maybe it is better to load different views?
or maybe i should load different view controllers and make the check in my parent view controller?
The iPhone UI is so small and crowded that you are usually better off creating a different view/view-controller pair for different UIs. Hiding UI elements leaves gaps that are very noticeable and manually rearranging the UI elements on the fly is a pain.
More importantly, different views communicate to the user that the app is in a different state. You don't want the app to switch to a different state without informing the user. It's hard enough for them to understand what is going on without confusing them with UI slight of hand.
It is very bad UI design to have the same user action present a different UI for no reason discernible to the user. For example, presenting a "a uiwebview at even hours and a form on odd hours" would be a fantastically bad idea because the user would have no idea why clicking on a specific button sometimes gets them a web view and a form view other times. Do you expect the user to check the clock before clicking so that they know what to expect?
If some UI element is unavailable for some reason e.g. no network access, then it's better UI design to present the element as disabled instead of disappearing it. The interface grammar teaches users that grayed out controls are temporarily unavailable. That is much less confusing that a constantly changing UI.
Lets suppose I am creating an application for the iphone with a webView down at the bottom of the window (the other part of the screen has a button and the user can interact with it).
I don't want the webView to stop the user from interacting with the other part of the UI when the webView loads a new url. From my limited testing through the iphone simulator, I haven't been able to determine IF it already behaves this way. Most of my web sites load pretty fast.
I seem to be able to load new requests and click the ui button while that happens.
So, again, do I need to worry about threading in this case?
No, you do not. The iPhone threads a great deal of the UI components behavior, or schedules them for you in the main run loop in such a way that you rarely need to be concerned, the UI elements will be available for user interaction.