出现错误:无效参数超出最大调用堆栈大小。如果您需要任何其他详细信息,请告诉我。在我将提供程序包添加到我的 pubsec.yaml 后,会出现此问题。并做了一些改变
import functools
import operator
filter = functools.reduce(operator.or_, (dt.f.itemid == id for id in ids))
sfr[filter, :]
模型类是:
import 'package:flutter/material.dart';
import 'package:luxurifyme/Models/car_attributes.dart';
import 'package:luxurifyme/Widgets/image_container.dart';
import 'package:luxurifyme/laptop_screen.dart';
import 'package:luxurifyme/mobile_screen.dart';
import 'package:provider/provider.dart';
void main() {
runApp(
ChangeNotifierProvider(
create: (context) => CarAttributes(),
child: LuxurifyMe(),
),
);
}
class LuxurifyMe extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Home(),
);
}
}
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
iconTheme: IconThemeData(color: Colors.grey),
elevation: 10.0,
centerTitle: false,
leadingWidth: 0,
backgroundColor: Colors.white,
title: MediaQuery.of(context).size.width > 500
? Container(
width: MediaQuery.of(context).size.width * 0.2,
child: Image.asset('images/luxury.png', fit: BoxFit.fitHeight),
)
: Container(
width: MediaQuery.of(context).size.width * 0.5,
child: Image.asset('images/luxury.png', fit: BoxFit.cover),
),
),
endDrawer: Drawer(
elevation: 10.0,
),
body: MediaQuery.of(context).size.width > 700
? LaptopScreen()
: MobileScreen(),
);
}
}
最终屏幕页面是,附加错误:
import 'package:flutter/material.dart';
class CarAttributes extends ChangeNotifier {
String img;
String brandName;
String model;
String modelYear;
String fueltype;
String driven;
CarAttributes({
this.img,
this.brandName,
this.model,
this.modelYear,
this.fueltype,
this.driven,
});
List<CarAttributes> cars = [
CarAttributes(
img: "images/l1.jpeg",
brandName: "BMW",
model: "Xl6",
modelYear: "2018",
fueltype: "Diesel",
driven: "1182 Km",
),
CarAttributes(
img: "images/l2.jpeg",
brandName: "Hyundai",
model: "Creta",
modelYear: "2018",
fueltype: "Petrol",
driven: "1194 Km",
),
CarAttributes(
img: "images/l3.jpeg",
brandName: "Mercedez",
model: "Gl6",
modelYear: "2016",
fueltype: "Diesel",
driven: "4296 Km",
),
CarAttributes(
img: "images/l4.jpeg",
brandName: "Mercedez",
model: "Gl6",
modelYear: "2017",
fueltype: "Diesel",
driven: "99212 Km",
),
];
notifyListeners();
}
答案 0 :(得分:0)
是的,我可以通过将值初始化与模型类分开来纠正这个问题。