Flutter imageCache.clear(); error messages

Viewed 31

How do I put imageCache.clear(); into my Flutter app? Five of my six images are loading but one refusing to load. I tried flutter clean and restarting Android Studio. When I do this at the top of the program:

import 'package:flutter/material.dart';
imageCache.clear();

I get this error message:

lib/main.dart:2:19: Error: Expected a function body or '=>'.
Try adding {}.
imageCache.clear();

I tried this

imageCache.clear() {}

but that got a different error message.

enter image description here

1 Answers

You probably put the function in the wrong place.

You can put in the initState

void initState() {
    super.initState();
    imageCache.clear();
}

or wherever a function should be not where a widget should be.

Related