小编Sam*_*RAK的帖子

如何通过foreach函数在Dart Map中避免使用等待键

因此,我有一个映射,该映射与使用其中的项目进行的一些异步处理有关。我使用了forEach循环构造,并且在回调内部设计为异步的,因为我在迭代体内调用了await

myMap.forEach((a, b) { await myAsyncFunc(); } );
callFunc();
Run Code Online (Sandbox Code Playgroud)

在所有项目都经过迭代之后,我需要调用callFunc()。但是forEach立即退出。救命!

foreach dictionary asynchronous async-await dart

2
推荐指数
3
解决办法
2311
查看次数

如何在flutter中设计像whatsapp这样的文本字段

我需要文本字段应该垂直扩展到 5 按下回车键

第 5 次输入后,其他行应包含在滚动条内

如何使用颤振实现我需要的文本字段

现在我在文本字段中设置了 maxlines: null

uitextfield flutter-layout

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

使用一种方法打印素数

我正在尝试创建一个void方法,将素数打印到给定的int参数.这就是我所拥有的,它不起作用.

public class listPrimes {
    public static void main(String[] args) {
        printPrimes(1000);

    }

static void printPrimes(int max) {
    int counter = 0;
    for (int i = 2; i <= max; i++) {
        for (int n = 2; n < i; n++) {
            if (i % n == 0) {
                counter++;
            }
        }
        if (counter == 0) {
            System.out.println(i);
            counter = 0;
        }
    }
}
}
Run Code Online (Sandbox Code Playgroud)

我能够使用下面的两种方法创建所需的效果,但我想用一个方法来做.我的代码上面有什么问题?

public class listPrimes {
    public static void main(String[] args) {
        printPrimes(1000);
    }

private static …
Run Code Online (Sandbox Code Playgroud)

java

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

简单的插入排序

我写了一个简单的插入排序程序,但输出不正确.

class InsertionSort{
    public static void main(String h[]){
    int[] a = {5,4,3,2,1};
    int i,j,temp;
        for(i=1;i<a.length;i++){
            j = i-1; 
            while(i>0 && a[j] > a[i]){
                temp = a[i];
                a[i] = a[j];
                a[j] = temp;
            }
        }
        for(int x=0; x<a.length;x++){
            System.out.println(a[x]);   
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

java sorting insertion-sort

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

flutter:饼图周围有一个奇怪的边距。我怎样才能删除它?

我正在尝试在我的 flutter 应用程序中使用 flutter_charts 依赖项中的饼图小部件,但它周围有一个边距,占用了容器小部件内的空间,请问如何删除饼图周围的边距或填充。如何从 PieChart() 小部件中删除边距或填充

dart flutter

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

'_Type'不是'Widget'类型的子类型

我在NoContentPage中将红色屏幕“ _Type”不是“ Widget”类型的子类型异常记录下来,写下了完整的组件代码并将其放置在StatefulWidget中。这段代码有什么问题。我认为这是一个非常普遍的例外。

class NoContentPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return (new Container(
      width: 320.0,
      child: new Column(
        children: <Widget>[
          Center(
              child: Text(AppLocalizations.of(context).messageNoContent,
                  style: TextStyle(
                    color: Colors.black,
                    fontSize: 20.0,
                    fontWeight: FontWeight.w300,
                    letterSpacing: 0.3,
                  )))
        ],
      ),
    ));
  }
}
Run Code Online (Sandbox Code Playgroud)

body: Container(
            child: videos == null
                ? Center(child: CircularProgressIndicator())
                : videos.length == 0
                    ? NoContentPage
                    : ListView.builder(
                        itemCount: videos.length,
                        itemBuilder: (context, index) {
                          return GestureDetector(
                              onTap: () {
                                playYoutubeVideo(videos[index][Video.videoUrl]);
                              },
                              child: Column(children: [
                                new YoutubeCard(
                                  video: videos[index], …
Run Code Online (Sandbox Code Playgroud)

widget flutter

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

我在颤振中收到“SocketException:OS 错误:连接被拒绝”,但在登录时没有出现在浏览器中

我有一个运行 Auth 的 PHP laravel 后端。如何从flutter登录?

我使用 Laravel Blade 视图对它进行了注册和登录测试,然后使用一个简单的 HTML 表单进行了测试,并且它工作正常。我现在正在尝试从我的 flutter 应用程序登录,但总是遇到相同的异常:

“SocketException:操作系统错误:连接被拒绝,错误号 = 111,地址 = 127.0.0.1,端口 = 41978”

除了每次尝试时端口都会增加。

我首先从桌面上的文件进行了这个简单的调用并成功登录:

    <form method="POST" action="http://127.0.0.1:8000/login">
        <input id="email" name="email" type="email" />
        <input id="password" name="password" type="password" />
        <button type="submit">login</button>
    </form>
Run Code Online (Sandbox Code Playgroud)

这是我的颤振 HTTP 请求代码:

    http.Response webMessage;
    webMessage = await http.post('http://127.0.0.1:8000/login',
        body: {
            'email': myUser,
            'password': myPass,
        },
        headers: {
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
        'Content-Type': 'application/x-www-form-urlencoded'
        },
        encoding: Encoding.getByName('utf-8'),
    ).timeout(_timeout);
Run Code Online (Sandbox Code Playgroud)

我还尝试了 Accept 和 Content-Type: 'application/json'。发送一个字符串,一个地图。

我也在 VerifyCsrfToken 中间件中设置了这个:

    protected $except = [
        'login',
    ];
Run Code Online (Sandbox Code Playgroud)

我希望该请求能够让用户成功登录,并使用会话和令牌 …

api http laravel flutter

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

如何在 Flutter 中创建这样的圆形动画?

我想实现的个人资料照片像Instagram的故事有点像圆动画
我怎样才能做到这一点?

animation flutter

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