我的MaterialApp今天开始表现得很奇怪。当我单击管理选项卡时,TournamnetScreen被创建了两次。
是什么导致了这一切?我昨天升级了颤振。(稳定通道)
@override
Widget build(BuildContext context) {
debugPrint("Starting Chess Champion");
return MaterialApp(
theme: new ThemeData(
primarySwatch: Colors.blue,
scaffoldBackgroundColor: Colors.grey
),
home: DefaultTabController(
length: 5,
child:
Scaffold(
appBar: AppBar(
title: Text('Chess Champion', style: new TextStyle(fontWeight: FontWeight.normal, fontSize: 30.0)),
bottom: TabBar(
tabs: [
Tab(icon: Icon(Icons.home)),
Tab(icon: Icon(AntDesign.table)),
Tab(icon: Icon(Octicons.versions)),
Tab(icon: Icon(MaterialCommunityIcons.podium)),
Tab(icon: Icon(Octicons.tools)),
],
),
),
body: TabBarView(
children: [
HomeScreen(title: 'Home',),
DataTableScreen(),
ChangelogScreen(),
TeamTournamentScreen(),
AdminScreen(),
],
),
),
),
);}
这里的管理小部件。
class AdminScreen extends StatelessWidget {
final _scaffoldKey = GlobalKey<ScaffoldState>();
@override
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldKey,
appBar: AppBar(title: Text('Admin')),
body: Builder(builder: (BuildContext context) {
return Column(
children: <Widget>[
RaisedButton(
onPressed: _createTour2,
child: new Text('Create a tournament2'),
),
RaisedButton(
onPressed: _readTour,
child: new Text('Read a tournament'),
),
RaisedButton(
onPressed: _deleteTour,
child: new Text('Delete a tournament'),
),
RaisedButton(
onPressed: _setTourLevel,
child: new Text('Set level in all Tournaments'),
),
RaisedButton(
onPressed: _listTours,
child: new Text('List Tournaments'),
),
RaisedButton(
onPressed: _listTour2s,
child: new Text('List Tournament2s '),
),
RaisedButton(
onPressed: _deleteDuplicatedTours,
child: new Text('Delete Duplicated Tournaments'),
),
RaisedButton(
onPressed: _scrapeAllsvenskan,
child: new Text('Scrape Allsvenskan'),
),
RaisedButton(
onPressed: _listClubs,
child: new Text('List Clubs'),
),
RaisedButton(
onPressed: _updateTour,
child: new Text('Update a Tournament'),
),
RaisedButton(
onPressed: _deleteDuplicatClubs,
child: new Text('Remove duplicate Clubs'),
),
RaisedButton(
onPressed: _dbCounts,
child: new Text('Database Counts'),
),
],
);
}),
);
}发布于 2020-06-07 05:56:06
事实证明,我无意中创建了两个MaterialApp。
https://stackoverflow.com/questions/62167010
复制相似问题