Skip to content

Instantly share code, notes, and snippets.

@icatalud
Last active September 6, 2019 17:40
Show Gist options
  • Save icatalud/13698156fa4fb5cd5dc2c56d1b59e7a2 to your computer and use it in GitHub Desktop.
Save icatalud/13698156fa4fb5cd5dc2c56d1b59e7a2 to your computer and use it in GitHub Desktop.
Add alignment transition and restart it on click
class ImageDisplay extends StatelessWidget with Floop {
@override
Widget build(BuildContext context) {
return Scaffold(
body: floop['image'] == null
? Center(
child: Text(
'Loading...',
textScaleFactor: 2,
),
)
: Align(
alignment: Alignment(0, transition(2000, delayMillis: 800) - 1),
child: floop['image']),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.refresh),
onPressed: () async {
floop['image'] = null;
await fetchAndUpdateImage();
Transitions.restart(context: context);
}),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment