flutterx_color_picker 1.1.2
flutterx_color_picker: ^1.1.2 copied to clipboard
Material color picker inspired by chrome devtools. Also includes material palettes
import 'package:flutter/material.dart';
import 'package:flutterx_application/flutterx_application.dart';
import 'package:flutterx_color_picker/flutterx_color_picker.dart';
import 'package:flutterx_utils/flutterx_utils.dart';
void main() => runApplication(name: 'Flutterx Color Picker Demo', routes: {HomeActivity.route}, theme: _appTheme);
final _appTheme = ThemeData(
primaryColor: Colors.grey[900],
colorScheme: ColorScheme.fromSwatch(
primarySwatch: MaterialColor(
Colors.grey[900]!.value,
<int, Color>{
50: Colors.grey[600]!,
100: Colors.grey[700]!,
200: Colors.grey[800]!,
300: Colors.grey[850]!,
350: Colors.grey[900]!,
400: Colors.grey[900]!,
500: Colors.grey[900]!,
600: Colors.grey[900]!,
700: Colors.grey[900]!,
800: Colors.grey[900]!,
850: Colors.grey[900]!,
900: Colors.grey[900]!,
},
)));
class HomeActivity extends StatefulWidget {
static final ActivityRoute<void> route =
ActivityRoute(location: '/home', builder: (context, args) => const HomeActivity._());
const HomeActivity._({Key? key}) : super(key: key);
@override
State<HomeActivity> createState() => _HomeActivityState();
}
class _HomeActivityState extends State<HomeActivity> {
Color _color = Colors.white;
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: Text(HomeActivity.route.location)),
body: Stack(children: [
ColorIndicator(color: _color, size: double.infinity, shape: BoxShape.rectangle),
Center(
child: Text(findAffinity(_color).toString(),
style: Theme.of(context)
.textTheme
.displayMedium!
.copyWith(color: _color.brightness.isDark ? Colors.white : Colors.black))),
]),
floatingActionButton: FloatingActionButton(
onPressed: () => ColorPicker.open(context: context,
tracks: TrackType.values.toSet(),
initialValue: _color)
.then((value) => value == null ? null : setState(() => _color = value)),
child: const Icon(Icons.color_lens_outlined),
));
}