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
| class HomePage extends HookWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| final counter = useState(0); | |
| void onPressed() { | |
| counter.value++; | |
| } | |
| return Scaffold( |
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
| class HomePage extends StatefulWidget { | |
| @override | |
| _HomePageState createState() => _HomePageState(); | |
| } | |
| class _HomePageState extends State<HomePage> { | |
| int counter = 0; | |
| void onPressed() { | |
| setState(() { |
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
| class HomePage extends StatefulWidget { | |
| @override | |
| _HomePageState createState() => _HomePageState(); | |
| } | |
| class _HomePageState extends State<HomePage> { | |
| Future future; | |
| Future<String> fetchData() async { | |
| await Future.delayed(Duration(seconds: 2)); |
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
| class HomePage extends HookWidget { | |
| Future<String> fetchData() async { | |
| await Future.delayed(Duration(seconds: 2)); | |
| return 'ehe'; | |
| } | |
| @override | |
| Widget build(BuildContext context) { | |
| final future = useMemoized(fetchData); | |
| final snapshot = useFuture(future); |
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
| class HomePage extends StatefulWidget { | |
| @override | |
| _HomePageState createState() => _HomePageState(); | |
| } | |
| class _HomePageState extends State<HomePage> | |
| with SingleTickerProviderStateMixin { | |
| AnimationController controller; | |
| @override |
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
| class HomePage extends HookWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| final controller = useAnimationController(duration: Duration(seconds: 4)); | |
| controller.repeat(); | |
| return Scaffold( | |
| body: Center( | |
| child: AnimatedBuilder( | |
| animation: controller, | |
| builder: (_, child) { |
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
| class HomePage extends StatefulWidget { | |
| @override | |
| _HomePageState createState() => _HomePageState(); | |
| } | |
| class _HomePageState extends State<HomePage> | |
| with SingleTickerProviderStateMixin { | |
| TabController controller; | |
| @override |
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
| class HomePage extends HookWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| final controller = useTabController(initialLength: 3); | |
| onPressed() => controller.animateTo(Random().nextInt(3)); | |
| return Scaffold( | |
| appBar: AppBar( | |
| bottom: TabBar( |
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
| class HomePage extends HookWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| useEffect( | |
| () { | |
| // initState | |
| return () { | |
| // dispose | |
| }; | |
| }, |
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
| class HomePage extends StatefulWidget { | |
| @override | |
| _HomePageState createState() => _HomePageState(); | |
| } | |
| class _HomePageState extends State<HomePage> { | |
| @override | |
| void initState() { | |
| super.initState(); | |
| } |
OlderNewer