mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2025-11-08 20:50:04 +00:00
New Example - Platform Adaptive Example (#121)
* Adding Platform Adaptive Example * Adding screenshots
This commit is contained in:
21
using_platform_adaptive/lib/platform_adaptive.dart
Normal file
21
using_platform_adaptive/lib/platform_adaptive.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
abstract class PlatformAdaptiveWidget extends StatelessWidget {
|
||||
const PlatformAdaptiveWidget({super.key, this.forcePlatform});
|
||||
|
||||
final TargetPlatform? forcePlatform;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
switch (forcePlatform ?? defaultTargetPlatform) {
|
||||
case TargetPlatform.iOS:
|
||||
return buildIOS(context);
|
||||
default:
|
||||
return buildAndroid(context);
|
||||
}
|
||||
}
|
||||
|
||||
Widget buildIOS(BuildContext context);
|
||||
Widget buildAndroid(BuildContext context);
|
||||
}
|
||||
Reference in New Issue
Block a user