gpt4 book ai didi

flutter - 如何在此flutter代码中的每个引用映射之后放置Sizedbox或空格?

转载 作者:行者123 更新时间:2023-12-03 04:26:13 25 4
gpt4 key购买 nike

当我运行此代码时,我会得到一个排列较粗的引号。.每个引号后都需要空格..如何做到这一点,而无需手动输入Sizedbox或在每个Text小部件之间进行硬编码?


void main() => runApp(MaterialApp(
title: 'List of Data',
home: QuoteList()
));

class QuoteList extends StatefulWidget {
@override
_QuoteListState createState() => _QuoteListState();
}

class _QuoteListState extends State<QuoteList> {
List<Widget> quotes =[
Text('We are what we believe we are!'),
Text('Those who have courage and faith shall never perish in misery'),
Text('It takes courage to grow up and become who you really are')
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Amazing Quotes'),centerTitle: true,backgroundColor: Colors.yellowAccent,
),
body: Column(mainAxisAlignment: MainAxisAlignment.center,
children:quotes.map((quote)=> (quote)).toList(),
),
);
}
}


最佳答案

试试这个,

import 'package:flutter/material.dart';

void main() => runApp(
MaterialApp(title: 'List of Data', home: QuoteList()),
);

class QuoteList extends StatefulWidget {
@override
_QuoteListState createState() => _QuoteListState();
}

class _QuoteListState extends State<QuoteList> {
List<Widget> quotes = [
QuoteText('We are what we believe we are!'),
QuoteText('Those who have courage and faith shall never perish in misery'),
QuoteText('It takes courage to grow up and become who you really are')
];

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Amazing Quotes'),
centerTitle: true,
backgroundColor: Colors.yellowAccent,
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: quotes.map((quote) => (quote)).toList(),
),
),
);
}
}

class QuoteText extends StatelessWidget {
final String quote;

const QuoteText(this.quote, {Key key})
: assert(quote != null),
super(key: key);

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
quote,
style: const TextStyle(
fontSize: 18.0,
fontStyle: FontStyle.italic,
),
),
);
}
}

关于flutter - 如何在此flutter代码中的每个引用映射之后放置Sizedbox或空格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59606925/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com