我正在构建一个 Flutter 应用程序,并且我已经集成了 Firebase。我试图在 dart2 更新后启动我的 homedart 但由于某种原因我不能只需要一些帮助我附上了下面的代码:
`class SearchPage extends StatefulWidget {
@override
_SearchPageState createState() => _SearchPageState();
}
class _SearchPageState extends State<SearchPage> {
late Screen size;
int _selectedIndex = -1;
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
List<Property> recentList = [];
List<Property> topList = [];
var citiesList = ["Ahmedabad", "Mumbai", "Anand", "Delhi ", "Vadodara", "Chennai","Goa","Kolkata","Indore","Jaipur"];
Image? image1;
String? docRef;
String? isLoggedIn;
late DocumentSnapshot? docsSnap;
void getUserDetails() async{
isLoggedIn= await LocalStorage.sharedInstance.loadAuthStatus(Constants.isLoggedIn);
docRef= await LocalStorage.sharedInstance.loadUserRef(Constants.userRef);
print('docRef :'+ docRef!);
if(docRef != "NULL"){
FirebaseFirestore.instance.doc('/User/'+docRef!).get().then((DocumentSnapshot docs) {
print("Doc found");
setState(() {
docsSnap = docs;
});
});
}else{
setState((){docsSnap=null;});
print("Doc Not Exist");
}
}
@override
void initState() {
// TODO: implement initState
super.initState();
setState((){docsSnap=null;});
getUserDetails();
image1 = Image.asset("assets/drawer_design.png", gaplessPlayback: true);
topList
..add(Property(propertyName:"Omkar Lotus", propertyLocation:"Ahmedabad ", image:"feature_1.jpg", propertyPrice:"26000", propertyDesc: '', id: ''))
..add(Property(propertyName:"Sandesh Heights", propertyLocation:"Baroda ", image:"feature_2.jpg", propertyPrice:"11500", propertyDesc: '', id: ''))
..add(Property(propertyName:"Sangath Heights", propertyLocation:"Pune ", image:"feature_3.jpg", propertyPrice:"19000", propertyDesc: '', id: ''));
recentList
..add(Property(propertyName:"Vishwas CityRise", propertyLocation:"Pune ", image:"hall_1.jpg", propertyPrice:"17500", propertyDesc: '', id: ''))
..add(Property(propertyName:"Gift City", propertyLocation:"Ahmedabad ", image:"hall_2.jpeg", propertyPrice:"13500000", propertyDesc: '', id: ''));
}
@override
void didChangeDependencies() {
super.didChangeDependencies();
precacheImage(image1!.image, context);
}`
我不知道该怎么做,但现在我已经用尽了我的选择