简体   繁体   English

Flutter 流生成器在发布模式下没有数据

[英]Flutter streambuilder has no data in release mode

My application for some reason isn't working correctly on profile/release version.由于某种原因,我的应用程序在配置文件/发布版本上无法正常工作。

@override
  Widget build(BuildContext context) {
    print('1');
    final userData = context.watch<UserModel>();
    return StreamBuilder<List<AppointmentModel>>(
        stream: widget._eventStream as Stream<List<AppointmentModel>>,
        builder: (context, snapshot) {
          print('2');
          if (!snapshot.hasData) return const CircularProgressIndicator();
          if (snapshot.hasData) {
            print('3');
            final events = snapshot.data;

basically the snapshot has no data in profile/release mode but in debug mode it's fine... profile mode returns 1 and 2 only and i keep seeing CircularProgressIndicator.基本上快照在配置文件/发布模式下没有数据,但在调试模式下很好......配置文件模式仅返回 1 和 2,我一直看到 CircularProgressIndicator。 while debug mode returns 1-2-3 and correct data.而调试模式返回 1-2-3 和正确的数据。 Anyone know what could be the cause?有谁知道可能是什么原因?

Please provide more information:请提供更多信息:

  1. how does widget._eventStream gets the data? widget._eventStream如何获取数据?
  2. Could you confirm that on both platforms (iOS and Android) on profile/release modes, you have the problem?您能否确认在配置文件/发布模式的两个平台(iOS 和 Android)上,您有问题吗?

First, I can guess that you get data for the stream from some backed over HTTP or WebSocket.首先,我猜你从 HTTP 或 WebSocket 上获得了 stream 的数据。 Second, if the problem is only on Android, make sure that in the AppManifest.xml files under /android/app/src/profile and /android/app/src/main , you have the next line of code for permission:其次,如果问题仅出现在 Android 上,请确保在/android/app/src/profile/android/app/src/main下的AppManifest.xml文件中,您有下一行代码以获得权限:

<uses-permission android:name="android.permission.INTERNET"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM