Skip to content

Commit bbc6d0c

Browse files
authored
Merge pull request #37 from shravyackm/gf_border
Gf border
2 parents bd4ea44 + 771207c commit bbc6d0c

File tree

7 files changed

+386
-17
lines changed

7 files changed

+386
-17
lines changed

example/lib/main.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ class MyApp extends StatelessWidget {
1414
);
1515
}
1616

17-
//
1817
class MyHomePage extends StatefulWidget {
1918
@override
2019
_MyHomePageState createState() => _MyHomePageState();

example/pubspec.lock

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,66 @@ packages:
77
name: async
88
url: "https://pub.dartlang.org"
99
source: hosted
10+
<<<<<<< HEAD
11+
version: "2.5.0-nullsafety"
12+
=======
1013
version: "2.4.2"
14+
>>>>>>> bd4ea44a12e13d52c4f00d32ba891d0da56fde3c
1115
boolean_selector:
1216
dependency: transitive
1317
description:
1418
name: boolean_selector
1519
url: "https://pub.dartlang.org"
1620
source: hosted
21+
<<<<<<< HEAD
22+
version: "2.1.0-nullsafety"
23+
=======
1724
version: "2.0.0"
25+
>>>>>>> bd4ea44a12e13d52c4f00d32ba891d0da56fde3c
1826
characters:
1927
dependency: transitive
2028
description:
2129
name: characters
2230
url: "https://pub.dartlang.org"
2331
source: hosted
32+
<<<<<<< HEAD
33+
version: "1.1.0-nullsafety.2"
34+
=======
2435
version: "1.0.0"
36+
>>>>>>> bd4ea44a12e13d52c4f00d32ba891d0da56fde3c
2537
charcode:
2638
dependency: transitive
2739
description:
2840
name: charcode
2941
url: "https://pub.dartlang.org"
3042
source: hosted
43+
<<<<<<< HEAD
44+
version: "1.2.0-nullsafety"
45+
=======
3146
version: "1.1.3"
47+
>>>>>>> bd4ea44a12e13d52c4f00d32ba891d0da56fde3c
3248
clock:
3349
dependency: transitive
3450
description:
3551
name: clock
3652
url: "https://pub.dartlang.org"
3753
source: hosted
54+
<<<<<<< HEAD
55+
version: "1.1.0-nullsafety"
56+
=======
3857
version: "1.0.1"
58+
>>>>>>> bd4ea44a12e13d52c4f00d32ba891d0da56fde3c
3959
collection:
4060
dependency: transitive
4161
description:
4262
name: collection
4363
url: "https://pub.dartlang.org"
4464
source: hosted
65+
<<<<<<< HEAD
66+
version: "1.15.0-nullsafety.2"
67+
=======
4568
version: "1.14.13"
69+
>>>>>>> bd4ea44a12e13d52c4f00d32ba891d0da56fde3c
4670
convert:
4771
dependency: transitive
4872
description:
@@ -63,7 +87,11 @@ packages:
6387
name: fake_async
6488
url: "https://pub.dartlang.org"
6589
source: hosted
90+
<<<<<<< HEAD
91+
version: "1.1.0-nullsafety"
92+
=======
6693
version: "1.1.0"
94+
>>>>>>> bd4ea44a12e13d52c4f00d32ba891d0da56fde3c
6795
flutter:
6896
dependency: "direct main"
6997
description: flutter
@@ -99,21 +127,29 @@ packages:
99127
name: matcher
100128
url: "https://pub.dartlang.org"
101129
source: hosted
130+
<<<<<<< HEAD
131+
version: "0.12.10-nullsafety"
132+
=======
102133
version: "0.12.8"
134+
>>>>>>> bd4ea44a12e13d52c4f00d32ba891d0da56fde3c
103135
meta:
104136
dependency: transitive
105137
description:
106138
name: meta
107139
url: "https://pub.dartlang.org"
108140
source: hosted
109-
version: "1.1.8"
141+
version: "1.3.0-nullsafety.2"
110142
path:
111143
dependency: transitive
112144
description:
113145
name: path
114146
url: "https://pub.dartlang.org"
115147
source: hosted
148+
<<<<<<< HEAD
149+
version: "1.8.0-nullsafety"
150+
=======
116151
version: "1.7.0"
152+
>>>>>>> bd4ea44a12e13d52c4f00d32ba891d0da56fde3c
117153
path_drawing:
118154
dependency: transitive
119155
description:
@@ -153,49 +189,65 @@ packages:
153189
name: source_span
154190
url: "https://pub.dartlang.org"
155191
source: hosted
192+
<<<<<<< HEAD
193+
version: "1.8.0-nullsafety"
194+
=======
156195
version: "1.7.0"
196+
>>>>>>> bd4ea44a12e13d52c4f00d32ba891d0da56fde3c
157197
stack_trace:
158198
dependency: transitive
159199
description:
160200
name: stack_trace
161201
url: "https://pub.dartlang.org"
162202
source: hosted
203+
<<<<<<< HEAD
204+
version: "1.10.0-nullsafety"
205+
=======
163206
version: "1.9.5"
207+
>>>>>>> bd4ea44a12e13d52c4f00d32ba891d0da56fde3c
164208
stream_channel:
165209
dependency: transitive
166210
description:
167211
name: stream_channel
168212
url: "https://pub.dartlang.org"
169213
source: hosted
170-
version: "2.0.0"
214+
version: "2.1.0-nullsafety"
171215
string_scanner:
172216
dependency: transitive
173217
description:
174218
name: string_scanner
175219
url: "https://pub.dartlang.org"
176220
source: hosted
177-
version: "1.0.5"
221+
version: "1.1.0-nullsafety"
178222
term_glyph:
179223
dependency: transitive
180224
description:
181225
name: term_glyph
182226
url: "https://pub.dartlang.org"
183227
source: hosted
184-
version: "1.1.0"
228+
version: "1.2.0-nullsafety"
185229
test_api:
186230
dependency: transitive
187231
description:
188232
name: test_api
189233
url: "https://pub.dartlang.org"
190234
source: hosted
235+
<<<<<<< HEAD
236+
version: "0.2.19-nullsafety"
237+
=======
191238
version: "0.2.17"
239+
>>>>>>> bd4ea44a12e13d52c4f00d32ba891d0da56fde3c
192240
typed_data:
193241
dependency: transitive
194242
description:
195243
name: typed_data
196244
url: "https://pub.dartlang.org"
197245
source: hosted
246+
<<<<<<< HEAD
247+
version: "1.3.0-nullsafety.2"
248+
=======
198249
version: "1.2.0"
250+
>>>>>>> bd4ea44a12e13d52c4f00d32ba891d0da56fde3c
199251
url_launcher:
200252
dependency: "direct main"
201253
description:
@@ -230,7 +282,7 @@ packages:
230282
name: vector_math
231283
url: "https://pub.dartlang.org"
232284
source: hosted
233-
version: "2.0.8"
285+
version: "2.1.0-nullsafety.2"
234286
xml:
235287
dependency: transitive
236288
description:
@@ -239,5 +291,9 @@ packages:
239291
source: hosted
240292
version: "4.2.0"
241293
sdks:
294+
<<<<<<< HEAD
295+
dart: ">=2.10.0-0.0.dev <2.10.0"
296+
=======
242297
dart: ">=2.9.0-14.0.dev <3.0.0"
298+
>>>>>>> bd4ea44a12e13d52c4f00d32ba891d0da56fde3c
243299
flutter: ">=1.18.0-6.0.pre <2.0.0"
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import 'dart:ui';
2+
import 'package:flutter/material.dart';
3+
import 'package:getwidget/components/border/gf_dashed_border.dart';
4+
import 'package:getwidget/types/gf_border_type.dart';
5+
6+
class GFBorder extends StatelessWidget {
7+
GFBorder({
8+
@required this.child,
9+
this.color = Colors.black,
10+
this.strokeWidth = 1,
11+
this.type = GFBorderType.Rect,
12+
this.dashedLine = const <double>[3, 1],
13+
this.padding = const EdgeInsets.all(10),
14+
this.radius = const Radius.circular(0),
15+
this.customPath,
16+
}) : assert(child != null),
17+
assert(_isValiddashedLine(dashedLine), 'Invalid dash pattern');
18+
19+
/// child of type [Widget] which can be any component or text , etc
20+
final Widget child;
21+
22+
/// padding of time [EdgeInsets] where in padding is given to the border types
23+
final EdgeInsets padding;
24+
25+
/// storkeWidth of type [double] which is used to define the thickness of the border
26+
final double strokeWidth;
27+
28+
/// color of type [Color] or GFColor which is used to change the color of the border type
29+
final Color color;
30+
31+
/// dashedLine of type [List<double>] which is used for the linear and simple dashed line of border
32+
final List<double> dashedLine;
33+
34+
/// type of [GFBorderType] which is used to define the different types of borders ie, circle, Rect, RRect and oval
35+
final GFBorderType type;
36+
37+
/// radius of type [Radius] used to give a curved border only when the border type is RRect, in other cases radius will not work
38+
final Radius radius;
39+
40+
/// customPath of type [PathBuilder] used for drawing the paths
41+
final PathBuilder customPath;
42+
43+
@override
44+
Widget build(BuildContext context) => Stack(
45+
children: <Widget>[
46+
Positioned.fill(
47+
child: CustomPaint(
48+
painter: DashedType(
49+
strokeWidth: strokeWidth,
50+
radius: radius,
51+
color: color,
52+
type: type,
53+
dashedLine: dashedLine,
54+
customPath: customPath,
55+
),
56+
),
57+
),
58+
Container(padding: padding, child: child),
59+
],
60+
);
61+
}
62+
63+
/// the value of dashedLine cannot be 0 or null, it should have some definite and proper value
64+
bool _isValiddashedLine(List<double> dash) {
65+
final Set<double> _dashSet = dash.toSet();
66+
if (_dashSet == null) {
67+
return false;
68+
}
69+
if (_dashSet.length == 1 && _dashSet.elementAt(0) == 0.0) {
70+
return false;
71+
}
72+
if (_dashSet.isEmpty) {
73+
return false;
74+
}
75+
return true;
76+
}

0 commit comments

Comments
 (0)