Wisit Phusi
Wisit Phusi

Reputation: 451

How can I make second widget in Stack widget is important?

I use Stack widget for making overlay.


Let's imagine that.

1) I add PageView at the Bottom.

2) I add Container to make Gradient at the Top.


I WANT TO KNOW THAT

How can I scroll PageView in spite of Gradient is over it?

This is a example

body: Stack(
    children: <Widget>[
      PageView.builder(
        itemBuilder: (BuildContext context, int index) => Container(
              height: double.infinity,
              width: double.infinity,
              child: Text("Index: $index"),
              color: _pageColors[index],
            ),
        onPageChanged: (number) {
          setState(() {
            _pageFocus = number + 1;
          });
          print(number);
        },
        controller: _pageController,
        itemCount: _pageColors != null ? _pageColors.length : 0,
      ),
      Align(
        alignment: AlignmentDirectional.bottomEnd,
        child: Container(
          height: 100.0,
          child: Stack(
            children: <Widget>[
              Container(
                decoration: BoxDecoration(
                  gradient: LinearGradient(
                      colors: [
                        Color.fromRGBO(255, 255, 255, 0.0),
                        Colors.white,
                      ],
                      stops: [
                        0.0,
                        3.0
                      ],
                      begin: FractionalOffset.topCenter,
                      end: FractionalOffset.bottomCenter,
                      tileMode: TileMode.repeated),
                ),
                width: double.infinity,
                height: double.infinity,
              ),
              Padding(
                padding: const EdgeInsets.all(16.0),
                child: Align(
                    alignment: AlignmentDirectional.centerStart,
                    child: Text('$_pageFocus/${_pageColors.length}')),
              )
            ],
          ),
        ),
      ),
    ],
  ),

Upvotes: 0

Views: 78

Answers (1)

scottstoll2017
scottstoll2017

Reputation: 1124

See if wrapping the Align in an IgonorePointer helps. docs.flutter.io/flutter/widgets/IgnorePointer-class.html

Upvotes: 1

Related Questions