小编Bam*_*oUA的帖子

flutter AndroidManifest.xml 中的 ${applicationName} 是什么意思?

AndroidManifext.xml这个代码:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.skeleton">
   <application
        android:label="skeleton"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">

Run Code Online (Sandbox Code Playgroud)

插值的实际值applicationName是多少?

android manifest flutter

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

如何从“ImmutableBuffer”获取“Uint8List”?

load新的 Flutter 3.3 弃用了class 的方法ImageProvider,现在我的一些代码变得无法工作,因为有一个type 的load参数,但有一个.bytesUit8ListloadBufferbufferImmutableBuffer

我曾经使用包Uint8List解码图像image

final bytes = img.decodeImage(bytes); // bytes is instance of Uit8List
Run Code Online (Sandbox Code Playgroud)

完整的代码可以从文章《Remove a color from an image in Flutter》中阅读,从第 4. 节开始解码

在此输入图像描述

现在我需要转换ImmutableBufferUint8List. 有人知道该怎么做吗?

type-conversion dart flutter

8
推荐指数
0
解决办法
1112
查看次数

从 Stream 获取当前值

有一个 StreamBuilder(使用 RxDart)显示一些日期。单击 InkWell 小部件后,我需要根据旧日期计算新日期。下面的代码只是简单地解释了算法,但是当我运行它时,没有任何反应并且执行在带下划线的行之后停止,即我从未看到lastCalcDate的值。

图形用户界面:

child: StreamBuilder(
  stream: bloc.getDate,
  builder: (context,snapshot) {
    return InkWell(
      onTap: () => tapHandler
    );
}),

void tapHandler() async {
  var lastCalcDate = await bloc.getDate.single;
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  print(lastCalcDate);
  var newCalcDate = lastCalcDate.add(Duration(days:1));
  bloc.setDate(newCalcDate)
}
Run Code Online (Sandbox Code Playgroud)

集团:

class Bloc {
  // BehaviourSubject is usedto be sure that last sent date will be accessible in `tapHandler`.
  final _dateSubject = BehaviourSubject<DateTime>(); 
  Observable<DateTime> get getDate => _dateSubject.stream;
  Function(DateTime) get setDate => _dateSubject.add;
}
Run Code Online (Sandbox Code Playgroud)

为了实现我需要的东西,我创建了一些解决方法,但我不喜欢它,因为我认为我可以使用 observables 做同样的事情。

BLoC(解决方法):

class Bloc …
Run Code Online (Sandbox Code Playgroud)

dart flutter rxdart

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

RawKeyboardListener 未在 Flutter Web 中触发任何事件

这是一些小部件内的简单代码。的RawKeyboardListener没有onKey被触发!那么问题是为什么呢?这是一个错误吗?

Container(
  child: StreamProvider<Item>.value(
    value: stream
    child: Consumer<Item>(
      builder: (_, item, __) {
        return RawKeyboardListener(
          focusNode: focusNode,
          onKey: (event) {
            print(event); // NOT PRINTED!!
          }
          child: TextField(
            controller: controller,
            ...
          ),
        );
      }
    ),
  ),
),
Run Code Online (Sandbox Code Playgroud)

PS Flutter是1.17.0-3.2pre,Dart是2.8.0-dev.20.10

keyboard widget listener flutter

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

如何在 VS Code 中将命令行参数传递给 Web 调试会话

在 flutter/dart 中编程时,我需要将参数传递给 VS Code 中的调试会话。launch.json我按照文档中的描述添加了以下数据。

{
  "configurations": {
    ..
    // Any custom environment variables to set when running the app with this
    // launch config.
    "env": {
      "DEBUG_MODE": true
    }

    // Arguments to be passed to the Dart or Flutter app.
    "args": [
        "--dart-define", 
        "DEBUG_VALUE=true",
    ],  
}

Run Code Online (Sandbox Code Playgroud)

并尝试读取该值:

void main(List<String> args) {
  final debugMode = String.fromEnvironment('DEBUG_MODE');
  final debugValue = String.fromEnvironment('DEBUG_VALUE');
  ...
}
Run Code Online (Sandbox Code Playgroud)

但变量是空的,args列表也是空的。所以请告诉我我做错了什么?

dart visual-studio-code flutter

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

如果两个不同的对象具有相同的哈希码,是否可能?这是否意味着它们是相同的?

我有课

class Controller with EquatableMixin {
  final int id;
  //... other props

  Controller.from(Controller controller) :   
    id = controller.id,
    //... other props assignments

  List<Object> props => [
    id,
    //... other props
  ];
}

final ctrl1 = Controller(...); // Create ctrl1
final ctrl2 = Controller.from(ctrl1); // Create ctrl2 (actually clonning)
assert(ctrl1.hasCode != ctrl2.hasCode); // triggered!
Run Code Online (Sandbox Code Playgroud)

我期望 和ctrl1ctrl2具有不同hashCodes 的不同对象,但它们具有相同的hashCode。为什么?我如何确保这ctrl12不是指向 的指针ctrl2

object hashcode cloning flutter

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