In Flutter I have showAdaptiveDialog
which on most platforms this function will act the same as showDialog, except for iOS and macOS, in which case it will act the same as showCupertinoDialog. Is there any in Flutter which could replace cupertinoswitch
to be platform independent?
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:note_app/theme/theme_provider.dart';
import 'package:provider/provider.dart';
class SettingsPage extends StatelessWidget {
const SettingsPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Theme.of(context).colorScheme.background,
appBar: AppBar(
elevation: 0,
backgroundColor: Colors.transparent,
foregroundColor: Theme.of(context).colorScheme.inversePrimary,
),
body: Row(
children: [
//dark mode
Text("Dark Mode"),
// swith toggle
CupertinoSwitch(
value:
Provider.of<ThemeProvider>(context, listen: false).isDarkMode,
onChanged: (value) =>
Provider.of<ThemeProvider>(context, listen: false)
.toggleTheme(),
)
],
),
);
}
}