Проблема с флаттером о гибкости - PullRequest
0 голосов
/ 11 сентября 2018

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

сообщение об ошибке:

  • флаттер: во время выполнения executeResize () было выдано следующее утверждение:
  • флаттер: задан вертикальный видовой экраннеограниченная высота.
  • Окна просмотра расширяются в направлении прокрутки, чтобы заполнить свой контейнер. В этом случае вертикальному окну просмотра
  • было предоставлено неограниченное количество вертикального пространства для расширения.Эта ситуация
  • обычно возникает, когда прокручиваемый виджет вложен в другой прокручиваемый виджет.

enter image description here enter image description here Здесь смой код:

    body: Container(
          child: Flexible(
            child: FirebaseAnimatedList(
              query: databaseReference,
              itemBuilder: (_, DataSnapshot snapshot,
                  Animation<double> animation,
                  int index) {
                return new Card(
                  color: Colors.black38,
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      ListTile(
                        leading: IconButton(
                          icon: Icon(Icons.format_list_bulleted),
                          color: Colors.blueAccent,
                          splashColor: Colors.greenAccent,
                          onPressed: () {
                            // Perform some action
                            debugPrint('button ok');
                          },
                        ),
                        title: Text(shopList[index].shopName),
                        subtitle: Text(shopList[index].address),
                      ),

                      Container(
                        child: Flexible(
                          child: Form(
                            key: formShopKey,
                            child: ListView(
                              children: <Widget>[
                                ListTile(
                                  leading: Icon(
                                    Icons.money_off,
                                    color: Colors.white,
                                  ),
                                  title: TextFormField(
                                    maxLength: 100,
                                    initialValue: "",
                                    maxLines: 3,
                                    //onSaved: (val) => booking.seafoodRequest = val,
                                    //validator: (val) => val == "" ? val : null,
                                    decoration: new InputDecoration(

                                    ),
                                  ),
                                ),
                              ],
                            ),
                          ),
                        ),
                      ),

                      ButtonTheme.bar(
                        // make buttons use the appropriate styles for cards
                        child: new ButtonBar(
                          children: <Widget>[
                            new FlatButton(
                              child: const Text('BUY TICKETS'),
                              onPressed: () {
                                /* ... */
                              },
                            ),
                            new FlatButton(
                              child: const Text('LISTEN'),
                              onPressed: () {
                                /* ... */
                              },
                            ),
                          ],
                        ),
                      ),
                    ],
                  ),
                );
              },
            ),
          ),
        );


  [1]: https://i.stack.imgur.com/5vAsv.png
  [2]: https://i.stack.imgur.com/LuZEl.png

1 Ответ

0 голосов
/ 11 сентября 2018

Я должен был заполнить несколько пробелов, но ниже следует построить для вас. Я также поменял FirebaseAnimatedList с обычным AnimatedList, чтобы заставить его строить. Вы можете сравнить и настроить макет.

import 'package:flutter/material.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Demo',
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: new MyHomePage(title: 'Flutter Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: Column(
        mainAxisSize: MainAxisSize.max,
        children: <Widget>[
          Expanded(
            child: AnimatedList(
              initialItemCount: 10,
              itemBuilder: (BuildContext context, int index,
                  Animation<double> animation) {
                return new Card(
                  color: Colors.black38,
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      ListTile(
                        leading: IconButton(
                          icon: Icon(Icons.format_list_bulleted),
                          color: Colors.blueAccent,
                          splashColor: Colors.greenAccent,
                          onPressed: () {
                            // Perform some action
                            debugPrint('button ok');
                          },
                        ),
                        title: Text('Name'),
                        subtitle: Text('Address'),
                      ),
                      Container(
                        constraints: BoxConstraints(
                          minHeight: 100.0,
                          maxHeight: 200.0,
                        ),
                        child: Column(
                          mainAxisSize: MainAxisSize.min,
                          children: <Widget>[
                            Expanded(
                              child: Form(
                                child: ListView(
                                  children: <Widget>[
                                    ListTile(
                                      leading: Icon(
                                        Icons.money_off,
                                        color: Colors.white,
                                      ),
                                      title: TextFormField(
                                        maxLength: 100,
                                        initialValue: "",
                                        maxLines: 3,
                                        //onSaved: (val) => booking.seafoodRequest = val,
                                        //validator: (val) => val == "" ? val : null,
                                        decoration: new InputDecoration(),
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                            ),
                          ],
                        ),
                      ),
                      ButtonTheme.bar(
                        // make buttons use the appropriate styles for cards
                        child: new ButtonBar(
                          children: <Widget>[
                            new FlatButton(
                              child: const Text('BUY TICKETS'),
                              onPressed: () {
                                /* ... */
                              },
                            ),
                            new FlatButton(
                              child: const Text('LISTEN'),
                              onPressed: () {
                                /* ... */
                              },
                            ),
                          ],
                        ),
                      ),
                    ],
                  ),
                );
              },
            ),
          ),
        ],
      ),
    );
  }
}
...