【发布时间】:2020-07-21 18:07:35
【问题描述】:
我不明白构造函数部分和静态函数部分。 极好的? 依赖InheritedWidgetOfExactType?
import 'comments_bloc.dart';
export 'comments_bloc.dart';
class CommentsProvider extends InheritedWidget {
final CommentsBloc commentsBloc;
CommentsProvider({Key key, Widget child})
: commentsBloc = CommentsBloc(), // what this line is doing.
super(key: key, child: child);
bool updateShouldNotify(_) => true;
//below code?
static CommentsBloc of(BuildContext context) {
return context
.dependOnInheritedWidgetOfExactType<CommentsProvider>()
.commentsBloc;
}
}
【问题讨论】:
标签: flutter syntax bloc inherited-widget