颤振调色板未显示确切的主色

时间:2020-07-05 14:50:13

标签: flutter dart colors

我正在尝试从人脸颜色中获取肤色

human face

因此,此处的主要颜色应该是肤色。在线网站已正确显示主色为肤色代码,但是当我运行抖动代码时,在此图像上得到的主色棕色

有人可以帮我吗?

这是我的密码

Future<PaletteGenerator>_updatePaletteGenerator ()async
{
  paletteGenerator = await PaletteGenerator.fromImageProvider(
    Image.asset("assets/images/8.jfif").image,
  );
return paletteGenerator;
}

借助此方法,我将在 palette_generator 软件包的帮助下返回调色板,然后将其传递给将来的构建器。


 FutureBuilder<PaletteGenerator>(
                  future: _updatePaletteGenerator(), // async work
                  builder: (BuildContext context, AsyncSnapshot<PaletteGenerator> snapshot) {
                    switch (snapshot.connectionState) {
                      case ConnectionState.waiting: return Center(child:CircularProgressIndicator());
                      default:
                        if (snapshot.hasError)
                          return new Text('Error: ${snapshot.error}');
                        else {
                         // Color color=new Color(snapshot.data.dominantColor.color);
                          face=snapshot.data.dominantColor.color;
                          return new Text('Color: ${face}');
                             }}})

0 个答案:

没有答案