image_palette 0.0.1 image_palette: ^0.0.1 copied to clipboard
A Flutter package that allows you to generate a color palette from an image and use it in your Flutter app.
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:image_palette/image_palette.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Image palette & Color picker'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: ImagePalette(
image: Image.asset('assets/images/991409.jpg'),
onValueChanged: (Color color) {
// color
log('Color = $color');
},
),
),
);
}
}