【发布时间】:2018-03-22 15:25:42
【问题描述】:
我最近更新了 Flutter 和我的包,现在我遇到了这个我以前没有遇到的错误。我已经重新启动了 IntelliJ,并且正在对我的 FlutterDoctor 进行所有检查。
NoSuchMethodError: Class 'Window' has no instance setter 'onTextScaleFactorChanged='.
Receiver: Instance of 'Window'
Tried calling: onTextScaleFactorChanged=Closure: () => void from Function 'handleTextScaleFactorChanged':.
* 添加了 textAlign 代码 *
class NumberOnesPageState extends State<NumberOnesPage> {List names = new List();
List numbers = new List();
List ids = new List();
List vidImages = new List();
void _handleJson(value) {
Map myMap = value; //store each map
var titles = myMap.values;
for (var items in titles){
names.add(items['vidTitle']);
numbers.add(items['Value']);
ids.add(items['vidId']);
vidImages.add(items['vidImage']);
}
}
final fb = FirebaseDatabase.instance.reference();
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
backgroundColor: Colors.amber,
title: new Text('Number Ones',
style: new TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black
),),
),
body: new Container(
child: new Center(
child: new Column(
children: <Widget>[
new Flexible(
child: new FirebaseAnimatedList(
query: fb.child('NumberOnes').orderByChild('Value'),
padding: new EdgeInsets.all(15.0),
//sort: (a, b) => b.key.compareTo(a.key),
reverse: false,
itemBuilder: (_, DataSnapshot followerSnap,
Animation<double> animation, int Index) {
return new StreamBuilder<Event>(
stream: fb
.child('NumberOnes')
.orderByChild('Value')
.onValue,
builder: (BuildContext context,
AsyncSnapshot<Event> event) {
switch (event.connectionState) {
case ConnectionState.none:
return new Card(
child: new Text('Loading...',
style: new TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.bold,
fontStyle: FontStyle.italic)),
);
case ConnectionState.waiting:
return new Card(
child: new Text('Awaiting Results...',
style: new TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.bold,
fontStyle: FontStyle.italic)),
);
default:
if (event.hasError)
return new Card(
child: new Text('Error: ${event.error}',
style: new TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.bold,
fontStyle: FontStyle.italic)),
);
else
_handleJson(event.data.snapshot.value);
return new InkWell(
splashColor: Colors.blueAccent,
onTap: (){
Navigator.push(context,
new MaterialPageRoute(builder: (_) => new Video.VideoPage()));
Video.id = ids[Index];
Video.title = names[Index];
Video.videoImage = vidImages[Index];
},
child: new Card(
child: new Column(
children: <Widget>[
new Padding(padding: new EdgeInsets.all(5.0)),
new Image.network(vidImages[Index]),
new Padding(padding: new EdgeInsets.all(3.0)),
new Text('${numbers[Index]} MyFavKPopers Have Made This Their #1'),
new Padding(padding: new EdgeInsets.all(3.0)),
new Text(names[Index],
style: new TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.bold,
color: Colors.black),
//textAlign: TextAlign.center,
),
new Padding(padding: new EdgeInsets.all(5.0)),
],
),
),
);
}
});
}))
],
)),
));
}
}
这是我的 textAlign 代码。它在升级之前没有给出任何错误,并且按预期生成了居中的文本。不确定是否是导致错误的代码。
我已经注释掉了我所有的 textAlign 函数。没有任何工作。它有效地将我锁定在我的代码库之外。
【问题讨论】:
-
您能提供一些背景信息吗?这个方法在哪里调用?
-
@rainerwittman 就是这样。我不会在任何地方调用它。不确定它是否是实际的 Flutter 功能。我使用的最接近的文本函数是
textAlign.center -
@CharlesJr 请添加您的代码
-
@aziza 添加了 textAlign.center 代码。
-
我无法使用您添加到问题中的代码重现错误。我会做一点研究;)
标签: intellij-idea text window flutter