为了方便后面开发,简单了封装一下 BaseWidget ,将一些重复内容可以放进去。
BaseWidget:
import 'package:flutter/material.dart';
abstract class BaseWidget extends StatefulWidget {
@override
BaseWidgetState createState() => getState();
BaseWidgetState getState();
}
abstract class BaseWidgetState extends State {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {}
@override
void dispose() {
super.dispose();
}
}
使用:
import 'package:flutter/material.dart';
import 'package:flutter_blbl/model/base/stateful_widget_base.dart';
import 'package:flutter_blbl/model/video_model.dart';
class VideoDetailPage extends BaseWidget {
final VideoModel videoModel;
VideoDetailPage({this.videoModel});
@override
_VideoDetailPageState createState() => _VideoDetailPageState();
@override
BaseWidgetState getState() {
return _VideoDetailPageState();
}
}
class _VideoDetailPageState extends BaseWidgetState {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Container(
child: Text('视频详情页-vid:' + widget.videoModel.vid.toString()),
),
);
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)