Skip to content

Instantly share code, notes, and snippets.

@stephaniefash
Created August 16, 2020 07:09
Show Gist options
  • Save stephaniefash/4a9ddbf39aa7defadd350b191677054a to your computer and use it in GitHub Desktop.
Save stephaniefash/4a9ddbf39aa7defadd350b191677054a to your computer and use it in GitHub Desktop.
class _MyHomePageState extends State<MyHomePage> {
final String myImageUrl =
"https://images.unsplash.com/photo-1485841890310-6a055c88698a?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80"; // <- defines the url path of our image
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
body: Container(
color: Colors.red,
child: Center(
child: Image.network(myImageUrl,
semanticLabel: "This is an image of a row of plants", // <- A description of the image for voice applications.
errorBuilder: (BuildContext context, Object exception,
StackTrace stackTrace) {
return Text(
'Sorry, cannot load image', // <- What we show when image fails to load
style: TextStyle(color: Colors.white, fontSize: 30), // <- Styling for default text
);
}),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment