final
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class DemoButtons extends StatefulWidget {
|
||||
const DemoButtons({super.key});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _DemoButtonsState();
|
||||
}
|
||||
}
|
||||
|
||||
class _DemoButtonsState extends State<DemoButtons> {
|
||||
var _isUnderstood = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print('DemoButtons BUILD called');
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_isUnderstood = false;
|
||||
});
|
||||
},
|
||||
child: const Text('No'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_isUnderstood = true;
|
||||
});
|
||||
},
|
||||
child: const Text('Yes'),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (_isUnderstood) const Text('Awesome!'),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_internals/demo_buttons.dart';
|
||||
|
||||
class UIUpdatesDemo extends StatefulWidget {
|
||||
class UIUpdatesDemo extends StatelessWidget {
|
||||
const UIUpdatesDemo({super.key});
|
||||
|
||||
@override
|
||||
StatefulElement createElement() {
|
||||
print('UIUpdatesDemo CREATEELEMENT called');
|
||||
return super.createElement();
|
||||
}
|
||||
|
||||
@override
|
||||
State<UIUpdatesDemo> createState() {
|
||||
return _UIUpdatesDemo();
|
||||
}
|
||||
}
|
||||
|
||||
class _UIUpdatesDemo extends State<UIUpdatesDemo> {
|
||||
var _isUnderstood = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print('UIUpdatesDemo BUILD called');
|
||||
@@ -27,40 +13,19 @@ class _UIUpdatesDemo extends State<UIUpdatesDemo> {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const Text(
|
||||
children: const [
|
||||
Text(
|
||||
'Every Flutter developer should have a basic understanding of Flutter\'s internals!',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
SizedBox(height: 16),
|
||||
Text(
|
||||
'Do you understand how Flutter updates UIs?',
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_isUnderstood = false;
|
||||
});
|
||||
},
|
||||
child: const Text('No'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_isUnderstood = true;
|
||||
});
|
||||
},
|
||||
child: const Text('Yes'),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (_isUnderstood) const Text('Awesome!'),
|
||||
SizedBox(height: 24),
|
||||
Expanded(child: DemoButtons(),),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user