Skip to content

Latest commit

 

History

History
53 lines (47 loc) · 1.12 KB

ex10-1.md

File metadata and controls

53 lines (47 loc) · 1.12 KB

10.1 Incorporating Rich Text

Example

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    const title = 'RichText Demo';
    return MaterialApp(
      title: title,
      home: Scaffold(
        appBar: AppBar(
          title: const Text(title),
        ),
        body: const MyRichText(),
      ),
    );
  }
}

double screenHeight = 0.0;

class MyRichText extends StatelessWidget {
  const MyRichText({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    screenHeight = MediaQuery.of(context).size.height / 3;
    return RichText(
      text: const TextSpan(
        children: [
          TextSpan(
            text: 'Hello',
            style: TextStyle(fontWeight: FontWeight.bold, fontSize: 24),
          ),
          TextSpan(
            text: 'Luxembourg',
            style: TextStyle(
                fontWeight: FontWeight.bold, fontSize: 32, color: Colors.grey),
          ),
        ],
      ),
    );
  }
}