data dari firebase tidak tampil

Beranda › Forums › Belajar Flutter Mobile Apps Tingkat Mahir › data dari firebase tidak tampil

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #49903
    [email protected]
    Participant

      saya mencoba menampilkan data sesuai dengan cetegory, tapi tidak bisa tampil dan pesan di logcatnya ini
      using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ‘”.indexOn”: “category”‘ at places to your security and Firebase Database rules for better performance

      #49904
      Anonymous

        Hi,
        itu sebuah warning ya biar performancenya lebih baik aja.
        sebelumnya kamu lagi menggunakan realtime database atau firestore databse ya?
        trus untuk masalah datanya tidak muncul, bisa dikirimin codenya ya biar jelas masalahnya ada dimana.

        #50006
        [email protected]
        Participant

          saya 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

          #50252
          Anonymous

            Hi,
            error : No Network Security Config specified, using platform default
            kamu bisa coba dengan menambahkan android:usesCleartextTraffic="true" didalam file AndroidManifest.xml dibagian applicationnya.
            contoh:
            ` <application
            android:label=”notes”
            android:icon=”@mipmap/ic_launcher”
            android:usesCleartextTraffic=”true”>`

            selain itu aku lihat kamu querynya dengan kondisi .equalTo(“-LxFhKjE8VLleirz703c”) ya
            pastiin aja didatabase kamu itu ada isinya dengan apa yang kamu equalTo in ya.

            #50518
            [email protected]
            Participant

              terima kasih
              sudah bisa sekarang

              #50588
              Anonymous

                Sama-sama

              Viewing 6 posts - 1 through 6 (of 6 total)
              • You must be logged in to reply to this topic.
              Shopping cart0
              There are no products in the cart!
              Continue shopping