Skip to content

Instantly share code, notes, and snippets.

@flutterdevrelgists
Created January 24, 2023 23:08
Show Gist options
  • Save flutterdevrelgists/d90bbafc72fa1096600967d723483a9d to your computer and use it in GitHub Desktop.
Save flutterdevrelgists/d90bbafc72fa1096600967d723483a9d to your computer and use it in GitHub Desktop.
Adaptive UI Talk FocusableActionDetector Example
// 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