小编dev*_*996的帖子

RenderFlex 底部溢出了 41 个像素。导致错误的相关小部件是 Column

我需要创建一个搜索框,其中包含搜索结果ListView.Builder,但我遇到了崩溃!我试图通过获取Container高度值来解决它MediaQuery.of(context).size.height,但给我带来了同样的问题!

\n\n
\n

\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90 捕获异常通过渲染库 \xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\ x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\ xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90

\n\n

布局期间抛出以下断言:RenderFlex 底部溢出 41 像素。

\n\n

导致错误的相关小部件为\n Column lib/pages/search.dart:78 溢出的 RenderFlex 的方向为 Axis.vertical。渲染中溢出的 RenderFlex 边缘已用黄色和黑色条纹图案标记。这通常是由于内容对于 RenderFlex 来说太大造成的。

\n\n

考虑应用弹性因子(例如使用 Expanded widget)来强制 RenderFlex 的子项适应可用空间,而不是调整其自然大小。这被视为错误情况,因为它表明存在无法看到的内容。如果内容确实大于可用空间,请考虑在将其放入 Flex 之前使用 ClipRect 小部件对其进行剪辑,或者使用可滚动容器而不是 Flex,例如 ListView。

\n\n

有问题的具体 RenderFlex 是: RenderFlex#1a63c\n relayoutBoundary=up1 OVERFLOWING\n \xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2 \x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95 \x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90 \xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2 \x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95 \x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90 \xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2 \x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90

\n
\n\n

我的代码:

\n\n
body: Column(\n        children: <Widget>[\n          Container(\n              width: MediaQuery.of(context).size.width,\n              margin: EdgeInsets.all(10),\n              padding: EdgeInsets.only(right: 10),\n              decoration: BoxDecoration(\n                  color: Colors.white,\n                  border: new …
Run Code Online (Sandbox Code Playgroud)

dart flutter

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

如何从 JSON API 调用项目并将其添加到 TabBar - Flutter

我想创建(新闻应用程序),我在网站中有一个类别列表,我遵循了此文档,所以我需要将网站的类别添加到我的TabBar,就像这个图片一样:

在此输入图像描述

我怎样才能做到这一点?

我想将方向从左到右更改为从右到左,我该怎么做?

代码:

Category Class:

import 'dart:async';
import 'dart:convert';
import 'package:http/http.dart' as http;

Future<Category> fetchCatgeory() async {
  final response = await http.get("url");

  if (response.statusCode == 200) {
    return Category.fromJson(json.decode(response.body));
  } else {
    throw Exception('Failed to load category');
  }
}

class Category {
  final int id;
  final String title;

  Category({this.id, this.title});

  factory Category.fromJson(Map<String, dynamic> json) {
    return Category (
      id: json['id'],
      title: json['title'],
    );
  }

}
Run Code Online (Sandbox Code Playgroud)

HomePage Class:

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:munaw3_news/extra/json_file.dart';

class HomePage …
Run Code Online (Sandbox Code Playgroud)

json dart flutter

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

ScrollToItem不起作用

为什么scrollToItem在我的CollectionView中不起作用?我要在上工作scrollToItem EnabledID。那么,有什么问题以及如何解决?

码:

var dataArray = NSMutableArray() // dataArray is has a data from Database
var EnabledID = Int()

EnabledID = UserDefaults.standard.integer(forKey: "EnabledID")

if EnabledID == 0 {

    EnabledID = 1
    UserDefaults.standard.set(1, forKey: "EnabledID")

} else {
    if EnabledID < dataArray.count {
        let index = NSIndexPath(item: EnabledID, section: 0)
        self.myCollectionView.scrollToItem(at: index as IndexPath, at: .centeredVertically, animated: true)
    }
}
Run Code Online (Sandbox Code Playgroud)

database scroll ios uicollectionview swift

0
推荐指数
4
解决办法
2402
查看次数

标签 统计

dart ×2

flutter ×2

database ×1

ios ×1

json ×1

scroll ×1

swift ×1

uicollectionview ×1