Skip to main content

spotlyt 1.0.0 copy "spotlyt: ^1.0.0" to clipboard
spotlyt: ^1.0.0 copied to clipboard

A simple spotlight overlay for highlighting widgets in Flutter apps.

example/lib/main.dart

// ignore_for_file: deprecated_member_use

import 'package:flutter/material.dart';

import 'package:spotlyt/spotlyt.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Spotlyt Example',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        colorScheme: .fromSeed(seedColor: Colors.deepPurple),
        scaffoldBackgroundColor: Color.fromARGB(255, 13, 14, 16),
        useMaterial3: true,
      ),
      home: const ExampleScreen(),
    );
  }
}

class ExampleScreen extends StatefulWidget {
  const ExampleScreen({super.key});

  @override
  State<ExampleScreen> createState() => _ExampleScreenState();
}

class _ExampleScreenState extends State<ExampleScreen> {
  final _summaryCardKey = GlobalKey();
  final _startButtonKey = GlobalKey();
  final _firstExerciseKey = GlobalKey();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: const Color(0xFF050509),
      appBar: AppBar(
        backgroundColor: Colors.transparent,
        elevation: 0,
        title: const Text(
          "Today's workout",
          style: TextStyle(fontWeight: FontWeight.w700, color: Colors.white),
        ),
        actions: [
          IconButton(
            icon: const Icon(Icons.tips_and_updates_outlined, color: Colors.white),
            onPressed: _showShowcase,
          ),
          IconButton(
            icon: const Icon(Icons.close, color: Colors.white),
            onPressed: Spotlyt.instance.hide,
          ),
        ],
      ),
      body: SafeArea(
        child: Padding(
          padding: const EdgeInsets.fromLTRB(16, 12, 16, 16),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              const Text('Remaining time', style: TextStyle(color: Colors.white70, fontSize: 14)),
              const SizedBox(height: 4),
              const Text(
                '24:15',
                style: TextStyle(
                  fontSize: 40,
                  fontWeight: FontWeight.w800,
                  letterSpacing: 1.5,
                  color: Colors.white,
                ),
              ),
              const SizedBox(height: 24),
              Container(
                key: _summaryCardKey,
                padding: const EdgeInsets.all(16),
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(24),
                  gradient: const LinearGradient(
                    begin: Alignment.topLeft,
                    end: Alignment.bottomRight,
                    colors: [Color(0xFF23213A), Color(0xFF111016)],
                  ),
                  border: Border.all(color: Colors.white12),
                ),
                child: Row(
                  children: [
                    Container(
                      width: 60,
                      height: 60,
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(18),
                        image: const DecorationImage(
                          image: NetworkImage(
                            'https://images.pexels.com/photos/3823063/pexels-photo-3823063.jpeg',
                          ),
                          fit: BoxFit.cover,
                        ),
                      ),
                    ),
                    const SizedBox(width: 16),
                    const Expanded(
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text(
                            'Full body strength',
                            style: TextStyle(
                              fontSize: 18,
                              fontWeight: FontWeight.w700,
                              color: Colors.white,
                            ),
                          ),
                          SizedBox(height: 4),
                          Text(
                            '40 min · Intermediate',
                            style: TextStyle(fontSize: 13, color: Colors.white70),
                          ),
                        ],
                      ),
                    ),
                    const SizedBox(width: 12),
                    FilledButton(
                      key: _startButtonKey,
                      onPressed: () {
                        Spotlyt.instance.hide();
                      },
                      style: FilledButton.styleFrom(
                        padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
                        shape: const StadiumBorder(),
                      ),
                      child: const Text('Start now'),
                    ),
                  ],
                ),
              ),
              const SizedBox(height: 24),
              const Text(
                'Exercises',
                style: TextStyle(
                  fontSize: 16,
                  fontWeight: FontWeight.w600,
                  color: Colors.white,
                ),
              ),
              const SizedBox(height: 12),
              Expanded(
                child: ListView.separated(
                  itemCount: 6,
                  separatorBuilder: (_, _) => const SizedBox(height: 10),
                  itemBuilder: (context, index) {
                    final isSecond = index == 1;
                    return Container(
                      key: isSecond ? _firstExerciseKey : null,
                      padding: const EdgeInsets.all(14),
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(18),
                        color: const Color(0xFF14131A),
                        border: Border.all(
                          color: isSecond ? Colors.deepPurpleAccent : Colors.white10,
                          width: isSecond ? 1.2 : 0.6,
                        ),
                      ),
                      child: Row(
                        children: [
                          CircleAvatar(
                            radius: 18,
                            backgroundColor: Colors.deepPurple.withOpacity(0.2),
                            child: Text(
                              '${index + 1}',
                              style: const TextStyle(color: Colors.white),
                            ),
                          ),
                          const SizedBox(width: 12),
                          Expanded(
                            child: Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                Text(
                                  [
                                    'Squat to press',
                                    'Push ups',
                                    'Dead bug',
                                    'Reverse lunges',
                                    'Plank hold',
                                    'Glute bridge',
                                  ][index],
                                  style: const TextStyle(
                                    fontSize: 15,
                                    fontWeight: FontWeight.w600,
                                    color: Colors.white,
                                  ),
                                ),
                                const SizedBox(height: 4),
                                const Text(
                                  '3 sets · 12 reps',
                                  style: TextStyle(fontSize: 13, color: Colors.white70),
                                ),
                              ],
                            ),
                          ),
                          const SizedBox(width: 8),
                          Icon(
                            Icons.check_circle_rounded,
                            color: isSecond ? Colors.deepPurpleAccent : Colors.white24,
                          ),
                        ],
                      ),
                    );
                  },
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }

  void _showShowcase() {
    Spotlyt.instance.showMany(
      context: context,
      targets: [
        SpotlytTargetConfig(
          key: _summaryCardKey,
          padding: 12,
          borderRadius: 24,
          absorbTouchesInsideHole: false,
        ),
        SpotlytTargetConfig(
          key: _startButtonKey,
          padding: 8,
          borderRadius: 999,
          absorbTouchesInsideHole: true,
        ),
        SpotlytTargetConfig(
          key: _firstExerciseKey,
          padding: 8,
          borderRadius: 16,
          absorbTouchesInsideHole: false,
        ),
      ],
      dimColor: Colors.black.withOpacity(0.5),
      blurSigma: 14,
      dismissOnTapOutside: false,
      overlayBuilder: (context, targets) {
        final summaryRect = targets
            .firstWhere((t) => t.key == _summaryCardKey, orElse: () => targets.first)
            .rect;

        return Stack(
          children: [
            Positioned(
              left: 24,
              right: 24,
              bottom: MediaQuery.of(context).size.height - summaryRect.top + 16,
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  const Text(
                    'This is your daily session.',
                    style: TextStyle(
                      fontSize: 20,
                      fontWeight: FontWeight.w700,
                      color: Colors.white,
                    ),
                  ),
                  const SizedBox(height: 8),
                  const Text(
                    'Here you see today’s focus, duration and difficulty.',
                    style: TextStyle(fontSize: 14, color: Colors.white70),
                  ),
                ],
              ),
            ),
            Positioned(
              bottom: 40,
              left: 24,
              right: 24,
              child: Center(
                child: FilledButton(
                  onPressed: () {
                    Spotlyt.instance.hide();
                  },
                  style: FilledButton.styleFrom(
                    padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 14),
                    shape: const StadiumBorder(),
                  ),
                  child: const Text('Got it!'),
                ),
              ),
            ),
          ],
        );
      },
    );
  }
}
1
likes
0
points
19
downloads

Publisher

unverified uploader

Weekly Downloads

A simple spotlight overlay for highlighting widgets in Flutter apps.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on spotlyt