Created
December 18, 2020 17:17
-
-
Save dossy/c667fe72a1d8af49cb597d6fadf10805 to your computer and use it in GitHub Desktop.
Dart List<NetworkImage> example
This file contains hidden or 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
// for: https://stackoverflow.com/questions/65272176/how-to-solve-type-listdynamic-is-not-a-subtype-of-type-string | |
import 'package:flutter/material.dart'; | |
import 'package:flutter/painting.dart'; | |
final Color darkBlue = Color.fromARGB(255, 18, 32, 47); | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue), | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
body: Center( | |
child: MyWidget() | |
) | |
) | |
); | |
} | |
} | |
class MyWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
List<NetworkImage> _listOfImages = <NetworkImage>[]; | |
_listOfImages.add(NetworkImage('http://placekitten.com/200/300')); | |
return Image( | |
image: _listOfImages[0] | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment