flutter/dev/a11y_assessments/lib/use_cases/dialog.dart
Yegor d0664bcd79
a few web tweaks for a11y assessment app (#134479)
Mostly tweaks for better focus management, namely:

* Use `autofocus` throughout so the a11y focus is transferred to a logical place when overlaid content pops up (screen transitions, dialogs).
* Consolidate "enabled" and "disabled" widgets into the same screen. Otherwise, when only a disabled widget is shown, there's nothing to focus on and the screen reader is lost.
2023-09-21 19:38:20 +00:00

62 lines
1.7 KiB
Dart

// 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';
import 'use_cases.dart';
class DialogUseCase extends UseCase {
@override
String get name => 'Dialog';
@override
String get route => '/dialog';
@override
Widget build(BuildContext context) => const _MainWidget();
}
class _MainWidget extends StatelessWidget {
const _MainWidget();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: const Text('Dialog'),
),
body: Center(
child: TextButton(
autofocus: true,
onPressed: () => showDialog<String>(
context: context,
builder: (BuildContext context) => Dialog(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text('This is a typical dialog.'),
const SizedBox(height: 15),
TextButton(
autofocus: true,
onPressed: () {
Navigator.pop(context);
},
child: const Text('Close'),
),
],
),
),
),
),
child: const Text('Show Dialog'),
),
),
);
}
}