1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] Class 'List<_JsonQueryDocumentSnapshot>' has no instance getter 'lenght'. Receiver:...

Discussão em 'Mobile' iniciado por Stack, Novembro 7, 2024 às 15:02.

  1. Stack

    Stack Membro Participativo

    home page class

    i am new to flutter and tying to made a ticket services application.

    now i am getting this error.

    Exception caught by widgets library

    Class 'List<_JsonQueryDocumentSnapshot>' has no instance getter 'lenght'.

    Receiver: Instance(length:3) of '_GrowableList'

    Tried calling: lenght

    body: CustomScrollView(
    slivers: [
    SliverPersistentHeader(
    pinned: true,
    delegate: TextDelegateHeaderWidget(title : "My Services"),
    ),


    //1. write Query

    // model class

    // ui design Widget


    StreamBuilder
    (
    stream: FirebaseFirestore.instance.
    collection("sellers").doc(sharedPreferences!.
    getString("uid")).collection("brands").snapshots(),
    builder: (context, AsyncSnapshot dataSnapshot)
    {
    if(dataSnapshot.hasData) // if brands has extis.
    {
    // display data
    return SliverStaggeredGrid.countBuilder
    (
    crossAxisCount: 1,
    staggeredTileBuilder: (c)=> const StaggeredTile.fit(1),
    itemBuilder: (context, index)
    {
    Brands brandsModel = Brands.fromJson(
    dataSnapshot.data!.docs[index].data() as Map<String, dynamic>);
    //dataSnapshot.data!.docs[index].data()as Map<String, dynamic>);


    return BrandsUiDesignWidget(
    model: brandsModel,
    context: context,

    );
    },
    itemCount: dataSnapshot.data.docs.lenght,
    );
    }
    else // if not exists.
    {
    return const SliverToBoxAdapter(
    child: Center(
    child: Text(
    "No Services Exists. Please Add Some" ,

    ),
    ),
    );

    }


    }

    )

    ],
    ),


    Brands class


    class _BrandsUiDesignWidgetState extends State<BrandsUiDesignWidget>
    {
    @override
    Widget build(BuildContext context)
    {
    return Card(
    elevation: 10,
    shadowColor: Colors.black,
    child: Padding(
    padding: const EdgeInsets.all(0),
    child: SizedBox(
    height: 270,

    width: MediaQuery.of(context).size.width,
    child: Column(
    children: [
    Image.network(
    widget.model!.thumbnailUrl.toString(),
    height: 220,
    fit: BoxFit.cover,

    ),
    const SizedBox(height: 1,),

    Row(
    mainAxisAlignment: MainAxisAlignment.center,
    children: [
    Text(
    widget.model!.brandTitle.toString(),
    style: const TextStyle(
    color: Colors.deepPurple,
    fontWeight: FontWeight.bold,
    fontSize: 20,
    letterSpacing: 3,
    ),
    ),

    IconButton(
    onPressed: ()
    {

    } ,
    icon: const Icon(
    Icons.delete_sweep,
    color: Colors.pinkAccent,

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



    i am trying to show data in my services. but the code is giving this error i am new to flutter. by changing my code will be a lot helpful than explaining. cuz I am new and don't know a lot of things.

    Continue reading...

Compartilhe esta Página