as I'm coding some app I was wondering if there's any cheat sheet explaining navigation and routing options I have and when should I use the specific one (for which usecase its the best solution)?
For example I'm creating a form, when I press the button I need to load a list of items (Listview) from which I will chose one item and go back to the form. This list should cover all screen (something like full screen modal I guess)
Im not sure what should I use, whether MaterialPageRoute, ModalRoute or maybe somethig different like dialog?
Is there any good source to learn besides of reading documentation?
You can read this for push and pop concepts. An example related to that.
This example is for routing.
See this and this for complete understanding of Routing and Navigation
Related
I'm coming from Flutter Mobile and have been asked to build a flutter web app. I'm literally stuck on what feels like something that should be easy to do and I cannot for the life of me find any tutorial that is helpful.
The long and short is how can I build a flutter web app with a static navigation bar and only load pages into the "content" portion of the app.
I've been looking at this tutorial: https://dariadobszai.medium.com/interactive-navigation-items-in-flutter-web-7fccc5975779 however I can't figure out how to get it working with GoRouter. The pages also load a bit clunky.
Almost all the tutorials I can find are about resizing for web/mobile and do not get into any actual navigation. The responsiveness is nice, but how the heck do I navigate between pages with a static menu bar for a nice user experience?
Ideally the solution will utilize this menu (or one like it): https://pub.dev/packages/easy_sidemenu and https://pub.dev/packages/go_router.
Thank you!
I suggest start researching about Go router first not how to implement a static menu navigation bar, since Go router uses declarative routing which changes completely how navigation should be handled.
I recommend this repo since it has different examples to use Go router, though be careful some examples may be deprecated.
I'm currently working on updating a Flutter Web app to support sharing pages via URLs. I currently have a screen that uses a TabBar, and shows different views based on the selected tab. I want to be able to do two things:
Update the URL when a tab is selected (e.g. append §ion=tabName to the URL)
Paste the URL into a new browser tab and have the application open on the tab specified by the URL
The second part of this was simple enough, just take the §ion=... argument and use that to set the initialIndex of the tab controller. Updating the URL however seems quite difficult.
I've tried using RouteInformationParser to generate a new route from a list of arguments, but that triggers the onGenerateRoute callback and just seems to re-navigate to the page with the initialIndex updated from the new URL. I can get around this by replacing the TabBarView with a nested Navigator that navigates to the selected tab's content, but it seems like this could quickly become quite clunky if you wanted to navigate deeper than just a selected tab.
A simpler option I've seen mentioned is window.history.replaceState, which seems a lot simpler but feels like a bit of a kludge. Are there any ways of doing this that I've missed?
Thanks!
It's a little hacky, but I was able to force a URL change on tabbed navigation by using the TabBar.onTap, which provides the tab index, and having navigation happen through that. It ruined the nice slide action, but I got the custom URL in the address bar, which was more important for my use.
Before I begin, I want to mention that I've found a million answers showing how to do this from code, which involves setDisplayHomeAsUpEnabled(true) from your Activity. However, what I have not been able to find is a way how to do it from XML. (I would like to hide as much UI code in the XML files as possible).
One article I did find is this, which states
Step 3: Specifying the parent activity name in the AndroidManifest.xml adds the Back-Button arrow
and Click-action. Tapping on the back-arrow takes us to the Parent
Activity i.e Home Screen.
which doesn't work for me (the Back Button doesn't appear). I've followed all the steps in the article.
Does anyone know how to do this via xml? Is it even possible?
Yes, it's possible but still, you have to set the listener in java code. You can create a custom toolbar view and add a button to it. Then create a button in the java file and set the CilckListener.
Or You can use the default toolbar and do setDisplayHomeAsUpEnabled(true) from your Activity.
We usually make a custom toolbar, suppose you need a search bar in the toolbar then what you will do? So try to make an xml then use <include> tag in xml. You can search youtube. Follow the channel CodingInFlow, that guy explains very perfectly. If you don't understand what I am saying then understand the basics first, it will help you learn faster.
I've been trying to find a solution but I can't find any.
I'll use basic examples so anyone who knows ionic can understand my problem well.
ionic start myApp tabs will create a new project with tabs ready to go.
Those tabs are Dashboard, Chat and Settings.
When you go to the Chat Tab you will then select a person to view its chat content (which directs you to the Chat-Detail Page in actuallity)
I wanted to hide the ion-tabs directive when I go to the chat-detail page so I can force the user to use the Back button instead of clicking anything on the ion-tabs.
Simply put : you will have a hard time doing that. At best it will not look good, IF you succeed to hide using css (I did it, and really, it's not pretty). Basically you would need to define a variable on the parent scope, that changes when entering the chat-detail state, and bind it to ng-class directives on multiple elements (the ion-tabs to hide it, the ion-content to translate it up to cover the area where the tabs were, and add some transition to make it not too brutal).
The logical thing to do would be to have the chat-detail state not being a child of the state containing the tabs. The problem you will have, though, is that there is a huge bug going to / from tabbed state. See details here : https://github.com/driftyco/ionic/issues/2997
At the end of this discussion you can find some posts by Jason and Jerrybels (that would be me), that could lead you on the right way to do it. Basically, you will have to get rid of the ion-tabs directive, and use Ionic's CSS for tabs instead, doing all the states manipulations yourself.
Good luck !
You can use "hidden" attribute of ion-tab like this -
<ion-tab hidden={{condition}}" />
Using this we can show/hide tab.
In my iPhone app, I must have around 9-15 different views, all available from a main menu. I started yesterday with a simple tab bar controllers, but they are only ideal with 6-7 views. Which controller can I use? Is there a nice one for my needs?
Edit: I am talking about around 9-15 menu-points for my application.
Each point is a single, categorizable function. I though about something like the Facebook app, where the app shows 2 menu-pages (slideable) and 9 icons on each page, each with another view / function in it.
look for cocoacontrols.com . i think you will find your need there .....
I think the component you are looking for(the same used in facebook app) is in the three20 library. Its called Launcher. It's like having iphone springboard inside the app. I'd go with that.
Can your views be split into categories? If so, I would suggest using the tab bar tabs as categories, and then using a table view as a menu in each tab.
You could also try using a page control, but 9-15 views seems like they would be obnoxious to navigate with a page control.
I understand that you need to have access to those "views" all the time. You can do what an iphone CNN app does. It uses horizontal scroll, where it has lot's of "views".
This is propably the most challenging part of writing an app for mobile phones. At least i find it not that easy to find the perfect user interface. Espcially if you have so much content and navigation to show.
I think the best way to solve this problem is to write your own navigation. If you want to use something similar like the facebook app - this is not so hard.
Take a UIScrollView in combination with the UIPagingControl. Create a new View for your buttons or whatever you want your user to see and put it in the scroll view. Enable paging for the UIScrollVIew and your almost done. Maybe it's not the easiest way - but in the end it's the most flexible way. You can decide what you want to show and you dont have to be dependent on what some other developer wrote.
Just a thought :)
// Edit: Just read in another question about appLauncher. This might be such a control you are looking for.
https://github.com/rigoneri/myLauncher