Flutter stack clicking through top object

287 views
Skip to first unread message

leo nx

unread,
May 25, 2018, 4:58:56 PM5/25/18
to Flutter Dev

I coded a menu in my flutter app, it is a rectangle that you can draw up from the bottom of the screen, and its in a stack with my main page, so it overlays the main page.

But when i click on one of the Inkwells in my menu, it instead clicks on the same position on the Card below it(tested that with an inkwell on the bottom layer).

Why is that happening(clicking through the inkwell in my menu)?

Here's the code:

new Stack(children: [
              new Column(
                children: <Widget>[
                  new Expanded(
                      child: new TabBarView(children: <Widget>[
                    new CostumCard(
                      imgUrl:
                          url1,
                    ),
                    new CostumCard(
                      imgUrl:
                          url2,
                    ),
                  ]))
                ],
              ),
              new Transform(
                transform: new Matrix4.translationValues(0.0, yTransform, 0.0),
                child: new Transform(
                  transform: new Matrix4.translationValues(
                      0.0, MediaQuery.of(context).size.height - 80 - 70, 0.0),
                  child: new Container(
                    width: double.infinity,
                    height: 500.0,
                    child: new Material(
                      child: new Column(
                        children: <Widget>[
                          new RaisedButton(onPressed: (){print('hello world.');}, child: new Text('Hello World!')),
                          new CostumListTile(
                            itemTitle: 'Vertretungsplan',
                            onTap: () {print('NONONONO');},
                            menuIcon: Icons.assignment_late,
                          ),
                          new CostumListTile(
                            itemTitle: 'Kalender',
                            onTap: () {
                              Navigator.push(
                                  context,
                                  new MaterialPageRoute(
                                      builder: (context) => new WebViewPage(
                                          url:
                                              url,
                                          title: 'Kalender')));
                            },
                            menuIcon: Icons.calendar_today,
                          ),
                          new CostumListTile(
                            itemTitle: 'Aktuelles',
                            onTap: () {
                              Navigator.push(
                                  context,
                                  new MaterialPageRoute(
                                      builder: (context) => new WebViewPage(
                                          url:
                                              url,
                                          title: 'Aktuelles')));
                            },
                            menuIcon: Icons.info_outline,
                          ),
                          new CostumListTile(
                            itemTitle: 'Mensaplan',
                            onTap: () {
                              Navigator.push(
                                  context,
                                  new MaterialPageRoute(
                                      builder: (context) => new WebViewPage(
                                          url:
                                              url,
                                          title: 'Mensaplan')));
                            },
                            menuIcon: Icons.restaurant,
                          ),
                        ],
                      ),
                    ),
                  ),
                ),
              ),
            ]),

and here's the code for CostumListTile

import 'package:flutter/material.dart';

class CostumListTile extends StatelessWidget {
  String itemTitle;
  IconData menuIcon;
  VoidCallback onTap;

  CostumListTile({this.itemTitle, this.menuIcon, this.onTap});

  @override
  Widget build(BuildContext context) {
    return new InkWell(

      onTap: onTap,
      child: new Row(
        children: <Widget>[
          new Padding(
            padding: const EdgeInsets.all(20.0),
            child: new Icon(menuIcon, color: Colors.white, size: 30.0),
          ),
          new Text(itemTitle,
              style: new TextStyle(
                fontSize: 20.0,
              ))
        ],
      ),
    );
  }
}
Reply all
Reply to author
Forward
0 new messages