typography_screen.dart 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright 2021 The Flutter team. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. import 'package:flutter/material.dart';
  5. class TypographyScreen extends StatelessWidget {
  6. const TypographyScreen({super.key});
  7. @override
  8. Widget build(BuildContext context) {
  9. final textTheme = Theme.of(context)
  10. .textTheme
  11. .apply(displayColor: Theme.of(context).colorScheme.onSurface);
  12. return Expanded(
  13. child: ListView(
  14. children: <Widget>[
  15. const SizedBox(height: 7),
  16. TextStyleExample(
  17. name: 'Display Large', style: textTheme.displayLarge!),
  18. TextStyleExample(
  19. name: 'Display Medium', style: textTheme.displayMedium!),
  20. TextStyleExample(
  21. name: 'Display Small', style: textTheme.displaySmall!),
  22. TextStyleExample(
  23. name: 'Headline Large', style: textTheme.headlineLarge!),
  24. TextStyleExample(
  25. name: 'Headline Medium', style: textTheme.headlineMedium!),
  26. TextStyleExample(
  27. name: 'Headline Small', style: textTheme.headlineSmall!),
  28. TextStyleExample(name: 'Title Large', style: textTheme.titleLarge!),
  29. TextStyleExample(name: 'Title Medium', style: textTheme.titleMedium!),
  30. TextStyleExample(name: 'Title Small', style: textTheme.titleSmall!),
  31. TextStyleExample(name: 'Label Large', style: textTheme.labelLarge!),
  32. TextStyleExample(name: 'Label Medium', style: textTheme.labelMedium!),
  33. TextStyleExample(name: 'Label Small', style: textTheme.labelSmall!),
  34. TextStyleExample(name: 'Body Large', style: textTheme.bodyLarge!),
  35. TextStyleExample(name: 'Body Medium', style: textTheme.bodyMedium!),
  36. TextStyleExample(name: 'Body Small', style: textTheme.bodySmall!),
  37. ],
  38. ),
  39. );
  40. }
  41. }
  42. class TextStyleExample extends StatelessWidget {
  43. const TextStyleExample({
  44. super.key,
  45. required this.name,
  46. required this.style,
  47. });
  48. final String name;
  49. final TextStyle style;
  50. @override
  51. Widget build(BuildContext context) {
  52. return Padding(
  53. padding: const EdgeInsets.all(8.0),
  54. child: Text(name, style: style),
  55. );
  56. }
  57. }