Skip to content

Commit c560aba

Browse files
authored
Merge pull request #115 from StanleyCocos/fix/analyze
fix: analyze issues
2 parents 6a68e33 + c278272 commit c560aba

17 files changed

+112
-67
lines changed

analysis_options.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
include: package:flutter_lints/flutter.yaml
2+
3+
analyzer:
4+
exclude:
5+
- '**/*.g.dart'
6+
- '**/*.freezed.dart'
7+
8+
linter:
9+
rules:
10+
- always_specify_types
11+
- prefer_final_fields
12+
- prefer_const_constructors
13+
- avoid_print
14+
- public_member_api_docs
15+
- unnecessary_this

example/lib/main.dart

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:flutter/foundation.dart';
12
import 'package:flutter/material.dart';
23
import 'package:flutter_line_sdk/flutter_line_sdk.dart';
34

@@ -6,7 +7,9 @@ import 'src/app.dart';
67
void main() {
78
WidgetsFlutterBinding.ensureInitialized();
89
LineSDK.instance.setup('1620019587').then((_) {
9-
print('LineSDK Prepared');
10+
if (kDebugMode) {
11+
print('LineSDK Prepared');
12+
}
1013
});
11-
runApp(App());
14+
runApp(const App());
1215
}

example/lib/src/app.dart

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import 'screen/api_page.dart';
44
import 'screen/home_page.dart';
55

66
class App extends StatelessWidget {
7+
const App({Key? key}) : super(key: key);
8+
9+
@override
710
Widget build(BuildContext context) {
811
return MaterialApp(
912
theme: ThemeData(
@@ -15,15 +18,15 @@ class App extends StatelessWidget {
1518
child: Scaffold(
1619
appBar: AppBar(
1720
title: const Text('LINE SDK'),
18-
bottom: TabBar(
21+
bottom: const TabBar(
1922
tabs: [
2023
Tab(text: 'User'),
2124
Tab(text: 'API'),
2225
],
2326
indicatorColor: null,
2427
),
2528
),
26-
body: TabBarView(
29+
body: const TabBarView(
2730
children: [
2831
Center(
2932
child: HomePage(),

example/lib/src/screen/api_page.dart

+11-7
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import 'package:flutter/services.dart';
55
import 'package:flutter_line_sdk/flutter_line_sdk.dart';
66

77
class APIPage extends StatefulWidget {
8+
const APIPage({Key? key}) : super(key: key);
9+
810
@override
9-
_APIPageState createState() => _APIPageState();
11+
State<StatefulWidget> createState() => _APIPageState();
1012
}
1113

1214
class _APIPageState extends State<APIPage> {
@@ -48,23 +50,25 @@ class _APIPageState extends State<APIPage> {
4850
Expanded(
4951
flex: 1,
5052
child: Container(
51-
padding: EdgeInsets.all(16),
53+
padding: const EdgeInsets.all(16),
54+
color: const Color.fromARGB(30, 30, 30, 30),
55+
height: 200,
5256
child: SingleChildScrollView(
5357
child: Text(
5458
isError ? _error! : _result!,
55-
style:
56-
TextStyle(color: isError ? Colors.red : Colors.green),
59+
style: TextStyle(
60+
color: isError ? Colors.red : Colors.green,
61+
),
5762
),
5863
),
59-
color: Color.fromARGB(30, 30, 30, 30),
60-
height: 200,
6164
),
6265
),
6366
],
6467
),
6568
Expanded(
6669
child: ListView.separated(
67-
separatorBuilder: (BuildContext context, int index) => Divider(),
70+
separatorBuilder: (BuildContext context, int index) =>
71+
const Divider(),
6872
itemCount: apis.length,
6973
itemBuilder: (context, index) {
7074
return ListTile(

example/lib/src/screen/home_page.dart

+32-21
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:flutter/foundation.dart';
12
import 'package:flutter/material.dart';
23
import 'package:flutter/services.dart';
34
import 'package:flutter_line_sdk/flutter_line_sdk.dart';
@@ -6,8 +7,10 @@ import '../theme.dart';
67
import '../widget/user_info_widget.dart';
78

89
class HomePage extends StatefulWidget {
10+
const HomePage({Key? key}) : super(key: key);
11+
912
@override
10-
_HomePageState createState() => _HomePageState();
13+
State<StatefulWidget> createState() => _HomePageState();
1114
}
1215

1316
class _HomePageState extends State<HomePage>
@@ -17,7 +20,7 @@ class _HomePageState extends State<HomePage>
1720
StoredAccessToken? _accessToken;
1821
bool _isOnlyWebLogin = false;
1922

20-
final Set<String> _selectedScopes = Set.from(['profile']);
23+
final Set<String> _selectedScopes = {'profile'};
2124

2225
@override
2326
bool get wantKeepAlive => true;
@@ -38,7 +41,9 @@ class _HomePageState extends State<HomePage>
3841
userProfile = await LineSDK.instance.getProfile();
3942
}
4043
} on PlatformException catch (e) {
41-
print(e.message);
44+
if (kDebugMode) {
45+
print(e.message);
46+
}
4247
}
4348

4449
if (!mounted) return;
@@ -60,11 +65,15 @@ class _HomePageState extends State<HomePage>
6065
_configCard(),
6166
Expanded(
6267
child: Center(
63-
child: ElevatedButton(
64-
child: Text('Sign In'),
65-
onPressed: _signIn,
66-
style: ElevatedButton.styleFrom(
67-
backgroundColor: accentColor, foregroundColor: textColor))),
68+
child: ElevatedButton(
69+
onPressed: _signIn,
70+
style: ElevatedButton.styleFrom(
71+
backgroundColor: accentColor,
72+
foregroundColor: textColor,
73+
),
74+
child: const Text('Sign In'),
75+
),
76+
),
6877
),
6978
],
7079
),
@@ -82,14 +91,12 @@ class _HomePageState extends State<HomePage>
8291
Widget _configCard() {
8392
return Card(
8493
child: Padding(
85-
padding: EdgeInsets.all(15.0),
94+
padding: const EdgeInsets.all(15.0),
8695
child: Column(
8796
crossAxisAlignment: CrossAxisAlignment.start,
8897
children: <Widget>[
8998
_scopeListUI(),
90-
SizedBox(
91-
height: 10.0,
92-
),
99+
const SizedBox(height: 10.0),
93100
Row(
94101
children: <Widget>[
95102
Checkbox(
@@ -101,7 +108,7 @@ class _HomePageState extends State<HomePage>
101108
});
102109
},
103110
),
104-
Text('only Web Login'),
111+
const Text('only Web Login'),
105112
],
106113
),
107114
],
@@ -113,7 +120,7 @@ class _HomePageState extends State<HomePage>
113120
Widget _scopeListUI() => Column(
114121
crossAxisAlignment: CrossAxisAlignment.start,
115122
children: <Widget>[
116-
Text('Scopes: '),
123+
const Text('Scopes: '),
117124
Wrap(
118125
children:
119126
_scopes.map<Widget>((scope) => _buildScopeChip(scope)).toList(),
@@ -126,7 +133,7 @@ class _HomePageState extends State<HomePage>
126133
child: ChipTheme(
127134
data: ChipTheme.of(context).copyWith(brightness: Brightness.dark),
128135
child: FilterChip(
129-
label: Text(scope, style: TextStyle(color: textColor)),
136+
label: Text(scope, style: const TextStyle(color: textColor)),
130137
selectedColor: accentColor,
131138
backgroundColor: secondaryBackgroundColor,
132139
selected: _selectedScopes.contains(scope),
@@ -158,6 +165,7 @@ class _HomePageState extends State<HomePage>
158165
_accessToken = accessToken;
159166
});
160167
} on PlatformException catch (e) {
168+
if (!mounted) return;
161169
_showDialog(context, e.toString());
162170
}
163171
}
@@ -171,7 +179,9 @@ class _HomePageState extends State<HomePage>
171179
_accessToken = null;
172180
});
173181
} on PlatformException catch (e) {
174-
print(e.message);
182+
if (kDebugMode) {
183+
print(e.message);
184+
}
175185
}
176186
}
177187

@@ -183,11 +193,12 @@ class _HomePageState extends State<HomePage>
183193
content: Text(text),
184194
actions: <Widget>[
185195
TextButton(
186-
child: Text('Close'),
187-
onPressed: () {
188-
Navigator.of(context).pop();
189-
},
190-
style: TextButton.styleFrom(foregroundColor: accentColor)),
196+
onPressed: () {
197+
Navigator.of(context).pop();
198+
},
199+
style: TextButton.styleFrom(foregroundColor: accentColor),
200+
child: const Text('Close'),
201+
),
191202
],
192203
);
193204
},

example/lib/src/theme.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import 'package:flutter/material.dart';
22

33
const Color textColor = Colors.white;
44
final Color secondaryBackgroundColor = Colors.grey.shade300;
5-
const Color accentColor = const Color(0xFF58BF38);
6-
const Color darkAccentColor = const Color(0xFF50AF33);
5+
const Color accentColor = Color(0xFF58BF38);
6+
const Color darkAccentColor = Color(0xFF50AF33);

example/lib/src/widget/user_info_widget.dart

+20-17
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import 'package:flutter_line_sdk/flutter_line_sdk.dart';
33
import '../theme.dart';
44

55
class UserInfoWidget extends StatelessWidget {
6-
const UserInfoWidget(
7-
{Key? key,
8-
required this.userProfile,
9-
this.userEmail,
10-
required this.accessToken,
11-
required this.onSignOutPressed})
12-
: super(key: key);
6+
const UserInfoWidget({
7+
Key? key,
8+
required this.userProfile,
9+
this.userEmail,
10+
required this.accessToken,
11+
required this.onSignOutPressed,
12+
}) : super(key: key);
1313

1414
final UserProfile userProfile;
1515
final String? userEmail;
@@ -28,21 +28,24 @@ class UserInfoWidget extends StatelessWidget {
2828
width: 200,
2929
height: 200,
3030
)
31-
: Icon(Icons.person),
31+
: const Icon(Icons.person),
3232
Text(
3333
userProfile.displayName,
3434
style: Theme.of(context).textTheme.headlineSmall,
3535
),
3636
if (userEmail != null) Text(userEmail!),
37-
if (userProfile.statusMessage != null) Text(userProfile.statusMessage!),
38-
Container(
39-
child: ElevatedButton(
40-
child: Text('Sign Out'),
41-
onPressed: () {
42-
onSignOutPressed.call();
43-
},
44-
style: ElevatedButton.styleFrom(
45-
backgroundColor: accentColor, foregroundColor: textColor))),
37+
if (userProfile.statusMessage != null)
38+
Text(userProfile.statusMessage!),
39+
ElevatedButton(
40+
onPressed: () {
41+
onSignOutPressed.call();
42+
},
43+
style: ElevatedButton.styleFrom(
44+
backgroundColor: accentColor,
45+
foregroundColor: textColor,
46+
),
47+
child: const Text('Sign Out'),
48+
),
4649
],
4750
),
4851
);

example/pubspec.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ dependencies:
1313
# The following adds the Cupertino Icons font to your application.
1414
# Use with the CupertinoIcons class for iOS style icons.
1515
cupertino_icons: ^1.0.8
16+
flutter_line_sdk:
17+
path: ../
1618

1719
dev_dependencies:
1820
flutter_test:
1921
sdk: flutter
2022

21-
flutter_line_sdk:
22-
path: ../
23+
# flutter_line_sdk:
24+
# path: ../
2325

2426
# For information on the generic Dart part of this file, see the
2527
# following page: https://www.dartlang.org/tools/pub/pubspec

lib/src/line_sdk.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020
//
2121

22-
part of flutter_line_sdk;
22+
part of '../flutter_line_sdk.dart';
2323

2424
/// A general manager class for LINE SDK login features.
2525
///
@@ -30,7 +30,7 @@ class LineSDK {
3030
///
3131
/// Don't use this channel directly. Instead, call the public methods on the [LineSDK] class.
3232
static const MethodChannel channel =
33-
const MethodChannel('com.linecorp/flutter_line_sdk');
33+
MethodChannel('com.linecorp/flutter_line_sdk');
3434

3535
/// The shared singleton object of `LineSDK`.
3636
///

lib/src/model/access_token.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020
//
2121

22-
part of flutter_line_sdk;
22+
part of '../../flutter_line_sdk.dart';
2323

2424
/// An access token used to access the LINE Platform.
2525
///

lib/src/model/access_token_verify_result.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020
//
2121

22-
part of flutter_line_sdk;
22+
part of '../../flutter_line_sdk.dart';
2323

2424
/// Response to [LineSDK.verifyAccessToken].
2525
class AccessTokenVerifyResult {

lib/src/model/bot_friendship_status.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020
//
2121

22-
part of flutter_line_sdk;
22+
part of '../../flutter_line_sdk.dart';
2323

2424
/// Response to [LineSDK.getBotFriendshipStatus].
2525
class BotFriendshipStatus {

lib/src/model/login_option.dart

+7-4
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020
//
2121

22-
part of flutter_line_sdk;
22+
part of '../../flutter_line_sdk.dart';
2323

2424
/// Options related to LINE login process.
2525
class LoginOption {
2626
/// Default request code that LINE login activity (in Android Platform) will be called with.
27-
static const int DEFAULT_ACTIVITY_RESULT_REQUEST_CODE = 8192;
27+
static const int DEFAULT_ACTIVITY_RESULT_REQUEST_CODE = 8192; // ignore: constant_identifier_names
2828

2929
/// Enable to use web authentication flow instead of LINE app-to-app authentication flow.
3030
///
@@ -48,6 +48,9 @@ class LoginOption {
4848
/// in received ID token locally.
4949
String? idTokenNonce;
5050

51-
LoginOption(this.onlyWebLogin, this.botPrompt,
52-
{this.requestCode = DEFAULT_ACTIVITY_RESULT_REQUEST_CODE});
51+
LoginOption(
52+
this.onlyWebLogin,
53+
this.botPrompt, {
54+
this.requestCode = DEFAULT_ACTIVITY_RESULT_REQUEST_CODE,
55+
});
5356
}

0 commit comments

Comments
 (0)