-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
Description
Steps to Reproduce
- Create a complex and nested
Widgetthat takes a significant time to build (~100 widgets, with ~10 nesting levels). - Use an
Isolatethrough thecomputefunction in order to build it:
FutureBuilder(
future: compute<int, Widget>(
buildComments, this.storyId),
builder: (BuildContext context, AsyncSnapshot snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.none:
case ConnectionState.active:
case ConnectionState.waiting:
return LinearProgressIndicator();
case ConnectionState.done:
if (snapshot.hasError) {
final ArgumentError myError = snapshot.error;
return Text('Error: ${myError.message}');
} else {
final Widget comments = snapshot.data;
return comments;
}
}
},
)Note that the prototype of the function is Future<Widget> buildComments(int storyId) async, so the future should be executed inside the isolate.
- The linear progress indicator will hang for a visible amount of time.
More information here: https://stackoverflow.com/q/55632971/3634271

(Sorry for the quality of this GIF but I think that it helps to understand the issue.)
Logs
C:\Users\noname120\AndroidStudioProjects\hacker_news_core>flutter analyze
Analyzing hacker_news_core...
No issues found! (ran in 3.7s)
Output of `flutter doctor -v`
C:\Users\noname120\AndroidStudioProjects\hacker_news_core>flutter doctor -v
[√] Flutter (Channel master, v1.4.11-pre.34, on Microsoft Windows [Version 10.0.17134.590], locale en-US)
• Flutter version 1.4.11-pre.34 at C:\flutter
• Framework revision 0b8403b61c (5 days ago), 2019-04-07 21:29:32 -0700
• Engine revision ff1bcdc009
• Dart version 2.2.1 (build 2.2.1-dev.3.0 None)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at C:\Users\noname120\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
• All Android licenses accepted.
[√] Android Studio (version 3.3)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 34.0.1
• Dart plugin version 182.5215
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
[!] IntelliJ IDEA Ultimate Edition (version 2019.1)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2019.1
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
https://flutter.dev/intellij-setup/#installing-the-plugins
[!] VS Code, 64-bit edition (version 1.30.2)
• VS Code at C:\Program Files\Microsoft VS Code
X Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[√] Connected device (1 available)
• ZTE A2017G • 16246042 • android-arm64 • Android 7.1.1 (API 25)
! Doctor found issues in 2 categories.
Metadata
Metadata
Assignees
Labels
No labels