痴情

文章 评论 浏览 30

痴情 2025-02-11 20:22:07

那是因为getImagePathfromsharedPreferences不返回字符串?,它返回未来,

您要么在initstate中处理异步任务,要么使用FutureBuilder

请确保设置getimagePathfromsharedPreferences的返回类型

Future<String?> getImagePathFromSharedPreferences() async {
   // ...
}

我将使用FutureBuilder:我将使用FutureBuilder:

FutureBuilder<String?>(
  future: getImagePathFromSharedPreferences(),
  initialData: null,
  builder: (
      BuildContext context,
      AsyncSnapshot<String?> snapshot,
      ) {
    if (snapshot.connectionState != ConnectionState.done) {
      return const CircularProgressIndicator();
    } else if (!snapshot.hasError) {
      return CircleAvatar(
        radius: 45.0,
        backgroundImage: _imageFile != null
          ? Image.file(_imageFile).image
          : snapshot.hasData
            ? FileImage(snapshot.data!)
            : AssetImage(_imageUrl),
      );
    } else {
      return const Text('Error');
    }
  },
),

that's because getImagePathFromSharedPreferences doesn't return String?, it returns a Future

you either handle the async task in the initState or use a FutureBuilder

make sure to set the return type of getImagePathFromSharedPreferences

Future<String?> getImagePathFromSharedPreferences() async {
   // ...
}

I'm gonna use FutureBuilder:

FutureBuilder<String?>(
  future: getImagePathFromSharedPreferences(),
  initialData: null,
  builder: (
      BuildContext context,
      AsyncSnapshot<String?> snapshot,
      ) {
    if (snapshot.connectionState != ConnectionState.done) {
      return const CircularProgressIndicator();
    } else if (!snapshot.hasError) {
      return CircleAvatar(
        radius: 45.0,
        backgroundImage: _imageFile != null
          ? Image.file(_imageFile).image
          : snapshot.hasData
            ? FileImage(snapshot.data!)
            : AssetImage(_imageUrl),
      );
    } else {
      return const Text('Error');
    }
  },
),

从画廊或相机挑选后,如何将图像永久保存在颤抖上?设置挑选的图像时,我会遇到此错误

痴情 2025-02-11 18:05:22

您可以使用纯Matplotlib。作为UP系列的一部分,在UP之后选择行,以确保加入积分。对于传说,添加一个以要跳过的下划线开头的标签:

import matplotlib.pyplot as plt
m = df['c']=='up'
upDF = df.loc[m|m.shift()]
downDF = df.loc[~m]
ax = plt.subplot()
upDF.plot(x='A', y='B', label='r', ax=ax)
downDF.plot(x='A', y='B', label='_skip', ax=ax)
ax.legend()

输出:

“在此处输入图像说明”

You can use pure matplotlib. Select the rows after an up as part of the up Series to ensure joining the points. For the legend, add a label that starts with an underscore to be skipped:

import matplotlib.pyplot as plt
m = df['c']=='up'
upDF = df.loc[m|m.shift()]
downDF = df.loc[~m]
ax = plt.subplot()
upDF.plot(x='A', y='B', label='r', ax=ax)
downDF.plot(x='A', y='B', label='_skip', ax=ax)
ax.legend()

output:

enter image description here

如何组合线图&amp; Seaborn/Matplotlib中的传奇

痴情 2025-02-11 15:27:27

我丢失了所有喜欢的数据(未保存我的数据)

likes属于每篇文章,应该将其保存到您的 db 并致电API以再次检索组件安装:

export default {
  name: 'CardArticle',
  data () {
    return {
      likes: 0   // It's not managed by component state
    }
  },
  methods: {
    sendLike() {
      axios.post("http://localhost:3000/api/articles/" + this.post._id + "/like", {
        userId: this.user.userId
      }, {
        headers: {
          Authorization: "Bearer " + this.user.token
        }
      })
        .then(
          // invalidates, update allPosts props (emit to parent)
        )
        .catch(error => console.log(error))
    }
  }
}

i lost all my data likes (my data is not saved)

likes is belong to each articles and It should have been saved to your db and call API to retrieve it again on component mounting:

export default {
  name: 'CardArticle',
  data () {
    return {
      likes: 0   // It's not managed by component state
    }
  },
  methods: {
    sendLike() {
      axios.post("http://localhost:3000/api/articles/" + this.post._id + "/like", {
        userId: this.user.userId
      }, {
        headers: {
          Authorization: "Bearer " + this.user.token
        }
      })
        .then(
          // invalidates, update allPosts props (emit to parent)
        )
        .catch(error => console.log(error))
    }
  }
}

当我在vuejs中刷新页面时丢失数据

痴情 2025-02-09 15:13:47

尝试在标签之前设置单选按钮

.slider {
        transform: translateX(20%);
        display: inline-block;
        position: relative;
        width: 61%;
        overflow: hidden;
        box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px 0px; 
    }
    
    .images {
        display: flex;
        width: 100%;
    }
    
    .images img {
        width: 100%;
        transition: all 0.15s ease;  
    }
    
    .images input {
        display: none; 
    }
    
    .dots {
        display: flex;
        justify-content: center;
        margin: 5px; 
    }
    
    .dots label {
        height: 15px;
        width: 15px;
        border-radius: 50%;
        border: solid #13447E 3px;
        cursor: pointer;
        transition: all 0.15s ease;
        margin: 5px;
    } 
   
    #img1:checked ~ .m1 {
        margin-left: 0;   
    }
     
    #img2:checked ~ .m2 {
        margin-left: -100%;
    }
    
    #img3:checked ~ .m3 {
        margin-left: -200%;
    }
    [type="radio"] {
    display: none;
}
    input[type="radio"]:checked+label{border-color:red;}
<div class="slider">
        <div class="images">
            <img src="img/img1.jpeg" class="m1" alt="img1">
            <img src="img/img2.jpeg" class="m2" alt="img2">
            <img src="img/img3.jpeg" class="m3" alt="img3">
             
        </div>
        <div class="dots">
        <input type="radio" name="slide" id="img1" checked>
            <label for="img1"></label>
             <input type="radio" name="slide" id="img2">
            <label for="img2"> </label>
             <input type="radio" name="slide" id="img3">
            <label for="img3"></label>
             
        </div>
      </div>  

Try to set radio button before label

.slider {
        transform: translateX(20%);
        display: inline-block;
        position: relative;
        width: 61%;
        overflow: hidden;
        box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px 0px; 
    }
    
    .images {
        display: flex;
        width: 100%;
    }
    
    .images img {
        width: 100%;
        transition: all 0.15s ease;  
    }
    
    .images input {
        display: none; 
    }
    
    .dots {
        display: flex;
        justify-content: center;
        margin: 5px; 
    }
    
    .dots label {
        height: 15px;
        width: 15px;
        border-radius: 50%;
        border: solid #13447E 3px;
        cursor: pointer;
        transition: all 0.15s ease;
        margin: 5px;
    } 
   
    #img1:checked ~ .m1 {
        margin-left: 0;   
    }
     
    #img2:checked ~ .m2 {
        margin-left: -100%;
    }
    
    #img3:checked ~ .m3 {
        margin-left: -200%;
    }
    [type="radio"] {
    display: none;
}
    input[type="radio"]:checked+label{border-color:red;}
<div class="slider">
        <div class="images">
            <img src="img/img1.jpeg" class="m1" alt="img1">
            <img src="img/img2.jpeg" class="m2" alt="img2">
            <img src="img/img3.jpeg" class="m3" alt="img3">
             
        </div>
        <div class="dots">
        <input type="radio" name="slide" id="img1" checked>
            <label for="img1"></label>
             <input type="radio" name="slide" id="img2">
            <label for="img2"> </label>
             <input type="radio" name="slide" id="img3">
            <label for="img3"></label>
             
        </div>
      </div>  

检查时如何更改单选按钮背景颜色

痴情 2025-02-08 22:15:17

更新以下信息:

@Embeddable
public class Item {
   // .....
   @Embedded
   private SubItems subItems;
   //.......
}

@Embeddable
public class SubItems {
   // .....
   @ElementCollection
   private List<String> extraItems;
   //.......
}


@Entity
@Table(name = "orders", schema = "public")
public class Order implements Serializable {
   //.....
   @ElementCollection
   private List<Item> products;
   //.......
}

Update the following information like this :

@Embeddable
public class Item {
   // .....
   @Embedded
   private SubItems subItems;
   //.......
}

@Embeddable
public class SubItems {
   // .....
   @ElementCollection
   private List<String> extraItems;
   //.......
}


@Entity
@Table(name = "orders", schema = "public")
public class Order implements Serializable {
   //.....
   @ElementCollection
   private List<Item> products;
   //.......
}

如何将多个类映射到JPA中的一个表?

痴情 2025-02-08 04:13:21

也许您可以尝试添加一些CSS
@Media屏幕和(最小宽度:1240px){...}

Maybe you could try to add some css like
@media screen and (min-width: 1240px) {...}

我如何根据屏幕尺寸扩展网站或缩小规模

痴情 2025-02-07 20:22:50

您可以使用get_model并在调用该函数时导入其他模型:

from django.apps import apps

Class B:
    @classmethod
    def bar():
        A = apps.get_model('app_name', 'A')
        a = A()
        a.foo()

也可以以相反的方式进行。

You can use get_model and import the other model when the function is called:

from django.apps import apps

Class B:
    @classmethod
    def bar():
        A = apps.get_model('app_name', 'A')
        a = A()
        a.foo()

It's possible to do it the other way around also.

其他模型中的导入模型方法

痴情 2025-02-07 18:19:35

枢轴表是一种很好的方法,尝试:

table = pd.pivot_table(
    df, 
    values=['Amount'],
    index=['Name', 'Card'],
    aggfunc=['count', 'sum'],
)

# Adds subtotals, and sorts:
pd.concat([
    d.append(d.sum().rename((k, 'Total')))
    for k, d in table.groupby(level=0)
]).sort_index(ascending=[False, True])

输出:

                count    sum
               Amount Amount
Name     Card
Joe Doe  Total      3    141
         j544       1     53
         t077       2     88
Jane Doe Total      1     13
         s044       1     13

次数参考: link。

Pivot table is a good approach, try:

table = pd.pivot_table(
    df, 
    values=['Amount'],
    index=['Name', 'Card'],
    aggfunc=['count', 'sum'],
)

# Adds subtotals, and sorts:
pd.concat([
    d.append(d.sum().rename((k, 'Total')))
    for k, d in table.groupby(level=0)
]).sort_index(ascending=[False, True])

Output:

                count    sum
               Amount Amount
Name     Card
Joe Doe  Total      3    141
         j544       1     53
         t077       2     88
Jane Doe Total      1     13
         s044       1     13

Subtotal reference: link.

Pandas Pivot表 - 在多索引表中添加小计

痴情 2025-02-07 08:43:08

您可以通过使用PGDUMP导出表模式并将其导入到本地环境中来做到这一点。您可以遵循本指南 https://supabase.com/docs/guides/guides com /平台/迁移和升级项目

You can do this by using pgdump to export the table schema and importing it back into your local environment. You can follow this guide https://supabase.com/docs/guides/platform/migrating-and-upgrading-projects

我如何将所有数据项目生产推向Supabase中的本地环境

痴情 2025-02-07 07:30:41

使用正确的轴:

df_input.gt(df_input.median(axis=1), axis=0).astype(int)

输出:

            row1  row2
2021-02-24     1     0
2021-02-25     0     1
2021-02-26     0     1

Use gt with the correct axis:

df_input.gt(df_input.median(axis=1), axis=0).astype(int)

output:

            row1  row2
2021-02-24     1     0
2021-02-25     0     1
2021-02-26     0     1

如何基于在行中值(如果&gt;中位数为1,else 0)的值之上/低于/下方的值转换为二进制文件?

痴情 2025-02-07 02:06:34

根据 不使用使用|分隔符用于您要做的事情。我相信您正在寻找此选项:

segment_times times
指定拆分点列表。时代包含以增加顺序的逗号分隔持续时间规格的列表。另请参阅segment_time选项。

因此,您的命令应读取,

ffmpeg -i input.wav -f segment -segment_times 60,150 output%03d.wav

请注意,如果要准确拆分,则不建议使用-c复制

According to the docs, segment demuxer does not use | separator for what you want to do. I believe you are looking for this option:

segment_times times
Specify a list of split points. times contains a list of comma separated duration specifications, in increasing order. See also the segment_time option.

So, your command should read

ffmpeg -i input.wav -f segment -segment_times 60,150 output%03d.wav

Note that -c copy is not recommended if you want accurate split.

如何使用ffmpeg将音频文件分为两个?

痴情 2025-02-06 16:11:20

您可以使用 redirect_to Matcher。根据您的状况,您可以期望

在促销活动不活动时会重定向吗?

expect(response).to redirect_to(plans_path)

You can use the redirect_to matcher. Based on your condition you can expect response to be redirected or not

when promotional campaign is inactive

expect(response).to redirect_to(plans_path)

如何使用RSPEC在控制器方法中测试条件重定向

痴情 2025-02-06 10:33:00

看来您只在scans中更新$ path,但这应该在设置中我认为:

 export PATH=$PATH:/opt/coverity/coverity-base/bin

Looks like you're only updating the $PATH in scans, but this ought to be in setup I think:

 export PATH=$PATH:/opt/coverity/coverity-base/bin

找不到构建命令。 &#x27; go&#x27;

痴情 2025-02-05 07:09:54

您可以在调用渲染时添加条件,在哪里检查ID或插槽的类型,并在绘制插槽后绘制暗色。

这是可以帮助您使其正常工作的条件:

if (complication.boundsType == ComplicationSlotBoundsType.BACKGROUND) {
    ...
} else {
    ...
}

You can add a condition when calling render, where you check the id or the type of the slot, and draw a darkening color just after drawing the slot.

This is the kind of condition that can help you make it work:

if (complication.boundsType == ComplicationSlotBoundsType.BACKGROUND) {
    ...
} else {
    ...
}

使用WatchFaceKotlin佩戴OS样品分别绘制并发症

痴情 2025-02-05 00:56:05

是否可以将布尔密钥转换为int在内部输入
分区逻辑

,因此您需要将列表中的值与01(例如)相关联,以将数据存储在数据库中 )基于给定谓词

为此,代替partitioningby()您可以使用collector groupingby()

Map<Integer, List<String>> partitioned = numbers.stream()
    .collect(Collectors.groupingBy(num -> predicate.test(num) ? 1 : 0));

Is it possible to convert the boolean keys to the int type inside the
partitioning logic

So you need to associate the values in a list with 0 and 1 (for instance, in order to store the data into the database) based on the given predicate.

For that, instead of partitioningBy() you can use collector groupingBy() in conjunction with the predicate.

Map<Integer, List<String>> partitioned = numbers.stream()
    .collect(Collectors.groupingBy(num -> predicate.test(num) ? 1 : 0));

Java 8流 - 如何使用整数键获得相当于分区的()?

更多

推荐作者

佚名

文章 0 评论 0

今天

文章 0 评论 0

゛时过境迁

文章 0 评论 0

达拉崩吧

文章 0 评论 0

呆萌少年

文章 0 评论 0

孤者何惧

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文