{"id":2318,"date":"2021-07-16T12:43:21","date_gmt":"2021-07-16T12:43:21","guid":{"rendered":"https:\/\/www.bearloga.space\/?page_id=2318"},"modified":"2021-07-16T12:43:21","modified_gmt":"2021-07-16T12:43:21","slug":"flutter-provider-obyasnenie-raboty","status":"publish","type":"page","link":"https:\/\/www.bearloga.space\/uk\/flutter-provider-obyasnenie-raboty\/","title":{"rendered":"Flutter Provider \u2014 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u044b"},"content":{"rendered":"\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/dartflutter.ru\/wp-content\/uploads\/2019\/12\/flutter-provider-min-1200x750.jpg\" alt=\"flutter-provider\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 Flutter Provider \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u043c\u0435\u0441\u044c \u0418\u043d\u044a\u0435\u043a\u0446\u0438\u0438 \u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 (Dependency Injection \u0438\u043b\u0438 DI) \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c, \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432 \u0438 \u0434\u043b\u044f \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u041e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0424\u043b\u0430\u0442\u0442\u0435\u0440-\u0432\u0438\u0434\u0436\u0435\u0442\u044b \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u0432\u043c\u0435\u0441\u0442\u043e \u0414\u0430\u0440\u0442 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a&nbsp;<code>Steam<\/code>. \u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u0438\u0434\u0436\u0435\u0442\u044b \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u044b, \u043d\u043e \u043d\u0430\u0434\u0435\u0436\u043d\u044b \u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u044b.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438:<\/h4>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/dartflutter.ru\/flutter-provider\/#ustanovka-znacheniya-flutter-provider\" target=\"_blank\" rel=\"noopener\">\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f Provider<\/a><\/li><li><a href=\"https:\/\/dartflutter.ru\/flutter-provider\/#chtenie-znacheniya-flutter-provider\" target=\"_blank\" rel=\"noopener\">\u0427\u0442\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u041f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430<\/a><\/li><li><a href=\"https:\/\/dartflutter.ru\/flutter-provider\/#multiprovider\" target=\"_blank\" rel=\"noopener\">Multiprovider<\/a><\/li><li><a href=\"https:\/\/dartflutter.ru\/flutter-provider\/#proxyprovider\" target=\"_blank\" rel=\"noopener\">ProxyProvider<\/a><\/li><li><a href=\"https:\/\/dartflutter.ru\/flutter-provider\/#consumer\" target=\"_blank\" rel=\"noopener\">Consumer<\/a><\/li><li><a href=\"https:\/\/dartflutter.ru\/flutter-provider\/#selector\" target=\"_blank\" rel=\"noopener\">Selector<\/a><\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0432\u0438\u0434\u0436\u0435\u0442\u044b \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c, \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u043e\u043c, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u043e\u0434\u043d\u043e\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u043f\u043e\u0442\u043e\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445<\/li><li>\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c \u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0443\u0435\u043c\u043e\u0441\u0442\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/li><li>\u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0441\u0442\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u0442\u044f\u0436\u0435\u043b\u043e \u0437\u0430\u0431\u044b\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0438\u043b\u0438 \u0432\u0438\u0434\u0436\u0435\u0442\u0430<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043f\u0430\u043a\u0435\u0442\u0430&nbsp;<a href=\"https:\/\/pub.dev\/packages\/provider\" target=\"_blank\" rel=\"noopener\">pub.dev\/packages\/provider<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"ustanovka-znacheniya-flutter-provider\">\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f Flutter Provider&nbsp;<a href=\"https:\/\/dartflutter.ru\/flutter-provider\/#\" target=\"_blank\" rel=\"noopener\">#<\/a><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u0414\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440, \u043e\u0431\u0435\u0440\u043d\u0438\u0442\u0435 \u043e\u0434\u0438\u043d \u0438\u0437 \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432 \u0432 \u0432\u0438\u0434\u0436\u0435\u0442&nbsp;<code>Provider<\/code>&nbsp;(\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440) \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0439\u0442\u0435 \u0435\u043c\u0443 \u0441\u0432\u043e\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e. \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0432\u0441\u0435 \u043f\u043e\u0442\u043e\u043c\u043a\u0438 \u044d\u0442\u043e\u0433\u043e \u0432\u0438\u0434\u0436\u0435\u0442\u0430 \u0441\u043c\u043e\u0433\u0443 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043d\u0435\u0439.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u2014 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c \u0432\u0441\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u0432\u0438\u0434\u0436\u0435\u0442&nbsp;<code>Provider<\/code>&nbsp;\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0435\u043c\u0443 \u043d\u0430\u0448\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Provider&lt;String&gt;.value(\n  value: 'Hello World',\n  child: MaterialApp(\n    home: Home(),\n  )\n)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0434\u043b\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u041f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u043f\u0440\u0438 \u0432\u0441\u0442\u0430\u0432\u043a\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u0430 \u0432 \u0434\u0435\u0440\u0435\u0432\u043e, \u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u042d\u0442\u043e \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c (\u0432\u0438\u0434\u0436\u0435\u0442\u044b&nbsp;<code>StatefulWidget<\/code>).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u043b\u0430\u0441\u0441&nbsp;<code>MyComplexClass<\/code>. \u0418 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0437 \u0434\u0435\u0440\u0435\u0432\u0430 \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432, \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440&nbsp;<code>MyComplexClass<\/code>&nbsp;\u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u0435\u043d.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Provider&lt;MyComplexClass&gt;(\n  create: (context) =&gt; MyComplexClass(),\n  dispose: (context, value) =&gt; value.dispose()\n  child: SomeWidget(),\n)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"chtenie-znacheniya-flutter-provider\">\u0427\u0442\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 Flutter Provider&nbsp;<a href=\"https:\/\/dartflutter.ru\/flutter-provider\/#\" target=\"_blank\" rel=\"noopener\">#<\/a><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0447\u0442\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u2014 \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430&nbsp;<code>Provider.of&lt;T&gt;(BuildContext context)<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043a\u0430\u0442\u044c \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0438\u0434\u0436\u0435\u0442\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u043c&nbsp;<code>BuildContext<\/code>(\u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0432\u0438\u0434\u0436\u0435\u0442), \u0438 \u043e\u043d \u0432\u0435\u0440\u043d\u0435\u0442 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0443\u044e \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0442\u0438\u043f\u0430&nbsp;<code>T<\/code>&nbsp;\u0438\u043b\u0438 \u0432\u0435\u0440\u043d\u0435\u0442&nbsp;<code>Throw<\/code>, \u0435\u0441\u043b\u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0438 \u0441 \u043f\u0435\u0440\u0432\u044b\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c, \u0433\u0434\u0435 \u043c\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u044d\u0442\u043e\u0442 \u0432\u0438\u0434\u0436\u0435\u0442 \u0431\u0443\u0434\u0435\u0442 \u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0430\u0448\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (value) \u0442\u0438\u043f\u0430&nbsp;<code>String<\/code>&nbsp;\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u00abHello World\u00bb:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Home extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return Text(\n      \/\/\/ \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0438\u043f \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\n      Provider.of&lt;String&gt;(context)\n    );\n  }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u0430\u043d\u0442\u0438\u0432\u044b&nbsp;<code>Provider.of<\/code>, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c&nbsp;<code>Consumer<\/code>&nbsp;and&nbsp;<code>Selector<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u041e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0438\u043b\u0438 \u0436\u0435 \u043f\u0440\u0438 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u044f\u0445 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f&nbsp;<code>BuildContext<\/code>&nbsp;\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"multiprovider\">MultiProvider<\/h2>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 MultiProvider, \u043a\u043e\u0433\u0434\u0430 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043d\u0438\u0436\u0435 \u043f\u043e \u0434\u0435\u0440\u0435\u0432\u0443.<\/p><cite>Dart Flutter<\/cite><\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">\u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, Flutter Provider \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043d\u0435\u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u041d\u0435\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442<code>Provider&lt;Foo&gt;(\n  create: (_) =&gt; Foo(),\n  child: Provider&lt;Bar&gt;(\n    create: (_) =&gt; Bar(),\n    child: Provider&lt;Baz&gt;(\n      create: (_) =&gt; Baz(),\n      child: someWidget,\n    )\n  )\n)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c&nbsp;<code>MultiProvider<\/code>, \u0434\u043b\u044f \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u0438:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u0427\u0438\u0442\u0430\u0435\u043c\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442<code>MultiProvider(\n  providers: [\n    Provider&lt;Foo&gt;(create: (_) =&gt; Foo()),\n    Provider&lt;Bar&gt;(create: (_) =&gt; Bar()),\n    Provider&lt;Baz&gt;(create: (_) =&gt; Baz()),\n  ],\n  child: someWidget,\n)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u041f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445 \u0431\u043b\u043e\u043a\u043e\u0432 \u043a\u043e\u0434\u0430 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e, \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434 \u043a\u043e\u0434\u0430.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"proxyprovider\">ProxyProvider<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 3.0.0, \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u0432\u0438\u0434 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430:&nbsp;<code>ProxyProvider<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">ProxyProvider \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432 \u0432 \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0443.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u042d\u0442\u043e\u0442 \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432\u0441\u044f\u043a\u0438\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432 \u0437\u0430\u0432\u0438\u0441\u044f\u0449\u0438\u0439 \u043e\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440&nbsp;<code>ChangeNotifierProvider<\/code>).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u041f\u0440\u043e\u043a\u0441\u0438-\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u0432 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430, \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0449\u0435\u0433\u043e \u043e\u0442 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Widget build(BuildContext context) {\n  return MultiProvider(\n    providers: &#91;\n      ChangeNotifierProvider(create: (_) =&gt; Counter()),\n      ProxyProvider&lt;Counter, Translations&gt;(\n        create: (_, counter, __) =&gt; Translations(counter.value),\n      ),\n    ],\n    child: Foo(),\n  );\n}\n\nclass Translations {\n  const Translations(this._value);\n\n  final int _value;\n\n  String get title =&gt; 'You clicked $_value times';\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"consumer\">Consumer&nbsp;<a href=\"https:\/\/dartflutter.ru\/flutter-provider\/#\" target=\"_blank\" rel=\"noopener\">#<\/a><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u0418\u043d\u043e\u0433\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e\u0431\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u044b \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u043b\u0438\u0441\u044c, \u0430 \u043d\u0435 \u0432\u0441\u0435 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u043c\u0435\u0441\u0442\u043e&nbsp;<code>Provider.of<\/code>&nbsp;\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c&nbsp;<code>Consumer<\/code>&nbsp;\u0438\u043b\u0438&nbsp;<code>Selector<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0418\u0445 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 child, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u0442\u044c \u0434\u0435\u0440\u0435\u0432\u0430 \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Foo(\n  child: Consumer&lt;A&gt;(\n    builder: (_, a, child) {\n      return Bar(a: a, child: child);\n    },\n    child: Baz(),\n  ),\n)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0442\u043e\u043b\u044c\u043a\u043e&nbsp;<code>Bar<\/code>&nbsp;\u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u043e\u0435\u043d, \u043a\u043e\u0433\u0434\u0430 \u043e\u0431\u043d\u043e\u0447\u0438\u0442\u044c\u0441\u044f&nbsp;<code>A<\/code>. \u041d\u043e&nbsp;<code>Foo<\/code>&nbsp;\u0438&nbsp;<code>Baz<\/code>&nbsp;\u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c\u0441\u044f.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"selector\">Selector&nbsp;<a href=\"https:\/\/dartflutter.ru\/flutter-provider\/#\" target=\"_blank\" rel=\"noopener\">#<\/a><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u0427\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044c\u0441\u044f \u0435\u0449\u0435 \u0433\u043b\u0443\u0431\u0436\u0435, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c&nbsp;<code>Selector<\/code>&nbsp;\u0434\u043b\u044f \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u043d\u0435 \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u0434\u0435\u0440\u0435\u0432\u043e \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Selector&lt;List, int&gt;(\n  selector: (_, list) =&gt; list.length,\n  builder: (_, length, __) {\n    return Text('$length');\n  }\n);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u042d\u0442\u043e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u043e\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0434\u043b\u0438\u043d\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f. \u041d\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043f\u0438\u0441\u043a\u0430.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 Flutter Provider \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u043c\u0435\u0441\u044c \u0418\u043d\u044a\u0435\u043a\u0446\u0438\u0438 \u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 (Dependency Injection \u0438\u043b\u0438 DI) \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c, \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[87],"tags":[],"class_list":["post-2318","page","type-page","status-publish","hentry","category-flutter"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/pages\/2318","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/comments?post=2318"}],"version-history":[{"count":0,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/pages\/2318\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/media?parent=2318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/categories?post=2318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/tags?post=2318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}