build method

  1. @override
Widget build(
  1. BuildContext context
)
override

Describes the part of the user interface represented by this widget.

The framework calls this method when this widget is inserted into the tree in a given BuildContext and when the dependencies of this widget change (e.g., an InheritedWidget referenced by this widget changes). This method can potentially be called in every frame and should not have any side effects beyond building a widget.

The framework replaces the subtree below this widget with the widget returned by this method, either by updating the existing subtree or by removing the subtree and inflating a new subtree, depending on whether the widget returned by this method can update the root of the existing subtree, as determined by calling Widget.canUpdate.

Typically implementations return a newly created constellation of widgets that are configured with information from this widget's constructor and from the given BuildContext.

The given BuildContext contains information about the location in the tree at which this widget is being built. For example, the context provides the set of inherited widgets for this location in the tree. A given widget might be built with multiple different BuildContext arguments over time if the widget is moved around the tree or if the widget is inserted into the tree in multiple places at once.

The implementation of this method must only depend on:

If a widget's build method is to depend on anything else, use a StatefulWidget instead.

See also:

  • StatelessWidget, which contains the discussion on performance considerations.

Implementation

@override
Widget build(BuildContext context) {
  return DefaultTabController(
    length: 4,
    child: Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.transparent,
        elevation: 0,
        toolbarHeight: 0, // Hide the standard toolbar
        bottom: TabBar(
          padding: const EdgeInsets.symmetric(horizontal: 16),
          indicatorColor: Theme.of(context).colorScheme.primary,
          indicatorSize: TabBarIndicatorSize.label,
          indicatorWeight: 3,
          labelColor: Theme.of(context).colorScheme.primary,
          unselectedLabelColor: Colors.grey,
          labelStyle: const TextStyle(fontWeight: FontWeight.bold),
          tabs: const [
            Tab(text: 'Guide'),
            Tab(text: 'Opening'),
            Tab(text: 'Closing'),
            Tab(text: 'Wisdom'),
          ],
        ),
      ),
      body: TabBarView(
        children: [
          SingleChildScrollView(
            padding: const EdgeInsets.all(24.0),
            child: AppMarkdownBody(
              data: '# How to Meditate\n'
                  '  \n'
                  '---\n'
                  '  \n'
                  'To meditate you must learn to be still.  \n'
                  'Meditation is perfect stillness of body and spirit.  \n'
                  '  \n'
                  'The stillness of body we achieve by sitting still. '
                  'When you begin to meditate, take a couple of moments '
                  'to assume a comfortable posture. '
                  'The only essential rule is to have your spine '
                  'as upright as possible. '
                  'Your eyes should be lightly closed. '
                  '  \n'
                  'The way to a stillness of spirit is to learn to say silently '
                  'in the depth of your spirit a word or a short phrase. '
                  'To repeat that word over and over again. '
                  'The recommended word is the Aramaic word Maranatha.'
                  'Say it slowly in four equally stressed syllables. \n'
                  '  \n'
                  'Ma, Ra, Na, Tha.  \n'
                  '  \n'
                  'Say it silently. '
                  'Don\'t move your lips but recite it interiorly. '
                  'Recite your word from beginning to end. \n'
                  '  \n'
                  'Let go of your thoughts, of your ideas, of your imagination. '
                  'Don\'t think.  '
                  'Don\'t use any words other than your one word. '
                  'Just say the word in the depth of your spirit and listen to it. '
                  'Concentrate upon it with all your attention. '
                  '  \n'
                  'Maranatha.  \n'
                  '  \n'
                  'And that\'s all you have to do.  \n'
                  '  \n'
                  '---\n'
                  '  \n'
                  '*John Main OSB*',
              styleSheet:
                  MarkdownStyleSheet.fromTheme(Theme.of(context)).copyWith(
                p: const TextStyle(fontSize: 18, height: 1.6),
                h1: TextStyle(
                  fontSize: 28,
                  fontWeight: FontWeight.bold,
                  color: Theme.of(context).colorScheme.primary,
                ),
              ),
            ),
          ),
          SingleChildScrollView(
            padding: const EdgeInsets.all(24.0),
            child: AppMarkdownBody(
              data: '# Opening Prayer\n'
                  '---\n'
                  'Heavenly Father.  \n'
                  '  \n'
                  'Open our hearts to the silent '
                  'presence of the spirit of your son.  \n'
                  '  \n'
                  'Lead us into that mysterious silence '
                  'where your love is revealed to all who call.  \n'
                  '  \n'
                  'Maranatha.  \n'
                  'Come Lord Jesus.  \n'
                  '  \n'
                  '---\n'
                  '  \n'
                  '*John Main OSB*',
              styleSheet:
                  MarkdownStyleSheet.fromTheme(Theme.of(context)).copyWith(
                p: const TextStyle(fontSize: 18, height: 1.6),
                h1: TextStyle(
                  fontSize: 28,
                  fontWeight: FontWeight.bold,
                  color: Theme.of(context).colorScheme.primary,
                ),
              ),
            ),
          ),
          SingleChildScrollView(
            padding: const EdgeInsets.all(24.0),
            child: AppMarkdownBody(
              data: '# Closing Prayer\n'
                  '  \n'
                  '---\n'
                  '  \n'
                  'May this group be a true spiritual home '
                  'for the seeker, a friend for the lonely, '
                  'a guide for the confused.  \n'
                  '  \n'
                  'May those who pray here be strengthened '
                  'by the Holy Spirit to serve all who come '
                  'and to receive them as Christ himself.  \n'
                  '  \n'
                  'In the silence of this group may all the suffering, '
                  'violence and confusion of the world encounter '
                  'the power that will console, renew, and uplift the '
                  'human spirit.  \n'
                  '  \n'
                  'May this silence be a power to open the hearts of '
                  'men and women to the vision of God, and so to '
                  'each other, in love and peace, justice and human '
                  'dignity.  \n'
                  '  \n'
                  'May the beauty of the Divine Life fill the hearts of '
                  'all who pray here with joyful hope. '
                  '  \n'
                  'May all who come here weighed down by the '
                  'problems of humanity leave giving thanks for the '
                  'wonder of human life.  \n'
                  '  \n'
                  'We make this prayer through Christ our Lord. '
                  '  \n'
                  'Amen\n'
                  '  \n'
                  '---\n'
                  '  \n'
                  '\n*Laurence Freeman OSB*',
              styleSheet:
                  MarkdownStyleSheet.fromTheme(Theme.of(context)).copyWith(
                p: const TextStyle(fontSize: 18, height: 1.6),
                h1: TextStyle(
                  fontSize: 28,
                  fontWeight: FontWeight.bold,
                  color: Theme.of(context).colorScheme.primary,
                ),
              ),
            ),
          ),
          SingleChildScrollView(
            padding: const EdgeInsets.all(24.0),
            child: AppMarkdownBody(
              data: '''
> Quiet the mind and the soul will speak.

*Buddha*
---

> When you pray, go into your inner room,
> close the door and pray to your Father,
> who is there in that secret place...

*Matthew 6:6*
---

> When you pray, do not babble like the
> pagans, who think the more they say the
> more likely they are to be heard...

*Matthew 6:7*
---

> Because I live, you too will live.
> Then you will know that I am in my Father,
> and you in me, and I in you.

*John 14:20*
---

> Remain in me, as I in you. As a branch
> cannot bear fruit all by itself, unless it
> remains part of the vine, neither can you
> unless you remain in me. I am the vine,
> you are the branches. Whoever remains in
> me, with me in him, bears fruit in plenty;
> for cut off from me you can do nothing.
> I have loved you just as the Father has
> loved me. Remain in my love.

*John 15:4-5,9*
---

''',
              styleSheet:
                  MarkdownStyleSheet.fromTheme(Theme.of(context)).copyWith(
                p: const TextStyle(fontSize: 18, height: 1.6),
                blockquote: TextStyle(
                  fontSize: 20,
                  fontStyle: FontStyle.italic,
                  color: Theme.of(context).colorScheme.primary,
                ),
                blockquotePadding:
                    const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
                blockquoteDecoration: BoxDecoration(
                  border: Border(
                    left: BorderSide(
                      color: Theme.of(context)
                          .colorScheme
                          .primary
                          .withValues(alpha: 0.3),
                      width: 4,
                    ),
                  ),
                ),
              ),
            ),
          ),
        ],
      ),
    ),
  );
}