Created with <3 with dartpad.dev.
Last active
August 10, 2023 15:49
-
-
Save esDotDev/7f3586efc8ae89f3ec27356260ea71f3 to your computer and use it in GitHub Desktop.
flying-neutron-5516
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
mport 'package:flutter/material.dart'; | |
void main() { runApp(SomeWidget()); } | |
class SomeWidget extends StatefulWidget { @override State createState() => SomeWidgetState(); } | |
class SomeWidgetState extends State { int count = 0; | |
void incrementCount() => setState(() => count++); | |
@override Widget build(BuildContext context) { return SomeWidgetView(controller: this); } } | |
class SomeWidgetView extends StatelessWidget { const SomeWidgetView({super.key, required this.controller}); | |
final SomeWidgetState controller; | |
@override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: Center( child: TextButton( onPressed: controller.incrementCount, child: MyDeepChild(count: controller.count), ), ), ), ); } } | |
class MyDeepChild extends StatelessWidget { const MyDeepChild({super.key, required this.count}); final int count; | |
@override Widget build(BuildContext context) { return Text('$count'); } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment