Created
July 6, 2020 21:19
-
-
Save fedotxxl/29dc358df3a182c6c986b212df29e1f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:evtrip/utils/my_future_nullable_builder.dart'; | |
import 'package:flutter/widgets.dart'; | |
class PreloadingImageBuilder extends StatefulWidget { | |
final ImageProvider imageProvider; | |
final AsyncWidgetBuilder<dynamic> builder; | |
PreloadingImageBuilder({this.imageProvider, this.builder}); | |
@override | |
_PreloadingImageBuilderState createState() => _PreloadingImageBuilderState(); | |
} | |
class _PreloadingImageBuilderState extends State<PreloadingImageBuilder> { | |
Future future; | |
@override | |
void didChangeDependencies() { | |
super.didChangeDependencies(); | |
if (this.future == null) { | |
this.future = precacheImage(this.widget.imageProvider, context); | |
} | |
} | |
@override | |
Widget build(BuildContext context) { | |
return MyFutureNullableBuilder( | |
future: this.future, | |
builder: this.widget.builder, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment