11import 'package:flutter/material.dart' ;
22import 'package:provider/provider.dart' ;
33import 'package:pslab/l10n/app_localizations.dart' ;
4+ import 'package:pslab/others/logger_service.dart' ;
45import 'package:pslab/providers/locator.dart' ;
56import 'package:pslab/providers/board_state_provider.dart' ;
67import 'package:pslab/view/widgets/main_scaffold_widget.dart' ;
@@ -23,13 +24,7 @@ class ConnectDeviceScreen extends StatefulWidget {
2324}
2425
2526Widget _stepText (String text) {
26- return Text (
27- text,
28- style: const TextStyle (
29- fontSize: 14 ,
30- height: 1.35 ,
31- ),
32- );
27+ return Text (text, style: const TextStyle (fontSize: 14 , height: 1.35 ));
3328}
3429
3530class _HomeScreenState extends State <ConnectDeviceScreen > {
@@ -39,10 +34,7 @@ class _HomeScreenState extends State<ConnectDeviceScreen> {
3934 void _showSnackBar (String message, {Color ? backgroundColor}) {
4035 ScaffoldMessenger .of (context).hideCurrentSnackBar ();
4136 ScaffoldMessenger .of (context).showSnackBar (
42- SnackBar (
43- content: Text (message),
44- backgroundColor: backgroundColor,
45- ),
37+ SnackBar (content: Text (message), backgroundColor: backgroundColor),
4638 );
4739 }
4840
@@ -97,9 +89,7 @@ class _HomeScreenState extends State<ConnectDeviceScreen> {
9789 child: Column (
9890 mainAxisAlignment: MainAxisAlignment .center,
9991 children: [
100- const SizedBox (
101- height: 10 ,
102- ),
92+ const SizedBox (height: 10 ),
10393 Center (
10494 child: Image .asset (
10595 provider.pslabIsConnected
@@ -114,7 +104,11 @@ class _HomeScreenState extends State<ConnectDeviceScreen> {
114104 Center (
115105 child: Container (
116106 margin: const EdgeInsets .only (
117- top: 20 , bottom: 24 , left: 40 , right: 40 ),
107+ top: 20 ,
108+ bottom: 24 ,
109+ left: 40 ,
110+ right: 40 ,
111+ ),
118112 child: Text (
119113 provider.pslabIsConnected
120114 ? '${appLocalizations .deviceConnected }\n\n ${provider .pslabVersionID }'
@@ -139,9 +133,9 @@ class _HomeScreenState extends State<ConnectDeviceScreen> {
139133 color: Theme .of (context).colorScheme.surface,
140134 borderRadius: BorderRadius .circular (12 ),
141135 border: Border .all (
142- color: Theme .of (context)
143- .dividerColor
144- .withValues (alpha: 0.6 ),
136+ color: Theme .of (
137+ context,
138+ ).dividerColor .withValues (alpha: 0.6 ),
145139 ),
146140 ),
147141 child: Column (
@@ -172,9 +166,7 @@ class _HomeScreenState extends State<ConnectDeviceScreen> {
172166 child: Center (
173167 child: Text (
174168 appLocalizations.wifiConnection,
175- style: const TextStyle (
176- fontSize: 14 ,
177- ),
169+ style: const TextStyle (fontSize: 14 ),
178170 ),
179171 ),
180172 ),
@@ -213,8 +205,11 @@ class _HomeScreenState extends State<ConnectDeviceScreen> {
213205 ),
214206 ),
215207 Container (
216- margin:
217- const EdgeInsets .only (top: 30 , left: 120 , right: 120 ),
208+ margin: const EdgeInsets .only (
209+ top: 30 ,
210+ left: 120 ,
211+ right: 120 ,
212+ ),
218213 child: Divider (color: dividerColor, height: 1 ),
219214 ),
220215 Center (
@@ -223,8 +218,14 @@ class _HomeScreenState extends State<ConnectDeviceScreen> {
223218 padding: const EdgeInsets .all (10 ),
224219 child: GestureDetector (
225220 onTap: () async {
226- await launchUrl (
227- Uri .parse (appLocalizations.pslabUrl));
221+ final uri = Uri .parse (appLocalizations.pslabUrl);
222+ if (await canLaunchUrl (uri)) {
223+ await launchUrl (uri);
224+ } else {
225+ logger.e (
226+ 'Could not launch ${appLocalizations .pslabUrl }' ,
227+ );
228+ }
228229 },
229230 child: Text (
230231 appLocalizations.whatIsPslab,
@@ -240,9 +241,7 @@ class _HomeScreenState extends State<ConnectDeviceScreen> {
240241 ),
241242 ),
242243 ),
243- const SizedBox (
244- height: 10 ,
245- ),
244+ const SizedBox (height: 10 ),
246245 ],
247246 ),
248247 ),
0 commit comments