Skip to content

Instantly share code, notes, and snippets.

@swavkulinski
Created February 27, 2018 19:14
Show Gist options
  • Save swavkulinski/8f0981a6760f33da76a779da5c8a3c9d to your computer and use it in GitHub Desktop.
Save swavkulinski/8f0981a6760f33da76a779da5c8a3c9d to your computer and use it in GitHub Desktop.
PlatformWidget
import 'package:flutter/material.dart';
import 'dart:io' show Platform;
abstract class PlatformWidget<I extends Widget, A extends Widget> extends StatelessWidget {
@override
Widget build(BuildContext context) {
if(Platform.isAndroid) {
return createAndroidWidget(context);
} else if (Platform.isIOS) {
return createIosWidget(context);
}
// platform not supported returns an empty widget
return new Container();
}
I createIosWidget(BuildContext context);
A createAndroidWidget(BuildContext context);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment