{"id":303956,"date":"2020-05-20T15:02:06","date_gmt":"2020-05-20T15:02:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=303956"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=303956","title":{"rendered":"\u041a\u0430\u043a \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u0430\u0448\u0435\u0433\u043e Flutter \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/502882\/\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/76\/nr\/ut\/76nrutrkfl7c49c7ifdu9qgb134.png\"><\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432, \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438 \u0437\u0430\u0431\u043b\u0443\u0436\u0434\u0435\u043d\u0438\u0439, \u043a\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0448\u0435\u0433\u043e Flutter \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0440\u0430\u0437\u0443 \u0443\u0442\u043e\u0447\u043d\u0438\u0442\u044c, \u0447\u0442\u043e Flutter \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043d\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043a\u043e\u0434\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0438 \u0431\u044b\u0441\u0442\u0440\u043e. \u041d\u0438\u0436\u0435 \u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b \u0434\u043b\u044f \u0432\u0430\u0441 \u0440\u044f\u0434 \u0441\u043e\u0432\u0435\u0442\u043e\u0432 \u0438 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043e\u043a, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p><strong>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435:<\/strong><\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"#ne-vynosite-vidzhety-v-metody-klassa\">\u041d\u0435 \u0432\u044b\u043d\u043e\u0441\u0438\u0442\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u044b \u0432 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430<\/a><\/li>\n<li><a href=\"#izbegayte-povtornyh-perestroeniy-vseh-vidzhetov\">\u0418\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0439 \u0432\u0441\u0435\u0445 \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432<\/a><\/li>\n<li><a href=\"#ispolzuyte-const\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 const<\/a><\/li>\n<li><a href=\"#ispolzuyte-itemextent-v-listview-dlya-bolshih-spiskov\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 itemExtent \u0432 ListView \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0441\u043f\u0438\u0441\u043a\u043e\u0432<\/a><\/li>\n<li><a href=\"#izbegayte-nenuzhnyh-perestroeniy-vidzhetov-vnutri-animatedbuilder\">\u0418\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0439 \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432 \u0432\u043d\u0443\u0442\u0440\u0438 AnimatedBuilder<\/a><\/li>\n<li><a href=\"#ne-ispolzuyte-vidzhet-opacity-v-animaciyah\">\u041d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0432\u0438\u0434\u0436\u0435\u0442 Opacity \u0432 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f\u0445<\/a><\/li>\n<li><a href=\"#zaklyuchenie\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<h2 id=\"ne-vynosite-vidzhety-v-metody-klassa\">\u041d\u0435 \u0432\u044b\u043d\u043e\u0441\u0438\u0442\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u044b \u0432 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430<\/h2>\n<p>  <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u0434\u0438\u043d \u0432\u0438\u0434\u0436\u0435\u0442, \u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u043c\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u043d\u0430 \u0432\u0438\u0434\u0436\u0435\u0442\u044b \u043f\u043e\u043c\u0435\u043d\u044c\u0448\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0432 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0432\u0438\u0434\u0436\u0435\u0442, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a, \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0438 &quot;\u043f\u043e\u0434\u0432\u0430\u043b&quot; <em>(footer)<\/em>.<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">class MyHomePage extends StatelessWidget {   Widget _buildHeaderWidget() {     final size = 40.0;     return Padding(       padding: const EdgeInsets.all(8.0),       child: CircleAvatar(         backgroundColor: Colors.grey[700],         child: FlutterLogo(           size: size,         ),         radius: size,       ),     );   }    Widget _buildMainWidget(BuildContext context) {     return Expanded(       child: Container(         color: Colors.grey[700],         child: Center(           child: Text(             'Hello Flutter',             style: Theme.of(context).textTheme.display1,           ),         ),       ),     );   }    Widget _buildFooterWidget() {     return Padding(       padding: const EdgeInsets.all(8.0),       child: Text('This is the footer '),     );   }    @override   Widget build(BuildContext context) {     return Scaffold(       body: Padding(         padding: const EdgeInsets.all(15.0),         child: Column(           mainAxisSize: MainAxisSize.min,           children: [             _buildHeaderWidget(),             _buildMainWidget(context),             _buildFooterWidget(),           ],         ),       ),     );   } }<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/e5\/fo\/gl\/e5fogldinutl4jybj3cpd5m5wju.gif\"><\/p>\n<p>  <\/p>\n<p>\u0422\u043e, \u0447\u0442\u043e \u043c\u044b \u0443\u0432\u0438\u0434\u0435\u043b\u0438 \u0432\u044b\u0448\u0435, \u2013 \u044d\u0442\u043e \u0430\u043d\u0442\u0438\u043f\u0430\u0442\u0442\u0435\u0440\u043d. \u041f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a? \u0412\u0441\u0451 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u043d\u043e\u0441\u0438\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c <code>MyHomePage<\/code> \u0432\u0438\u0434\u0436\u0435\u0442, \u0442\u043e \u0432\u0438\u0434\u0436\u0435\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443 \u043d\u0430\u0441 \u0432\u044b\u043d\u0435\u0441\u0435\u043d\u044b \u043c\u0435\u0442\u043e\u0434\u0430\u0445, \u0442\u0430\u043a\u0436\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432 \u044d\u0442\u043e\u043c \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e \u043b\u0438\u0448\u043d\u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0432 <code>StatelessWidget<\/code> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">class MyHomePage extends StatelessWidget {   @override   Widget build(BuildContext context) {     return Scaffold(       body: Padding(         padding: const EdgeInsets.all(15.0),         child: Column(           mainAxisSize: MainAxisSize.min,           children: [             HeaderWidget(),             MainWidget(),             FooterWidget(),           ],         ),       ),     );   } }  class HeaderWidget extends StatelessWidget {   @override   Widget build(BuildContext context) {     final size = 40.0;     return Padding(       padding: const EdgeInsets.all(8.0),       child: CircleAvatar(         backgroundColor: Colors.grey[700],         child: FlutterLogo(           size: size,         ),         radius: size,       ),     );   } }  class MainWidget extends StatelessWidget {   @override   Widget build(BuildContext context) {     return Expanded(       child: Container(         color: Colors.grey[700],         child: Center(           child: Text(             'Hello Flutter',             style: Theme.of(context).textTheme.display1,           ),         ),       ),     );   } }  class FooterWidget extends StatelessWidget {   @override   Widget build(BuildContext context) {     return Padding(       padding: const EdgeInsets.all(8.0),       child: Text('This is the footer '),     );   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0423 <code>Stateful<\/code>\/<code>Stateless<\/code> \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432 \u0435\u0441\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c &quot;\u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f&quot;, \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043a\u043b\u044e\u0447, \u0442\u0438\u043f \u0432\u0438\u0434\u0436\u0435\u0442\u0430 \u0438 \u0435\u0433\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0435 \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0432\u0438\u0434\u0436\u0435\u0442 \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u044d\u0442\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043d\u0430\u043c \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u0432\u0438\u0434\u0436\u0435\u0442\u044b. (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Divide-and-conquer_algorithm\" rel=\"nofollow\">\u0420\u0430\u0437\u0434\u0435\u043b\u044f\u0439 \u0438 \u0432\u043b\u0430\u0441\u0442\u0432\u0443\u0439<\/a>)<\/p>\n<p>  <\/p>\n<p>\u0418 \u0431\u044b\u043b\u043e \u0431\u044b \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <code>const<\/code> \u0432 \u043d\u0430\u0448\u0438 \u0432\u0438\u0434\u0436\u0435\u0442\u044b. \u041f\u043e\u0437\u0436\u0435 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u043e.<\/p>\n<p>  <\/p>\n<h2 id=\"izbegayte-povtornyh-perestroeniy-vseh-vidzhetov\">\u0418\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0439 \u0432\u0441\u0435\u0445 \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432<\/h2>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043d\u043e\u0433\u0438\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u044e\u0442, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Flutter \u0438 \u0432\u043f\u0435\u0440\u0432\u044b\u0435 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c <code>StatefulWidget<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>setState<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u2014 \u044d\u0442\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0435 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u0432 \u0446\u0435\u043d\u0442\u0440\u0435 \u0438 <code>FloatingActionButton<\/code> \u043a\u043d\u043e\u043f\u043a\u0443, \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0446\u0432\u0435\u0442\u0430. \u041e, \u0430 \u0435\u0449\u0435 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0442\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u0432\u0438\u0434\u0436\u0435\u0442 \u0441 \u0444\u043e\u043d\u043e\u0432\u044b\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432\u044b\u0437\u043e\u0432 <code>print<\/code> \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 <code>build<\/code> \u043c\u0435\u0442\u043e\u0434\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0438\u0434\u0436\u0435\u0442\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">class _MyHomePageState extends State&lt;MyHomePage&gt; {   Color _currentColor = Colors.grey;    Random _random = new Random();    void _onPressed() {     int randomNumber = _random.nextInt(30);     setState(() {       _currentColor = Colors.primaries[randomNumber % Colors.primaries.length];     });   }    @override   Widget build(BuildContext context) {     print('building `MyHomePage`');     return Scaffold(       floatingActionButton: FloatingActionButton(         onPressed: _onPressed,         child: Icon(Icons.colorize),       ),       body: Stack(         children: [           Positioned.fill(             child: BackgroundWidget(),           ),           Center(             child: Container(               height: 150,               width: 150,               color: _currentColor,             ),           ),         ],       ),     );   } }  class BackgroundWidget extends StatelessWidget {   @override   Widget build(BuildContext context) {     print('building `BackgroundWidget`');     return Image.network(       'https:\/\/cdn.pixabay.com\/photo\/2017\/08\/30\/01\/05\/milky-way-2695569_960_720.jpg',       fit: BoxFit.cover,     );   } }<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/yk\/0k\/-h\/yk0k-heypf5gclu8em7abi1jp2y.gif\"><\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043a\u043b\u0438\u043a\u0430 \u043f\u043e \u043a\u043d\u043e\u043f\u043a\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0434\u0432\u0430 \u0432\u044b\u0432\u043e\u0434\u0430<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">flutter: building `MyHomePage` flutter: building `BackgroundWidget`<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043a\u043d\u043e\u043f\u043a\u0443, \u043c\u044b \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0432\u0435\u0441\u044c \u044d\u043a\u0440\u0430\u043d: <code>Scaffold<\/code>, <code>BackgroundWidget<\/code> \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0442\u043e, \u0447\u0442\u043e \u0438 \u0445\u043e\u0442\u0435\u043b\u0438 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c, \u2013 \u043a\u0432\u0430\u0434\u0440\u0430\u0442-<code>Container<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u043c\u044b \u0443\u0436\u0435 \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u0438 \u0432\u044b\u0448\u0435, \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0432\u0438\u0434\u0436\u0435\u0442\u044b \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u2013 \u043d\u0435\u0445\u043e\u0440\u043e\u0448\u0430\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430. \u041e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e. \u041c\u043d\u043e\u0433\u0438\u0435 \u0437\u043d\u0430\u044e\u0442, \u0447\u0442\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c: <a href=\"https:\/\/pub.dev\/packages\/flutter_bloc\" rel=\"nofollow\">flutter_bloc<\/a>, <a href=\"https:\/\/pub.dev\/packages\/mobx\" rel=\"nofollow\">mobx<\/a>, <a href=\"https:\/\/pub.dev\/packages\/provider\" rel=\"nofollow\">provider<\/a> \u0438 \u0442. \u0434. \u041d\u043e \u043c\u0430\u043b\u043e \u043a\u0442\u043e \u0437\u043d\u0430\u0435\u0442, \u0447\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 Flutter \u0443\u0436\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438, \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u043e\u0442 \u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>ValueNotifier<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">class _MyHomePageState extends State&lt;MyHomePage&gt; {   final _colorNotifier = ValueNotifier&lt;Color&gt;(Colors.grey);   Random _random = new Random();    void _onPressed() {     int randomNumber = _random.nextInt(30);     _colorNotifier.value =         Colors.primaries[randomNumber % Colors.primaries.length];   }    @override   void dispose() {     _colorNotifier.dispose();     super.dispose();   }    @override   Widget build(BuildContext context) {     print('building `MyHomePage`');     return Scaffold(       floatingActionButton: FloatingActionButton(         onPressed: _onPressed,         child: Icon(Icons.colorize),       ),       body: Stack(         children: [           Positioned.fill(             child: BackgroundWidget(),           ),           Center(             child: ValueListenableBuilder(               valueListenable: _colorNotifier,               builder: (_, value, __) =&gt; Container(                 height: 150,                 width: 150,                 color: value,               ),             ),           ),         ],       ),     );   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043b\u0438\u043a\u043d\u0435\u043c \u043f\u043e \u043a\u043d\u043e\u043f\u043a\u0435 \u0438\u2026 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0443\u0432\u0438\u0434\u0438\u043c \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438. \u042d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043a\u0430\u043a \u0438 \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c, \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0442 \u0432\u0438\u0434\u0436\u0435\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d <em>(\u043f\u0440\u0438\u043c. \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e <a href=\"https:\/\/www.youtube.com\/watch?v=s-ZG-jS5QHQ\" rel=\"nofollow\">ValueListenableBuilder \u0438 ValueNotifier<\/a>)<\/em>. <\/p>\n<p>  <\/p>\n<p>\u041d\u043e \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u0432\u0438\u0434\u0436\u0435\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443 \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 (\u043d\u043e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043b\u043e\u0433\u0438\u043a\u0438 \u0432 \u043d\u0435\u0433\u043e) \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u043d\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u0430 <em>(\u0432 \u0443\u0432\u0435\u0434\u043e\u043c\u0438\u0442\u0435\u043b\u0435)<\/em>.<\/p>\n<p>  <\/p>\n<p>\u0421\u043d\u043e\u0432\u0430 \u0442\u043e\u0442 \u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u043e \u0443\u0436\u0435 \u0441 <code>ChangeNotifier<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">\/\/------ ChangeNotifier class ----\/\/ class MyColorNotifier extends ChangeNotifier {   Color myColor = Colors.grey;   Random _random = new Random();    void changeColor() {     int randomNumber = _random.nextInt(30);     myColor = Colors.primaries[randomNumber % Colors.primaries.length];     notifyListeners();   } } \/\/------ State class ----\/\/  class _MyHomePageState extends State&lt;MyHomePage&gt; {   final _colorNotifier = MyColorNotifier();    void _onPressed() {     _colorNotifier.changeColor();   }    @override   void dispose() {     _colorNotifier.dispose();     super.dispose();   }    @override   Widget build(BuildContext context) {     print('building `MyHomePage`');     return Scaffold(       floatingActionButton: FloatingActionButton(         onPressed: _onPressed,         child: Icon(Icons.colorize),       ),       body: Stack(         children: [           Positioned.fill(             child: BackgroundWidget(),           ),           Center(             child: AnimatedBuilder(               animation: _colorNotifier,               builder: (_, __) =&gt; Container(                 height: 150,                 width: 150,                 color: _colorNotifier.myColor,               ),             ),           ),         ],       ),     );   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0430\u043c\u043e\u0435 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e\u0435, \u0447\u0442\u043e \u0438 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<h2 id=\"ispolzuyte-const\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>const<\/code><\/h2>\n<p>  <\/p>\n<p>\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <code>const<\/code> \u0434\u043b\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0432\u0438\u0434\u0436\u0435\u0442\u0430 (\u0435\u0441\u043b\u0438 \u043e\u043d \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 <code>const<\/code>, \u043a\u043e\u043d\u0435\u0447\u043d\u043e), \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043e\u0434\u043d\u0438\u043c \u0438 \u0442\u0435\u043c \u0436\u0435 \u043a\u0430\u043d\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0438\u0437\u0431\u0435\u0433\u0430\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 <em>(\u043f\u0440\u0438\u043c. \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e <a href=\"https:\/\/habr.com\/ru\/post\/501804\/\">\u0440\u0430\u0431\u043e\u0442\u0443 const<\/a>)<\/em>.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0435\u0449\u0451 \u0440\u0430\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u0430\u0448 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 <code>setState<\/code>, \u043d\u043e \u0432 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u0447\u0435\u0442\u0447\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 1 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443.<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">class _MyHomePageState extends State&lt;MyHomePage&gt; {   int _counter = 0;    void _onPressed() {     setState(() {       _counter++;     });   }    @override   Widget build(BuildContext context) {     print('building `MyHomePage`');     return Scaffold(       floatingActionButton: FloatingActionButton(         onPressed: _onPressed,         child: Icon(Icons.colorize),       ),       body: Stack(         children: [           Positioned.fill(             child: BackgroundWidget(),           ),           Center(               child: Text(             _counter.toString(),             style: Theme.of(context).textTheme.display4.apply(                   color: Colors.white,                   fontWeightDelta: 2,                 ),           )),         ],       ),     );   } }  class BackgroundWidget extends StatelessWidget {   @override   Widget build(BuildContext context) {     print('building `BackgroundWidget`');     return Image.network(       'https:\/\/cdn.pixabay.com\/photo\/2017\/08\/30\/01\/05\/milky-way-2695569_960_720.jpg',       fit: BoxFit.cover,     );   } }<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/yl\/yf\/kg\/ylyfkggjsh4yge2qbnsofptsjdu.gif\"><\/p>\n<p>  <\/p>\n<p>\u0423 \u043d\u0430\u0441 \u0441\u043d\u043e\u0432\u0430 2 \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438, \u043e\u0434\u0438\u043d \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0432\u0443 \u0432\u0438\u0434\u0436\u0435\u0442\u0443, \u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u2013 \u043a <code>BackgroundWidget<\/code>. \u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043a\u043d\u043e\u043f\u043a\u0443, \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u0432\u0438\u0434\u0436\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0445\u043e\u0442\u044f \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">flutter: building `MyHomePage` flutter: building `BackgroundWidget`<\/code><\/pre>\n<p>  <\/p>\n<p>\u0410 \u0441\u0435\u0439\u0447\u0430\u0441 \u0434\u043e\u0431\u0430\u0432\u0438\u043c <code>const<\/code> \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u043c <code>BackgroundWidget<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">class _MyHomePageState extends State&lt;MyHomePage&gt; {   int _counter = 0;    void _onPressed() {     setState(() {       _counter++;     });   }    @override   Widget build(BuildContext context) {     print('building `MyHomePage`');     return Scaffold(       floatingActionButton: FloatingActionButton(         onPressed: _onPressed,         child: Icon(Icons.colorize),       ),       body: Stack(         children: [           Positioned.fill(             child: const BackgroundWidget(),           ),           Center(               child: Text(             _counter.toString(),             style: Theme.of(context).textTheme.display4.apply(                   color: Colors.white,                   fontWeightDelta: 2,                 ),           )),         ],       ),     );   } }  class BackgroundWidget extends StatelessWidget {   const BackgroundWidget();    @override   Widget build(BuildContext context) {     print('building `BackgroundWidget`');     return Image.network(       'https:\/\/cdn.pixabay.com\/photo\/2017\/08\/30\/01\/05\/milky-way-2695569_960_720.jpg',       fit: BoxFit.cover,     );   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043b\u0435 \u043a\u043b\u0438\u043a\u0430 \u043f\u043e \u043a\u043d\u043e\u043f\u043a\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0432\u044b\u0432\u043e\u0434 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u0436\u0435\u0442\u0430 (\u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b, \u0447\u0442\u043e \u044f \u043e\u043f\u0438\u0441\u0430\u043b \u0432\u044b\u0448\u0435, \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043c\u043e\u0436\u043d\u043e \u0438 \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0430) \u0438 \u0438\u0437\u0431\u0435\u0433\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u0436\u0435\u0442\u0430, \u0432\u044b\u0437\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0441 <code>const<\/code>.<\/p>\n<p>  <\/p>\n<h2 id=\"ispolzuyte-itemextent-v-listview-dlya-bolshih-spiskov\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>itemExtent<\/code> \u0432 <code>ListView<\/code> \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0441\u043f\u0438\u0441\u043a\u043e\u0432<\/h2>\n<p>  <\/p>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u0434\u043b\u0438\u043d\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a, \u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c\u0441\u044f \u043f\u043e \u043d\u0435\u043c\u0443, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0441\u0430\u043c\u044b\u0439 \u043a\u043e\u043d\u0435\u0446, \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>itemExtent<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440. \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0437 10 \u0442\u044b\u0441\u044f\u0447 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u041f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u043c\u044b \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443. \u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>itemExtent<\/code> \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0441\u043f\u0438\u0441\u043a\u0430 \u0441\u0430\u043c\u0438\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440.<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">class MyHomePage extends StatelessWidget {   final widgets = List.generate(     10000,     (index) =&gt; Container(       height: 200.0,       color: Colors.primaries[index % Colors.primaries.length],       child: ListTile(         title: Text('Index: $index'),       ),     ),   );    final _scrollController = ScrollController();    void _onPressed() async {     _scrollController.jumpTo(       _scrollController.position.maxScrollExtent,     );   }    @override   Widget build(BuildContext context) {     return Scaffold(       floatingActionButton: FloatingActionButton(         onPressed: _onPressed,         splashColor: Colors.red,         child: Icon(Icons.slow_motion_video),       ),       body: ListView(         controller: _scrollController,         children: widgets,       ),     );   } }<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/of\/fi\/h9\/offih9w4zrrrkbtj8q1dbh-sys8.gif\"><\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043d\u0430 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0432\u044b\u0448\u0435, \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0447\u0435\u043d\u044c \u0434\u043e\u043b\u0433\u043e (~10 \u0441\u0435\u043a\u0443\u043d\u0434). \u0422\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0441\u0430\u043c\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u0441\u0432\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440. \u042d\u0442\u043e \u0434\u0430\u0436\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 UI!<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u044d\u0442\u043e\u0433\u043e, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>itemExtent<\/code>, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0440\u0438 \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u0435 \u043d\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u043b\u0438\u0448\u043d\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e \u0440\u0430\u0441\u0447\u0435\u0442\u0443 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0441\u043a\u0440\u043e\u043b\u043b\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b.<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">class MyHomePage extends StatelessWidget {   final widgets = List.generate(     10000,     (index) =&gt; Container(       color: Colors.primaries[index % Colors.primaries.length],       child: ListTile(         title: Text('Index: $index'),       ),     ),   );    final _scrollController = ScrollController();    void _onPressed() async {     _scrollController.jumpTo(       _scrollController.position.maxScrollExtent,     );   }    @override   Widget build(BuildContext context) {     return Scaffold(       floatingActionButton: FloatingActionButton(         onPressed: _onPressed,         splashColor: Colors.red,         child: Icon(Icons.slow_motion_video),       ),       body: ListView(         controller: _scrollController,         children: widgets,         itemExtent: 200,       ),     );   } }<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/pk\/le\/rt\/pklertikfqc-kab5nr4bskx3dke.gif\"><\/p>\n<p>  <\/p>\n<p>\u0421 \u044d\u0442\u0438\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u043c\u044b \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0441\u0430\u043c\u044b\u0439 \u043d\u0438\u0437 \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0437\u0430\u0434\u0435\u0440\u0436\u0435\u043a.<\/p>\n<p>  <\/p>\n<h2 id=\"izbegayte-nenuzhnyh-perestroeniy-vidzhetov-vnutri-animatedbuilder\">\u0418\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0439 \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432 \u0432\u043d\u0443\u0442\u0440\u0438 <code>AnimatedBuilder<\/code><\/h2>\n<p>  <\/p>\n<p>\u0427\u0430\u0441\u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448\u0438 \u0432\u0438\u0434\u0436\u0435\u0442\u044b \u0431\u044b\u043b\u0438 \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u044b. \u0412 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043e\u0431\u044b\u0447\u043d\u043e \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044f <em>(addListener)<\/em> \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e <code>AnimationController<\/code> \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>setState<\/code>. \u041d\u043e, \u043a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0435\u043b\u0438 \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435, \u0442\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0435 \u043b\u0443\u0447\u0448\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0438\u0434\u0436\u0435\u0442 <code>AnimatedBuilder<\/code> \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u043e \u0432\u0438\u0434\u0436\u0435\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u044d\u043a\u0440\u0430\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0438\u0434\u0436\u0435\u0442 \u0432 \u0446\u0435\u043d\u0442\u0440\u0435 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430 \u0438 \u043a\u043d\u043e\u043f\u043a\u0443, \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u0438\u0434\u0436\u0435\u0442 \u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043d\u0430 360 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0432 \u0432\u0438\u0434\u0436\u0435\u0442 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430 <code>CounterWidget<\/code>, \u0438 \u043d\u0430\u0436\u043c\u0451\u043c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442.<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">class _MyHomePageState extends State&lt;MyHomePage&gt;     with SingleTickerProviderStateMixin {   AnimationController _controller;   int counter = 0;    void _onPressed() {     setState(() {       counter++;     });     _controller.forward(from: 0.0);   }    @override   void initState() {     _controller = AnimationController(         vsync: this, duration: const Duration(milliseconds: 600));     super.initState();   }    @override   void dispose() {     _controller.dispose();     super.dispose();   }    @override   Widget build(BuildContext context) {     return Scaffold(       floatingActionButton: FloatingActionButton(         onPressed: _onPressed,         splashColor: Colors.red,         child: Icon(Icons.slow_motion_video),       ),       body: AnimatedBuilder(         animation: _controller,         builder: (_, child) =&gt; Transform(           alignment: Alignment.center,           transform: Matrix4.identity()             ..setEntry(3, 2, 0.001)             ..rotateY(360 * _controller.value * (pi \/ 180.0)),           child: CounterWidget(             counter: counter,           ),         ),       ),     );   } }  class CounterWidget extends StatelessWidget {   final int counter;    const CounterWidget({Key key, this.counter}) : super(key: key);    @override   Widget build(BuildContext context) {     print('building `CounterWidget`');     return Center(       child: Text(         counter.toString(),         style: Theme.of(context).textTheme.display4.apply(fontWeightDelta: 3),       ),     );   } }<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ob\/aj\/te\/obajte6yg6rrtbrqsux8b_14v30.gif\"><\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0440\u044f\u0434 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">flutter: building `CounterWidget` flutter: building `CounterWidget` flutter: building `CounterWidget` flutter: building `CounterWidget` flutter: building `CounterWidget` ... flutter: building `CounterWidget`<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u043b\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u0432\u0438\u0434\u0436\u0435\u0442\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 1, \u043d\u043e \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u043b\u043e\u0433\u043e\u0432, \u0445\u043e\u0442\u044f \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u043b \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d, \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u044b \u0437\u0430\u0434\u0430\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>setState<\/code>. \u041a\u0430\u043a \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u043b\u0438\u0448\u043d\u0438\u0445 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 <code>CounterWidget<\/code>?<\/p>\n<p>  <\/p>\n<p>\u0412\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e! \u041d\u0430\u0434\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443 <code>AnimatedBuilder<\/code> \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>child<\/code>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0438\u0434\u0436\u0435\u0442\u044b \u0434\u043b\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0445 \u0432 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438. \u041c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u0432\u0438\u0434\u0436\u0435\u0442 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f, \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u0447\u0442\u043e \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c, \u044d\u0442\u043e \u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f, \u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c <code>Transform<\/code> \u0432\u0438\u0434\u0436\u0435\u0442.<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">  @override   Widget build(BuildContext context) {     return Scaffold(       floatingActionButton: FloatingActionButton(         onPressed: _onPressed,         splashColor: Colors.red,         child: Icon(Icons.slow_motion_video),       ),       body: AnimatedBuilder(         animation: _controller,         child: CounterWidget(           counter: counter,         ),         builder: (_, child) =&gt; Transform(           alignment: Alignment.center,           transform: Matrix4.identity()             ..setEntry(3, 2, 0.001)             ..rotateY(360 * _controller.value * (pi \/ 180.0)),           child: child,         ),       ),     );   }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u043d\u0435\u0448\u043d\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c, \u043d\u043e \u0435\u0441\u043b\u0438 \u0437\u0430\u0433\u043b\u044f\u043d\u0435\u043c \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u043c \u0442\u0430\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0443 \u0437\u0430\u043f\u0438\u0441\u044c, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044e \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430, \u0434\u0440\u0443\u0433\u0438\u0445 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u043d\u0435\u0442. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043d\u0430\u0448\u0443 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e.<\/p>\n<p>  <\/p>\n<h2 id=\"ne-ispolzuyte-vidzhet-opacity-v-animaciyah\">\u041d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0432\u0438\u0434\u0436\u0435\u0442 <code>Opacity<\/code> \u0432 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f\u0445<\/h2>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0435\u0449\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c. <\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0430\u043c \u0447\u0442\u043e-\u0442\u043e \u043d\u0430\u0434\u043e \u0441\u043a\u0440\u044b\u0442\u044c \u0438\u043b\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0442\u043e \u043c\u044b \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u0432\u0438\u0434\u0436\u0435\u0442 <code>Opacity<\/code>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u043e \u0432\u043c\u0435\u0441\u0442\u043e <code>Transform<\/code>, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>Opacity<\/code>, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448 \u0432\u0438\u0434\u0436\u0435\u0442 \u0438\u0441\u0447\u0435\u0437\u0430\u043b \u0438 \u043f\u043e\u044f\u0432\u043b\u044f\u043b\u0441\u044f \u0441\u043d\u043e\u0432\u0430 \u0438 \u0441\u043d\u043e\u0432\u0430.<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">class _MyHomePageState extends State&lt;MyHomePage&gt;     with SingleTickerProviderStateMixin {   AnimationController _controller;   int counter = 0;    void _onPressed() {     setState(() {       counter++;     });     _controller.forward(from: 0.0);   }    @override   void initState() {     _controller = AnimationController(         vsync: this, duration: const Duration(milliseconds: 600));     _controller.addStatusListener((status) {       if (status == AnimationStatus.completed) {         _controller.reverse();       }     });     super.initState();   }    @override   void dispose() {     _controller.dispose();     super.dispose();   }    @override   Widget build(BuildContext context) {     return Scaffold(       floatingActionButton: FloatingActionButton(         onPressed: _onPressed,         splashColor: Colors.red,         child: Icon(Icons.slow_motion_video),       ),       body: AnimatedBuilder(         animation: _controller,         child: CounterWidget(           counter: counter,         ),         builder: (_, child) =&gt; Opacity(           opacity: (1 - _controller.value),           child: child,         ),       ),     );   } }<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/40\/pa\/uq\/40pauqmutbkxqml9gfgkwkcsc0m.gif\"><\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043e\u0434\u043d\u0430\u043a\u043e, \u0432\u0438\u0434\u0436\u0435\u0442 <code>Opacity<\/code> (\u0438, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0435\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0435\u0432\u043e) \u043f\u0435\u0440\u0435\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u0430\u0434\u0440, \u0447\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0437\u0434\u043e\u0440\u043e\u0432\u043e.<\/p>\n<p>  <\/p>\n<p>\u041d\u043e \u0443 \u043d\u0430\u0441 \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0435\u0441\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b:<\/p>\n<p>  <\/p>\n<p>1 \u2013 \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>FadeTransition<\/code><\/p>\n<p>  <\/p>\n<pre><code class=\"java\">class _MyHomePageState extends State&lt;MyHomePage&gt;     with SingleTickerProviderStateMixin {   AnimationController _controller;   int counter = 0;    void _onPressed() {     setState(() {       counter++;     });     _controller.forward(from: 0.0);   }    @override   void initState() {     _controller = AnimationController(         vsync: this, duration: const Duration(milliseconds: 600));     _controller.addStatusListener((status) {       if (status == AnimationStatus.completed) {         _controller.reverse();       }     });     super.initState();   }    @override   void dispose() {     _controller.dispose();     super.dispose();   }    @override   Widget build(BuildContext context) {     return Scaffold(       floatingActionButton: FloatingActionButton(         onPressed: _onPressed,         splashColor: Colors.red,         child: Icon(Icons.slow_motion_video),       ),       body: FadeTransition(         opacity: Tween(begin: 1.0, end: 0.0).animate(_controller),         child: CounterWidget(           counter: counter,         ),       ),     );   } }<\/code><\/pre>\n<p>  <\/p>\n<p>2 \u2013 \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>AnimatedOpacity<\/code><\/p>\n<p>  <\/p>\n<pre><code class=\"java\">const duration = const Duration(milliseconds: 600);  class _MyHomePageState extends State&lt;MyHomePage&gt; {   int counter = 0;   double opacity = 1.0;    void _onPressed() async {     counter++;     setState(() {       opacity = 0.0;     });     await Future.delayed(duration);     setState(() {       opacity = 1.0;     });   }    @override   Widget build(BuildContext context) {     return Scaffold(       floatingActionButton: FloatingActionButton(         onPressed: _onPressed,         splashColor: Colors.red,         child: Icon(Icons.slow_motion_video),       ),       body: AnimatedOpacity(         opacity: opacity,         duration: duration,         child: CounterWidget(           counter: counter,         ),       ),     );   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431\u0430 \u044d\u0442\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435, \u0447\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u0430 <code>Opacity<\/code>.<\/p>\n<p>  <\/p>\n<h2 id=\"zaklyuchenie\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u044f \u0443\u0436\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b \u0440\u0430\u043d\u0435\u0435, Flutter \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043e\u0449\u0435\u043d, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0430\u0448\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c. \u041e\u0434\u043d\u0430\u043a\u043e, \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430\u043c \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u0435\u0449\u0451 \u0431\u043e\u043b\u044c\u0448\u0435 \u0443\u0437\u043d\u0430\u0442\u044c \u043f\u043e \u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0435\u043c\u0435, \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0432\u0438\u0434\u0435\u043e-\u0432\u044b\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435 Filip Hr\u00e1\u010dek \u043d\u0430 Flutter Europe, \u0433\u0434\u0435 \u043e\u043d \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0431 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 <a href=\"https:\/\/www.youtube.com\/watch?v=vVg9It7cOfY\" rel=\"nofollow\">\u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 Flutter \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439<\/a>.<\/p>\n<p>  <\/p>\n<p><strong>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b:<\/strong><\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/flutter.dev\/docs\/perf\/rendering\/best-practices\" rel=\"nofollow\">https:\/\/flutter.dev\/docs\/perf\/rendering\/best-practices<\/a><\/li>\n<li><a href=\"https:\/\/api.flutter.dev\/flutter\/widgets\/StatefulWidget-class.html#performance-considerations\" rel=\"nofollow\">https:\/\/api.flutter.dev\/flutter\/widgets\/StatefulWidget-class.html#performance-considerations<\/a><\/li>\n<li><a href=\"https:\/\/api.flutter.dev\/flutter\/widgets\/Opacity-class.html#transparent-image\" rel=\"nofollow\">https:\/\/api.flutter.dev\/flutter\/widgets\/Opacity-class.html#transparent-image<\/a><\/li>\n<\/ul>\n<p>  <\/p>\n<p><strong>\u041e\u0431 \u0430\u0432\u0442\u043e\u0440\u0435:<\/strong><\/p>\n<p>  <\/p>\n<p>Diego Vel\u00e1squez \u2013\u00a0\u044d\u0442\u043e Flutter \u0438 Dart <a href=\"https:\/\/en.wikipedia.org\/wiki\/Google_Developer_Expert\" rel=\"nofollow\">GDE<\/a> \u0438\u0437 \u041b\u0438\u043c\u044b, \u041f\u0435\u0440\u0443. \u041e\u043d \u0442\u0430\u043a\u0436\u0435 \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u043a\u043e\u043c\u0438\u0442\u0435\u0442 \u043f\u043e Flutter. Diego \u0443\u0432\u043b\u0435\u0447\u0435\u043d \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u043e\u0440\u0430 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0435\u0433\u043e \u0432 <a href=\"https:\/\/twitter.com\/diegoveloper\" rel=\"nofollow\">Twitter<\/a>.<\/p>\n<p>  <\/p>\n<hr>\n<p>  <\/p>\n<p>P.S. \u0415\u0449\u0451 \u0440\u0430\u0437 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e <a href=\"https:\/\/blog.codemagic.io\/how-to-improve-the-performance-of-your-flutter-app.\/\" rel=\"nofollow\">How to improve the performance of your Flutter app<\/a> \u043e\u0442 Diego Vel\u00e1squez<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/502882\/\"> https:\/\/habr.com\/ru\/post\/502882\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/502882\/\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/76\/nr\/ut\/76nrutrkfl7c49c7ifdu9qgb134.png\"><\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432, \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438 \u0437\u0430\u0431\u043b\u0443\u0436\u0434\u0435\u043d\u0438\u0439, \u043a\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0448\u0435\u0433\u043e Flutter \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0440\u0430\u0437\u0443 \u0443\u0442\u043e\u0447\u043d\u0438\u0442\u044c, \u0447\u0442\u043e Flutter \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043d\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043a\u043e\u0434\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u0438 \u0431\u044b\u0441\u0442\u0440\u043e. \u041d\u0438\u0436\u0435 \u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b \u0434\u043b\u044f \u0432\u0430\u0441 \u0440\u044f\u0434 \u0441\u043e\u0432\u0435\u0442\u043e\u0432 \u0438 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043e\u043a, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c \u043f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-303956","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/303956","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=303956"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/303956\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=303956"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=303956"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=303956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}