buildEditor method

  1. @override
Widget buildEditor(
  1. BuildContext context
)
override

Implementation

@override
Widget buildEditor(BuildContext context) {
  return Column(
    crossAxisAlignment: CrossAxisAlignment.start,
    children: [
      const Text('Animation Speed'),
      const SizedBox(height: 8),
      ListenableBuilder(
        listenable: this,
        builder: (context, child) => SliderTheme(
          data: Theme.of(context).sliderTheme.copyWith(
                // ignore: deprecated_member_use
                showValueIndicator: ShowValueIndicator.always,
              ),
          child: Row(
            spacing: 12,
            children: [
              Text('${(value).toStringAsFixed(1)}x'),
              Flexible(
                child: Slider(
                  label: '${value.toStringAsFixed(1)}x',
                  value: value,
                  min: .1,
                  max: 4,
                  padding: EdgeInsets.symmetric(horizontal: 4),
                  onChangeStart: (value) => timeDilation = 1,
                  onChanged: (double value) => this.value = value,
                  onChangeEnd: (value) => timeDilation = 1 / value,
                ),
              ),
              AnimatedOpacity(
                opacity: value != 1 ? 1.0 : 0.0,
                duration: const Duration(milliseconds: 160),
                child: IgnorePointer(
                  ignoring: value == 1,
                  child: IconButton(
                    onPressed: () => timeDilation = value = 1,
                    icon: Icon(Icons.replay_outlined),
                  ),
                ),
              )
            ],
          ),
        ),
      ),
    ],
  );
}