Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why does this code display a blank screen when running?

Before displaying the code, here are the things that I checked to avoid similar answers :

  • android:extratNativeLibs="true"

  • Jsonfile firebase connected

    MEDevel.com: Open-source for Healthcare and Education

    Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

    Visit Medevel

  • routegenerator and initialroute checked in the main file and
    generatorfile

.I like to avoid mediaQuery and work with percentages, that is why I use FractionallySizedBox. Here is the code of the initial route :

 import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class Start extends StatelessWidget {
  const Start({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
            body: Align(
                alignment: Alignment.center,
                child: Center(
                    child: Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
                  FractionallySizedBox(widthFactor: 0.15, heightFactor: 0.15, child: Image.asset('assets/crown.png')),
                  FractionallySizedBox(
                      widthFactor: 0.40,
                      heightFactor: 0.20,
                      child: TextButton(
                          onPressed: () {
                            Navigator.of(context).pushNamed('/items');
                          },
                          child: Container(
                              decoration: BoxDecoration(color: Colors.purple),
                              child: Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
                                const Text('Start shopping',
                                    style: TextStyle(
                                      color: Colors.white,
                                      fontStyle: FontStyle.italic,
                                      fontSize: 25,
                                    )),
                                Image.asset('assets/crown.png')
                              ]))))
                ])))));
  }
}

>Solution :

Warp your FractionallySizedBox with Expanded

              Expanded(
                child: FractionallySizedBox(
                    widthFactor: 0.15,
                    heightFactor: 0.15,
                    child: Image.asset('assets/crown.png')),
              ),
              Expanded(
                child: FractionallySizedBox(
                  widthFactor: 0.40,
                  heightFactor: 0.20,
                  child: TextButton(
                    onPressed: () {
                      Navigator.of(context).pushNamed('/items');
                    },
                    child: Container(
                      decoration: BoxDecoration(color: Colors.purple),
                      child: Row(
                        mainAxisSize: MainAxisSize.min,
                        children: <Widget>[
                          const Text('Start shopping',
                              style: TextStyle(
                                color: Colors.white,
                                fontStyle: FontStyle.italic,
                                fontSize: 25,
                              )),
                          Image.asset('assets/crown.png')
                        ],
                      ),
                    ),
                  ),
                ),
              ),
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading