0

I'm Working with SliverAppBar.

Previous I have 2 Page Let's Say (Search,and Detail) ,

In Detail Page,I have problem When i Scroll Down and make Image not visible after that I'm press button Back , My Image lost in Search Page. But if i Scroll down and then little Scroll Up to make Image visible after that i press Back button , My image not lost and still stay there.

It's may be confusing, but you can see the GIF for more detail. SliverAppBar Image

Can you help Me with this ?

Thank's

It's Detail.dart :

import 'package:flutter/material.dart';
import 'package:flutter_news/model/Berita_model.dart';
import 'package:flutter_news/widget/Widget_builder.dart';

class WartawanDetail extends StatefulWidget {
  final int idWartawan;
  final String gambarWartawan;
  final String namaWartawan;
  WartawanDetail({this.idWartawan, this.gambarWartawan, this.namaWartawan});
  @override
  _WartawanDetailState createState() => _WartawanDetailState();
}

class _WartawanDetailState extends State<WartawanDetail> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomScrollView(
        slivers: <Widget>[
          SliverAppBar(
            floating: true,
            pinned: false,
            leading: IconButton(
              icon: Icon(Icons.arrow_left),
              onPressed: () => Navigator.pop(context),
            ),
            expandedHeight: 300.0,
            centerTitle: true,
            flexibleSpace: FlexibleSpaceBar(
              background: Hero(
                tag: widget.idWartawan,
                child: Container(
                  decoration: BoxDecoration(
                    image: DecorationImage(
                        image: AssetImage(widget.gambarWartawan),
                        fit: BoxFit.cover),
                  ),
                  child: Stack(
                    children: <Widget>[
                      Positioned(
                        bottom: 10,
                        left: 10,
                        child: Material(
                          color: Colors.transparent,
                          child: Chip(
                            backgroundColor: Colors.blue,
                            labelStyle: TextStyle(color: Colors.white),
                            label: Text(widget.namaWartawan),
                          ),
                        ),
                      ),
                      Positioned(
                        bottom: 10,
                        right: 10,
                        child: Material(
                          color: Colors.transparent,
                          child: Chip(
                            backgroundColor: Colors.blue,
                            labelStyle: TextStyle(color: Colors.white),
                            label: Text("2 Berita"),
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              ),
            ),
            actions: <Widget>[
              IconButton(
                icon: Icon(Icons.more_horiz),
                onPressed: () => "",
              ),
            ],
          ),
          SliverFixedExtentList(
            itemExtent: MediaQuery.of(context).size.height,
            delegate: SliverChildListDelegate(
              [
                Container(
                  padding: EdgeInsets.all(8),
                  child: ListView.builder(
                      shrinkWrap: true,
                      physics: NeverScrollableScrollPhysics(),
                      itemCount: beritas.length,
                      itemBuilder: newsBuilderHome),
                ),
              ],
            ),
          )
        ],
      ),
    );
  }
}

It's My Search.dart

Widget wartawanBuilderSearch(BuildContext context, int index) {
  ThemeData localTheme = Theme.of(context);
  return Container(
    margin: EdgeInsets.all(8),
    child: Column(
      crossAxisAlignment: CrossAxisAlignment.center,
      children: <Widget>[
        Expanded(
          child: Container(
            child: Hero(
              tag: wartawans[index].idWartawan,
              child: Material(
                color: Colors.transparent,
                child: InkWell(
                  onTap: () => Navigator.push(
                    context,
                    PageTransition(
                      type: PageTransitionType.downToUp,
                      child: WartawanDetail(
                        idWartawan:wartawans[index].idWartawan,
                        gambarWartawan: wartawans[index].gambarWartawan,
                        namaWartawan: wartawans[index].namaWartawan,
                      ),
                    ),
                  ),
                  child: CircleAvatar(
                    backgroundColor: Colors.red,
                    radius: 50,
                    backgroundImage:
                        AssetImage(wartawans[index].gambarWartawan),
                  ),
                ),
              ),
            ),
          ),
        ),
        Container(
          child: Align(
            alignment: Alignment.bottomLeft,
            child: Text(
              wartawans[index].namaWartawan,
              style: localTheme.textTheme.caption
                  .copyWith(fontSize: 14, fontWeight: FontWeight.bold),
              overflow: TextOverflow.ellipsis,
            ),
          ),
        )
      ],
    ),
  );
}
Zeffry Reynando
  • 3,445
  • 12
  • 49
  • 89
  • Can you share code of that list where you clicking on the image? – Aakash Kumar Sep 20 '19 at 10:51
  • @AakashKumar sure, please see my update question. – Zeffry Reynando Sep 20 '19 at 11:27
  • Hi, I tried This with your code and my own code. Strangely when I did this 4 month ago it was working fine but when I tried this now it's not working. It seems to be an issue of latest Flutter release. See this https://github.com/flutter/flutter/issues/40239 – Aakash Kumar Sep 20 '19 at 14:59

0 Answers0