简体   繁体   中英

How do I bring the button closer to the Flutter

as you can see in the picture, there is a huge gap between the first button, the number and the second button. I tried using and not using containers, I switched between body: Center and Listview. I pretty much want the arrows to be directly above and below the number.

body: ListView(
          children: <Widget>[
            Container(
              width: 350,
              height: 36,
              child: Row(children: <Widget>[
                Text(
                  "ATH: " + highScore.toString(),
                  textAlign: TextAlign.right,
                  style: TextStyle(
                      fontSize: 30, color: Color.fromRGBO(0, 136, 255, 70)),
                ),
                Spacer(),
                Text(
                  Score.toString(),
                  textAlign: TextAlign.right,
                  style: TextStyle(
                      fontSize: 30, color: Color.fromRGBO(0, 136, 255, 70)),
                )
              ]),
            ),
            IconButton(
                onPressed: PfeilHoch,
                alignment: Alignment.bottomCenter,
                icon: Icon(Icons.arrow_drop_up),
                iconSize: 350,
                color: Color.fromRGBO(0, 300, 0, 100),
                padding: EdgeInsets.all(0),
              ),
            
            Text(
                (randomNumber.toString()),
                textAlign: TextAlign.center,
                style: TextStyle(fontSize: 90, ),
              ),
            
            IconButton(
                alignment: Alignment.topCenter,
                onPressed: PfeilRunter,
                icon: Icon(Icons.arrow_drop_down),
                iconSize: 350,
                color: Color.fromRGBO(300, 0, 0, 100),
                padding: EdgeInsets.all(0),
              ), 
          ],
        )

How it's looking right now

在此处输入图像描述

Instead of Listview use Column with SingleScrollChild

That is because IconButton is a Material Design widget that follows the spec that tappable objects need to be at least 48px on each side. You can click on the icon button implementation from any IDEs

Use GestureDetector instead of IconButton

Container(
  padding: const EdgeInsets.all(0.0),
  height: 200,
  width: 200,
  child: GestureDetector(onTap: () {}, child: Icon(Icons.arrow_drop_up, size: 200) )
  ,
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM