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
final repo= FetchColorsFromImage(); | |
// i have used networkImage you can use any ImageProvider class for it | |
var image=NetworkImage(<imageurl>); | |
Color backgroundColor =Colors.black; | |
void initState(){ | |
getColors(); |
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:palette_generator/palette_generator.dart'; | |
class FetchColorFromImage{ | |
Future<Color?> getColor(ImageProvider image>{ | |
final PaletteGenerator paletteGenerator = | |
await PaletteGenerator.fromImageProvider( | |
image, | |
); | |
return paletteGenrator.dominantColor!.color; |
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
// 'Dominant', | |
paletteGen.dominantColor?.color | |
// 'Light Vibrant', | |
paletteGen.lightVibrantColor?.color | |
// 'Vibrant', | |
paletteGen.vibrantColor?.color | |
// 'Dark Vibrant', | |
paletteGen.darkVibrantColor?.color | |
// 'Light Muted', | |
paletteGen.lightMutedColor?.color |
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
final PaletteGenerator paletteGenerator = | |
await PaletteGenerator.fromImageProvider( | |
image, | |
); |
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
FaIcon(FontAwesomeIcons.gamepad) |
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:http/http.dart' as http; | |
var client = http.Client(); | |
try { | |
var uriResponse = await client.post(Uri.parse('https://example.com/whatsit/'), | |
var data =await client.get(uriResponse); | |
print(json.decode(data)); | |
} finally { |
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
Text( | |
'This is Google Fonts', | |
style: GoogleFonts.lato( | |
textStyle: Theme.of(context).textTheme.headline4, | |
fontSize: 48, | |
fontWeight: FontWeight.w700, | |
fontStyle: FontStyle.italic, | |
), | |
), |
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
Future<Null> _launchInBrowser(String url) async { | |
if (await canLaunch(url)) { | |
await launch(url, forceSafariVC: false, forceWebView: false); | |
} else { | |
throw 'Could not launch $url'; | |
} | |
} | |
// or |
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:cached_network_image/cached_network_image.dart'; | |
CachedNetworkImage( | |
imageUrl: "http://via.placeholder.com/350x150", | |
placeholder: (context, url) => CircularProgressIndicator(), | |
errorWidget: (context, url, error) => Icon(Icons.error), | |
); |