mchome / flutter_advanced_networkimage

flutter advanced network image provider
https://pub.dev/packages/flutter_advanced_networkimage
MIT License
285 stars 180 forks source link

Flash on image loaded #78

Closed erf closed 5 years ago

erf commented 5 years ago

I'm experiencing a 'flash' and distorted text, after images are loaded inside a GridView, with an appbar with a title, using a custom loadingWidget. You need to close and open the app again to see the flash. See this minimal example:

import 'package:flutter/material.dart';
import 'package:flutter_advanced_networkimage/provider.dart';
import 'package:flutter_advanced_networkimage/transition.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'My App',
      home: Scaffold(
        appBar: AppBar(
          title: Text('NOTICE FLASH HERE 1TIME LOADED'),
        ),
        body: GridView.builder(
          itemCount: 50,
          gridDelegate:
              SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
          itemBuilder: (context, index) {
            return TransitionToImage(
              image: AdvancedNetworkImage(
                  'https://sample-videos.com/img/Sample-jpg-image-500kb.jpg'),
              loadingWidget: Container(color: Colors.red),
            );
          },
        ),
      ),
    );
  }
}

Version info:

flutter --version
Flutter 1.2.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 8661d8aecd (2 weeks ago) • 2019-02-14 19:19:53 -0800
Engine • revision 3757390fa4
Tools • Dart 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)

I'm testing on an iPhone 7 device.

erf commented 5 years ago

I tried now to return Image.network inside builder, and it's super buggy.

I made an issue on Flutter here: https://github.com/flutter/flutter/issues/28680

mchome commented 5 years ago

Yeah, the loading widget will disappear immediately and fade in image. For the fullscreen loading widget, it looks like flashing. I can add fade out transition for loading widget.

erf commented 5 years ago

I find it strange that this interferes with the AppBar title text, and from the issue i made on Flutter, it seem there is some kind of other issue. But fade out ( and in? ) transition for loading view would still be cool.

Update: I tested now on a Simulator ( iPhone XR 12.1 ) and the problem is not here. Maybe it's only on real devices ( or just my phone iPhone 7 12.1.4 ).

erf commented 5 years ago

The issue seem to come from adding:

<key>io.flutter.embedded_views_preview</key>
<true/>

to info.plist, so i will close this now and hope that the Flutter team will fix this.