firebase 来自云存储的图片显示在调试模式下,但未显示在发布apk-flutter中

qv7cva1a  于 2022-11-17  发布在  Flutter
关注(0)|答案(2)|浏览(78)

我正在显示图像从firebase云存储到flutter应用程序通过流构建器。我正在显示图像在警报对话框时,按下按钮。图片显示在调试模式罚款,但不显示在释放模式。我已经尝试获得apk与--no-shrink,但错误仍然相同。我的功能是当用户选择月份和年份从下拉菜单,并按下按钮,图片显示在该月的警报对话框中,并保存在云存储中。Picture in release apkPicture in debug mode

**Future showimage() async {
return showDialog(
    context: context,
    builder: (BuildContext context) {
      return Container(
        width: MediaQuery.of(context).size.width * 0.9,
        height: MediaQuery.of(context).size.height * 0.8,
        child: AlertDialog(
            content: Expanded(
          child: FutureBuilder(
            future: storage.downloadedUrl('${dropdownmonth}${dropdowndate}', '${dropdownmonth}${dropdowndate}Record'),
            builder: (BuildContext context, AsyncSnapshot<String> snap) {
              if (snap.connectionState == ConnectionState.done &&
                  snap.hasData) {
                return Expanded(
                  child: ListView.builder(
                      itemCount: 1,
                      itemBuilder: (BuildContext context, index) {
                        return Container(
                            width: 400,
                            height: 450,
                            child: Image.network(
                              snap.data!,
                              fit: BoxFit.cover,
                            ));
                      }),
                );
                //Container(width: 300,height: 450,
                // child: Image.network(snap.data!,
                // fit: BoxFit.cover,),
              }
              if (snap.connectionState == ConnectionState.waiting) {
                return Center(child: CircularProgressIndicator());
              }
              if(snap.data==null){
                return Center(child: Text("No Report Found"));
              }
              return Container();
            },
          ),
        )),
      );
    });

}**

pbwdgjma

pbwdgjma1#

这个问题是通过删除一些小部件如expanded,flex来解决的。我在发布状态下通过flutter run --release运行了更新

0lvr5msh

0lvr5msh2#

将blow中的行添加到AndroidManifest.xml

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

大概是这样的:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.stagered_grid_view">

// ----------------------------------------
    <uses-permission android:name="android.permission.INTERNET"/>
// ----------------------------------------
    
   <application
        android:label="stagered_grid_view"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

相关问题