Flutter SingleTickerProviderStateMixin和自定义mixin
我对颤振和飞镖有点生疏,谷歌在这个问题上帮不了我 假设我有这个: 类_MapPageState使用SingleTickerProviderStateMixin扩展BaseState 我想在此基础上添加另一个mixin BasePage,其中包含可重用的appbar、drawer等 我知道这是不可能的,我的IDE抛出了一个错误,告诉我如何集成它们,但我不知道如何集成它们。有解决办法吗?我需要SingleTickerProviderStateMixin,因为我正在使用的AnimationController需要它 以下是定制的mixin代码(如果需要):Flutter SingleTickerProviderStateMixin和自定义mixin,flutter,dart,mixins,Flutter,Dart,Mixins,我对颤振和飞镖有点生疏,谷歌在这个问题上帮不了我 假设我有这个: 类_MapPageState使用SingleTickerProviderStateMixin扩展BaseState 我想在此基础上添加另一个mixin BasePage,其中包含可重用的appbar、drawer等 我知道这是不可能的,我的IDE抛出了一个错误,告诉我如何集成它们,但我不知道如何集成它们。有解决办法吗?我需要SingleTickerProviderStateMixin,因为我正在使用的AnimationContro
abstract class Base extends StatefulWidget {
Base({Key key}) : super(key: key);
}
abstract class BaseState<Page extends Base> extends State<Page> {
String screenName();
}
mixin BasePage<Page extends Base> on BaseState<Page> {
MapFunctions functions = MapFunctions();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Guidey'),
backgroundColor: Colors.deepOrangeAccent,
centerTitle: true,
),
drawer: Theme(
data: Theme.of(context).copyWith(
canvasColor: Colors.black.withOpacity(0.5)
),
child: Drawer(
child: ListView(
padding: EdgeInsets.fromLTRB(40.0, 10.0, 40.0, 10.0),
children: <Widget>[
DrawerHeader(
child: Padding(
padding: EdgeInsets.fromLTRB(0, 35, 0, 0),
child: Text('Navigation', textAlign: TextAlign.center, style: TextStyle(fontSize: 20, color: Colors.white))
)
),
ListTile(
title: Text('Profile', style: TextStyle(color: Colors.white)),
trailing: Icon(Icons.account_circle, color: Colors.white70),
onTap: (){
Navigator.of(context).pop();
},
),
ListTile(
title: Text('Map', style: TextStyle(color: Colors.white)),
trailing: Icon(Icons.drive_eta, color: Colors.white70),
onTap: (){
Navigator.of(context).pop();
},
),
ListTile(
title: Text('My Location', style: TextStyle(color: Colors.white)),
trailing: Icon(Icons.store, color: Colors.white70),
onTap: (){
},
)
],
)
),
),
);
}
Widget body();
}
原来我想的太多了,用一个简单的逗号就可以组合mixin 。。。使用SingleTickProviderMixin、BasePageMixin