11// ignore_for_file: unused_local_variable
2-
32import 'package:flutter/material.dart' ;
43import 'package:native_flutter_proxy/native_flutter_proxy.dart' ;
54
@@ -12,13 +11,15 @@ void main() async {
1211 var enabled = false ;
1312 String ? host;
1413 int ? port;
14+
1515 try {
1616 final settings = await NativeProxyReader .proxySetting;
1717 enabled = settings.enabled;
1818 host = settings.host;
1919 port = settings.port;
2020 } catch (e) {
21- print (e);
21+ // Using debugPrint instead of print for production code
22+ debugPrint ('Error fetching proxy settings: $e ' );
2223 }
2324
2425 // Enable the proxy if it is enabled and the host is not null.
@@ -27,22 +28,36 @@ void main() async {
2728 debugPrint ('proxy enabled' );
2829 }
2930
30- runApp (MyApp ());
31+ runApp (const MyApp ());
3132}
3233
34+ /// The main application widget.
35+ ///
36+ /// This widget is the root of the application.
3337class MyApp extends StatelessWidget {
38+ /// Creates a new instance of [MyApp] .
39+ const MyApp ({super .key});
40+
3441 @override
3542 Widget build (BuildContext context) {
3643 return MaterialApp (
3744 title: 'Flutter Demo' ,
3845 theme: ThemeData (primarySwatch: Colors .blue),
39- home: MyHomePage (title: 'Flutter Demo Home Page' ),
46+ home: const MyHomePage (title: 'Flutter Demo Home Page' ),
4047 );
4148 }
4249}
4350
51+ /// A widget that displays the home page of the application.
52+ ///
53+ /// This widget is stateful and keeps track of a counter value.
4454class MyHomePage extends StatefulWidget {
45- MyHomePage ({super .key, required this .title});
55+ /// Creates a new instance of [MyHomePage] .
56+ ///
57+ /// The [title] parameter is required and displayed in the app bar.
58+ const MyHomePage ({required this .title, super .key});
59+
60+ /// The title displayed in the app bar.
4661 final String title;
4762
4863 @override
@@ -52,6 +67,7 @@ class MyHomePage extends StatefulWidget {
5267class _MyHomePageState extends State <MyHomePage > {
5368 int counter = 0 ;
5469
70+ /// Increments the counter value.
5571 void _incrementCounter () => setState (() => counter++ );
5672
5773 @override
@@ -62,7 +78,7 @@ class _MyHomePageState extends State<MyHomePage> {
6278 child: Column (
6379 mainAxisAlignment: MainAxisAlignment .center,
6480 children: [
65- Text ('You have pushed the button this many times:' ),
81+ const Text ('You have pushed the button this many times:' ),
6682 Text (
6783 '$counter ' ,
6884 style: Theme .of (context).textTheme.headlineMedium,
@@ -73,7 +89,7 @@ class _MyHomePageState extends State<MyHomePage> {
7389 floatingActionButton: FloatingActionButton (
7490 onPressed: _incrementCounter,
7591 tooltip: 'Increment' ,
76- child: Icon (Icons .add),
92+ child: const Icon (Icons .add),
7793 ),
7894 );
7995 }
0 commit comments