android - 如何“A RenderFlex 在底部溢出 61 个像素。” 在Android虚拟键盘的顶部
问题描述
这是用户界面。下面是 main.dart 文件和错误消息 ,我在 Flutter 应用程序中使用了 Text Field,它在虚拟键盘的顶部给出了渲染 flex 错误。请检查以下代码。在底部我添加了错误消息。以前我尝试过其他所有方法来解决这个问题,但我不同意
import 'package:flutter/material.dart';
import './transaction.dart';
import 'package:intl/intl.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Expenses Tracker',
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
final List<Transaction> transactions = [
Transaction(
id: 't1',
title: 'New Shoes',
amount: 87.25,
date: DateTime.now(),
),
Transaction(
id: 't2',
title: 'Weekly Groceries',
amount: 83.25,
date: DateTime.now(),
),
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Expenses Tracker'),
),
body: Column(
children: <Widget>[
Container(
width: double.infinity,
child: Card(
child: Text("Chart!"),
color: Colors.deepOrange,
elevation: 9,
),
),
Card(
elevation: 5,
child: Container(
padding: EdgeInsets.all(10),
child: Column(
children: <Widget>[
TextField(
decoration: InputDecoration(labelText: 'Title'),
),
TextField(
decoration: InputDecoration(labelText: 'Amount'),
),
],
),
),
),
Column(
children: transactions.map((tx) {
return Card(
child: Row(
children: <Widget>[
Container(
margin: EdgeInsets.symmetric(
vertical: 10,
horizontal: 15,
),
decoration: BoxDecoration(
border: Border.all(
color: Colors.purple,
width: 3,
),
),
padding: EdgeInsets.all(10),
child: Text(
'\$ ${tx.amount}',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20,
color: Colors.purple,
),
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
tx.title,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
),
),
Text(
DateFormat.yMMMEd().format(tx.date),
style: TextStyle(color: Colors.grey, fontSize: 14),
),
],
),
],
),
);
}).toList(),
),
],
),
);
}
}
下面是错误。
════════════════════════════════════════════════════════════════════════════════
══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during layout:
A RenderFlex overflowed by 61 pixels on the bottom.
The relevant error-causing widget was:
Column
lib\main.dart:41
The overflowing RenderFlex has an orientation of Axis.vertical.
The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and
black striped pattern. This is usually caused by the contents being too big for the RenderFlex.
Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the
RenderFlex to fit within the available space instead of being sized to their natural size.
This is considered an error condition because it indicates that there is content that cannot be
seen. If the content is legitimately bigger than the available space, consider clipping it with a
ClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex,
like a ListView.
The specific RenderFlex in question is: RenderFlex#0559b relayoutBoundary=up1 OVERFLOWING:
needs compositing
creator: Column ← _BodyBuilder ← MediaQuery ← LayoutId-[<_ScaffoldSlot.body>] ←
CustomMultiChildLayout ← AnimatedBuilder ← DefaultTextStyle ← AnimatedDefaultTextStyle ←
_InkFeatures-[GlobalKey#39d3c ink renderer] ← NotificationListener<LayoutChangedNotification> ←
PhysicalModel ← AnimatedPhysicalModel ← ⋯
parentData: offset=Offset(0.0, 80.0); id=_ScaffoldSlot.body (can use size)
constraints: BoxConstraints(0.0<=w<=360.0, 0.0<=h<=263.0)
size: Size(360.0, 263.0)
direction: vertical
mainAxisAlignment: start
mainAxisSize: max
crossAxisAlignment: center
verticalDirection: down
════════════════════════════════════════════════════════════════════════════════════════════════════
解决方案
推荐阅读
- php - 有没有办法抓取 Google App Engine 的 getImageServingUrl 的错误?
- csv - 从 S3 下载时 CSV 编码损坏
- android - Best practices for controlling flow data when moving to different activities flow and coming back
- html - 为什么引导程序可以使用内联样式?
- javascript - Vue 2.5 动态下拉点击失败
- php - Pass url parameters from a page to use them later on Woocommerce
- sql - Remove the zeros using SQL Server
- javascript - How do I access an object within itself, within another object?
- rust - 我可以使用 strum 将字符串转换为 f64 吗?
- java - Can't get a database to be created