颤振:SliverAppBar中的图像丢失

时间:2019-09-20 03:37:39

标签: flutter dart flutter-sliver

我正在使用SliverAppBar

上一页我有2页让我们说(搜索和详细信息),  

详细信息页面中,当我按下按钮返回后,当我向下滚动并使图像不可见时,我的图像丢失了搜索页面。但是,如果我向下滚动,然后小的向上滚动使图像可见,然后按返回按钮,则我的图像不会丢失并且仍然停留在该位置。

这可能令人困惑,但是您可以查看 GIF 了解更多详细信息。 SliverAppBar Image

您能帮我吗?

谢谢

是Detail.dart:

<script>
        document.getElementById("textarea").value = document.getElementById("content").innerHTML;
</script>

<div id="content" contenteditable="true">Text</div>

<form>
    <textarea id="textarea" style="display:none"></textarea>
</form>

这是我的Search.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),
                ),
              ],
            ),
          )
        ],
      ),
    );
  }
}

0 个答案:

没有答案