fluffychat/lib/widgets/sentry_switch_list_tile.dart

37 lines
987 B
Dart
Raw Normal View History

2022-01-28 18:21:20 +01:00
//@dart=2.12
2021-10-26 18:50:34 +02:00
2022-01-28 18:21:20 +01:00
import 'package:flutter/material.dart';
2021-01-17 15:33:31 +01:00
2021-10-26 18:50:34 +02:00
import 'package:fluffychat/utils/sentry_controller.dart';
2021-01-17 15:33:31 +01:00
class SentrySwitchListTile extends StatefulWidget {
2021-01-22 21:39:37 +01:00
final String label;
2022-01-28 18:21:20 +01:00
const SentrySwitchListTile.adaptive({Key? key, required this.label})
: super(key: key);
2021-01-22 21:39:37 +01:00
2021-01-17 15:33:31 +01:00
@override
_SentrySwitchListTileState createState() => _SentrySwitchListTileState();
}
class _SentrySwitchListTileState extends State<SentrySwitchListTile> {
bool _enabled = false;
@override
Widget build(BuildContext context) {
return FutureBuilder<bool>(
future: SentryController.getSentryStatus(),
builder: (context, snapshot) {
_enabled = snapshot.data ?? false;
2021-11-27 10:10:29 +01:00
return SwitchListTile.adaptive(
2022-01-28 18:21:20 +01:00
title: Text(widget.label),
2021-01-17 15:33:31 +01:00
value: _enabled,
onChanged: (b) =>
SentryController.toggleSentryAction(context, b).then(
2022-01-28 18:21:20 +01:00
(_) => setState(() {}),
2021-01-17 15:33:31 +01:00
),
);
});
}
}