{"action":"created","comment":{"url":"https://api.github.com/repos/flutter/flutter/pulls/comments/67728300","id":67728300,"diff_hunk":"@@ -85,21 +85,89 @@ class SystemChrome {\n   /// embedder (if any). The embedder may choose to ignore unsupported\n   /// overlays.\n   ///\n+  /// This method will schedule the embedder update to be run in a microtask.\n+  /// Any subsequent calls to this method during the current event loop will\n+  /// overwrite the pending value to be set on the embedder.\n+  ///\n   /// Arguments:\n   ///\n   ///  * [style]: A [SystemUiOverlayStyle] enum value denoting the style to use\n   ///\n   /// Return Value:\n   ///\n-  ///   boolean indicating if the preference was conveyed successfully to the\n-  ///   embedder.\n+  ///   The preference that was eventually conveyed to the embedder, along with\n+  ///   whether it was successfully conveyed. This can be different than the\n+  ///   value you specify here if another caller specified a different value\n+  ///   later in the same event loop.\n   ///\n   /// Platform Specific Notes:\n   ///\n   ///   If the overlay is unsupported on the platform, enabling or disabling\n   ///   that overlay is a no-op and always return true.\n-  static Future<bool> setSystemUIOverlayStyle(SystemUiOverlayStyle style) async {\n-    return (await _systemChromeProxy.setSystemUiOverlayStyle(\n-      style)).success;\n+  static Future<SystemUiOverlayStyleUpdate> setSystemUIOverlayStyle(SystemUiOverlayStyle style) {\n+    assert(style != null);\n+\n+    if (_pendingStyleUpdate != null) {\n+      _pendingStyleUpdate.style = style;\n+      return _pendingStyleUpdate.future;\n+    }\n+\n+    _pendingStyleUpdate = new _PendingStyleUpdate(style);\n+    scheduleMicrotask(() {\n+      assert(_pendingStyleUpdate != null);\n+      if (_pendingStyleUpdate.style == _latestStyle) {\n+        // No update needed; trivial success\n+        _pendingStyleUpdate.complete();\n+        _pendingStyleUpdate = null;\n+        return;\n+      }\n+\n+      _PendingStyleUpdate update = _pendingStyleUpdate;\n+      _systemChromeProxy.setSystemUiOverlayStyle(update.style).then((dynamic value) {\n+        update.complete(value.success);\n+      }, onError: () {\n+        update.complete(false);\n+      });\n+      _latestStyle = _pendingStyleUpdate.style;\n+      _pendingStyleUpdate = null;\n+    });\n+\n+    return _pendingStyleUpdate.future;\n+  }\n+\n+  static _PendingStyleUpdate _pendingStyleUpdate;\n+  static SystemUiOverlayStyle _latestStyle;\n+}\n+\n+/// Struct that represents an attempted update to the system overlays that are\n+/// visible on the embedder\n+class SystemUiOverlayStyleUpdate {\n+  /// The style that was passed to the embedder\n+  final SystemUiOverlayStyle style;\n+  /// Whether the preference was successfully conveyed to the embedder\n+  final bool success;\n+  const SystemUiOverlayStyleUpdate._({this.style, this.success});\n+}\n+\n+class _PendingStyleUpdate {\n+  final Completer<SystemUiOverlayStyleUpdate> _completer =\n+    new Completer<SystemUiOverlayStyleUpdate>();\n+  SystemUiOverlayStyle _style;\n+\n+  _PendingStyleUpdate(this._style);","path":"packages/flutter/lib/src/services/system_chrome.dart","position":78,"original_position":78,"commit_id":"8e4364d5e181c46205ddfad5c649cc830f6e3529","original_commit_id":"8e4364d5e181c46205ddfad5c649cc830f6e3529","user":{"login":"Hixie","id":551196,"avatar_url":"https://avatars.githubusercontent.com/u/551196?v=3","gravatar_id":"","url":"https://api.github.com/users/Hixie","html_url":"https://github.com/Hixie","followers_url":"https://api.github.com/users/Hixie/followers","following_url":"https://api.github.com/users/Hixie/following{/other_user}","gists_url":"https://api.github.com/users/Hixie/gists{/gist_id}","starred_url":"https://api.github.com/users/Hixie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hixie/subscriptions","organizations_url":"https://api.github.com/users/Hixie/orgs","repos_url":"https://api.github.com/users/Hixie/repos","events_url":"https://api.github.com/users/Hixie/events{/privacy}","received_events_url":"https://api.github.com/users/Hixie/received_events","type":"User","site_admin":false},"body":"constructor first","created_at":"2016-06-20T17:15:28Z","updated_at":"2016-06-20T17:15:28Z","html_url":"https://github.com/flutter/flutter/pull/4627#discussion_r67728300","pull_request_url":"https://api.github.com/repos/flutter/flutter/pulls/4627","_links":{"self":{"href":"https://api.github.com/repos/flutter/flutter/pulls/comments/67728300"},"html":{"href":"https://github.com/flutter/flutter/pull/4627#discussion_r67728300"},"pull_request":{"href":"https://api.github.com/repos/flutter/flutter/pulls/4627"}}},"pull_request":{"url":"https://api.github.com/repos/flutter/flutter/pulls/4627","id":74478447,"html_url":"https://github.com/flutter/flutter/pull/4627","diff_url":"https://github.com/flutter/flutter/pull/4627.diff","patch_url":"https://github.com/flutter/flutter/pull/4627.patch","issue_url":"https://api.github.com/repos/flutter/flutter/issues/4627","number":4627,"state":"open","locked":false,"title":"System chrome overlay style fixes","user":{"login":"tvolkert","id":15253456,"avatar_url":"https://avatars.githubusercontent.com/u/15253456?v=3","gravatar_id":"","url":"https://api.github.com/users/tvolkert","html_url":"https://github.com/tvolkert","followers_url":"https://api.github.com/users/tvolkert/followers","following_url":"https://api.github.com/users/tvolkert/following{/other_user}","gists_url":"https://api.github.com/users/tvolkert/gists{/gist_id}","starred_url":"https://api.github.com/users/tvolkert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tvolkert/subscriptions","organizations_url":"https://api.github.com/users/tvolkert/orgs","repos_url":"https://api.github.com/users/tvolkert/repos","events_url":"https://api.github.com/users/tvolkert/events{/privacy}","received_events_url":"https://api.github.com/users/tvolkert/received_events","type":"User","site_admin":false},"body":"1) Add a cache to avoid superfluous calls to the embedder\r\n2) Coalesce calls to the embedder that are made in the same event loop\r\n3) Move callsite to material's AppBar from Title widget","created_at":"2016-06-20T17:08:24Z","updated_at":"2016-06-20T17:15:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0d3ac5c985c62a26d5725b6a1b7789fb91cfce9e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/flutter/flutter/pulls/4627/commits","review_comments_url":"https://api.github.com/repos/flutter/flutter/pulls/4627/comments","review_comment_url":"https://api.github.com/repos/flutter/flutter/pulls/comments{/number}","comments_url":"https://api.github.com/repos/flutter/flutter/issues/4627/comments","statuses_url":"https://api.github.com/repos/flutter/flutter/statuses/8e4364d5e181c46205ddfad5c649cc830f6e3529","head":{"label":"tvolkert:gallery","ref":"gallery","sha":"8e4364d5e181c46205ddfad5c649cc830f6e3529","user":{"login":"tvolkert","id":15253456,"avatar_url":"https://avatars.githubusercontent.com/u/15253456?v=3","gravatar_id":"","url":"https://api.github.com/users/tvolkert","html_url":"https://github.com/tvolkert","followers_url":"https://api.github.com/users/tvolkert/followers","following_url":"https://api.github.com/users/tvolkert/following{/other_user}","gists_url":"https://api.github.com/users/tvolkert/gists{/gist_id}","starred_url":"https://api.github.com/users/tvolkert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tvolkert/subscriptions","organizations_url":"https://api.github.com/users/tvolkert/orgs","repos_url":"https://api.github.com/users/tvolkert/repos","events_url":"https://api.github.com/users/tvolkert/events{/privacy}","received_events_url":"https://api.github.com/users/tvolkert/received_events","type":"User","site_admin":false},"repo":{"id":59706548,"name":"flutter","full_name":"tvolkert/flutter","owner":{"login":"tvolkert","id":15253456,"avatar_url":"https://avatars.githubusercontent.com/u/15253456?v=3","gravatar_id":"","url":"https://api.github.com/users/tvolkert","html_url":"https://github.com/tvolkert","followers_url":"https://api.github.com/users/tvolkert/followers","following_url":"https://api.github.com/users/tvolkert/following{/other_user}","gists_url":"https://api.github.com/users/tvolkert/gists{/gist_id}","starred_url":"https://api.github.com/users/tvolkert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tvolkert/subscriptions","organizations_url":"https://api.github.com/users/tvolkert/orgs","repos_url":"https://api.github.com/users/tvolkert/repos","events_url":"https://api.github.com/users/tvolkert/events{/privacy}","received_events_url":"https://api.github.com/users/tvolkert/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tvolkert/flutter","description":"Framework for building high-performance, high-fidelity iOS and Android apps.","fork":true,"url":"https://api.github.com/repos/tvolkert/flutter","forks_url":"https://api.github.com/repos/tvolkert/flutter/forks","keys_url":"https://api.github.com/repos/tvolkert/flutter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tvolkert/flutter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tvolkert/flutter/teams","hooks_url":"https://api.github.com/repos/tvolkert/flutter/hooks","issue_events_url":"https://api.github.com/repos/tvolkert/flutter/issues/events{/number}","events_url":"https://api.github.com/repos/tvolkert/flutter/events","assignees_url":"https://api.github.com/repos/tvolkert/flutter/assignees{/user}","branches_url":"https://api.github.com/repos/tvolkert/flutter/branches{/branch}","tags_url":"https://api.github.com/repos/tvolkert/flutter/tags","blobs_url":"https://api.github.com/repos/tvolkert/flutter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tvolkert/flutter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tvolkert/flutter/git/refs{/sha}","trees_url":"https://api.github.com/repos/tvolkert/flutter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tvolkert/flutter/statuses/{sha}","languages_url":"https://api.github.com/repos/tvolkert/flutter/languages","stargazers_url":"https://api.github.com/repos/tvolkert/flutter/stargazers","contributors_url":"https://api.github.com/repos/tvolkert/flutter/contributors","subscribers_url":"https://api.github.com/repos/tvolkert/flutter/subscribers","subscription_url":"https://api.github.com/repos/tvolkert/flutter/subscription","commits_url":"https://api.github.com/repos/tvolkert/flutter/commits{/sha}","git_commits_url":"https://api.github.com/repos/tvolkert/flutter/git/commits{/sha}","comments_url":"https://api.github.com/repos/tvolkert/flutter/comments{/number}","issue_comment_url":"https://api.github.com/repos/tvolkert/flutter/issues/comments{/number}","contents_url":"https://api.github.com/repos/tvolkert/flutter/contents/{+path}","compare_url":"https://api.github.com/repos/tvolkert/flutter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tvolkert/flutter/merges","archive_url":"https://api.github.com/repos/tvolkert/flutter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tvolkert/flutter/downloads","issues_url":"https://api.github.com/repos/tvolkert/flutter/issues{/number}","pulls_url":"https://api.github.com/repos/tvolkert/flutter/pulls{/number}","milestones_url":"https://api.github.com/repos/tvolkert/flutter/milestones{/number}","notifications_url":"https://api.github.com/repos/tvolkert/flutter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tvolkert/flutter/labels{/name}","releases_url":"https://api.github.com/repos/tvolkert/flutter/releases{/id}","deployments_url":"https://api.github.com/repos/tvolkert/flutter/deployments","created_at":"2016-05-26T00:15:42Z","updated_at":"2016-05-26T00:15:45Z","pushed_at":"2016-06-20T17:06:37Z","git_url":"git://github.com/tvolkert/flutter.git","ssh_url":"git@github.com:tvolkert/flutter.git","clone_url":"https://github.com/tvolkert/flutter.git","svn_url":"https://github.com/tvolkert/flutter","homepage":"https://flutter.io","size":19158,"stargazers_count":0,"watchers_count":0,"language":"Dart","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"flutter:master","ref":"master","sha":"327d974dc5cb9f5d60d336cfad5fc0a48b688072","user":{"login":"flutter","id":14101776,"avatar_url":"https://avatars.githubusercontent.com/u/14101776?v=3","gravatar_id":"","url":"https://api.github.com/users/flutter","html_url":"https://github.com/flutter","followers_url":"https://api.github.com/users/flutter/followers","following_url":"https://api.github.com/users/flutter/following{/other_user}","gists_url":"https://api.github.com/users/flutter/gists{/gist_id}","starred_url":"https://api.github.com/users/flutter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flutter/subscriptions","organizations_url":"https://api.github.com/users/flutter/orgs","repos_url":"https://api.github.com/users/flutter/repos","events_url":"https://api.github.com/users/flutter/events{/privacy}","received_events_url":"https://api.github.com/users/flutter/received_events","type":"Organization","site_admin":false},"repo":{"id":31792824,"name":"flutter","full_name":"flutter/flutter","owner":{"login":"flutter","id":14101776,"avatar_url":"https://avatars.githubusercontent.com/u/14101776?v=3","gravatar_id":"","url":"https://api.github.com/users/flutter","html_url":"https://github.com/flutter","followers_url":"https://api.github.com/users/flutter/followers","following_url":"https://api.github.com/users/flutter/following{/other_user}","gists_url":"https://api.github.com/users/flutter/gists{/gist_id}","starred_url":"https://api.github.com/users/flutter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flutter/subscriptions","organizations_url":"https://api.github.com/users/flutter/orgs","repos_url":"https://api.github.com/users/flutter/repos","events_url":"https://api.github.com/users/flutter/events{/privacy}","received_events_url":"https://api.github.com/users/flutter/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/flutter/flutter","description":"Framework for building high-performance, high-fidelity iOS and Android apps.","fork":false,"url":"https://api.github.com/repos/flutter/flutter","forks_url":"https://api.github.com/repos/flutter/flutter/forks","keys_url":"https://api.github.com/repos/flutter/flutter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/flutter/flutter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/flutter/flutter/teams","hooks_url":"https://api.github.com/repos/flutter/flutter/hooks","issue_events_url":"https://api.github.com/repos/flutter/flutter/issues/events{/number}","events_url":"https://api.github.com/repos/flutter/flutter/events","assignees_url":"https://api.github.com/repos/flutter/flutter/assignees{/user}","branches_url":"https://api.github.com/repos/flutter/flutter/branches{/branch}","tags_url":"https://api.github.com/repos/flutter/flutter/tags","blobs_url":"https://api.github.com/repos/flutter/flutter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/flutter/flutter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/flutter/flutter/git/refs{/sha}","trees_url":"https://api.github.com/repos/flutter/flutter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/flutter/flutter/statuses/{sha}","languages_url":"https://api.github.com/repos/flutter/flutter/languages","stargazers_url":"https://api.github.com/repos/flutter/flutter/stargazers","contributors_url":"https://api.github.com/repos/flutter/flutter/contributors","subscribers_url":"https://api.github.com/repos/flutter/flutter/subscribers","subscription_url":"https://api.github.com/repos/flutter/flutter/subscription","commits_url":"https://api.github.com/repos/flutter/flutter/commits{/sha}","git_commits_url":"https://api.github.com/repos/flutter/flutter/git/commits{/sha}","comments_url":"https://api.github.com/repos/flutter/flutter/comments{/number}","issue_comment_url":"https://api.github.com/repos/flutter/flutter/issues/comments{/number}","contents_url":"https://api.github.com/repos/flutter/flutter/contents/{+path}","compare_url":"https://api.github.com/repos/flutter/flutter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/flutter/flutter/merges","archive_url":"https://api.github.com/repos/flutter/flutter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/flutter/flutter/downloads","issues_url":"https://api.github.com/repos/flutter/flutter/issues{/number}","pulls_url":"https://api.github.com/repos/flutter/flutter/pulls{/number}","milestones_url":"https://api.github.com/repos/flutter/flutter/milestones{/number}","notifications_url":"https://api.github.com/repos/flutter/flutter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/flutter/flutter/labels{/name}","releases_url":"https://api.github.com/repos/flutter/flutter/releases{/id}","deployments_url":"https://api.github.com/repos/flutter/flutter/deployments","created_at":"2015-03-06T22:54:58Z","updated_at":"2016-06-20T14:05:41Z","pushed_at":"2016-06-20T17:08:24Z","git_url":"git://github.com/flutter/flutter.git","ssh_url":"git@github.com:flutter/flutter.git","clone_url":"https://github.com/flutter/flutter.git","svn_url":"https://github.com/flutter/flutter","homepage":"https://flutter.io","size":113282,"stargazers_count":2842,"watchers_count":2842,"language":"Dart","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":299,"mirror_url":null,"open_issues_count":1048,"forks":299,"open_issues":1048,"watchers":2842,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/flutter/flutter/pulls/4627"},"html":{"href":"https://github.com/flutter/flutter/pull/4627"},"issue":{"href":"https://api.github.com/repos/flutter/flutter/issues/4627"},"comments":{"href":"https://api.github.com/repos/flutter/flutter/issues/4627/comments"},"review_comments":{"href":"https://api.github.com/repos/flutter/flutter/pulls/4627/comments"},"review_comment":{"href":"https://api.github.com/repos/flutter/flutter/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/flutter/flutter/pulls/4627/commits"},"statuses":{"href":"https://api.github.com/repos/flutter/flutter/statuses/8e4364d5e181c46205ddfad5c649cc830f6e3529"}}}}
{"actor":{"display_login":"Hixie"}}