flutterdartuser-interfacebuttonspacing

How to remove the space under the elevated button at the bottom of the screen?


 import 'package:flutter/material.dart';

class AddPlaceScreen extends StatefulWidget {
  static const routeName = '/add-place';
  @override
  _AddPlaceScreenState createState() => _AddPlaceScreenState();
}

class _AddPlaceScreenState extends State<AddPlaceScreen> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Add new Place data'),
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: [
          Text('User Inputs'),
          ElevatedButton.icon(
            onPressed: () {},
            icon: Icon(Icons.add),
            label: Text('Add Place'),
          ),
        ],
      ),
    );
  }
}

Here I am getting a space under the elevated button located at the bottom of the page please provide any solution to remove it.

enter image description here


Solution

  • enter image description here

    Please refer below code

    Add this piece of code inside ElevatedButton.icon Widget

    style: ButtonStyle(
        tapTargetSize: MaterialTapTargetSize.shrinkWrap, /* Please add this to avoid padding */
    ),
    
    class AddPlaceScreen extends StatefulWidget {
      static const routeName = '/add-place';
      @override
      _AddPlaceScreenState createState() => _AddPlaceScreenState();
    }
    
    class _AddPlaceScreenState extends State<AddPlaceScreen> {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: Text('Add new Place data'),
          ),
          body: Column(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
              Text('User Inputs'),
              ElevatedButton.icon(
                style: ButtonStyle(
                  tapTargetSize: MaterialTapTargetSize
                      .shrinkWrap, /* Please add this to avoid padding */
                ),
                onPressed: () {},
                icon: Icon(Icons.add),
                label: Text('Add Place'),
              ),
            ],
          ),
        );
      }
    }