小编Cyb*_*ter的帖子

任务“:app:mapDebugSourceSetPaths”执行失败。> 评估任务的属性“extraGeneeratedResDir”时出错

我检查过这个答案: https ://stackoverflow.com/a/34834772/13519865

它告诉我们删除这一行

apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)

按照要求删除该行即可完成构建,但我无法使用 Firebase (ofc!),它导致了一个新错误,它告诉我添加该行: https ://stackoverflow.com/a/40085096/13519865

所以,我在这里陷入了循环。此处添加了相关代码示例https://github.com/Cyber ​​avater/A.Reader

android firebase google-play-services android-gradle-plugin google-cloud-platform

169
推荐指数
8
解决办法
13万
查看次数

如何将 Flow 转换为 MutableStateFlow?

我试图在我的类中保留可变的状态流,但是当我对其应用任何方法时,它将转换为不可变的Flow<T>

class MyClass : Listener<String> {

       private val source = Source()

       val flow: Flow<String?>
          get() = _flow

       // region listener
        override fun onUpdate(value: String?) {
            if (value!= null) {
                // emit object changes to the flow
               // not possible, because the builder operators on the flow below convert it to a `Flow` and it doesn't stay as a `MutableSharedFlow` :(
                _flow.tryEmit(value) 
            }
        }
        // end-region

        @OptIn(ExperimentalCoroutinesApi::class)
        private val _flow by lazy {
            MutableStateFlow<String?>(null).onStart {
                emitAll(
                    flow<String?> {
                        val …
Run Code Online (Sandbox Code Playgroud)

kotlin kotlin-coroutines kotlin-flow

11
推荐指数
2
解决办法
1万
查看次数

如何使用语法糖创建 null 安全的默认值构造函数

如何使用语法糖创建一个 null 安全构造函数,如果提供的值为 null,该构造函数将设置默认值?

class Person {
  Person({
    required this.name, //Idealy, adding (?? "friend") instead of "required" should've worked but doesn't.
    required this.age,
  });
  String name;
  int age;
  greet() {
    print("Hello $name");
  }
}
Run Code Online (Sandbox Code Playgroud)

所以,我其实想要这样的东西,

class Person {
  Person({
    this.name ?? "friend",
    this.age ?? 0,
  });
  String name;
  int age;
  greet() {
    print("Hello $name");
  }
}
Run Code Online (Sandbox Code Playgroud)

但是,正如你所知,这在 dart 中是无效的。那么,实际上我应该如何实现这一目标呢?

dart

1
推荐指数
1
解决办法
2085
查看次数