Skip to content

Commit

Permalink
Flutter 3.16 adaptations (#262)
Browse files Browse the repository at this point in the history
* Update text scaler + removed useMaterial3

* Use universal io + migrated to popscope

* Implemented linter suggestions
  • Loading branch information
ferraridamiano authored Nov 19, 2023
1 parent 4cbdcdb commit 24e4031
Show file tree
Hide file tree
Showing 16 changed files with 93 additions and 105 deletions.
10 changes: 3 additions & 7 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'dart:io';
import 'package:universal_io/io.dart';
import 'package:converterpro/models/order.dart';
import 'package:converterpro/models/properties_list.dart';
import 'package:converterpro/models/settings.dart';
Expand Down Expand Up @@ -32,7 +32,7 @@ void main() async {
}

class MyApp extends ConsumerWidget {
const MyApp({Key? key}) : super(key: key);
const MyApp({super.key});

@override
Widget build(BuildContext context, WidgetRef ref) {
Expand Down Expand Up @@ -138,12 +138,8 @@ class MyApp extends ConsumerWidget {
);
}

ThemeData lightTheme = ThemeData(
useMaterial3: true,
colorScheme: lightColorScheme,
);
ThemeData lightTheme = ThemeData(colorScheme: lightColorScheme);
ThemeData darkTheme = ThemeData(
useMaterial3: true,
brightness: Brightness.dark,
colorScheme: darkColorScheme,
);
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/conversion_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'package:intl/intl.dart';
class ConversionPage extends ConsumerWidget {
final int page;

const ConversionPage(this.page, {Key? key}) : super(key: key);
const ConversionPage(this.page, {super.key});

@override
Widget build(BuildContext context, WidgetRef ref) {
Expand Down
6 changes: 3 additions & 3 deletions lib/pages/custom_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class CustomDrawer extends ConsumerWidget {
final void Function() openSearch;

const CustomDrawer({
key,
required this.isDrawerFixed,
required this.openCalculator,
required this.openSearch,
}) : super(key: key);
super.key,
});

@override
Widget build(BuildContext context, WidgetRef ref) {
Expand All @@ -42,7 +42,7 @@ class CustomDrawer extends ConsumerWidget {
'Converter NOW',
// Fixed independently of the accessibility settings. Already as
// large as possible
textScaleFactor: 1,
textScaler: TextScaler.noScaling,
maxLines: 1,
style: GoogleFonts.josefinSans(
fontWeight: FontWeight.w300,
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/error_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:go_router/go_router.dart';
import 'package:translations/app_localizations.dart';

class ErrorPage extends StatelessWidget {
const ErrorPage({Key? key}) : super(key: key);
const ErrorPage({super.key});

@override
Widget build(BuildContext context) {
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/reorder_properties_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:translations/app_localizations.dart';
import 'package:go_router/go_router.dart';

class ReorderPropertiesPage extends ConsumerWidget {
const ReorderPropertiesPage({Key? key}) : super(key: key);
const ReorderPropertiesPage({super.key});

@override
Widget build(BuildContext context, WidgetRef ref) {
Expand Down
8 changes: 5 additions & 3 deletions lib/pages/reorder_units_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ class ChoosePropertyPage extends ConsumerWidget {
/// "Choose property page" to the "Reorder units" page
final bool isPropertySelected;

const ChoosePropertyPage(
{this.selectedProperty, this.isPropertySelected = false, Key? key})
: super(key: key);
const ChoosePropertyPage({
this.selectedProperty,
this.isPropertySelected = false,
super.key,
});

static const BorderRadius borderRadius =
BorderRadius.all(Radius.circular(30));
Expand Down
5 changes: 1 addition & 4 deletions lib/pages/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ class SettingsPage extends ConsumerWidget {
leading: Icon(Icons.language, color: iconColor),
title: AppLocalizations.of(context)!.language,
textStyle: textStyle,
items: [
AppLocalizations.of(context)!.system,
...mapLocale.values.toList()
],
items: [AppLocalizations.of(context)!.system, ...mapLocale.values],
value: mapLocale[ref.watch(CurrentLocale.provider).valueOrNull] ??
AppLocalizations.of(context)!.system,
onChanged: (String? string) {
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/splash_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';

class SplashScreen extends ConsumerWidget {
const SplashScreen({Key? key}) : super(key: key);
const SplashScreen({super.key});

@override
Widget build(BuildContext context, WidgetRef ref) {
Expand Down
36 changes: 14 additions & 22 deletions lib/utils/app_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ import 'package:translations/app_localizations.dart';
import 'package:go_router/go_router.dart';

class AppScaffold extends ConsumerWidget {
const AppScaffold({
required this.child,
Key? key,
}) : super(key: key);
const AppScaffold({required this.child, super.key});

final Widget child;

Expand Down Expand Up @@ -112,25 +109,20 @@ class AppScaffold extends ConsumerWidget {
);
}
// if the drawer is not fixed
return WillPopScope(
onWillPop: () async {
switch (selectedSection) {
case AppPage.settings:
context.go('/');
return false;
case AppPage.reorder:
return PopScope(
canPop: selectedSection == AppPage.conversions,
onPopInvoked: (var didPop) {
if (selectedSection == AppPage.settings) {
context.go('/');
} else if (selectedSection == AppPage.reorder) {
context.goNamed('settings');
} else if (selectedSection == AppPage.reorderDetails) {
//2 sided page
if (_isDrawerFixed) {
context.goNamed('settings');
return false;
case AppPage.reorderDetails:
//2 sided page
if (_isDrawerFixed) {
context.goNamed('settings');
} else {
context.goNamed('reorder-units');
}
return false;
default:
return true;
} else {
context.goNamed('reorder-units');
}
}
},
child: Scaffold(
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/reorder_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class ReorderPage extends StatefulWidget {
required this.itemsList,
required this.onSave,
required this.title,
Key? key,
}) : super(key: key);
super.key,
});

@override
State<ReorderPage> createState() => _ReorderPageState();
Expand Down
17 changes: 8 additions & 9 deletions lib/utils/utils_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ class UnitWidget extends StatefulWidget {
final void Function(String)? onChanged;

const UnitWidget({
Key? key,
super.key,
required this.tffKey,
this.keyboardType,
required this.controller,
this.validator,
required this.unitName,
this.unitSymbol,
this.onChanged,
}) : super(key: key);
});

@override
State<UnitWidget> createState() => _UnitWidgetState();
Expand Down Expand Up @@ -98,7 +98,7 @@ class SearchUnit {

class SearchUnitTile extends StatelessWidget {
final SearchUnit searchUnit;
const SearchUnitTile(this.searchUnit, {Key? key}) : super(key: key);
const SearchUnitTile(this.searchUnit, {super.key});

@override
Widget build(BuildContext context) {
Expand All @@ -119,7 +119,7 @@ class SearchUnitTile extends StatelessWidget {

class SuggestionList extends StatelessWidget {
final List<SearchUnit> suggestions;
const SuggestionList({required this.suggestions, Key? key}) : super(key: key);
const SuggestionList({required this.suggestions, super.key});

@override
Widget build(BuildContext context) {
Expand All @@ -142,8 +142,8 @@ class SearchGridTile extends StatelessWidget {
required this.footer,
required this.onTap,
required this.darkMode,
Key? key,
}) : super(key: key);
super.key,
});

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -289,7 +289,7 @@ class DropdownListTile extends StatelessWidget {
}

class SplashScreenWidget extends StatelessWidget {
const SplashScreenWidget({Key? key}) : super(key: key);
const SplashScreenWidget({super.key});
@override
Widget build(BuildContext context) {
return const Scaffold(
Expand All @@ -308,8 +308,7 @@ class SplashScreenWidget extends StatelessWidget {
class ConstrainedContainer extends StatelessWidget {
final Widget child;
final double maxWidth;
const ConstrainedContainer(this.child, {this.maxWidth = 500, Key? key})
: super(key: key);
const ConstrainedContainer(this.child, {this.maxWidth = 500, super.key});

@override
Widget build(BuildContext context) {
Expand Down
6 changes: 3 additions & 3 deletions packages/calculator_widget/lib/calculator_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class CalculatorHeader extends ConsumerWidget {
color: Theme.of(context).colorScheme.onBackground,
),
maxLines: 1,
textScaleFactor: 1,
textScaler: TextScaler.noScaling,
scrollPhysics: const ClampingScrollPhysics(),
),
),
Expand All @@ -138,7 +138,7 @@ class CalculatorHeader extends ConsumerWidget {
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.onBackground,
),
textScaleFactor: 1,
textScaler: TextScaler.noScaling,
maxLines: 1,
),
),
Expand Down Expand Up @@ -360,7 +360,7 @@ class CalculatorButton extends StatelessWidget {
text ?? '',
style: const TextStyle(fontSize: 27),
maxLines: 1,
textScaleFactor: 1,
textScaler: TextScaler.noScaling,
),
),
),
Expand Down
26 changes: 13 additions & 13 deletions packages/calculator_widget/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ packages:
dependency: transitive
description:
name: collection
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.17.2"
version: "1.18.0"
decimal:
dependency: "direct main"
description:
Expand Down Expand Up @@ -124,10 +124,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.10.0"
path:
dependency: transitive
description:
Expand Down Expand Up @@ -169,10 +169,10 @@ packages:
dependency: transitive
description:
name: stack_trace
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.11.1"
state_notifier:
dependency: transitive
description:
Expand All @@ -185,10 +185,10 @@ packages:
dependency: transitive
description:
name: stream_channel
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.1.2"
string_scanner:
dependency: transitive
description:
Expand All @@ -209,10 +209,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
version: "0.6.0"
version: "0.6.1"
translations:
dependency: "direct main"
description:
Expand All @@ -232,10 +232,10 @@ packages:
dependency: transitive
description:
name: web
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
url: "https://pub.dev"
source: hosted
version: "0.1.4-beta"
version: "0.3.0"
sdks:
dart: ">=3.1.0-185.0.dev <4.0.0"
dart: ">=3.2.0-194.0.dev <4.0.0"
flutter: ">=3.0.0"
Loading

0 comments on commit 24e4031

Please sign in to comment.