Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "come.csgo.server.manager"
minSdkVersion 16
targetSdkVersion 29
minSdkVersion 26
targetSdkVersion 35
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:exported="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
Expand Down
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true
android.enableR8=true
12 changes: 6 additions & 6 deletions lib/app_bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ import 'localization/app_localizations.dart';
import 'models/language.dart';

class AppBootstrap extends StatefulWidget {
const AppBootstrap(this.selectedLocale, {Key key,}) : super(key: key);
const AppBootstrap(this.selectedLocale, {Key? key,}) : super(key: key);

final Locale selectedLocale;
final Locale? selectedLocale;

@override
_AppBootstrapState createState() => _AppBootstrapState();

static void setLocale(BuildContext context, Locale locale) {
final _AppBootstrapState state = context
.findAncestorStateOfType<_AppBootstrapState>();
.findAncestorStateOfType<_AppBootstrapState>()!;
state.setLocale(locale);
}
}

class _AppBootstrapState extends State<AppBootstrap> {
Locale _selectedLocale;
Locale? _selectedLocale;

@override
void initState() {
Expand Down Expand Up @@ -57,14 +57,14 @@ class _AppBootstrapState extends State<AppBootstrap> {
],
locale: _selectedLocale,
supportedLocales: Language.supportedLocales(),
localeResolutionCallback: (Locale deviceLocale,
localeResolutionCallback: (Locale? deviceLocale,
Iterable<Locale> supportedLocales) {
if (_selectedLocale != null) {
return _selectedLocale;
}
// set device locale as selected locale
for (final Locale locale in supportedLocales) {
if (locale.languageCode == deviceLocale.languageCode
if (locale.languageCode == deviceLocale!.languageCode
&& locale.countryCode == deviceLocale.countryCode) {
return deviceLocale;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/localization/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class AppLocalizations {

final Locale locale;

static AppLocalizations of (BuildContext context) =>
static AppLocalizations? of (BuildContext context) =>
Localizations.of<AppLocalizations>(context, AppLocalizations);

Map<String, String> _localizationValues;
late Map<String, String> _localizationValues;

Future<dynamic> load() async {
final String jsonStringValues = await rootBundle
Expand All @@ -25,7 +25,7 @@ class AppLocalizations {
MapEntry<String, String>(key, value.toString()));
}

String getTranslatedValue(String key) => _localizationValues[key];
String? getTranslatedValue(String key) => _localizationValues[key];

static const LocalizationsDelegate<AppLocalizations> delegate =
_AppLocalizationsDelegate();
Expand Down
6 changes: 3 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ void main () {
// get selected settings for theme and locale
SharedPreferences.getInstance().then((SharedPreferences prefs) {
final bool darkModeOn = prefs.getBool('darkMode') ?? true;
final String selectedLocaleCode = prefs.getString('selectedLocale');
Locale selectedLocale;
final String? selectedLocaleCode = prefs.getString('selectedLocale');
Locale? selectedLocale;

if (selectedLocaleCode != null) {
if (selectedLocaleCode.split('-').length == 2) {
Expand All @@ -46,7 +46,7 @@ class MyApp extends StatelessWidget {
const MyApp(this._darkModeOn, this._selectedLocale,);

final bool _darkModeOn;
final Locale _selectedLocale;
final Locale? _selectedLocale;

@override
Widget build(BuildContext context) {
Expand Down
4 changes: 2 additions & 2 deletions lib/models/player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ class Player {
String ping;
String id;
String steamId;
String flag;
String? flag;
String timesConnected;

@override
String toString() {
return name;
}

Map<String, String> toJson() => <String, String> {
Map<String, String?> toJson() => <String, String?> {
'name': name,
'score': score,
'duration': duration,
Expand Down
10 changes: 5 additions & 5 deletions lib/models/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ class Server {
Server(this.serverName, this.serverIp, this.serverPort, this.serverRcon,
this.serverGame);

String serverName;
String serverIp;
String? serverName;
String? serverIp;
String serverPort;
String serverRcon;
String? serverRcon;
String serverGame;

@override
String toString() {
return serverName;
return serverName!;
}

Map<String, String> toJson() => <String, String> {
Map<String, String?> toJson() => <String, String?> {
'serverName': serverName,
'serverIp': serverIp,
'serverPort': serverPort,
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/custom_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CustomRouter {
case serverDetailsRoute:
return MaterialPageRoute<dynamic>(
builder: (_) => ServerDetailsPage(
routeSettings.arguments as Server));
routeSettings.arguments as Server?));

default:
return MaterialPageRoute<dynamic>(builder: (_) => const HomePage());
Expand Down
2 changes: 1 addition & 1 deletion lib/steam_api/steam_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Future<dynamic> getPlayerDetails(String id) async {
}
}

Future<dynamic> checkForSvUpdate(String ver) async {
Future<dynamic> checkForSvUpdate(String? ver) async {

final http.Response response = await http.get(
Uri.parse('http://api.steampowered.com/ISteamApps/UpToDateCheck/v0001/'
Expand Down
10 changes: 5 additions & 5 deletions lib/ui/pages/home_page/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:turrant/ui/pages/pages.dart';
import 'package:turrant/ui/widgets/widgets.dart';

class HomePage extends StatefulWidget {
const HomePage({Key key,}) : super(key: key);
const HomePage({Key? key,}) : super(key: key);

@override
_HomePageState createState() => _HomePageState();
Expand All @@ -20,7 +20,7 @@ class HomePage extends StatefulWidget {
class _HomePageState extends State<HomePage> {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
List<Server> servers = <Server>[];
Server _currentServer;
Server? _currentServer;

@override
void initState() {
Expand All @@ -30,19 +30,19 @@ class _HomePageState extends State<HomePage> {

@override
Widget build(BuildContext context) {
final String _title = AppLocalizations.of(context)
final String? _title = AppLocalizations.of(context)!
.getTranslatedValue('app_bar_title');

final bool isSmallScreen = MediaQuery.of(context).size.width < 900;

if (!isSmallScreen) {
return _buildLargeScreenLayout(context, _title);
return _buildLargeScreenLayout(context, _title!);
}

return Scaffold(
body: CustomScrollView(
slivers: <Widget>[
_buildAppBar(context, _title),
_buildAppBar(context, _title!),
ServersList(servers, _removeServer,
_handleSvLongPress, _setSelectedServer),
],
Expand Down
60 changes: 30 additions & 30 deletions lib/ui/pages/server_details_page/server_details_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import 'package:turrant/utils/utils.dart';
class ServerDetailsPage extends StatefulWidget {
const ServerDetailsPage(this.server);

final Server server;
final Server? server;

@override
_ServerDetailsPageState createState() => _ServerDetailsPageState();
Expand All @@ -26,9 +26,9 @@ class ServerDetailsPage extends StatefulWidget {
class Choice {
Choice({this.title, this.icon, this.onSelect});

final String title;
final IconData icon;
final Function onSelect;
final String? title;
final IconData? icon;
final Function? onSelect;
}

const List<String> defaultMaps = <String>[
Expand All @@ -37,20 +37,20 @@ const List<String> defaultMaps = <String>[
];

class _ServerDetailsPageState extends State<ServerDetailsPage> {
String ip;
int port;
String rconPassword;
String? ip;
late int port;
String? rconPassword;

bool isLoading = true;
SourceServer sourceServer;
List<Player> players;
SourceServer? sourceServer;
List<Player>? players;
List<String> maps = defaultMaps;
List<Command> commands = <Command>[];
String map;
String numOfPlayers;
String maxPlayers;
String version;
int tvPort;
String? map;
String? numOfPlayers;
String? maxPlayers;
String? version;
int? tvPort;
bool isPublic = true;
bool isVacEnabled = true;
bool isTvEnabled = false;
Expand All @@ -62,9 +62,9 @@ class _ServerDetailsPageState extends State<ServerDetailsPage> {
void initState() {
super.initState();

ip = widget.server.serverIp;
port = int.parse(widget.server.serverPort);
rconPassword = widget.server.serverRcon;
ip = widget.server!.serverIp;
port = int.parse(widget.server!.serverPort);
rconPassword = widget.server!.serverRcon;

refreshInfo();
choices = <Choice>[
Expand All @@ -77,9 +77,9 @@ class _ServerDetailsPageState extends State<ServerDetailsPage> {

@override
void didUpdateWidget(covariant ServerDetailsPage oldWidget) {
ip = widget.server.serverIp;
port = int.parse(widget.server.serverPort);
rconPassword = widget.server.serverRcon;
ip = widget.server!.serverIp;
port = int.parse(widget.server!.serverPort);
rconPassword = widget.server!.serverRcon;

refreshInfo();
choices = <Choice>[
Expand All @@ -94,7 +94,7 @@ class _ServerDetailsPageState extends State<ServerDetailsPage> {

void _selectChoice(Choice choice) {
if (choice.onSelect != null) {
choice.onSelect(context);
choice.onSelect!(context);
}
}

Expand All @@ -112,7 +112,7 @@ class _ServerDetailsPageState extends State<ServerDetailsPage> {
durationSec: 2);

final ClipboardData data = ClipboardData(
text: '${widget.server.serverIp}:${widget.server.serverPort}');
text: '${widget.server!.serverIp}:${widget.server!.serverPort}');

await Clipboard.setData(data);
}
Expand All @@ -124,7 +124,7 @@ class _ServerDetailsPageState extends State<ServerDetailsPage> {
length: 2,
child: Scaffold(
appBar: AppBar(
title: Text(widget.server.serverName),
title: Text(widget.server!.serverName!),
actions: <Widget>[
// overflow menu
PopupMenuButton<Choice>(
Expand All @@ -137,7 +137,7 @@ class _ServerDetailsPageState extends State<ServerDetailsPage> {
children: <Widget>[
Icon(choice.icon),
const SizedBox(width: 10,),
Text(choice.title),
Text(choice.title!),
],
),
);
Expand Down Expand Up @@ -167,8 +167,8 @@ class _ServerDetailsPageState extends State<ServerDetailsPage> {
children: <Widget>[
const FaIcon(FontAwesomeIcons.infoCircle, size: 18),
const SizedBox(width: 10,),
Text(AppLocalizations.of(context)
.getTranslatedValue('details_tab_label'),
Text(AppLocalizations.of(context)!
.getTranslatedValue('details_tab_label')!,
style: AppStyles.tabItemLabelStyle,)
],
),
Expand All @@ -178,8 +178,8 @@ class _ServerDetailsPageState extends State<ServerDetailsPage> {
children: <Widget>[
const FaIcon(FontAwesomeIcons.terminal, size: 18,),
const SizedBox(width: 10,),
Text(AppLocalizations.of(context)
.getTranslatedValue('console_tab_label'),
Text(AppLocalizations.of(context)!
.getTranslatedValue('console_tab_label')!,
style: AppStyles.tabItemLabelStyle,)
],
),
Expand Down Expand Up @@ -211,7 +211,7 @@ class _ServerDetailsPageState extends State<ServerDetailsPage> {
sendCommandToSv, showToast, maps, numOfPlayers,
maxPlayers, version, tvPort, isSvOutDated),
PlayersList(players, refreshInfo, sendCommandToSv, showToast),
if (players.isEmpty) EmptyServerState(),
if (players!.isEmpty) EmptyServerState(),
],
) : const Center(child: CircularProgressIndicator()),
);
Expand Down Expand Up @@ -241,7 +241,7 @@ class _ServerDetailsPageState extends State<ServerDetailsPage> {
}
}

Future<void> sendCommandToSv(String cmd, {Function callback}) async {
Future<void> sendCommandToSv(String cmd, {Function? callback}) async {
// clear console history
if (cmd == 'clear') {
setState(() {
Expand Down
Loading