Forum Replies Created
-
AuthorPosts
-
terima kasih
sudah bisa sekarangsaya pakai realtime database
import ‘dart:math’;
import ‘package:curved_navigation_bar/curved_navigation_bar.dart’;
import ‘package:firebase_database/firebase_database.dart’;
import ‘package:firebase_database/ui/firebase_animated_list.dart’;
import ‘package:flutter/cupertino.dart’;
import ‘package:flutter/material.dart’;
import ‘package:pekanbarutourism/menu.dart’;
import ‘package:pekanbarutourism/menu/kategori.dart’;
import ‘package:pekanbarutourism/model/model.dart’;class MainPageHotel extends StatefulWidget {
final Places? list;
MainPageHotel({this.list});
@override
_MainPageHotelState createState() => _MainPageHotelState();
}class _MainPageHotelState extends State<MainPageHotel> {
FirebaseDatabase _database = FirebaseDatabase.instance;
String nodeName = “Places”;
List<Places> postsList = [];@override
void initState() {
// TODO: implement initState
super.initState();
Query postRef = FirebaseDatabase.instance
.ref()
.child(“places”)
.orderByChild(“category”)
.equalTo(“-LxFhKjE8VLleirz703c”);
postRef.once().then((snapshot) => (snap) {
var KEYS = snap.value.keys;
var DATA = snap.value;postsList.clear();
for (var satuKey in KEYS) {
Places places1 = new Places(
DATA[satuKey][‘address’],
DATA[satuKey][‘category’],
DATA[satuKey][‘description’],
DATA[satuKey][‘facilities’],
DATA[satuKey][‘imageThumbnail’],
DATA[satuKey][‘imageurl’],
DATA[satuKey][‘info’],
DATA[satuKey][‘latitude’],
DATA[satuKey][‘longitude’],
DATA[satuKey][‘placeName’],
DATA[satuKey][‘telp’],
DATA[satuKey][‘web’]);
postsList.add(places1);
}
setState(() {
print(‘Length : $postsList.length’);
});
});
}int PageIndex = 0;
GlobalKey _bottomNavigationKey = GlobalKey();final MenuUtama _menuUtama = MenuUtama();
final Kategori _kategori = Kategori();
Widget _showPage = new MenuUtama();Widget _pageChooser(int page) {
switch (page) {
case 0:
return _menuUtama;
break;
case 1:
return _kategori;
break;
default:
return new Container(
child: Center(
child: Text(
‘No Page found by page chooser’,
style: TextStyle(fontSize: 30.0),
),
),
);
}
}@override
Widget build(BuildContext context) {
return Scaffold(
// Container(
// child: Center(
// child: TextButton(onPressed: showData, child: Text(‘Show Data’)),
//
// ),
// ),
bottomNavigationBar: CurvedNavigationBar(
key: _bottomNavigationKey,
index: PageIndex,
height: 50.0,
items: <Widget>[
Icon(Icons.home, size: 30),
Icon(Icons.list, size: 30),
],
color: Colors.white,
buttonBackgroundColor: Colors.white,
backgroundColor: Colors.grey.shade300,
animationCurve: Curves.easeInOut,
animationDuration: Duration(milliseconds: 600),
onTap: (int tappedindex) {
setState(() {
_showPage = _pageChooser(tappedindex);
});
},
),
body:_showPage == null
? Container(
child: Column(
children: <Widget>[
Visibility(
visible: postsList.isEmpty,
child: Center(
child: Container(
alignment: Alignment.center,
child: CircularProgressIndicator(),
),
),
),
Visibility(
visible: postsList.isNotEmpty,
child: Flexible(
child: postsList.length == 0
? new Text(“Data Tidak Ada”)
: new GridView.builder(
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2),
itemCount: postsList.length,
itemBuilder: (context, index) {
return new GestureDetector(
onTap: () {
// Navigator.of(context).push(
// new MaterialPageRoute(
// builder: (context) =>
// LihatPageHotel(
// postsList[index])
// ),
// );
},
child: ShowData(
postsList[index].address,
postsList[index].category,
postsList[index].description,
postsList[index].facilities,
postsList[index].imageThumbnail,
postsList[index].imageurl,
postsList[index].info,
postsList[index].latitude,
postsList[index].longitude,
postsList[index].placeName,
postsList[index].telp,
postsList[index].web),
);
},
),
),
),
],
),
)
: _showPage,
);
}Widget ShowData(
String address,
String category,
String description,
String facilities,
String imageThumbnail,
String imageurl,
String info,
String latitude,
String longitude,
String placeName,
String telp,
String web) {
return
Card(
semanticContainer: true,
clipBehavior: Clip.antiAliasWithSaveLayer,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
elevation: 10.0,
margin: EdgeInsets.all(5.0),
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(
imageurl,
),
fit: BoxFit.cover)),
child: Center(
child: Container(
decoration: BoxDecoration(color: Colors.black45),
child: Center(
child: Text(
placeName,
style: TextStyle(color: Colors.white),
textAlign: TextAlign.center,
))),
),
),
);
}
}ini coding saya , saya mau menampilkan places nya per kategori, ketika saya run kan tidak tampil
log nya
D/NetworkSecurityConfig(12241): No Network Security Config specified, using platform default
I/ekanbarutouris(12241): Background concurrent copying GC freed 15075(1086KB) AllocSpace objects, 18(668KB) LOS objects, 49% free, 2MB/4MB, paused 1.925ms total 100.100ms -
AuthorPosts