Created
August 16, 2022 19:33
-
-
Save vsomayaji/bc3776a8eb44557b41ffd247b45d4f68 to your computer and use it in GitHub Desktop.
chat_controls.dart
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
import 'package:flutter/material.dart'; | |
import 'package:flutter/rendering.dart'; | |
void main() { | |
WidgetsFlutterBinding.ensureInitialized(); | |
// Auto-enable accessibility for our Blind and Low Vision customers. | |
RendererBinding.instance.setSemanticsEnabled(true); | |
runApp(const MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({Key? key}) : super(key: key); | |
final String _title = 'Chat Controls'; | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: _title, | |
home: Scaffold( | |
appBar: AppBar( | |
title: Text(_title), | |
), | |
body: const ChatControls(), | |
), | |
); | |
} | |
} | |
class ChatControls extends StatefulWidget { | |
const ChatControls({Key? key}) : super(key: key); | |
@override | |
State<ChatControls> createState() => _ChatControlsState(); | |
} | |
class _ChatControlsState extends State<ChatControls> { | |
bool _checkboxValue = false; | |
@override | |
Widget build(BuildContext context) { | |
return Center( | |
child: Padding( | |
padding: const EdgeInsets.all(20), | |
child: Column( | |
children: <Widget>[ | |
Wrap( | |
runSpacing: 20, | |
spacing: 20, | |
children: <Widget>[ | |
ElevatedButton( | |
onPressed: () {}, | |
style: ElevatedButton.styleFrom( | |
shape: const CircleBorder(), | |
), | |
child: const Icon(Icons.attach_file), | |
), | |
Column( | |
crossAxisAlignment: CrossAxisAlignment.end, | |
children: <Widget>[ | |
Row( | |
mainAxisSize: MainAxisSize.min, | |
children: <Widget>[ | |
Flexible( | |
child: Semantics( | |
// Use Semantics instead of MergeSemantics for the label, since the latter breaks the | |
// checkbox (https://github.com/flutter/flutter/issues/99719). | |
label: 'I can\'t talk out loud right now', | |
child: Checkbox( | |
value: _checkboxValue, | |
onChanged: (bool? newValue) => setState(() => _checkboxValue = newValue!), | |
), | |
), | |
), | |
Flexible( | |
child: ExcludeSemantics( | |
child: InkWell( | |
canRequestFocus: false, // Avoid a second tab stop. | |
onTap: () => setState(() => _checkboxValue = !_checkboxValue), | |
child: const Text('I can\'t talk out loud right now'), | |
), | |
), | |
), | |
], | |
), | |
const SizedBox(height: 20), | |
Row( | |
mainAxisSize: MainAxisSize.min, | |
children: <Widget>[ | |
const Flexible( | |
child: ExcludeSemantics( | |
child: Text( | |
'Call an Aira Agent', | |
textAlign: TextAlign.right, | |
), | |
), | |
), | |
Flexible( | |
child: Tooltip( | |
excludeFromSemantics: true, | |
message: 'Call an Aira Agent (⌘ + Shift + U)', | |
child: ElevatedButton( | |
onPressed: () {}, | |
style: ElevatedButton.styleFrom( | |
shape: const CircleBorder(), | |
), | |
child: const Icon(Icons.headphones), | |
), | |
), | |
), | |
], | |
), | |
], | |
), | |
], | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment