initial commit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_internals/ui_updates_demo.dart';
|
||||
|
||||
void main() {
|
||||
runApp(const App());
|
||||
}
|
||||
|
||||
class App extends StatelessWidget {
|
||||
const App({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(useMaterial3: true),
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Flutter Internals'),
|
||||
),
|
||||
body: const UIUpdatesDemo(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class UIUpdatesDemo extends StatefulWidget {
|
||||
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');
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
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(
|
||||
'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!'),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user