Skip to content

Commit

Permalink
fix: flutter analyze issues (#4)
Browse files Browse the repository at this point in the history
* fix: flutter analysis options

* feat: add gha to verify formatting and analysis options

* fix: set flutter version in gha

* fix: format command

* fix: formatting issues

* fix: create env.dart in gha

* fix: add build script
  • Loading branch information
glitchedmob authored Oct 7, 2024
1 parent e4af600 commit 339a428
Show file tree
Hide file tree
Showing 19 changed files with 90 additions and 63 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/lint-analyze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Lint & Analyze
on:
pull_request:
branches:
- main
jobs:
lint-analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: flutter-actions/setup-flutter@v3
with:
channel: stable
version: 3.24.3
cache-sdk: true
- run: flutter pub get
- run: dart format --set-exit-if-changed .
- run: cp ./lib/env.dart.example ./lib/env.dart
- run: flutter pub run build_runner build --delete-conflicting-outputs
- run: flutter analyze
6 changes: 3 additions & 3 deletions lib/providers/session_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:method_conf_app/providers/speaker_provider.dart';
import 'package:method_conf_app/env.dart';
import 'package:method_conf_app/models/session.dart';

const SESSIONS_KEY = 'app-sessions';
const sessionsKey = 'app-sessions';

class SessionProvider extends ChangeNotifier {
final SpeakerProvider? speakerProvider;
Expand Down Expand Up @@ -72,7 +72,7 @@ class SessionProvider extends ChangeNotifier {
var prefs = await SharedPreferences.getInstance();

sessions = prefs
.getStringList(SESSIONS_KEY)
.getStringList(sessionsKey)
?.map((s) => Session.fromJson(json.decode(s)))
.toList() ??
[];
Expand Down Expand Up @@ -100,7 +100,7 @@ class SessionProvider extends ChangeNotifier {
var prefs = await SharedPreferences.getInstance();

var sessionsJson = sessions.map((s) => json.encode(s.toJson())).toList();
await prefs.setStringList(SESSIONS_KEY, sessionsJson);
await prefs.setStringList(sessionsKey, sessionsJson);
}

Session? getSessionForSpeaker(Speaker? speaker) {
Expand Down
6 changes: 3 additions & 3 deletions lib/providers/sponsor_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:http/http.dart' as http;
import 'package:method_conf_app/env.dart';
import 'package:method_conf_app/models/sponsor.dart';

const SPONSOR_KEY = 'app-sponsrs';
const sponsorKey = 'app-sponsrs';

class SponsorProvider extends ChangeNotifier {
bool _initialFetched = false;
Expand Down Expand Up @@ -39,7 +39,7 @@ class SponsorProvider extends ChangeNotifier {
var prefs = await SharedPreferences.getInstance();

sponsors = prefs
.getStringList(SPONSOR_KEY)
.getStringList(sponsorKey)
?.map((s) => Sponsor.fromJson(json.decode(s)))
.toList() ??
[];
Expand All @@ -65,6 +65,6 @@ class SponsorProvider extends ChangeNotifier {
var prefs = await SharedPreferences.getInstance();

var sponsorsJson = sponsors.map((s) => json.encode(s.toJson())).toList();
await prefs.setStringList(SPONSOR_KEY, sponsorsJson);
await prefs.setStringList(sponsorKey, sponsorsJson);
}
}
4 changes: 1 addition & 3 deletions lib/screens/not_found_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ class NotFoundScreen extends StatelessWidget {
Widget build(BuildContext context) {
return AppScreen(
title: 'Not Found',
body: Container(
child: const Text('Not Found'),
),
body: const Text('Not Found'),
);
}
}
5 changes: 3 additions & 2 deletions lib/screens/report_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ReportScreen extends StatefulWidget {
const ReportScreen({super.key});

@override
_ReportScreenState createState() => _ReportScreenState();
State<ReportScreen> createState() => _ReportScreenState();
}

class _ReportScreenState extends State<ReportScreen> {
Expand Down Expand Up @@ -142,7 +142,8 @@ class _ReportScreenState extends State<ReportScreen> {
children: <Widget>[
TextButton(
style: TextButton.styleFrom(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15),
padding: const EdgeInsets.symmetric(
horizontal: 20, vertical: 15),
backgroundColor: Colors.black,
),
onPressed: _submitReport,
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/schedule_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ScheduleScreen extends StatefulWidget {
const ScheduleScreen({super.key});

@override
_ScheduleScreenState createState() => _ScheduleScreenState();
State<ScheduleScreen> createState() => _ScheduleScreenState();
}

class _ScheduleScreenState extends State<ScheduleScreen> {
Expand Down
5 changes: 3 additions & 2 deletions lib/screens/session_feedback_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SessionFeedbackScreen extends StatefulWidget {
const SessionFeedbackScreen({super.key});

@override
_SessionFeedbackScreenState createState() => _SessionFeedbackScreenState();
State<SessionFeedbackScreen> createState() => _SessionFeedbackScreenState();
}

class _SessionFeedbackScreenState extends State<SessionFeedbackScreen> {
Expand Down Expand Up @@ -130,7 +130,8 @@ class _SessionFeedbackScreenState extends State<SessionFeedbackScreen> {
_submitFeedback(session);
},
style: TextButton.styleFrom(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 15),
padding: const EdgeInsets.symmetric(
horizontal: 20, vertical: 15),
backgroundColor: Colors.black),
child: const Text(
'SEND FEEDBACK',
Expand Down
29 changes: 17 additions & 12 deletions lib/screens/speaker_detail_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class SpeakerDetailScreen extends StatelessWidget {
Text(
speaker.name,
textAlign: TextAlign.left,
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
style: const TextStyle(
fontSize: 20, fontWeight: FontWeight.bold),
),
const SizedBox(height: 15),
Row(
Expand All @@ -49,14 +50,13 @@ class SpeakerDetailScreen extends StatelessWidget {
child: CachedNetworkImage(
imageUrl: speaker.image!,
placeholder: (context, url) {
return Container(
child: const CircularProgressIndicator(
valueColor:
AlwaysStoppedAnimation(Colors.transparent),
),
return const CircularProgressIndicator(
valueColor:
AlwaysStoppedAnimation(Colors.transparent),
);
},
errorWidget: (context, url, error) => const Icon(Icons.error),
errorWidget: (context, url, error) =>
const Icon(Icons.error),
),
),
const SizedBox(width: 20),
Expand Down Expand Up @@ -98,35 +98,40 @@ class SpeakerDetailScreen extends StatelessWidget {
icons.add(InkWell(
// padding: EdgeInsets.all(0),
onTap: () => launchUrl(speaker.twitterUrl!),
child: const Icon(AppIcons.twitter_logo, color: AppColors.accent, size: 35),
child:
const Icon(AppIcons.twitterLogo, color: AppColors.accent, size: 35),
));
}

if (speaker.twitter2Url != null) {
icons.add(InkWell(
onTap: () => launchUrl(speaker.twitter2Url!),
child: const Icon(AppIcons.twitter_logo, color: AppColors.accent, size: 35),
child:
const Icon(AppIcons.twitterLogo, color: AppColors.accent, size: 35),
));
}

if (speaker.linkedinUrl != null) {
icons.add(InkWell(
onTap: () => launchUrl(speaker.linkedinUrl!),
child: const Icon(AppIcons.linkedin_logo, color: AppColors.accent, size: 35),
child: const Icon(AppIcons.linkedInLogo,
color: AppColors.accent, size: 35),
));
}

if (speaker.githubUrl != null) {
icons.add(InkWell(
onTap: () => launchUrl(speaker.githubUrl!),
child: const Icon(AppIcons.github_logo, color: AppColors.accent, size: 35),
child:
const Icon(AppIcons.githubLogo, color: AppColors.accent, size: 35),
));
}

if (speaker.websiteURL != null) {
icons.add(InkWell(
onTap: () => launchUrl(speaker.websiteURL!),
child: const Icon(AppIcons.website_logo, color: AppColors.accent, size: 35),
child:
const Icon(AppIcons.websiteLogo, color: AppColors.accent, size: 35),
));
}

Expand Down
8 changes: 5 additions & 3 deletions lib/screens/sponsors_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class SponsorsScreen extends StatefulWidget {
const SponsorsScreen({super.key});

@override
_SponsorsScreenState createState() => _SponsorsScreenState();
State<SponsorsScreen> createState() => _SponsorsScreenState();
}

class _SponsorsScreenState extends State<SponsorsScreen> {
Expand Down Expand Up @@ -89,10 +89,12 @@ class _SponsorsScreenState extends State<SponsorsScreen> {
maxHeight: sponsor.mobileSponsor! ? 75 : 65,
child: CachedNetworkImage(
imageUrl: sponsor.image!,
placeholder: (context, url) => const CircularProgressIndicator(
placeholder: (context, url) =>
const CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation(Colors.transparent),
),
errorWidget: (context, url, error) => const Icon(Icons.error),
errorWidget: (context, url, error) =>
const Icon(Icons.error),
),
),
),
Expand Down
18 changes: 6 additions & 12 deletions lib/utils/app_icons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,10 @@ class AppIcons {
static const _kFontFam = 'AppIcons';

static const IconData hashtag = IconData(0xe800, fontFamily: _kFontFam);
static const IconData piggy_bank =
IconData(0xe801, fontFamily: _kFontFam);
static const IconData schedule =
IconData(0xe802, fontFamily: _kFontFam);
static const IconData github_logo =
IconData(0xe803, fontFamily: _kFontFam);
static const IconData linkedin_logo =
IconData(0xe804, fontFamily: _kFontFam);
static const IconData twitter_logo =
IconData(0xe805, fontFamily: _kFontFam);
static const IconData website_logo =
IconData(0xe806, fontFamily: _kFontFam);
static const IconData piggyBank = IconData(0xe801, fontFamily: _kFontFam);
static const IconData schedule = IconData(0xe802, fontFamily: _kFontFam);
static const IconData githubLogo = IconData(0xe803, fontFamily: _kFontFam);
static const IconData linkedInLogo = IconData(0xe804, fontFamily: _kFontFam);
static const IconData twitterLogo = IconData(0xe805, fontFamily: _kFontFam);
static const IconData websiteLogo = IconData(0xe806, fontFamily: _kFontFam);
}
13 changes: 9 additions & 4 deletions lib/utils/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@ import 'dart:math';

import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:url_launcher/url_launcher.dart' as url_launcher;

import 'package:method_conf_app/theme.dart';
import 'package:method_conf_app/widgets/app_html.dart';

Future<void> launchUrl(String url) async {
if (await canLaunch(url)) {
await launch(url, forceWebView: false, forceSafariVC: false);
return;
try {
final parsed = Uri.parse(url);
if (await url_launcher.canLaunchUrl(parsed)) {
await url_launcher.launchUrl(parsed);
return;
}
} catch (e) {
// ignore errors
}

Fluttertoast.showToast(
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/app_banner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class AppBanner extends StatelessWidget {
const SizedBox(height: 20),
TextButton(
style: TextButton.styleFrom(
padding:
const EdgeInsets.symmetric(horizontal: 20, vertical: 15),
padding: const EdgeInsets.symmetric(
horizontal: 20, vertical: 15),
backgroundColor: Colors.black),
onPressed: onButtonPress,
child: Text(
Expand Down
3 changes: 2 additions & 1 deletion lib/widgets/app_list_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class AppListItem extends StatelessWidget {
children: <Widget>[
Text(
text,
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
style:
const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
const Icon(Icons.chevron_right, size: 24),
],
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/app_navigation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AppNavigation extends StatefulWidget {
const AppNavigation({super.key});

@override
_AppNavigationState createState() => _AppNavigationState();
State<AppNavigation> createState() => _AppNavigationState();
}

class _AppNavigationState extends State<AppNavigation> {
Expand All @@ -42,7 +42,7 @@ class _AppNavigationState extends State<AppNavigation> {
),
_NavigationItem(
route: '/partners',
item: _buildNavigationBarItem(AppIcons.piggy_bank, 'Partners'),
item: _buildNavigationBarItem(AppIcons.piggyBank, 'Partners'),
),
_NavigationItem(
route: '/more',
Expand Down
14 changes: 6 additions & 8 deletions lib/widgets/app_navigator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class AppNavigator extends StatelessWidget {
);
static final _navigatorKey = GlobalKey<NavigatorState>();

final _RouteChangeCallBack? onRouteChange;
final RouteChangeCallBack? onRouteChange;
final Map<String, WidgetBuilder> routes;
final String initialRoute;
final WidgetBuilder notFoundBuilder;
Expand All @@ -24,14 +24,12 @@ class AppNavigator extends StatelessWidget {

@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () async {
return PopScope(
onPopInvokedWithResult: (_, __) {
if (_navigatorKey.currentState!.canPop()) {
_navigatorKey.currentState!.pop();
return false;
return;
}

return true;
},
child: Navigator(
key: _navigatorKey,
Expand Down Expand Up @@ -99,10 +97,10 @@ class AppNavigator extends StatelessWidget {
}
}

typedef _RouteChangeCallBack = void Function(Route? newRoute);
typedef RouteChangeCallBack = void Function(Route? newRoute);

class _AppNavigationObserver extends NavigatorObserver {
final _RouteChangeCallBack onRouteChange;
final RouteChangeCallBack onRouteChange;

_AppNavigationObserver({required this.onRouteChange});

Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/rating.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:method_conf_app/theme.dart';

class Rating extends StatelessWidget {
final _RatingSelectedCallback onSelected;
final RatingSelectedCallback onSelected;
final int? currentValue;

const Rating({
Expand Down Expand Up @@ -48,4 +48,4 @@ class Rating extends StatelessWidget {
}
}

typedef _RatingSelectedCallback = void Function(int value);
typedef RatingSelectedCallback = void Function(int value);
5 changes: 3 additions & 2 deletions lib/widgets/session_expansion_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SessionExpansionTile extends StatefulWidget {
});

@override
_SessionExpansionTileState createState() => _SessionExpansionTileState();
State<SessionExpansionTile> createState() => _SessionExpansionTileState();
}

class _SessionExpansionTileState extends State<SessionExpansionTile> {
Expand Down Expand Up @@ -99,7 +99,8 @@ class _SessionExpansionTileState extends State<SessionExpansionTile> {
Flexible(
child: Text(
widget.session.title,
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
style: const TextStyle(
fontSize: 20, fontWeight: FontWeight.bold),
),
),
const SizedBox(
Expand Down
Loading

0 comments on commit 339a428

Please sign in to comment.