假设我在一个spark.sql("drop table if exists example ").show()
case class Person(first: String, last: String, age: Integer)
val df = List(
Person("joe", "x", 9),
Person("fred", "z", 9)).toDF()
df.write.option("mode","overwrite").saveAsTable("example")
val recover1 = spark.read.table("example")
recover1.show()
val df3 = List(
Person("mouse", "x", 9),
Person("golf", "z", 9)).toDF()
df3.write.
option("mode","overwrite").saveAsTable("example")
val recover4 = spark.read.table("example")
recover4.show()
指定的高度内有一个Text
。我想制作一个Container
小部件来满足这两个条件,但不知道如何:
Text
内全部显示,那么我仍然希望Container
小部件尽可能地扩展,并用省略号代替最后显示的字符。答案 0 :(得分:2)
这是一种解决方法:
final loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
double containerHeight = 20.0;
Widget build(BuildContext context) {
print("building first");
return Scaffold(
appBar: AppBar(
title: Text('First Route'),
),
body: Center(
child: Container(
color: Colors.yellow,
height: containerHeight,
width: 100,
child: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
TextStyle currentTextStyle = Theme.of(context).textTheme.body1;
int maxLines = ((constraints.maxHeight / currentTextStyle.fontSize) * 0.8).floor();
maxLines = maxLines > 0 ? maxLines : 1;
return new Text(
loremIpsum,
overflow: TextOverflow.ellipsis,
maxLines: maxLines,
style: currentTextStyle,
);
}),
),
),
);
}
这是他们框架中的open凭单,从那里我得到了大部分答案。
结果: