Widget build()

in packages/diagrams/lib/src/text.dart [29:136]


  Widget build(BuildContext context) {
    Widget returnWidget;

    switch (name) {
      case _text:
        returnWidget = const Text(
          'Hello, Ruth! How are you?',
          textAlign: TextAlign.center,
          overflow: TextOverflow.ellipsis,
          style: TextStyle(fontWeight: FontWeight.bold),
        );
        break;
      case _textEllipsis:
        returnWidget = ConstrainedBox(
          constraints: const BoxConstraints(maxWidth: 100),
          child: const Text(
            'Hello, Ruth! How are you?',
            textAlign: TextAlign.center,
            overflow: TextOverflow.ellipsis,
            style: TextStyle(fontWeight: FontWeight.bold),
          ),
        );
        break;
      case _textRich:
        returnWidget = const Text.rich(
          TextSpan(
            text: 'Hello', // default text style
            children: <TextSpan>[
              TextSpan(
                text: ' beautiful ',
                style: TextStyle(fontStyle: FontStyle.italic),
              ),
              TextSpan(
                text: 'world',
                style: TextStyle(fontWeight: FontWeight.bold),
              ),
            ],
          ),
        );
        break;
      case _textBorder:
        returnWidget = ConstrainedBox(
          constraints: const BoxConstraints(maxWidth: 200),
          child: Stack(
            children: <Widget>[
              // Stroked text as border.
              Text(
                'Greetings, planet!',
                style: TextStyle(
                  fontSize: 40,
                  foreground: Paint()
                    ..style = PaintingStyle.stroke
                    ..strokeWidth = 6
                    ..color = Colors.blue[700]!,
                ),
              ),
              // Solid text as fill.
              Text(
                'Greetings, planet!',
                style: TextStyle(
                  fontSize: 40,
                  color: Colors.grey[300],
                ),
              ),
            ],
          ),
        );
        break;
      case _textGradient:
        returnWidget = ConstrainedBox(
          constraints: const BoxConstraints(maxWidth: 200),
          child: Stack(
            children: <Widget>[
              // Gradient text.
              Text(
                'Greetings, planet!',
                style: TextStyle(
                    fontSize: 40,
                    foreground: Paint()
                      ..shader = ui.Gradient.linear(
                        const Offset(0, 20),
                        const Offset(150, 20),
                        <Color>[
                          Colors.red,
                          Colors.yellow,
                        ],
                      )),
              ),
            ],
          ),
        );
        break;
      default:
        returnWidget = const Text('Error');
        break;
    }

    return ConstrainedBox(
      key: UniqueKey(),
      constraints: BoxConstraints.tight(const Size(240.0, 140.0)),
      child: Container(
        alignment: FractionalOffset.center,
        padding: const EdgeInsets.all(5.0),
        color: Colors.white,
        child: returnWidget,
      ),
    );
  }