starwars 0.5.2
starwars: ^0.5.2 copied to clipboard
Animated Star Wars themed Flutter widgets. Includes Bb8Toggle — a pixel-perfect BB-8 switch with Tatooine scenery, stars, and day/night transitions on iOS, Android, and Web.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:starwars/starwars.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(const ExampleApp());
}
class ExampleApp extends StatefulWidget {
const ExampleApp({super.key});
@override
State<ExampleApp> createState() => _ExampleAppState();
}
class _ExampleAppState extends State<ExampleApp> {
bool isOn = false;
bool enabled = true;
double size = 32;
@override
Widget build(BuildContext context) {
final background = isOn
? const Color(0xFF101820)
: const Color(0xFFE8E8E8);
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xFFDE7D2F)),
useMaterial3: true,
),
home: Scaffold(
backgroundColor: background,
appBar: AppBar(
title: const Text('starwars · Bb8Toggle'),
backgroundColor: background,
foregroundColor: isOn ? Colors.white : Colors.black87,
elevation: 0,
),
body: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 420),
child: Padding(
padding: const EdgeInsets.all(24),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
isOn ? 'Night mode on Tatooine' : 'Day mode on Tatooine',
style: Theme.of(context).textTheme.titleMedium?.copyWith(
color: isOn ? Colors.white70 : Colors.black54,
),
),
const SizedBox(height: 24),
Bb8Toggle(
value: isOn,
onChanged: enabled
? (value) => setState(() => isOn = value)
: null,
size: size,
semanticsLabel: 'Dark mode',
),
const SizedBox(height: 32),
Text(
'Size: ${size.toInt()}',
style: TextStyle(
color: isOn ? Colors.white70 : Colors.black54,
),
),
Slider(
value: size,
min: 16,
max: 48,
divisions: 8,
label: size.toInt().toString(),
onChanged: (value) => setState(() => size = value),
),
SwitchListTile(
title: Text(
'Enabled',
style: TextStyle(
color: isOn ? Colors.white : Colors.black87,
),
),
value: enabled,
onChanged: (value) => setState(() => enabled = value),
),
],
),
),
),
),
),
);
}
}