Hi everybody,
Could you help me solve this problem of showing nothing in listview.builder after a flutter web app released as shown in the next picture, although working well in the android release.
I tried to shorten city list but the problem still present
```
import 'package:admob_flutter/admob_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter_native_admob/flutter_native_admob.dart';
import 'package:flutter_native_admob/native_admob_controller.dart';
import 'package:weather/conistants.dart';
import 'package:weather/service/ad_manager.dart';
import 'package:weather/service/networking.dart';
class SearchScreen extends StatefulWidget {
@override
_SearchScreenState createState() => _SearchScreenState();
}
class _SearchScreenState extends State<SearchScreen> {
final _nativeAdController = NativeAdmobController();
TextEditingController _controller = TextEditingController();
dynamic cityWeatherData;
bool isLoading = false;
String cityName;
```
The list
```
List cities = [
City(city: 'Funafuti', lat: -8.5167, long: 179.2166),
City(city: 'Palikir', lat: 6.9166, long: 158.15),
City(city: 'Capitol Hill', lat: 15.2137, long: 145.7546),
City(city: 'Hagta', lat: 13.4745, long: 144.7504),
City(city: 'Al Quds', lat: 31.7764, long: 35.2269),
City(city: 'Philipsburg', lat: 18.0255, long: -63.045),
City(city: 'Gitega', lat: -3.4271, long: 29.9246),
City(city: 'Pristina', lat: 42.6666, long: 21.1724),
City(city: 'Ngerulmud', lat: 7.5, long: 134.6242),
];
```
The widgets
```
List result = [];
double cityLong;
double cityLat;
@override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: SafeArea(
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/city1.jpg'),
fit: BoxFit.cover,
colorFilter: ColorFilter.mode(
Colors.black.withOpacity(.2), BlendMode.dstATop))),
padding: EdgeInsets.all(15),
child: Column(
children: <Widget>[
Container(
height: 200,
padding: EdgeInsets.all(10),
margin: EdgeInsets.only(bottom: 20.0),
child: NativeAdmob(
// Your ad unit id
adUnitID: _adUnitID,
numberAds: 3,
controller: _nativeAdController,
type: NativeAdmobType.full,
),
),
TextField(
controller: _controller,
decoration: InputDecoration(
labelText: "Enter City...",
prefixIcon: Icon(Icons.search),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10),
),
),
),
onChanged: (value) {
setState(() {
cityName = value;
});
},
),
FlatButton(
onPressed: () async {
isLoading = true;
if (cityWeatherData == null) {
isLoading = true;
} else {
isLoading = false;
Map<dynamic, dynamic> data = {
'cityWeatherData': cityWeatherData,
'cityName': cityName
};
Navigator.pop(context, data);
}
},
child: Text(
'Get Weather',
style: KStatusTextStyle.copyWith(color: Colors.blue),
)),
Container(
height: 470,
child: Expanded(
child: ListView.builder(
itemCount: cities.length,
itemBuilder: (context, index) {
return cityName == null || cityName == ''
? null
: cities[index]
.city
.toLowerCase()
.contains(cityName.toLowerCase())
? Card(
color: Colors.transparent,
child: ListTile(
title: Text(cities[index].city),
onTap: () async {
setState(() {
_controller.text =
cities[index].city;
cityName = _controller.text;
print(cityName);
cityLong = cities[index].long;
cityLat = cities[index].lat;
});
CityNetworkHelper cityNetworkHelper =
CityNetworkHelper(
lat: cityLat, lon: cityLong);
cityWeatherData =
await cityNetworkHelper.getData();
},
),
)
: new Container();
}),
),
),
AdmobBanner(
adUnitId: AdManager.bannerAdUnitId,
adSize: AdmobBannerSize.BANNER)
],
),
),
),
),
);
}
}
```
class City as shown
```
class City {
final String city;
final double long;
final double lat;
City({this.city, this.lat, this.long});
}
```