简体   繁体   中英

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. while debug mode returns 1-2-3 and correct data. Anyone know what could be the cause?

Please provide more information:

  1. how does widget._eventStream gets the data?
  2. Could you confirm that on both platforms (iOS and Android) on profile/release modes, you have the problem?

First, I can guess that you get data for the stream from some backed over HTTP or WebSocket. 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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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