Created with <3 with dartpad.dev.
Created
December 22, 2022 23:12
-
-
Save isaacadariku/ee2949fae8e8879b95356a04cfcf1adb to your computer and use it in GitHub Desktop.
Accessibility Button Demo
This file contains 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
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: const FontSizeChanger(), | |
); | |
} | |
} | |
class FontSizeChanger extends StatefulWidget { | |
const FontSizeChanger({super.key}); | |
@override | |
State<FontSizeChanger> createState() => _FontSizeChangerState(); | |
} | |
class _FontSizeChangerState extends State<FontSizeChanger> { | |
double _fontSize = 14.0; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: const Text('Accessibility Button Demo'), | |
), | |
body: Center( | |
child: Semantics( | |
label: 'Increase font size', // <-- Semantics label | |
child: Focus( | |
onFocusChange: (hasFocus) { | |
if (hasFocus) { | |
setState(() { | |
_fontSize += 2.0; | |
}); | |
} | |
}, | |
child: Text( | |
'Hello World', | |
style: TextStyle(fontSize: _fontSize), | |
), | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment