Flutter Web - How to reload currently Active Page - web

I am using Flutter for developing a website. Everything is working fine with Flutter except when it comes to reloading the page. When I press the refresh button in the browser, the whole web app gets reloaded.
For example, if I have navigated to four pages from the initial page, when I press the refresh button from the fourth page, the initial page gets loaded and I'll have to manually browse all the way to the fourth page again.
Is there any way to load the currently active page in Flutter?

Or you can just use this as it refreshes the whole window natively
import 'dart:html' as html;
html.window.location.reload();

Check out navigation with named routes as it maps URLs seamlessly when using Flutter Web.
EDIT : If you want URL parameters (like an id, a token...), check out this article.

Use Navigator to push to the same page. .ie.
If CurrentPage() is your page that needs to be refreshed then use:
Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) => CurrentPage()));
This will reload the page.

import 'dart:html' as html;
html.window.location.reload();
as this is not allowed according to
https://dart-lang.github.io/linter/lints/avoid_web_libraries_in_flutter.html
this is how i have resolved my issue:
import this package
https://pub.dev/packages/universal_html/install
import whereever you want to use
import 'package:universal_html/html.dart' as html;
and you can use it like this
html.window.location.reload();

Related

Shopify Hamburger Menu Button Not Working On Mobile Devices (Debut Theme)

I'm using the Debut theme on my Shopify site and have an issue with the hamburger menu button not working. It will work once but when I navigate to a new page nothing happens when I press the button again. When the page loads the following message is shown on the console for theme.js:
TypeError: $.debounce is not a function. (In '$.debounce(50, function() {
styleDropdowns($(selectors.siteNavHasDropdown));
positionFullWidthDropdowns();
})', '$.debounce' is undefined)
If I manually empty caches through the browser and reload the page the error no longer appears in the console and the button works again. However, once I navigate away from the page the issue returns.
Any help would be greatly appreciated.
Check to see if you have your JS files included on all pages

How to stop page refresh when changing url by history.replacestate in angularjs?

I'm updating my page URL from on a span click in my angularjs+jade+nodejs application.
http://192.xxx.0.xxx:7071/page-1/blog
to
http://192.xxx.0.xxx:7071/page-2/blog
I am using history.replaceState to change.
But as the function execute the page gets automatically refreshed.
I want to stop the reload using replaceState. Is there any other solution available?
If I write history.replacestate(null, null, '/page-2/blog') in console of browser it works perfectly fine.
You should take a look to "reloadOnSearch: false" .
If you add this in your angularJS module you can't disable the refresh
[reloadOnSearch=true] - {boolean=} - reload route with true, or false if you don't want to refresh .

wait for page load for non-angular Application using protractor

i am new to protractor and testing Non-Angular login Page and on clicking login button on login page a new page appears and i need to click on a planning link.But on clicking Login button application takes around 50 seconds.I want the protractor to wait untill the planning link appears.I used browser.wait(),browser.driver.implicitltyWait() but no success. I am able to click on planning link using browser.sleep() only.
Please help me to resolve the issue.
You need to wait for any WebElement in the page that is loaded after you perform login operation.
var EC = protractor.ExpectedConditions;
browser.wait(EC.visibilityOf(element(by.id("someId"))),60000)
it will wait for the element and throw exception after waiting for 1 minute
So what I understood from your question is that you have a non angular login page and click on login button takes you to another page(Is this angular or non angular?) which takes around 50 sec to load and contains a link(planning). Right?? And clicking on that link will take you to your angular home page.
And the issue which you are facing now is that the protractor is not waiting 50sec for the page containing the planning link to load.
Please try this and let me know the result..
this.clickLoginBtn = function () {
browser.driver.findElement(loginBtn).click();
return browser.wait(function () {
return browser.driver.isElementPresent(planningLink);
}, 50000);
};
I used browser.driver.findElement since we are on the non angular page.
I wrote a blog post about this, and have working examples on github, specifically when testing non-Angular apps. It makes use of Expected Conditions, and Page Objects.
If you're not using Page Objects yet, you'd do something like:
var EC = protractor.ExpectedConditions;
// Waits for the element with id 'loginBtn' to be clickable.
browser.wait(EC.elementToBeClickable($('#loginBtn')), 50000);

Invoking Browser via application Icon Like Youtube Application Without Showing My Application

i want to invoke browser with a specific url like youtube application. I've try using Navigator Invoke but, its show my application. i dont want to show my application just show browser when user click the application icon, can anybody help me please ..
Put this into your main() in main.cpp
QDesktopServices::openUrl(QUrl("http://example.com",QUrl::TolerantMode));
But you MUST remove (comment) the following lines:
new ApplicationUI(&app);
return Application::exec();
Otherwise application will open anyway

sencha touch :: is it possible (and how) to open a website inside a panel or in external browser window?

i wonder if and how it is possible to open a website inside a panel or in an external browser window of the mobile safari! I tried to open a website inside a panel but due to crossdomain problems only the htm without the css was loaded.
any ideas?
thnx!
edit: let's say, we use phoneGap
As far as I know, cross-domain issues do block you from IFRAME solutions for displaying external links inside your app.
Best solution currently is to have links include target="_blank" to force a new browser window to open.
#Stevanicus #Dalar It does open a new window in Mobile Safari if you use Phonegap and allowed domains using phonegap.plist whitelist property, but if you do somthing like
var rateMsg = Ext.Msg.confirm('Title', 'Some message', function(e) {
if(e == 'yes')//If user confirms yes
{
window.open("http://www.example.com", "_blank");//We open a link with _blank to use mobile safari and not your webview
}
});
It does not work.

Resources