为类定义提供程序的简单问题。
在浏览下一个屏幕时,我应该使用Provide吗?
Navigator.push(context, MaterialPageRoute(builder: (BuildContext context) => ChangeNotifierProvider(create: (_) => locator<AddPatientBloc>(), child: AddNewPatient())));
那对我有用,但是有点困惑,这是正确的使用方法吗?
或者必须由
使用class AddNewPatient extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider(
create: (_) => locator<PatientDetailsBloc>(), child: SomeOtherWidget());
}
}
请为此清除我。