flutterx_color_picker 1.1.2 copy "flutterx_color_picker: ^1.1.2" to clipboard
flutterx_color_picker: ^1.1.2 copied to clipboard

Material color picker inspired by chrome devtools. Also includes material palettes

example/lib/main.dart

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),
      ));
}
1
likes
135
points
93
downloads

Publisher

unverified uploader

Weekly Downloads

Material color picker inspired by chrome devtools. Also includes material palettes

Repository (GitLab)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, flutterx_application, flutterx_live_data, flutterx_utils

More

Packages that depend on flutterx_color_picker