0
에서 vsync` 재산이에 따르면`TabController 생성자
: 나는 오류이 메시지를 받았습니다error: The argument type '_MyAppState' can't be assigned to the parameter type 'TickerProvider'. (argument_type_not_assignable at [swap] lib/main.dart:24)
_tabController = new TabController(vsync: this, length: choices.length);
: 라인에서
void main() {
runApp(new MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State<MyApp> {
TabController _tabController;
@override
void initState() {
super.initState();
_tabController = new TabController(vsync: this, length: choices.length);
}
@override
void dispose() {
_tabController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
bottomNavigationBar: new Material(
color: Colors.blue,
child: new TabBar(
controller: _tabController,
isScrollable: false,
tabs: choices.map((Choice choice) {
return new Tab(
text: null,
icon: new Icon(choice.icon),
);
}).toList(),
),
),
appBar: new AppBar(
title: const Text('Swap'),
),
body: new TabBarView(
controller: _tabController,
children: choices.map((Choice choice) {
return new Padding(
padding: const EdgeInsets.all(16.0),
child: new ChoiceCard(choice: choice),
);
}).toList(),
),
),
);
}
}
:
sample code 나는 TabController 내 자신의 구현을 생성
내 코드에 어떤 문제가 있습니까?
그것은 그 것이었다. 이제는 탭을 변경하는 동안 콘솔에 이상한 로그인이 발생합니다 : '패키지 : flutter/src/rendering/object.dart': 실패한 어설 션 : 2257 행 12 : '조각이 _InterestingSemanticsFragment': 사실이 아닙니다 .' –
소리가 들리지 않아요. 앱을 다시 시작하거나 플러터를 업그레이드 할 수 있습니까? –
괜찮습니다, 모든 것이 작동합니다, tnx :) –