Created
February 27, 2018 19:14
-
-
Save swavkulinski/8f0981a6760f33da76a779da5c8a3c9d to your computer and use it in GitHub Desktop.
PlatformWidget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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