'Flutter app show White screen in release app mode?

I am facing very strange issue in flutter app! When test my app in debug mode its working fine while in release mode it shows the white screen. This app is already published in playstore. After few days I changed this app. I want to release second version. When I try to build release apk its shows white screen while in debug mode working fine. Why does it happen? Is it flutter version issue?

image one

image two

here is code

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:tv/Online.dart';
import 'package:tv/paypal.dart';
import 'package:url_launcher/url_launcher.dart';


class Donateus extends StatefulWidget {
  @override
  _DonateusState createState() => _DonateusState();
}

class _DonateusState extends State<Donateus> {
  bool _isExpandedonline=false;
  bool _isExpandedpaypal=false;
  bool _isExpandedetransfer=false;
  bool _isExpandedtexttogive=false;

  void customLaunch(command) async {
    if (await canLaunch(command)) {
      await launch(command);
    } else {
      print(' could not launch $command');
    }
  }
  @override
  void initState() {
    // TODO: implement initState
    super.initState();

  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SingleChildScrollView(
        scrollDirection: Axis.vertical,
        child:Padding(
          padding: EdgeInsets.all(10),

          child: Container(
            child:Expanded(
              child: Column(
                children: <Widget>[
                  Text(
                    'WAYS TO DONATE',
                    style: TextStyle(
                      fontFamily: 'TT NORMS',
                      fontSize: 20,
                      fontWeight: FontWeight.w100,
                    ),


                  ),
                  Padding(
                    padding: EdgeInsets.only(left: 10),
                    child: Text(
                      'All of our Donations are processed through Cornerstone Asian Church.We are a registered Canadian Charity (842869265RR0001). A Canadian Tax-deductible receipt will be issued to you.',
                      style: TextStyle(

                          fontSize: 14
                      ),
                    ),
                  ),
                  Padding(
                    padding: EdgeInsets.only(left: 10),
                    child: ExpansionTile(
                        onExpansionChanged: (value) {
                          _isExpandedonline=value;
                          setState(() {});
                        },
                        children: <Widget>[
                          Text(
                            'Give a single gift, or schedule a recurring amount by using your Credit cards (i.e Mastercard, VISA, AMEX).'
                                'Note: Cornerstone uses the giving provider, Tithe.ly to securely process online donations from all over the world. Our Church will cover all associated fees for this service which are 2.5% + 15 cents (CAD) for all  Credit Cards. AMEX is 3.5% + 30 cents (CAD). However, if you wish to cover the fees as well, you can click on the option to "Cover Fees".',style: TextStyle(

                            fontSize: 14,


                          ),)
                        ],

                        title: Row(
                          children: <Widget>[
                            Image.asset(
                              'images/online.png',
                            ),
                            GestureDetector(
                              onTap: () {
                                Navigator.push(
                                  context,
                                  MaterialPageRoute(
                                      builder: (context) => Online()),
                                );
                              },
                              child: Text(

                                'Online Giving',
                                style: TextStyle(
                                  fontFamily: 'TT NORMS',
                                  fontSize: 18,
                                  fontWeight: FontWeight.w100,
                                  color: _isExpandedonline ? Colors.amber[800] : Colors.black,

                                ),


                              ),

                            )

                          ],


                        )),

                  ),

                  Padding(
                    padding: EdgeInsets.only(left: 10),
                    child: ExpansionTile(
                        onExpansionChanged: (value) {
                          _isExpandedpaypal=value;
                          setState(() {});
                        },
                        children: <Widget>[
                          Text(
                            'You can send your funds through PayPal to email [email protected]',style: TextStyle(
                            fontSize: 14,


                          ),)
                        ],
                        title: Row(
                          children: <Widget>[
                            Image.asset(
                              'images/paypal.png',
                            ),
                            Padding(
                              padding: EdgeInsets.only(left: 10),
                              child: Text(
                                'PAYPAL',
                                style: TextStyle(

                                  fontFamily: 'TT NORMS',
                                  color:_isExpandedpaypal ? Colors.amber[800] : Colors.black,
                                  fontSize: 18,
                                  fontWeight: FontWeight.w100,
                                ),
                              ),
                            ),
                            GestureDetector(
                              onTap: () {
                                Navigator.push(
                                  context,
                                  MaterialPageRoute(
                                      builder: (context) => paypal()),
                                );
                              },
                              child: Image.asset(
                                'images/donatebutton.png',
                                height: 33,
                              ),
                            )
                          ],
                        )),
                  ),
                  Padding(
                    padding: EdgeInsets.only(left: 10),

                    child: ExpansionTile(
                        onExpansionChanged: (value) {
                          _isExpandedetransfer=value;
                          setState(() {});
                        },
                        children: <Widget>[
                          Text(
                            'You can send your funds via Interac E-Transfer to email*',style: TextStyle(
                            fontSize: 14,


                          ),),

                          Text(
                            '
    [email protected]',
                            style: TextStyle(
                              color: Colors.blue,
                              fontSize: 18,

                            ),
                          ),

                          Text(
                            '
    This is an auto-deposit account
    so you you do not have to set up any password.
    Please do indicate the Purpose for your donation.
    This service is only available within Canada.',style: TextStyle(
                            fontSize: 14,


                          ),),
                        ],
                        title: Row(
                          children: <Widget>[
                            Image.asset(
                              'images/etransfer.png',
                              height: 28,
                            ),
                            Text(
                              'INTERAC E-TRANSFER',
                              style: TextStyle(

                                fontFamily: 'TT NORMS',
                                fontSize: 18,
                                fontWeight: FontWeight.w100,
                                color:_isExpandedetransfer? Colors.amber[800] : Colors.black,

                              ),
                            ),
                          ],
                        )),
                  ),
                  Padding(
                    padding: EdgeInsets.only(left: 10),
                    child: ExpansionTile(
                        onExpansionChanged: (value) {
                          _isExpandedtexttogive=value;
                          setState(() {});
                        },
                        children: <Widget>[
                          Text('STEP 1: TEXT the word GIVE to',style: TextStyle(
                            fontSize: 14,


                          ),),
                          Text(
                            '(844) 329-1637',
                            style: TextStyle(
                              color: Colors.red,
                            ),
                          ),
                          SizedBox(
                            height: 20,
                          ),
                          Text(
                            'STEP 2: Complete the information on link received via TEXT for the first time only.',style:TextStyle(
                            fontSize: 14,


                          ),),
                          SizedBox(
                            height: 20,
                          ),
                          Text(
                            'STEP 3: Once you are setup for TEXT GIVING you can continue to TEXT the amount without having to fill your information again. Simply TEXT the amounti.e 10, 15 etc to the number directly.',style: TextStyle(
                            fontSize: 14,


                          ),)
                        ],
                        title: Row(
                          children: <Widget>[
                            Image.asset(
                              'images/text.png',
                              height: 30,
                            ),
                            GestureDetector(
                              onTap: () {
                                customLaunch('sms:8443291637');
                              },
                              child: Padding(
                                padding: EdgeInsets.only(left: 10),
                                child: Text(
                                  'TEXT TO GIVE',
                                  style: TextStyle(
                                    fontSize: 18,
                                    fontWeight: FontWeight.w100,
                                    fontFamily: 'TT NORMS',
                                    color:_isExpandedtexttogive? Colors.amber[800] : Colors.black,

                                  ),
                                ),
                              ),
                            )
                          ],
                        )),
                  ),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}


Solution 1:[1]

The problem is you can't use Expand in child,means that An Expanded widget must be a descendant or parent,in debug mode,you can clearly see Incorrect Usage of Parent Widget in the terminal,it will work on debug mode,but in release build it will show blank page,so keep eye on above warning or error

Incorrect usage

child: Container(
            child:Expanded(
              child: Column(

example

Expanded(
      child: Container(),
    ),

In Row/Column

Row(
  children: [
    Expanded(
      child: MyWidget(),
    ),
    Expanded(
      child:Text("Text Widget"),
    ),
  ],
)

Solution 2:[2]

Unfortunately there can be more than one cause of this issue. One that I experienced is, for Android builds, that minifyEnabled appears to be turned on by default. I set

shrinkResources false
minifyEnabled false
useProguard false

and the build ran as expected. Just setting useProguard true and others false shrank the code as much as before; because of obfuscation. For more see https://medium.com/@swav.kulinski/flutter-and-android-obfuscation-8768ac544421

Solution 3:[3]

Check android.permission.INTERNET in android manifest

Solution 4:[4]

when i upgrade gradle version form gradle-5.6.2-all to gradle-6.1.1-all and build gradle com.android.tools.build:gradle:3.5.0 to com.android.tools.build:gradle:4.0.1

Finally, I got the solution as I have added in app/buidl.gradle file.

 buildTypes {
    release {
        signingConfig signingConfigs.debug
        shrinkResources false
        minifyEnabled false
        useProguard false
    }
}

Solution 5:[5]

Where should be widget library exception if you get such empty screen in releaser or profile mode. You could catch exceptions in debug console while debugging the app.

In your code, I see useless Container and Expanded widgets inside SingleChildScrollView. Consider removing them, it should help.

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SingleChildScrollView(
        scrollDirection: Axis.vertical,
        child:Padding(
          padding: EdgeInsets.all(10),
          child: Column(
                children: ... 
            ),
          ),
        ),
    );
  }

Solution 6:[6]

I've had same problem and it was of course, my fault. I've tried changing buildconfig.release configuration, different gradle versions, removing flavors but it was simple async error where data started to show before it was initialized (fetched).

App in debug mode was working fine, but in release it was showing white screen. Error was completely different from real reason: if you tapped on white screen there was a message like this:

E/flutter ( 6149): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: Null check operator used on a null value
E/flutter ( 6149): #0      RenderBox.hitTest (package:flutter/src/rendering/box.dart:2234)
E/flutter ( 6149): #1      RenderBoxContainerDefaultsMixin.defaultHitTestChildren.<anonymous closure> (package:flutter/src/rendering/box.dart:2596)
E/flutter ( 6149): #2      BoxHitTestResult.addWithPaintOffset (package:flutter/src/rendering/box.dart:787)
E/flutter ( 6149): #3      RenderBoxContainerDefaultsMixin.defaultHitTestChildren (package:flutter/src/rendering/box.dart:2591)
E/flutter ( 6149): #4      RenderCustomMultiChildLayoutBox.hitTestChildren (package:flutter/src/rendering/custom_layout.dart:412)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 ezaspi
Solution 3 rstrelba
Solution 4
Solution 5
Solution 6 bounxye