在Flutter中创建带有长字符串的Text小部件时,将其文本直接放在Column中时会自动换行。但是,当它在Column-Row-Column内时,文本会溢出屏幕的一侧。
如何在Column-Row-Column内换行?造成这种差异的原因是什么?在我看来,上一列的任何子级都具有相同的宽度是合乎逻辑的吗?为什么宽度无界?
我尝试根据其他答案将文本放在Expanded,Flexible,Container和FittedBox中,但这会导致新的错误,我不理解。
例:
MaterialApp(
title: 'Text overflow',
home: Scaffold(
appBar: AppBar(title: Text("MyApp"),),
body: Column(
children: <Widget>[
Row(
children: <Widget>[
// The long text inside this column overflows. Remove the row and column above this comment and the text wraps.
Column(
children: <Widget>[
Text("Short text"),
Text("Very long text. Very long text. Very long text. Very long text. Very long text. Very long text. Very long text. Very long text. Very long text. Very long text. Very long text. Very long …Run Code Online (Sandbox Code Playgroud) 在我的 Flutter 应用程序中,我使用 sqflite 与本地数据库进行通信。我需要查看 JSON 数据。JSON1扩展非常适合此目的。但是,我无法在 Flutter 应用程序中加载该扩展以使其在我的查询中可用,因为该文档适用于 C,而不是 Dart。
也欢迎为 Flutter 提供其他良好支持的本地数据库(文档数据库或支持 JSON 查询的数据库)的建议。我研究了 Couchbase Lite,但插件(Fluttercouch、couchbase-lite-flutter)仍在开发中。
当在 MaterialApp 的应用栏中创建带有图标的简单英雄动画时,英雄动画似乎不使用主题颜色,除非在图标本身中显式指定颜色。有人可以解释为什么在未明确设置图标颜色的情况下图标的颜色在飞行过程中发生变化吗?英雄无法访问主题数据吗?或者它使用其他颜色集?
例子:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: Hero(
tag: "mytag",
child: Material(
color: Colors.transparent,
child: IconButton(
icon: Icon(
Icons.menu,
// uncomment below line and the flying icon is white as expected...
// color: Theme.of(context).primaryIconTheme.color
),
onPressed: () {
Navigator.of(context).push(
PageRouteBuilder(
pageBuilder:
(context, animation, secondaryAnimation) => …Run Code Online (Sandbox Code Playgroud)