I have a parent widget and 3 children widgets managed by bottomNavigationBar and PageView together.
Data entered in Page 1 children widget will be sent to Page 2.
I have a method onTapped in Parent widget, will update the name to "John" entered in Page1 and then display in Page2.
Assuming if I entered the name "Jane" in Page1 and when I clicked Page2 on the bottomNavigationBar, the method onTapped will update the name to Page2 immediately (John is displayed). The problem is if I were to swipe from Page1 to Page2. The name on Page 2 is still "Jane". If I swipe to Page 3 then back to Page 2 or Page 1 to Page 2 another time, the name is then updated to "John".
The bottomNavigationBar's "onTap:" and PageView's "onPageChanged:" both using the same method onTapped.
I was expecting both page swipe or click on the navigationbar will produce the same result.
As mentioned in comment, PageView onPageChanged is called only after viewport changes as mentioned here: docs.flutter.io/flutter/widgets/PageView/onPageChanged.html It works differently from bottomNavigationBar: Called when one of the items is tapped.
To call the method before 2nd page: add Listener to the pageController. It solved my problem.
Related
I am creating a shopping cart in flutter as my first project. The link to the Cart is inside Appbar.
When I navigate to the Cart the back button on the top left of the Appbar is not showing, instead the drawer button is shown.
For other pages that I navigate say, a product page, the back button is shown.
What could be the issue, please suggest.
I compare line by line and the cart.dart have this offending line
drawer: appDrawer
between the appBar and Boxy which seems to override the back button.
#Viren V Varasadiya and #Harsha pulikollu thank you for your looking into my question.
I have the following drawer. it works as it should as long as i only want to hop between the widgets of my main drawer items.
Navigation with drawer
but inside those widgets i want to route to a new one, with a button click for example, while the drawer stays in my corner. So basically is there any way to reproduce a sticky android drawer in flutter ?
Drawer is a Scaffold property.
So when you go to another page you will normally have another Scaffold widget with its own Drawerand the previous one will be disposed.
In the new page you need to create and display the Drawer for this Scaffold but you can't keep the previous one in the corner.
Since the two widgets are independent of each other, you cannot use the same exact Drawer in the second widget.
Either you can create the exact copy of that Drawer in second one and open it on initState method or if possible instead of switching to the second, you can make the second widget as a subview inside firstWidget.
Ref: Tablesorter
Issue: expand-child element remains visible when select page number clicked
Hi
The problem I'm facing is best described in steps
1.) I have nested tables inside a parent table
2.) I'm using the 'toggle' class on a tr followed by a tr with the class 'expand-child' (structural association) - jquery hides all nested tr's onload
3.) If the hidden tr (expand-child) is clicked open and the outer parent table's (holding the nested table) 'select page number' is clicked the 'expand-child' tr remains open while it's associated toggle tr has moved onto the previous page
I need to pass the associated expand-child tr to the previous page so it can be with it's associated toggle tr so that it too is not visible until the page it's on is in focus
Many thanks
I think the easiest solution would be to hide all child rows after the pager page changes. Try something like this (demo):
$('.tablesorter').on('pageMoved', function(){
$(this).find('.expand-child td').hide();
});
I am new to jQuery Mobile. I am trying to move from page #one1 to #page2. #page2 contains an address book form. If I fill something in the form and click on the back button to move to #page1 and then I again move to #page2, the form will show all the previously filled data.
I want that when I go back to #page2 all the fields be blank.
I have also tried it with putting an alert. The alert will popup the first time but it is not showing when I revisit this page again.
$('#page2').live('pageinit',function(event){
alert("Edit");
});
Thanks
Vivek
In the button that shows up #page2, don't move right away to #page2, first call a function that clears the fields. And then you can move to #page2...
I'm starting with jQuery mobile and have some problems with my buttons.
The web application is a shopping list. It displays a list of items to shop and in the footer buttons on actions I can perform on the items.
The actions are:
increment number of items to buy
decrements number of items to buy
move item up in list
move item down in list
add new item
delete item
modify item text description
The actions are implemented in javascript and works fine. The problems I have is with controlling the buttons and the associated actions.
By experience, I have see that for the increment and decrement it is more convenient to have a button with an active state, for the other operations it is preferable to have a selected item and apply the action on the selected item when the button is pressed. When adding an item, the item would be inserted before the selected item, and if pressed when no item is selected, the new item is appended to the list.
I would also like to have 2 modes. In one mode, only the increment and decrement buttons are shown and the user can update the number of items in its list. In the other mode the user is modifying its list. It is in the second mode that the selected item is required.
I managed to associate a default action my item lists by using the .on() method as a delegate.
$('#itemList').on( "click", ".item", function(evt)
{ ctrl.doAction($(evt.currentTarget)); });
Here is the html code I use to test the first mode.
<!-- footer -->
<div data-role="footer" data-position="fixed" class="ui-bar" id="btnBar" >
Plus
Minus
</div>
<!-- /footer -->
What should I put as href value ? I don't want the page to be reloaded. In some examples I see "#".
This is how I associate the action to the button:
$('#btnPlus').on( "tap", function(evt)
{ ctrl.doAction = ctrl.increment; });
Another problem I have is that there is no feedback on the button click action. When I click a button I would expect to have it highlighted for a short time. This doesn't happen.
The browsers have also different behaviors. In firefox, the clicked button gets a blue halo apparently showing that it has the focus. But the button isn't displayed as active.
If I put "#!" as href (don't know what it means) on Android, the clicked button is shown active.
Should I use click or tap as event type ? How could I write click or tap ?
How could I implement a two state button displayed as active and inactive ?
How is an action button used : always displayed inactive and feedback when pressed ?
I solved the problem my self.
to switch between sets of buttons in the footer, I create multiple footers in my HTML document with style="display:none" in the hidden footers. The one without this will be shown. I assigned a specific id to each footer so that I can write $("#footer1").hide(); $("#footer2").show();
I have buttons to switch between footers. The footer switching event handler must be called with the "mouseup" event. This is required for it to work on the iPad and Android phones.
To change appearance, don't use .button() as suggested here. Use:
$("#myButton")
.removeClass( "ui-btn-up-a ui-btn-down-a ui-btn-hover-a" )
.addClass("ui-btn-up-b")
.attr( "data-theme", "b" );
Note: There was a bug in my code which caused desperate hair pulling