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) {
  final theme = Theme.of(context);

  return Scaffold(
    appBar: AppBar(title: const Text('Learning Guide')),
    body: WebContentFrame(
      variant: WebLayoutVariant.reader,
      child: ListView(
        padding: const EdgeInsets.all(16),
        children: [
          // Section 1: Mastery Levels
          Text('Mastery Levels', style: theme.textTheme.titleLarge),
          const SizedBox(height: 8),
          Text(
            'Each topic progresses through 6 mastery levels. '
            'Your goal is to advance each topic to full mastery.',
            style: theme.textTheme.bodyMedium,
          ),
          const SizedBox(height: 16),
          const MasteryProgressStepper(
            currentMastery: 'mastery',
            showNextStep: false,
          ),
          const SizedBox(height: 16),
          ..._masteryLevels.map(
            (level) => _MasteryLevelCard(
              name: level.name,
              description: level.description,
              color: level.color,
              icon: level.icon,
            ),
          ),

          const SizedBox(height: 32),

          // Section 2: Learning Tools
          Text('Learning Tools', style: theme.textTheme.titleLarge),
          const SizedBox(height: 8),
          Text(
            'Six tools help you learn in different ways. '
            'Each tool targets a different mastery level.',
            style: theme.textTheme.bodyMedium,
          ),
          const SizedBox(height: 16),
          ..._tools.map(
            (tool) => _ToolCard(
              name: tool.name,
              description: tool.description,
              howToUse: tool.howToUse,
              icon: tool.icon,
              color: tool.color,
              requiredMastery: tool.requiredMastery,
            ),
          ),

          const SizedBox(height: 32),

          // Section 3: How to Advance
          Text('How to Advance', style: theme.textTheme.titleLarge),
          const SizedBox(height: 8),
          Text(
            'Follow this path to take any topic from scratch to mastery.',
            style: theme.textTheme.bodyMedium,
          ),
          const SizedBox(height: 16),
          ..._steps.asMap().entries.map(
            (entry) => _StepTile(
              index: entry.key,
              step: entry.value,
              isLast: entry.key == _steps.length - 1,
            ),
          ),

          const SizedBox(height: 32),

          // Section 4: Spaced Repetition
          Text('Spaced Repetition', style: theme.textTheme.titleLarge),
          const SizedBox(height: 8),
          Card(
            child: Padding(
              padding: const EdgeInsets.all(16),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Row(
                    children: [
                      const Icon(
                        Icons.refresh_rounded,
                        color: DuTaToTheme.easy,
                        size: 24,
                      ),
                      const SizedBox(width: 12),
                      Expanded(
                        child: Text(
                          'Review at the right time',
                          style: theme.textTheme.titleMedium,
                        ),
                      ),
                    ],
                  ),
                  const SizedBox(height: 12),
                  Text(
                    'The Review tab schedules cards at optimal intervals. '
                    'When you review a card:',
                    style: theme.textTheme.bodyMedium,
                  ),
                  const SizedBox(height: 8),
                  const _BulletPoint(
                    text:
                        '"Again" — card comes back soon (you need more practice)',
                  ),
                  const _BulletPoint(
                    text: '"Hard" — shorter interval (needs reinforcement)',
                  ),
                  const _BulletPoint(
                    text: '"Good" — normal interval (on track)',
                  ),
                  const _BulletPoint(
                    text: '"Easy" — longer interval (you know this well)',
                  ),
                  const SizedBox(height: 12),
                  Text(
                    'Consistent short sessions beat occasional long ones. '
                    'Aim for 10-15 minutes daily.',
                    style: theme.textTheme.bodySmall?.copyWith(
                      fontStyle: FontStyle.italic,
                      color: theme.colorScheme.onSurfaceVariant,
                    ),
                  ),
                ],
              ),
            ),
          ),
          const SizedBox(height: 32),
        ],
      ),
    ),
  );
}