prasule/lib/pw/platformwidget.dart

30 lines
847 B
Dart

// SPDX-FileCopyrightText: (C) 2024 Matyáš Caras
//
// SPDX-License-Identifier: AGPL-3.0-only
import 'dart:io';
import 'package:flutter/material.dart';
/// Abstract class used to create widgets for the respective platform UI library
abstract class PlatformWidget<A extends Widget, I extends Widget>
extends StatelessWidget {
/// Abstract class used to create widgets
/// for the respective platform UI library
const PlatformWidget({super.key});
@override
Widget build(BuildContext context) {
if (Platform.isIOS || Platform.isMacOS) {
return createIosWidget(context);
} else {
return createAndroidWidget(context);
}
}
/// The widget that will be shown on Android
A createAndroidWidget(BuildContext context);
/// The widget that will be shown on iOS
I createIosWidget(BuildContext context);
}