fluttercommunity / flutter_blurhash

Compact representation of a placeholder for an image. Encode a blurry image under 30 caracters for instant display like used by Medium. Maintainer: @Solido
https://pub.dev/packages/flutter_blurhash
MIT License
519 stars 65 forks source link

Very slow when in ListView #1

Closed prasadsunny1 closed 4 years ago

prasadsunny1 commented 4 years ago

The screen is freezing. Here is what I did

import 'package:flutter_blurhash/flutter_blurhash.dart';

class BlurHashPage extends StatelessWidget {
  var hashList = [
    "L5H2EC=PM+yV0g-mq.wG9c010J}I",
    'LEHV6nWB2yk8pyo0adR*.7kCMdnj',
    "BkF=hb}MQ+=S#lNL",
    "B6C=+r000000?d9p",
    "BWJaZl^:^ky__\$jb",
    "BEM3Hy?K0x,.wgI=",
    "BWFpeiEb=RNx;EW?",
  ];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Blur Hash"),
      ),
      body: ListView.builder(
        itemCount: hashList.length,
        itemBuilder: (context, index) {
          return Card(
            clipBehavior: Clip.hardEdge,
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(10.0),
            ),
            child: SizedBox(
              height: 200,
              child: BlurHash(
                hash: hashList[index],
                color: Colors.lightBlue,
              ),
            ),
          );
        },
      ),
    );
  }
}
cbenhagen commented 4 years ago

2 will fix this ;)

@prasadsunny1 you can make your github code snippets much prettier by using code blocks.

prasadsunny1 commented 4 years ago

Thanks for the solution and tip