Created
January 24, 2023 20:38
-
-
Save gspencergoog/ac2a707ab259db2ab06989411f661370 to your computer and use it in GitHub Desktop.
FocusableActionDetector Example
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
| // Copyright 2014 The Flutter Authors. All rights reserved. | |
| // Use of this source code is governed by a BSD-style license that can be | |
| // found in the LICENSE file. | |
| import 'package:flutter/material.dart'; | |
| void main() { | |
| runApp(const MainApp()); | |
| } | |
| class MainApp extends StatelessWidget { | |
| const MainApp({super.key}); | |
| @override | |
| Widget build(BuildContext context) { | |
| return const MaterialApp( | |
| debugShowCheckedModeBanner: false, | |
| home: Scaffold( | |
| body: Center( | |
| child: HoverBox(), | |
| ), | |
| ), | |
| ); | |
| } | |
| } | |
| class HoverBox extends StatefulWidget { | |
| const HoverBox({super.key}); | |
| @override | |
| State<HoverBox> createState() => _HoverBoxState(); | |
| } | |
| class _HoverBoxState extends State<HoverBox> { | |
| bool _hovering = false; | |
| @override | |
| Widget build(BuildContext context) { | |
| return FocusableActionDetector( | |
| onShowHoverHighlight: (bool value) { setState(() { _hovering = value; }); }, | |
| child: Container( | |
| width: 100, height: 100, color: _hovering ? Colors.red : Colors.blue), | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment