-
Notifications
You must be signed in to change notification settings - Fork 1
/
scaffold.dart
48 lines (43 loc) · 1.59 KB
/
scaffold.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:platty/src/widgets/material_patcher.dart';
import 'package:platty/src/widgets/navigation_bar.dart';
import 'package:platty/src/widgets/platform.dart';
/// Adapts the widget to a [Scaffold] on Android and [CupertinoPageScaffold] on iOS.
/// This widget does not attempt to provide [FloatingActionButton] support on Android. If you need
/// that, use the [Scaffold] directly.
class PScaffold extends PlatformAdaptingWidget {
final Widget child;
final PNavigationBar appBar;
final Color backgroundColor;
/// On iOS see [CupertinoPageScaffold.resizeToAvoidBottomInset]
/// On Android see [Scaffold.resizeToAvoidBottomInset]
final resizeToAvoidBottomInset;
PScaffold(
{Key key,
@required this.child,
this.appBar,
this.backgroundColor,
this.resizeToAvoidBottomInset = true,
TargetPlatform renderPlatform})
: super(key: key, renderPlatform: renderPlatform);
@override
get renderMaterial => (BuildContext context) {
return Scaffold(
body: child,
appBar: appBar,
backgroundColor: backgroundColor,
resizeToAvoidBottomInset: resizeToAvoidBottomInset,
);
};
@override
get renderCupertino => (BuildContext context) => MaterialPatcher(
child: CupertinoPageScaffold(
child: child,
navigationBar: appBar,
backgroundColor: backgroundColor ?? Colors.white,
resizeToAvoidBottomInset: resizeToAvoidBottomInset,
),
);
}