Home > OS >  Flutter: realtime database quarrying using orderbychild() and only int value works string data not q
Flutter: realtime database quarrying using orderbychild() and only int value works string data not q

Time:01-02

starCountRef.orderByChild('Series').startAt('sam').endAt('1') this code only work if i use int values to fetch data String value not fetching data

DatabaseReference starCountRef =
      FirebaseDatabase.instance.ref('/Shop/qw1234/Inventory/');

bool data = false;

Expanded(
  child: FirebaseAnimatedList(
      query: starCountRef
          .orderByChild('Series')
          .startAt('sam')
          .endAt('1'),
      itemBuilder: (context, snapshot, animation, index) {
        return ListTile(
          onTap: (() {
            print(index);
          }),
          title: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Row(
                children: [
                  Text('Price: Rs '),
                  Text(
                      snapshot.child('Price').value.toString()),
                ],
              ),
            ],
          ),
          subtitle: Padding(
            padding: const EdgeInsets.only(top: 10, bottom: 10),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Row(
                  children: [
                    Text(
                      'Model: ',
                      style: TextStyle(
                          fontWeight: FontWeight.bold),
                    ),
                    Text(snapshot
                        .child('Series')
                        .value
                        .toString()),
                  ],
                ),

              ],
            ),
          ),
        );
      }),
)

MY firebase realtime database i am trying to setup a search box to search product and edit or delete them

Can any one help me i am developing a inventory app for a shop? I am trying to make a search box so the owners can see their stock limits and item prices.

CodePudding user response:

I rather think the firebase query works in ASCII order. In ASCII order, numbers appear before letters so starting at 'a letter string' and ending at 'a number string' is likely to cause you problems.

I don't see a '1' in your example of 'Series', you aren't trying to reference the '1' child in the 'Inventory' node are you?

  • Related