Sliver & futureBuilder

132 views
Skip to first unread message

Vikram S Sangotra

unread,
Jul 29, 2020, 10:11:19 AM7/29/20
to Flutter Development (flutter-dev)
Hello friends,


I am trying to get dynamic value in SliverAppBar with futureBuilder. But its not working and am not even sure if I am going in a right direction. I tried to find tutorial/help but no luck. Please guide me through....

TIA
Vikram

Suzuki Tomohiro

unread,
Jul 29, 2020, 10:13:35 AM7/29/20
to Flutter Development (flutter-dev)
> it’s not working

I don’t understand what’s the problem. Can you share screenshot/video and your code in GitHub repository?

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/1a8f5a93-1b66-45fb-8551-b789d06e52b9o%40googlegroups.com.

Vikram S Sangotra

unread,
Jul 29, 2020, 10:18:28 AM7/29/20
to Flutter Development (flutter-dev)
As I said I have no idea weather I am doing it write or wrong. 

I tried adding FutureBuilder inside  SliverAppBar - but nothing happened. JSonData is being fetched from database.




On Wednesday, 29 July 2020 19:43:35 UTC+5:30, Suzuki Tomohiro wrote:
> it’s not working

I don’t understand what’s the problem. Can you share screenshot/video and your code in GitHub repository?
On Wed, Jul 29, 2020 at 10:11 Vikram S Sangotra <trivi...@gmail.com> wrote:
Hello friends,


I am trying to get dynamic value in SliverAppBar with futureBuilder. But its not working and am not even sure if I am going in a right direction. I tried to find tutorial/help but no luck. Please guide me through....

TIA
Vikram

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutt...@googlegroups.com.

Souvik Dutta

unread,
Jul 29, 2020, 10:47:31 AM7/29/20
to Vikram S Sangotra, Flutter Development (flutter-dev)
Can you share your code? 

To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/a87a3161-7246-4429-9265-cc5eb2abcc86o%40googlegroups.com.

Vikram S Sangotra

unread,
Jul 29, 2020, 11:19:10 AM7/29/20
to Flutter Development (flutter-dev)






NestedScrollView(
        headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
          return <Widget>[
            SliverAppBar(
              expandedHeight: 300,
              floating: false,
              pinned: true,
              flexibleSpace: FlexibleSpaceBar(
                  centerTitle: true,
                  title: Text(
                    "Child Name",
                    style: TextStyle(fontSize: 30, color: clrWhite),
                  ),
                  background: Image.network(
                    'images/profile.jpg',
                    fit: BoxFit.cover,
                  )),
            )
          ];
        },
        body: Center(
          child: Text("Sample Text"),
        ),
      ),



On Wednesday, 29 July 2020 20:17:31 UTC+5:30, Souvik Dutta wrote:
Can you share your code? 

On Wed, Jul 29, 2020, 7:48 PM Vikram S Sangotra <trivi...@gmail.com> wrote:
As I said I have no idea weather I am doing it write or wrong. 

I tried adding FutureBuilder inside  SliverAppBar - but nothing happened. JSonData is being fetched from database.




On Wednesday, 29 July 2020 19:43:35 UTC+5:30, Suzuki Tomohiro wrote:
> it’s not working

I don’t understand what’s the problem. Can you share screenshot/video and your code in GitHub repository?

On Wed, Jul 29, 2020 at 10:11 Vikram S Sangotra <trivi...@gmail.com> wrote:
Hello friends,


I am trying to get dynamic value in SliverAppBar with futureBuilder. But its not working and am not even sure if I am going in a right direction. I tried to find tutorial/help but no luck. Please guide me through....

TIA
Vikram

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/1a8f5a93-1b66-45fb-8551-b789d06e52b9o%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutt...@googlegroups.com.

Vikram S Sangotra

unread,
Jul 29, 2020, 11:48:19 AM7/29/20
to Flutter Development (flutter-dev)

Vikram S Sangotra

unread,
Jul 30, 2020, 10:54:05 PM7/30/20
to Flutter Development (flutter-dev)
Hello friends,

Any updates on this ? I am held up here for last 5 days....

Suzuki Tomohiro

unread,
Jul 30, 2020, 11:11:02 PM7/30/20
to Vikram S Sangotra, Flutter Development (flutter-dev)
You're not giving what I'm asking for. Can you share screenshot/video and your code in GitHub repository?

On Thu, Jul 30, 2020 at 22:54 Vikram S Sangotra <trivi...@gmail.com> wrote:
Hello friends,

Any updates on this ? I am held up here for last 5 days....

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/10f4b151-5fb1-40d5-8cf9-4cf0aec79026o%40googlegroups.com.

Souvik Dutta

unread,
Aug 1, 2020, 2:15:50 AM8/1/20
to Vikram S Sangotra, Flutter Development (flutter-dev)
Why do you want to embed future builder inside sliver app bar? Can you show an example layout? Does your sliverappbar change any icon or button depending on the data fetched from the server? 

To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/a87a3161-7246-4429-9265-cc5eb2abcc86o%40googlegroups.com.

Vikram S Sangotra

unread,
Aug 1, 2020, 2:56:51 AM8/1/20
to Souvik Dutta, Flutter Development (flutter-dev)
I have Title & Image in SliverAppBar - which is a dynamic, JSON Data fetched from the database. And since it was not working I have removed that code. I will try to add again to post it here.
--
Regards,
Vikram S Sangotra
Trivia Info IT

+91 97235 60260 | trivia.co.in


Vikram S Sangotra

unread,
Aug 2, 2020, 1:51:22 AM8/2/20
to Flutter Development (flutter-dev)
Here are the codes :

 body: FutureBuilder<List<ImageDetails>>(
          future: downloadJSON(data),
          initialData: [],
          builder: (context, AsyncSnapshot snapshot) {
            if (snapshot.hasData) {
              List<cImageDetails> ImageDetails = snapshot.data;


              return ListView.builder(
                  itemCount: ImageDetails.length,
                  itemBuilder: (BuildContext context, int index) {
                    return NestedScrollView(
                      headerSliverBuilder:
                          (BuildContext context, bool innerBoxIsScrolled) {
                        return <Widget>[
                          SliverAppBar(
                            expandedHeight: 300,
                            floating: false,
                            pinned: true,
                            flexibleSpace: FlexibleSpaceBar(
                                centerTitle: true,
                                title: Text(
                                  ImageDetails[index].cName,
                                  style:
                                      TextStyle(fontSize: 30),
                                ),
                                background: Image.network(
                                  'images/images.jpg',
                                  fit: BoxFit.cover,
                                )),
                          )
                        ];
                      },
                      body: Center(
                        child: Text("Sample Text"),
                      ),
                    );
                  });
            } else if (snapshot.hasError) {
              print("Error" + snapshot.error);
              return Expanded(
                child: Center(
                  child: CircularProgressIndicator(),
                ),
              );
            }
          }),

Error I am getting is : 

Another exception was thrown: type 'String' is not a subtype of type 'int' of 'index'
════════ Exception caught by widgets library ═══════════════════════════════════
type 'String' is not a subtype of type 'int' of 'index'
The relevant error-causing widget was
FutureBuilder<List<ImageDetails>>


 

Souvik Dutta

unread,
Aug 2, 2020, 2:06:30 AM8/2/20
to Vikram S Sangotra, Flutter Development (flutter-dev)
Try printing the ImageDetails list. I think you have to replace ImageDetails[index] with ImageDetails.elementAt(index) or ImageDetails.itemAt(index) which ever is correct. 

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
Message has been deleted

Vikram S Sangotra

unread,
Aug 2, 2020, 2:22:54 AM8/2/20
to Flutter Development (flutter-dev)


On Sunday, 2 August 2020 11:36:30 UTC+5:30, Souvik Dutta wrote:
Try printing the ImageDetails list. I think you have to replace ImageDetails[index] with ImageDetails.elementAt(index) or ImageDetails.itemAt(index) which ever is correct. 

On trying your suggestion :
flexibleSpace: FlexibleSpaceBar(
                               centerTitle: true,
                               title: Text(
                                 ImageDetails.elementAt(index).child_name,
                                 style:
                                     TextStyle(fontSize: 30),
                               ),

I am getting same error :

Souvik Dutta

unread,
Aug 2, 2020, 2:23:17 AM8/2/20
to Vikram S Sangotra, Flutter Development (flutter-dev)
Is this is the complete error message. The line number should have been printed. 

On Sun, Aug 2, 2020, 11:50 AM Vikram S Sangotra <trivi...@gmail.com> wrote:
On Sunday, 2 August 2020 11:36:30 UTC+5:30, Souvik Dutta wrote:
Try printing the ImageDetails list. I think you have to replace ImageDetails[index] with ImageDetails.elementAt(index) or ImageDetails.itemAt(index) which ever is correct. 


Souvik  Datta - on trying your suggestion:

flexibleSpace: FlexibleSpaceBar(
                               centerTitle: true,
                               title: Text(
                                 childImageDetails.elementAt(index).child_name,
                                 style:
                                     TextStyle(fontSize: 30, color: clrWhite),
                               ),
Enter code here...


Getting same error :

════════ Exception caught by widgets library ═══════════════════════════════════
type 'String' is not a subtype of type 'int' of 'index'
The relevant error-causing widget was
    FutureBuilder<List<ChildImageDetails>> 


--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.

Vikram S Sangotra

unread,
Aug 2, 2020, 2:26:24 AM8/2/20
to Flutter Development (flutter-dev)


On Sunday, 2 August 2020 11:53:17 UTC+5:30, Souvik Dutta wrote:
Is this is the complete error message. The line number should have been printed. 

This one missed out while copying 
Another exception was thrown: type 'String' is not a subtype of type 'int' of 'index'



Suzuki Tomohiro

unread,
Aug 2, 2020, 8:12:04 AM8/2/20
to Vikram S Sangotra, Flutter Development (flutter-dev)
1. Read stacktrace to identify which line is throwing the error.
2. Read stacktrace to identify why the index is a String, not an int.

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.

Rishabh Shukla

unread,
Aug 2, 2020, 8:31:15 AM8/2/20
to Flutter Development (flutter-dev)
Hey friend I think so there is no data type defined for list as given in your eg.  List<cImageDetails> you should remove the c if You have not defined that datatype yet.

Souvik Dutta

unread,
Aug 3, 2020, 1:05:05 PM8/3/20
to Flutter Development (flutter-dev)
Hey Vikram, what happens when you remove the type int of index in your listview.builder? I hope that will solve the problem and create a new one.

Souvik flutter dev

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages