Visitar URL original
Add loading indicator web template by YazeedAlKhalaf · Pull Request #85464 · flutter/flutter · GitHub
Skip to content

Add loading indicator web template - #85464

Closed
YazeedAlKhalaf wants to merge 5 commits into
flutter:masterfrom
YazeedAlKhalaf:add_loading_indicator_web_template
Closed

YazeedAlKhalaf wants to merge 5 commits into
flutter:masterfrom
YazeedAlKhalaf:add_loading_indicator_web_template

Conversation

@YazeedAlKhalaf

Copy link
Copy Markdown
Contributor

This adds a loading indicator to the web template. It showed when there is no flutter app loaded. Once the Flutter app is loaded, the loading indicator is not visible to the user.

GIF showing the design of the loading indicator:
123546889-31151280-d767-11eb-9e5d-a79427f3862d

closes #85405

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Jun 28, 2021
@google-cla google-cla Bot added the cla: yes label Jun 28, 2021
@bernaferrari

Copy link
Copy Markdown
Contributor

The way you did it, wouldn't the loader be alive after Flutter app has loaded? Is there any benchmark to see if it doesn't affect anything?

@zanderso
zanderso requested review from jonahwilliams and yjbanov July 1, 2021 20:57
@christopherfujino

Copy link
Copy Markdown
Contributor

Note: that this PR (#83530) created a merge conflict with this PR.

@YazeedAlKhalaf

YazeedAlKhalaf commented Jul 2, 2021 •

Copy link
Copy Markdown
Contributor Author

@bernaferrari Yup you're right, it would stay spinning all the time even after the app loads.

So now the loader is there with its styling. We need to make it appear only when the flutter app is loading and remove it once the app paints the first frame. I am not sure how, to be honest, but will try to dig in to find a way.

Is there any way to know if the app has loaded? in web of course.

@jonahwilliams
jonahwilliams removed their request for review July 7, 2021 16:14
@jonahwilliams

Copy link
Copy Markdown
Contributor

I'm not sure whether this makes sense from a product perspective, adding @yjbanov for thoughts

@YazeedAlKhalaf

Copy link
Copy Markdown
Contributor Author

I suggest using the loading indicator that flutter photobooth used.
It looks cool and is material design compliant too.

Or do you think keeping it simple is better?

https://github.com/flutter/photobooth/blob/main/web/index.html#L56

@zanderso

Copy link
Copy Markdown
Member

@yjbanov any thoughts?

@yjbanov

yjbanov commented Jul 19, 2021

Copy link
Copy Markdown
Contributor

I think we should provide API for implementing custom loading indicators and/or splash screens, and provide an example that developers could learn from. The gallery should probably use one too. It would also be great if one of the flutter create templates added one. Whether it should be in the default template, I'm not sure. This is more of a product question, cc @mariamhas. It's also not clear to me what style the default loading indicator should use, or whether it matters at all. If it's intended to be a starting point for developers to hack from and customize, then maybe the style doesn't matter.

Aside from that, I think we lack API for implementing a proper loading indicator. For example, this implementation, as pointed out by @bernaferrari, will stay in the DOM tree forever. We could have the engine emit a "first frame rendered event" JavaScript event that the app could listen to and implement a transition from the loading screen to the app screen. We should also provide a JS API for controlling the visibility of the Flutter app, so one could implement different transitions, such as cross-fade.

This probably has enough devils in the detail to warrant a design doc before we jump into coding.

@yjbanov

yjbanov commented Jul 21, 2021

Copy link
Copy Markdown
Contributor

I think we should not do this before we add JS API and before we make decision on styling, defaults, etc. So I'm closing this PR. However, this is a good example, and could be a useful blog post. I would add loading indicator removal after the app renders its first frame (which can be done by using addPostFrameCallback).

@yjbanov yjbanov closed this Jul 21, 2021
@YazeedAlKhalaf

Copy link
Copy Markdown
Contributor Author

I think we should not do this before we add JS API and before we make decision on styling, defaults, etc. So I'm closing this PR. However, this is a good example, and could be a useful blog post. I would add loading indicator removal after the app renders its first frame (which can be done by using addPostFrameCallback).

Oh thanks for the suggestion @yjbanov. It makes so much sense.

Will make a blog post. 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancing the web index.html template

6 participants