Last active
May 20, 2020 15:42
-
-
Save kdmatrosov/8741cccdbb1c07728524dba79f1140d0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| void main() { | |
| runApp(MyApp()); | |
| } | |
| class MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| home: Scaffold( | |
| body: Example(), | |
| ), | |
| ); | |
| } | |
| } | |
| class Example extends StatefulWidget { | |
| @override | |
| _ExampleState createState() => _ExampleState(); | |
| } | |
| class _ExampleState extends State<Example> { | |
| int _counter = 0; | |
| Widget _weNeedItOnlyOnce() { | |
| print('_weNeedItOnlyOnce'); | |
| return Padding( | |
| padding: EdgeInsets.all(32), | |
| child: Text('Просто немного текста'), | |
| ); | |
| } | |
| @override | |
| Widget build(BuildContext context) { | |
| return Padding( | |
| padding: EdgeInsets.all(32), | |
| child: Column( | |
| children: [ | |
| FlatButton( | |
| color: Colors.blue, | |
| child: Text( | |
| 'Счетчик: $_counter', | |
| style: TextStyle(color: Colors.white), | |
| ), | |
| onPressed: () { | |
| setState(() { | |
| _counter++; | |
| }); | |
| }, | |
| ), | |
| _weNeedItOnlyOnce(), | |
| const WeNeedItOnlyOnce(), | |
| ], | |
| )); | |
| } | |
| } | |
| class WeNeedItOnlyOnce extends StatelessWidget { | |
| const WeNeedItOnlyOnce(); | |
| @override | |
| Widget build(BuildContext context) { | |
| print('WeNeedItOnlyOnce'); | |
| return Padding( | |
| padding: EdgeInsets.all(32), | |
| child: Text('Просто немного текста 2'), | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment