Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Flutter 3.0 fixes #1814

Merged
merged 10 commits into from
May 12, 2022
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/android-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
with:
channel: stable
cache: true
cache-key: flutter2.10 #change this to force refresh cache
cache-key: flutter3.00 # change this to force refresh cache
- run: flutter --version

- name: Get dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ios-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
with:
channel: stable
cache: true
cache-key: flutter2.10 # change this to force refresh cache
cache-key: flutter3.00 # change this to force refresh cache
- run: flutter --version

- name: Get dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/postsubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
with:
channel: stable
cache: true
cache-key: flutter2.10 #change this to force refresh cache
cache-key: flutter3.00 # change this to force refresh cache

- run: flutter --version

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
channel: stable
cache: true
cache-key: flutter2.10 #change this to force refresh cache
cache-key: flutter3.00 # change this to force refresh cache

- run: flutter --version

Expand Down
2 changes: 1 addition & 1 deletion packages/smooth_app/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
3 changes: 1 addition & 2 deletions packages/smooth_app/integration_test/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ flutter drive --driver=test_driver/screenshot_driver.dart --target=integration_t
/// Onboarding screenshots.
void main() {
final IntegrationTestWidgetsFlutterBinding binding =
IntegrationTestWidgetsFlutterBinding.ensureInitialized()
as IntegrationTestWidgetsFlutterBinding;
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

group('end-to-end test', () {
testWidgets('just a single screenshot', (WidgetTester tester) async {
Expand Down
3 changes: 2 additions & 1 deletion packages/smooth_app/l10n.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
arb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
output-localization-file: app_localizations.dart
nullable-getter: false
11 changes: 8 additions & 3 deletions packages/smooth_app/lib/cards/data_cards/image_upload_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ class _ImageUploadCardState extends State<ImageUploadCard> {
_imageProvider = FileImage(croppedImageFile);
_imageFullProvider = _imageProvider;
});

if (!mounted) {
return;
}
final bool isUploaded = await uploadCapturedPicture(
context,
barcode: widget.product
Expand All @@ -48,6 +50,9 @@ class _ImageUploadCardState extends State<ImageUploadCard> {
imageUri: croppedImageFile.uri,
);
croppedImageFile.delete();
if (!mounted) {
return;
}
if (isUploaded) {
widget.onUpload(context);
}
Expand Down Expand Up @@ -86,9 +91,9 @@ class _ImageUploadCardState extends State<ImageUploadCard> {
// we need to load the full resolution image

if (_imageFullProvider == null) {
final String _imageFullUrl =
final String imageFullUrl =
widget.productImageData.imageUrl!.replaceAll('.400.', '.full.');
_imageFullProvider = NetworkImage(_imageFullUrl);
_imageFullProvider = NetworkImage(imageFullUrl);
}

Navigator.push<Widget>(
Expand Down
12 changes: 6 additions & 6 deletions packages/smooth_app/lib/cards/data_cards/score_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,35 @@ class ScoreCard extends StatelessWidget {
return Container(
margin: const EdgeInsets.symmetric(vertical: 8.0),
padding: const EdgeInsets.all(8.0),
decoration: BoxDecoration(
color: backgroundColor,
borderRadius: ROUNDED_BORDER_RADIUS,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
if (iconChip != null)
Expanded(
flex: 1,
child: Padding(
padding: const EdgeInsets.only(right: 8.0),
child: iconChip,
),
flex: 1,
),
Expanded(
flex: 3,
child: Center(
child: Text(
description,
style: themeData.textTheme.headline4!.apply(color: textColor),
),
),
flex: 3,
),
const Icon(
Icons.keyboard_arrow_down_outlined,
),
],
),
decoration: BoxDecoration(
color: backgroundColor,
borderRadius: ROUNDED_BORDER_RADIUS,
),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class _KnowledgePanelTextElementCard extends StatelessWidget {

@override
Widget build(BuildContext context) {
final AppLocalizations appLocalizations = AppLocalizations.of(context)!;
final AppLocalizations appLocalizations = AppLocalizations.of(context);

Widget text = SmoothHtmlWidget(
textElement.html,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ class _KnowledgePanelTableCardState extends State<KnowledgePanelTableCard> {
children: <Widget>[
for (List<Widget> row in rowsWidgets)
Row(
children: row,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: row,
)
],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class KnowledgePanelsBuilder {
final bool nutritionAddOrUpdate = product.statesTags
?.contains('en:nutrition-facts-to-be-completed') ??
false;
final AppLocalizations appLocalizations = AppLocalizations.of(context)!;
final AppLocalizations appLocalizations = AppLocalizations.of(context);
knowledgePanelElementWidgets.add(
addPanelButton(
nutritionAddOrUpdate
Expand All @@ -137,6 +137,7 @@ class KnowledgePanelsBuilder {
if (cache == null) {
return;
}
//ignore: use_build_context_synchronously
final bool? refreshed = await Navigator.push<bool>(
context,
MaterialPageRoute<bool>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ProductImageCarousel extends StatelessWidget {

@override
Widget build(BuildContext context) {
final AppLocalizations appLocalizations = AppLocalizations.of(context)!;
final AppLocalizations appLocalizations = AppLocalizations.of(context);
final List<ProductImageData> allProductImagesData = <ProductImageData>[
ProductImageData(
imageField: ImageField.FRONT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ProductTitleCard extends StatelessWidget {

@override
Widget build(BuildContext context) {
final AppLocalizations appLocalizations = AppLocalizations.of(context)!;
final AppLocalizations appLocalizations = AppLocalizations.of(context);
final ThemeData themeData = Theme.of(context);
final String subtitleText;
final Widget trailingWidget;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SmoothProductCardError extends StatelessWidget {

@override
Widget build(BuildContext context) {
final AppLocalizations appLocalizations = AppLocalizations.of(context)!;
final AppLocalizations appLocalizations = AppLocalizations.of(context);

return Container(
decoration: BoxDecoration(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SmoothProductCardFound extends StatelessWidget {

@override
Widget build(BuildContext context) {
final AppLocalizations appLocalizations = AppLocalizations.of(context)!;
final AppLocalizations appLocalizations = AppLocalizations.of(context);
final UserPreferences userPreferences = context.watch<UserPreferences>();
final ProductPreferences productPreferences =
context.watch<ProductPreferences>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SmoothProductCardNotFound extends StatelessWidget {

@override
Widget build(BuildContext context) {
final AppLocalizations appLocalizations = AppLocalizations.of(context)!;
final AppLocalizations appLocalizations = AppLocalizations.of(context);
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return SmoothCard(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SmoothProductCardThanks extends StatelessWidget {
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(AppLocalizations.of(context)!.added_product_thanks),
Text(AppLocalizations.of(context).added_product_thanks),
const SizedBox(
height: 12.0,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import 'package:smooth_app/database/product_query.dart';
/// Helper around a product we download, store and reuse at onboarding.
class OnboardingDataProduct extends AbstractOnboardingData<Product> {
OnboardingDataProduct(
final LocalDatabase _localDatabase,
final LocalDatabase localDatabase,
this.fields,
this.assetPath,
) : super(_localDatabase);
) : super(localDatabase);

/// Was computed from [downloadDataString] in en_US
///
/// Something like https://world.openfoodfacts.org/api/v2/product/example/?fields=product_name%2Cbrands%2Ccode%2Cnutrition_grade_fr%2Cimage_small_url%2Cimage_front_small_url%2Cimage_front_url%2Cimage_ingredients_url%2Cimage_nutrition_url%2Cimage_packaging_url%2Cselected_images%2Cquantity%2Cserving_size%2Cproduct_quantity%2Cnutriments%2Cnutrient_levels%2Cnutriment_energy_unit%2Cadditives_tags%2Cingredients_analysis_tags%2Clabels_tags%2Clabels_tags_fr%2Cenvironment_impact_level_tags%2Ccategories_tags_fr%2Clang%2Cattribute_groups%2Cstates_tags%2Cecoscore_data%2Cecoscore_grade%2Cecoscore_score%2Cenvironment_impact_level_tags%2Cknowledge_panels&lc=en&cc=US
OnboardingDataProduct.forProduct(final LocalDatabase _localDatabase)
OnboardingDataProduct.forProduct(final LocalDatabase localDatabase)
: this(
_localDatabase,
localDatabase,
ProductQuery.fields,
'assets/onboarding/sample_product_data.json',
);
Expand Down
2 changes: 1 addition & 1 deletion packages/smooth_app/lib/data_models/onboarding_loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class OnboardingLoader {
await LoadingDialog.run<void>(
context: context,
future: _downloadData(),
title: AppLocalizations.of(context)!
title: AppLocalizations.of(context)
.onboarding_welcome_loading_dialog_title,
dismissible: false,
);
Expand Down
4 changes: 2 additions & 2 deletions packages/smooth_app/lib/database/product_query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ abstract class ProductQuery {
/// Sets the uuid id as "final variable", for instance for API queries.
///
/// To be called at main / init.
static Future<void> setUuid(final LocalDatabase _localDatabase) async {
final DaoString uuidString = DaoString(_localDatabase);
static Future<void> setUuid(final LocalDatabase localDatabase) async {
final DaoString uuidString = DaoString(localDatabase);
String? uuid = await uuidString.get(_UUID_NAME);

if (uuid == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ class _SmoothRevealAnimationState extends State<SmoothRevealAnimation>
@override
Widget build(BuildContext context) {
return FadeTransition(
opacity: _animationController,
child: SlideTransition(
position: _animationOffset,
child: widget.child,
),
opacity: _animationController,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ class SmoothActionButton extends StatelessWidget {
Widget build(BuildContext context) {
final ThemeData themeData = Theme.of(context);
return SmoothSimpleButton(
onPressed: onPressed,
height: height,
minWidth: minWidth,
child: AutoSizeText(
text,
style: themeData.textTheme.bodyText2!
.copyWith(color: themeData.colorScheme.onPrimary),
maxLines: 1,
),
onPressed: onPressed,
height: height,
minWidth: minWidth,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class SmoothLargeButtonWithIcon extends StatelessWidget {
final bool isDarkMode =
Provider.of<ThemeProvider>(context, listen: false).isDarkMode(context);
return SmoothSimpleButton(
minWidth: double.infinity,
padding: padding ?? const EdgeInsets.all(10),
buttonColor: isDarkMode ? Colors.grey : const Color(0xffeaf5fb),
onPressed: onPressed,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Expand All @@ -48,10 +52,6 @@ class SmoothLargeButtonWithIcon extends StatelessWidget {
const Spacer(),
],
),
minWidth: double.infinity,
padding: padding ?? const EdgeInsets.all(10),
buttonColor: isDarkMode ? Colors.grey : const Color(0xffeaf5fb),
onPressed: onPressed,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ class SmoothSimpleButton extends StatelessWidget {
final ThemeData themeData = Theme.of(context);
return MaterialButton(
color: buttonColor ?? themeData.colorScheme.primary,
child: Padding(
padding: padding,
child: child,
),
height: height,
minWidth: minWidth,
shape: RoundedRectangleBorder(
borderRadius: borderRadius,
),
onPressed: onPressed,
child: Padding(
padding: padding,
child: child,
),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,17 @@ class SmoothAlertDialog extends StatelessWidget {
Widget _buildCross(final bool isPlaceHolder, final BuildContext context) {
if (close) {
return Visibility(
maintainSize: true,
maintainAnimation: true,
maintainState: true,
visible: !isPlaceHolder,
child: InkWell(
child: const Icon(
Icons.close,
size: 29,
),
onTap: () => Navigator.of(context, rootNavigator: true).pop('dialog'),
),
maintainSize: true,
maintainAnimation: true,
maintainState: true,
visible: !isPlaceHolder,
);
} else {
return Container();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class _SmoothCategoryPickerState<T extends Comparable<T>>
initialData: null,
builder:
(BuildContext context, AsyncSnapshot<SmoothCategory<T>?> snapshot) {
final AppLocalizations appLocalizations = AppLocalizations.of(context)!;
final AppLocalizations appLocalizations = AppLocalizations.of(context);
final SmoothCategory<T>? category = snapshot.data;
if (category == null) {
return Container(
Expand Down
Loading