Skip to content

Instantly share code, notes, and snippets.

@craiglabenz
Last active August 4, 2022 14:37
Show Gist options
  • Select an option

  • Save craiglabenz/87f1f9cff36d28daffc3e05a836491dc to your computer and use it in GitHub Desktop.

Select an option

Save craiglabenz/87f1f9cff36d28daffc3e05a836491dc to your computer and use it in GitHub Desktop.

Revisions

  1. craiglabenz revised this gist Aug 4, 2022. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions text_style_demo.dart
    Original file line number Diff line number Diff line change
    @@ -19,11 +19,15 @@ class MyApp extends StatelessWidget {
    ),
    ),
    debugShowCheckedModeBanner: false,
    // Default functionality with a Scaffold, which provides a Material widget
    home: Scaffold(
    body: Center(
    child: MyWidget(),
    ),
    ),
    // Comment the above and uncomment the below to enjoy Flutter's jarring default
    // TextStyle, meant to be unattractive so you choose your own values!
    // home: Center(child: const Text('Error theme', style: TextStyle(color: Colors.blue))),
    );
    }
    }
  2. craiglabenz created this gist Aug 4, 2022.
    63 changes: 63 additions & 0 deletions text_style_demo.dart
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,63 @@
    import 'package:flutter/material.dart';

    const Color darkBlue = Color.fromARGB(255, 18, 32, 47);

    void main() {
    runApp(MyApp());
    }

    class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
    return MaterialApp(
    theme: ThemeData.light().copyWith(
    scaffoldBackgroundColor: darkBlue,
    textTheme: const TextTheme(
    headline4: TextStyle(
    color: Colors.white,
    ),
    ),
    ),
    debugShowCheckedModeBanner: false,
    home: Scaffold(
    body: Center(
    child: MyWidget(),
    ),
    ),
    );
    }
    }

    class MyWidget extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
    return Column(
    mainAxisAlignment: MainAxisAlignment.center,
    children: <Widget>[
    Text(
    'Hello, World!',
    style: Theme.of(context).textTheme.headline4,
    ),
    Text(
    'Hello, World!',
    style: Theme.of(context).textTheme.headline4!.copyWith(
    color: Colors.red,
    fontStyle: FontStyle.italic,
    ),
    ),
    const Text(
    'Hello, Flutter!',
    style: TextStyle(color: Colors.blue, fontSize: 48),
    ),
    const Text(
    'inherit: true (the default)',
    style: TextStyle(),
    ),
    const Text(
    'inherit: false',
    style: TextStyle(inherit: false),
    ),
    ],
    );
    }
    }