r_padding.dart
2.15 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_screenutil/src/size_extension.dart';
import 'size_extension.dart';
class RPadding extends SingleChildRenderObjectWidget {
/// Creates a adapt widget that insets its child.
///
/// The [padding] argument must not be null.
const RPadding({
Key? key,
required Widget child,
required this.padding,
}) : super(key: key, child: child);
/// The amount of space by which to inset the child.
final EdgeInsets padding;
@override
RenderPadding createRenderObject(BuildContext context) {
return RenderPadding(
padding: padding is REdgeInsets ? padding : padding.r,
textDirection: Directionality.maybeOf(context),
);
}
}
class REdgeInsets extends EdgeInsets {
/// Creates adapt insets from offsets from the left, top, right, and bottom.
REdgeInsets.fromLTRB(double left, double top, double right, double bottom)
: super.fromLTRB(left.r, top.r, right.r, bottom.r);
/// Creates adapt insets where all the offsets are `value`.
///
/// {@tool snippet}
///
/// Adapt height-pixel margin on all sides:
///
/// ```dart
/// const REdgeInsets.all(8.0)
/// ```
/// {@end-tool}
REdgeInsets.all(double value) : super.all(value.r);
/// Creates adapt insets with symmetrical vertical and horizontal offsets.
///
/// {@tool snippet}
///
/// Adapt Eight pixel margin above and below, no horizontal margins:
///
/// ```dart
/// const REdgeInsets.symmetric(vertical: 8.0)
/// ```
/// {@end-tool}
REdgeInsets.symmetric({
double vertical = 0,
double horizontal = 0,
}) : super.symmetric(vertical: vertical.r, horizontal: horizontal.r);
/// Creates adapt insets with only the given values non-zero.
///
/// {@tool snippet}
///
/// Adapt left margin indent of 40 pixels:
///
/// ```dart
/// const REdgeInsets.only(left: 40.0)
/// ```
/// {@end-tool}
REdgeInsets.only({
double bottom = 0,
double right = 0,
double left = 0,
double top = 0,
}) : super.only(
bottom: bottom.r,
right: right.r,
left: left.r,
top: top.r,
);
}