Во время прокрутки отсутствуют карты вида флаттера. - PullRequest
0 голосов
/ 29 мая 2019

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

 import 'package:flutter/material.dart';
 import 'package:samplea/components/ad_productlist.dart';
 import 'package:samplea/database/dbhub.dart';
 import 'package:samplea/pages/us_productdetail.dart';

 class UserProductList extends StatefulWidget {

 @override
 _UserProductListState createState() => _UserProductListState();
 }

 class _UserProductListState extends State<UserProductList> {

 @override
 Widget build(BuildContext context) {
 return new Scaffold(
  body: new FutureBuilder<List>(
    future: DBHub().getProductsData(),
    builder: (context, snapshot) {
      if (snapshot.hasError) print(snapshot.error);
      return snapshot.hasData
          ? new UserProducListSub(
              list: snapshot.data,
            )
          : new Center(
              child: CircularProgressIndicator(),
            );
    },
  ),
);
}
}

class UserProducListSub extends StatelessWidget {
final List list;
UserProducListSub({this.list});

@override
Widget build(BuildContext context) {
return new GridView.builder(
  itemCount: list == null ? 0 : list.length,
  gridDelegate:
      new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2),
  itemBuilder: (context, i) {
    return Card(
      child: Material(
        shadowColor: Colors.deepOrange,
        child: InkWell(
          onTap: () => Navigator.of(context).push(new MaterialPageRoute(
              builder: (BuildContext context) => new ProductDetails(
                    list: list,
                    index: i,
                  ))),
          child: new GridTile(
            footer: Container(
              child: new Row(
                children: <Widget>[
                  Expanded(
                    child: new Text(list[i]['name']),
                  ),
                  new Text("price: ${list[i]['price']}"),
                ],
              ),
            ),
            child: Container(
              color: Colors.red,
            ),
          ),
        ),
      ),
    );
  },
);
}
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...