Michiel
Michiel

Reputation: 486

Flutter Stack not showing child

The Flutter stack below is not working as it should, or I'm doing something wrong. I want to create the following stack:

  1. Image
  2. Black overlay
  3. Text (title)

1 and 3 show, but number 2 is not showing. I'm at a loss here since practically the same setup is working fine somewhere else and I've been breaking my head over this. Can anyone tell me what's going on here?

Stack(alignment: Alignment.center, fit: StackFit.passthrough, children: [
                    widget.currentTrick.imageUrl != null
                        ? Hero(tag: widget.currentTrick.id + "image", child: CachedNetworkImage(imageUrl: widget.currentTrick.imageUrl, fit: BoxFit.cover))
                        : Container(color: AppTheme.colorPrimary),
                    Container(
                      color: Colors.black.withOpacity(0.9),
                    ),
                    Center(
                      child: Hero(
                        tag: widget.currentTrick.id + "title",
                        child: Text(
                          widget.currentTrick.title,
                          textAlign: TextAlign.center,
                          style: AppTheme.bitTitleWhite,
                        ),
                      ),
                    ),
                  ]),

Upvotes: 1

Views: 1785

Answers (1)

w461
w461

Reputation: 2678

Try Position.fill for the black overlay

Upvotes: 1

Related Questions