Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
761 views
in Technique[技术] by (71.8m points)

dart - I'm trying to wrap a Stack widget on Flutter into an Expanded widget. How could I make the Stack fit in the Expanded with 0 margin?

image

I'm trying to wrap a Stack widget on Flutter into an Expanded widget. It looks like the Expanded widget forces the stack to be positioned with a default margin. So, How could I make the Stack fit in the Expanded widget with 0 margin? Or what would you recommend to layout widgets (with overlap) and make sure to use the suitable widget ensuring the responsivity of my app.

import 'package:WEW/constants.dart';
    import 'package:WEW/size_config.dart';
    import 'package:flutter/foundation.dart';
    import 'package:flutter/material.dart';
    
    // The body of my Scaffold widget in the main class
    class Body extends StatefulWidget {
      @override
      _BodyState createState() => _BodyState();
    }
    
    // Implementation of state State
    class _BodyState extends State<Body> {
      @override
      Widget build(BuildContext context) {
        return SafeArea(
          child: SizedBox(
            height: getScreenHeight(),
            width: getScreenWidth(),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisAlignment: MainAxisAlignment.start,
              children: <Widget>[
                Expanded(
                  // The stack I'm trying to fit into Expanded
                  child: Stack(
                    children: <Widget>[
                      Positioned(
                        top: 0,
                        left: 0,
                        child: Image.asset(
                          "assets/images/welcome_top.png",
                          height: getProportionateScreenHeight(144),
                          width: getProportionateScreenWidth(193),
                        ),
                      ),
                      Positioned(
                        top: 0,
                        left: 0,
                        child: Image.asset(
                          "assets/images/WEW_logo_light.png",
                          height: getProportionateScreenHeight(149),
                          width: getProportionateScreenWidth(228),
                        ),
                      ),
                    ],
                  ),
                ),
                Expanded(
                  flex: 2,
                  child: Column(
                    children: <Widget>[
                      Text(
                        "Werkgerers & Werknemers",
                        style: TextStyle(
                          fontSize: getProportionateScreenHeight(36),
                          //color: cPrimaryColor,
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                      Text("Verbinden van de wereld van logistiek"),
                    ],
                  ),
                ),
                Expanded(
                  child: SizedBox(),
                ),
              ],
            ),
          ),
        );
      }
    }
question from:https://stackoverflow.com/questions/65865782/im-trying-to-wrap-a-stack-widget-on-flutter-into-an-expanded-widget-how-could

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...