Skip to content

There is a weird behavior of Stack with Fittedbox in layout? #17287

@CircleCurve

Description

@CircleCurve

Steps to Reproduce

  1. follow the tutorial of card topic

  2. follow to write the code of flutter gallery card example
    https://github.com/flutter/flutter/blob/master/examples/flutter_gallery/lib/demo/material/cards_demo.dart
    fittedbox_stack_height2

  3. I don't know the logic with stack combine with fittedbox. Why there is a height ? I just follow the tutorial of setting bottom, left, right to 16.0,16.0,16.0. If i do not have any misunderstanding, it's a margin between parent and size-box. Why would have height existing ? Is there any black magic code of that? I just want to understand the logic of that.

fittedbox_stack_height

 var titleImage2 = new SizedBox(
          height: 200.0,
          child: new Stack(
            children : <Widget> [
                //new Text("First element" , style: new TextStyle(color: Colors.red),),
                new Positioned(
                    //top: 0.0,
                    left : 16.0, 
                    right : 16.0, 
                    bottom: 16.0,
                    //width: 100.0,
                  child: new FittedBox(
                    fit : BoxFit.scaleDown, 
                    alignment: Alignment.topLeft,
                    child : new Container(
                      child: new Text(
                          "Hello world"
                      ),
                    )
                  ),
                )],
          ),
    ); 

Summary : Why only set left ,right, bottom to margin 16.0, it will appear an existing height? I'm a newbie of flutter

left : 16.0, 
right : 16.0, 
bottom: 16.0,

fittedbox_stack_height3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions