Skip to content

Commit bb0dedd

Browse files
committed
url launcher added in example main
1 parent 7271db6 commit bb0dedd

File tree

8 files changed

+1112
-1096
lines changed

8 files changed

+1112
-1096
lines changed

example/lib/main.dart

Lines changed: 45 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,11 @@ class MyHomePage extends StatefulWidget {
2020
}
2121

2222
class _MyHomePageState extends State<MyHomePage> {
23-
24-
_launchPlayStore() async {
25-
const url = 'https://play.google.com/store/apps/details?id=dev.getflutter.appkit';
23+
Future _launchUrl(url) async {
2624
if (await canLaunch(url)) {
27-
await launch(url);
28-
} else {
29-
throw 'Could not launch $url';
30-
}
31-
}
32-
_launchGitHub() async {
33-
const url = 'https://github.com/ionicfirebaseapp/getflutter-app-kit';
34-
if (await canLaunch(url)) {
35-
await launch(url);
36-
} else {
37-
throw 'Could not launch $url';
25+
return await launch(url);
3826
}
27+
return Future.value(false);
3928
}
4029

4130
@override
@@ -53,43 +42,65 @@ class _MyHomePageState extends State<MyHomePage> {
5342
const Padding(
5443
padding: EdgeInsets.only(bottom: 25),
5544
child: Center(
56-
child: Text('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do ',
57-
style: TextStyle(fontSize: 16, color: GFColors.WHITE, ),
45+
child: Text(
46+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do ',
47+
style: TextStyle(
48+
fontSize: 16,
49+
color: GFColors.WHITE,
50+
),
5851
textAlign: TextAlign.center,
5952
),
6053
),
6154
),
6255
GFButton(
63-
size: GFSize.large,
64-
text: 'View on Github',
65-
textStyle: const TextStyle(fontSize: 16, color: GFColors.WHITE, ),
66-
icon: SvgPicture.asset('lib/assets/github.svg', height: 22,),
67-
color: GFColors.SUCCESS,
68-
blockButton: true,
69-
onPressed: _launchGitHub
70-
),
56+
size: GFSize.large,
57+
text: 'View on Github',
58+
textStyle: const TextStyle(
59+
fontSize: 16,
60+
color: GFColors.WHITE,
61+
),
62+
icon: SvgPicture.asset(
63+
'lib/assets/github.svg',
64+
height: 22,
65+
),
66+
color: GFColors.SUCCESS,
67+
blockButton: true,
68+
onPressed: () {
69+
_launchUrl(
70+
'https://github.com/ionicfirebaseapp/getflutter-app-kit');
71+
}),
7172
],
7273
),
7374
Column(
7475
children: <Widget>[
7576
const Padding(
7677
padding: EdgeInsets.only(bottom: 25),
7778
child: Center(
78-
child: Text('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do ',
79-
style: TextStyle(fontSize: 16, color: GFColors.WHITE, ),
79+
child: Text(
80+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do ',
81+
style: TextStyle(
82+
fontSize: 16,
83+
color: GFColors.WHITE,
84+
),
8085
textAlign: TextAlign.center,
8186
),
8287
),
8388
),
8489
GFButton(
85-
size: GFSize.large,
86-
text: 'View on Playstore',
87-
textStyle: const TextStyle(fontSize: 16, color: GFColors.WHITE),
88-
icon: SvgPicture.asset('lib/assets/playstore.svg', height: 20,),
89-
color: GFColors.SUCCESS,
90-
blockButton: true,
91-
onPressed: _launchPlayStore
92-
),
90+
size: GFSize.large,
91+
text: 'View on Playstore',
92+
textStyle:
93+
const TextStyle(fontSize: 16, color: GFColors.WHITE),
94+
icon: SvgPicture.asset(
95+
'lib/assets/playstore.svg',
96+
height: 20,
97+
),
98+
color: GFColors.SUCCESS,
99+
blockButton: true,
100+
onPressed: () {
101+
_launchUrl(
102+
'https://play.google.com/store/apps/details?id=dev.getflutter.appkit');
103+
}),
93104
],
94105
),
95106
],

lib/components/appbar/gf_appbar.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ class _GFAppBarState extends State<GFAppBar> {
421421
);
422422
}
423423

424-
if(showSearchBar) {
424+
if (showSearchBar) {
425425
searchBar = TextField(
426426
cursorColor: widget.searchBarColorTheme,
427427
style: widget.searchTextStyle,
Lines changed: 106 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,106 @@
1-
import 'package:flutter/widgets.dart';
2-
3-
/// A widget that positions its child to a fraction of the total available space.
4-
class FractionallyAlignedSizedBox extends StatelessWidget {
5-
/// Creates a widget that positions its child to a fraction of the total available space.
6-
///
7-
/// Only two out of the three horizontal values ([leftFactor], [rightFactor],
8-
/// [widthFactor]), and only two out of the three vertical values ([topFactor],
9-
/// [bottomFactor], [heightFactor]), can be set. In each case, at least one of
10-
/// the three must be null.
11-
///
12-
/// If non-null, the [widthFactor] and [heightFactor] arguments must be
13-
/// non-negative.
14-
FractionallyAlignedSizedBox({
15-
Key key,
16-
@required this.child,
17-
this.leftFactor,
18-
this.topFactor,
19-
this.rightFactor,
20-
this.bottomFactor,
21-
this.widthFactor,
22-
this.heightFactor,
23-
}) : assert(
24-
leftFactor == null || rightFactor == null || widthFactor == null),
25-
assert(
26-
topFactor == null || bottomFactor == null || heightFactor == null),
27-
assert(widthFactor == null || widthFactor >= 0.0),
28-
assert(heightFactor == null || heightFactor >= 0.0),
29-
super(key: key);
30-
31-
/// The relative distance that the child's left edge is inset from the left of the parent.
32-
final double leftFactor;
33-
34-
/// The relative distance that the child's top edge is inset from the top of the parent.
35-
final double topFactor;
36-
37-
/// The relative distance that the child's right edge is inset from the right of the parent.
38-
final double rightFactor;
39-
40-
/// The relative distance that the child's bottom edge is inset from the bottom of the parent.
41-
final double bottomFactor;
42-
43-
/// The child's width relative to its parent's width.
44-
final double widthFactor;
45-
46-
/// The child's height relative to its parent's height.
47-
final double heightFactor;
48-
49-
/// The widget below this widget in the tree.
50-
final Widget child;
51-
52-
@override
53-
Widget build(BuildContext context) {
54-
double dx = 0;
55-
double dy = 0;
56-
double width = widthFactor;
57-
double height = heightFactor;
58-
59-
if (widthFactor == null) {
60-
final left = leftFactor ?? 0;
61-
final right = rightFactor ?? 0;
62-
width = 1 - left - right;
63-
64-
if (width != 1) {
65-
dx = left / (1.0 - width);
66-
}
67-
}
68-
69-
if (heightFactor == null) {
70-
final top = topFactor ?? 0;
71-
final bottom = bottomFactor ?? 0;
72-
height = 1 - top - bottom;
73-
if (height != 1) {
74-
dy = top / (1.0 - height);
75-
}
76-
}
77-
78-
if (widthFactor != null && widthFactor != 1) {
79-
if (leftFactor != null) {
80-
dx = leftFactor / (1 - widthFactor);
81-
} else if (leftFactor == null && rightFactor != null) {
82-
dx = (1 - widthFactor - rightFactor) / (1 - widthFactor);
83-
}
84-
}
85-
86-
if (heightFactor != null && heightFactor != 1) {
87-
if (topFactor != null) {
88-
dy = topFactor / (1 - heightFactor);
89-
} else if (topFactor == null && bottomFactor != null) {
90-
dy = (1 - heightFactor - bottomFactor) / (1 - heightFactor);
91-
}
92-
}
93-
94-
return Align(
95-
alignment: FractionalOffset(
96-
dx,
97-
dy,
98-
),
99-
child: FractionallySizedBox(
100-
widthFactor: width,
101-
heightFactor: height,
102-
child: child,
103-
),
104-
);
105-
}
106-
}
1+
//import 'package:flutter/widgets.dart';
2+
//
3+
///// A widget that positions its child to a fraction of the total available space.
4+
//class FractionallyAlignedSizedBox extends StatelessWidget {
5+
// /// Creates a widget that positions its child to a fraction of the total available space.
6+
// ///
7+
// /// Only two out of the three horizontal values ([leftFactor], [rightFactor],
8+
// /// [widthFactor]), and only two out of the three vertical values ([topFactor],
9+
// /// [bottomFactor], [heightFactor]), can be set. In each case, at least one of
10+
// /// the three must be null.
11+
// ///
12+
// /// If non-null, the [widthFactor] and [heightFactor] arguments must be
13+
// /// non-negative.
14+
// FractionallyAlignedSizedBox({
15+
// Key key,
16+
// @required this.child,
17+
// this.leftFactor,
18+
// this.topFactor,
19+
// this.rightFactor,
20+
// this.bottomFactor,
21+
// this.widthFactor,
22+
// this.heightFactor,
23+
// }) : assert(
24+
// leftFactor == null || rightFactor == null || widthFactor == null),
25+
// assert(
26+
// topFactor == null || bottomFactor == null || heightFactor == null),
27+
// assert(widthFactor == null || widthFactor >= 0.0),
28+
// assert(heightFactor == null || heightFactor >= 0.0),
29+
// super(key: key);
30+
//
31+
// /// The relative distance that the child's left edge is inset from the left of the parent.
32+
// final double leftFactor;
33+
//
34+
// /// The relative distance that the child's top edge is inset from the top of the parent.
35+
// final double topFactor;
36+
//
37+
// /// The relative distance that the child's right edge is inset from the right of the parent.
38+
// final double rightFactor;
39+
//
40+
// /// The relative distance that the child's bottom edge is inset from the bottom of the parent.
41+
// final double bottomFactor;
42+
//
43+
// /// The child's width relative to its parent's width.
44+
// final double widthFactor;
45+
//
46+
// /// The child's height relative to its parent's height.
47+
// final double heightFactor;
48+
//
49+
// /// The widget below this widget in the tree.
50+
// final Widget child;
51+
//
52+
// @override
53+
// Widget build(BuildContext context) {
54+
// double dx = 0;
55+
// double dy = 0;
56+
// double width = widthFactor;
57+
// double height = heightFactor;
58+
//
59+
// if (widthFactor == null) {
60+
// final left = leftFactor ?? 0;
61+
// final right = rightFactor ?? 0;
62+
// width = 1 - left - right;
63+
//
64+
// if (width != 1) {
65+
// dx = left / (1.0 - width);
66+
// }
67+
// }
68+
//
69+
// if (heightFactor == null) {
70+
// final top = topFactor ?? 0;
71+
// final bottom = bottomFactor ?? 0;
72+
// height = 1 - top - bottom;
73+
// if (height != 1) {
74+
// dy = top / (1.0 - height);
75+
// }
76+
// }
77+
//
78+
// if (widthFactor != null && widthFactor != 1) {
79+
// if (leftFactor != null) {
80+
// dx = leftFactor / (1 - widthFactor);
81+
// } else if (leftFactor == null && rightFactor != null) {
82+
// dx = (1 - widthFactor - rightFactor) / (1 - widthFactor);
83+
// }
84+
// }
85+
//
86+
// if (heightFactor != null && heightFactor != 1) {
87+
// if (topFactor != null) {
88+
// dy = topFactor / (1 - heightFactor);
89+
// } else if (topFactor == null && bottomFactor != null) {
90+
// dy = (1 - heightFactor - bottomFactor) / (1 - heightFactor);
91+
// }
92+
// }
93+
//
94+
// return Align(
95+
// alignment: FractionalOffset(
96+
// dx,
97+
// dy,
98+
// ),
99+
// child: FractionallySizedBox(
100+
// widthFactor: width,
101+
// heightFactor: height,
102+
// child: child,
103+
// ),
104+
// );
105+
// }
106+
//}

0 commit comments

Comments
 (0)