ilksayfa.dart (iki sayfayı burada çağırıyorum)
Container(
height: 200.0,
width: double.maxFinite,
child: Yazilar(),
),
Container(
height: 500.0,
width: double.maxFinite,
child: GridView.count(
crossAxisCount: 3,
primary: false,
crossAxisSpacing: 0.0,
children: <Widget>[Resimler()],),
),
Aşağıdaki Yazilar.dart
class Yazilar extends StatefulWidget{
@override
_YState createState() => _YState();
}
class _YState extends State<Yazilar> {
Future<List> _bak() async{
final baglan=await http.get('http://www.***********.php');
try{
var bilgi= json.decode(baglan.body);
return bilgi;
}on Exception catch(e){
print(e);
}
}
@override
Widget build(BuildContext context){
return Scaffold(
body: FutureBuilder<List>(
future: _bak(),
builder: (context, AsyncSnapshot snapshot){
if(snapshot.hasError) print(snapshot.hasError);
return snapshot.hasData?new ItemList(
list:snapshot.data,
):new Center(
child: new CircularProgressIndicator(),
);
}
),
);
}
}
class ItemList extends StatelessWidget{
final List list;
ItemList({this.list});
@override
Widget build(BuildContext context) {
return Swiper(
itemCount: list==null?0:list.length,
itemBuilder: (context,i){
return GestureDetector(
onTap: (){},
child: new Container(
alignment: Alignment.bottomCenter,
margin: EdgeInsets.fromLTRB(5.0,5.0,5.0,25.0),
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(list[i]['fotograf']),
fit: BoxFit.cover,
),
),
child: Container(
color: Color(
list[i]['ad'].length>0 ? 0xcc000000 : 0x00000000
),
padding: EdgeInsets.all(5.0),
alignment: Alignment.bottomCenter,
width: double.maxFinite,
height: 25.0,
child: Text(list[i]['konus'],
style: TextStyle(color: Colors.white),
),
),
),
);
},
indicatorLayout: PageIndicatorLayout.COLOR,
autoplay: true,
autoplayDelay: 4000,
autoplayDisableOnInteraction: true,
pagination: new SwiperPagination(
builder: DotSwiperPaginationBuilder(
space: 5.0,
activeColor: Colors.black,
color: Colors.grey,
)
),
);
}
}
Aşağıdaki Resimler.dart
class Resimler extends StatefulWidget{
@override
_rState createState() => _rState();
}
class _rState extends State<Resimler> {
Future<List> _rebak() async{
final baglan1=await http.get('http://www.***********.php');
try{
var bilgi1= json.decode(baglan1.body);
return bilgi1;
}on Exception catch(e){
print(e);
}
}
@override
Widget build(BuildContext context){
return Scaffold(
body: FutureBuilder<List>(
future: _rebak(),
builder: (context, AsyncSnapshot snapshot){
if(snapshot.hasError) print(snapshot.hasError);
return snapshot.hasData?new ItemList1(
list:snapshot.data,
):new Center(
child: new CircularProgressIndicator(),
);
}
),
);
}
}
class ItemList1 extends StatelessWidget{
final List list;
ItemList1({this.list});
@override
Widget build(BuildContext context) {
return Swiper(
itemCount: list==null?0:list.length,
itemBuilder: (context,i){
return GestureDetector(
onTap: (){},
child: new Container(
alignment: Alignment.bottomCenter,
margin: EdgeInsets.fromLTRB(5.0,5.0,5.0,25.0),
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(list[i]['gorsel']),
fit: BoxFit.cover,
),
),
child: Container(
color: Color(
list[i]['ad'].length>0 ? 0xcc000000 : 0x00000000
),
padding: EdgeInsets.all(5.0),
alignment: Alignment.bottomCenter,
width: double.maxFinite,
height: 25.0,
child: Text(list[i]['yerlesim'],
style: TextStyle(color: Colors.white),
),
),
),
);
},
indicatorLayout: PageIndicatorLayout.COLOR,
autoplay: true,
autoplayDelay: 4000,
autoplayDisableOnInteraction: true,
pagination: new SwiperPagination(
builder: DotSwiperPaginationBuilder(
space: 5.0,
activeColor: Colors.black,
color: Colors.grey,
)
),
);
}
}
Yazılar ile Resimler yapı aynı ama farklı sayfalar. İlk sayfada (ilksayfa.dart) tek tek çağırdığımda çalışıyor. Lakin yukardaki gibi ilksayfada (ilksayfa.dart) ikisini de alt alta çağırdığımda ikisi de yüklenmiyor ve biraz zaman sonra program kırılıyor. “Exception has occurred. ClientException” hatası veriyor….