есть блок места, я не могу понять, как исправить в моем виджете ListTile для моего приложения flutter, кода и фотографии ниже - PullRequest
0 голосов
/ 18 июня 2020

Кажется, я могу понять причину этого, я попытался изменить поля, я даже поместил границу на всякий случай, если я что-то заметил, но ничего, ListTile может прокручиваться по горизонтали, пожалуйста, и спасибо

вот фото ListTile Mysterious Space

а вот код

Align(
        alignment: Alignment.topCenter,

  child: 

  Visibility (
  visible : showRideTypes, 
  child :
Container(
         height: 200.0, 
          width: 360.0,
                                    margin: EdgeInsets.only(left: 0, top: 0,bottom: 0),

                                    decoration: BoxDecoration(

                       ),

child:ListView(
  children: const <Widget>[

   Card(
      child: ListTile(
        leading: FlutterLogo(size: 56.0),
        title: Text('Two-line ListTile'),
        subtitle: Text('Here is a second line'),

      ),
    ),
    Card(
      child: ListTile(
        leading: FlutterLogo(size: 56.0),
        title: Text('Two-line ListTile'),
        subtitle: Text('Here is a second line'),

      ),
    ),
    Card(
      child: ListTile(
        leading: FlutterLogo(size: 56.0),
        title: Text('Two-line ListTile'),
        subtitle: Text('Here is a second line'),

      ),
    ),

  ],
)

        ),

)
   )

Код для строки поиска ниже ......................................... .................................................. .......................

,Align(
  alignment: Alignment.topCenter,

  child:Container(
  margin: EdgeInsets.only(left: 0, top: 10,bottom: 0),
  height: 55,
                    width: 350.0,
                    decoration: BoxDecoration(
                      color: Colors.white70,
                      boxShadow: [
                        BoxShadow(
                            color: Colors.lightBlueAccent,
                            offset: Offset(1.0, 1.0),
                            blurRadius: 0,
                            spreadRadius: 0)
                      ],
                    ),
                    child: TextField(controller:locationText,
                    onTap: () async{

     Prediction p = await PlacesAutocomplete.show(
                context: context, apiKey: kGoogleApiKey,
                language: "en", components: [new Component(Component.country, "mw")]


                );

                      _getLatLng(p);


  },

                      decoration: InputDecoration(
                        icon: Container(
                          margin: EdgeInsets.only(left: 20, top: 0,bottom: 6),
                          width: 10,
                          height: 10,
                          child: Icon(
                            Icons.search,
                            color: Colors.black,
                          ),
                        ),
                        hintText: "Where to?",
                        border: InputBorder.none,
                        contentPadding: EdgeInsets.only(left: 15.0, top: 10.0),
                      ),
                    ),



  )



)

1 Ответ

0 голосов
/ 20 июня 2020

Когда вы используете виджет ListView, внутри ListView есть отступы по умолчанию, поэтому, добавив свойство padding внутри ListView и установив его на ноль во всех направлениях, вы избавитесь от этого пустого пространства, которое вы хотите удалить. Я добавил, как должен выглядеть код, чтобы избавиться от пустого пространства внизу, чтобы вы могли видеть, о чем я говорю.

    Align(
        alignment: Alignment.topCenter,
        child: Visibility (
         visible : showRideTypes, 
         child : Container(
         height: 200.0, 
         width: 360.0,
         margin: EdgeInsets.only(left: 0, top: 0,bottom: 0),
         decoration: BoxDecoration(),
         child:ListView(
          padding: EdgeInsets.all(0),
          children: const <Widget>[
           Card(
            child: ListTile(
             leading: FlutterLogo(size: 56.0),
             title: Text('Two-line ListTile'),
             subtitle: Text('Here is a second line'),
             ),
           ),
           Card(
            child: ListTile(
             leading: FlutterLogo(size: 56.0),
             title: Text('Two-line ListTile'),
             subtitle: Text('Here is a second line'),
             ),
            ),
            Card(
             child: ListTile(
             leading: FlutterLogo(size: 56.0),
             title: Text('Two-line ListTile'),
             subtitle: Text('Here is a second line'),
             ),
           ),
          ],
         )
        ),
       )
      )
...