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

refactor: #920 - when relevant, switched to "Navigator.push<void>" #2799

Merged
merged 1 commit into from
Aug 20, 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
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class _ImageUploadCardState extends State<ImageUploadCard> {
_imageFullProvider = NetworkImage(imageFullUrl);
}

// TODO(monsieurtanuki): careful, waiting for pop'ed value
final bool? refreshed = await Navigator.push<bool>(
context,
MaterialPageRoute<bool>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ class ProductTitleCard extends StatelessWidget {
onTap: (getProductName(product, appLocalizations) ==
appLocalizations.unknownProductName)
? () async {
await Navigator.push<Product?>(
await Navigator.push<void>(
context,
MaterialPageRoute<Product>(
MaterialPageRoute<void>(
builder: (BuildContext context) =>
AddBasicDetailsPage(product),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ class SmoothProductCardFound extends StatelessWidget {
borderRadius: ROUNDED_BORDER_RADIUS,
onTap: onTap ??
() async {
await Navigator.push<Widget>(
await Navigator.push<void>(
context,
MaterialPageRoute<Widget>(
MaterialPageRoute<void>(
builder: (BuildContext context) => ProductPage(product),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class SmoothProductCardNotFound extends StatelessWidget {
icon: Icons.add,
padding: const EdgeInsets.symmetric(vertical: LARGE_SPACE),
onPressed: () async {
// TODO(monsieurtanuki): careful, waiting for pop'ed value
final String? result = await Navigator.push<String>(
context,
MaterialPageRoute<String>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class AddCategoryButton extends StatelessWidget {
if (!await ProductRefresher().checkIfLoggedIn(context)) {
return;
}
await Navigator.push<Product>(
await Navigator.push<void>(
context,
MaterialPageRoute<Product>(
MaterialPageRoute<void>(
builder: (BuildContext context) => SimpleInputPage(
helper: SimpleInputPageCategoryHelper(),
product: product,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class AddIngredientsButton extends StatelessWidget {
if (!await ProductRefresher().checkIfLoggedIn(context)) {
return;
}
await Navigator.push<bool>(
await Navigator.push<void>(
context,
MaterialPageRoute<bool>(
MaterialPageRoute<void>(
builder: (BuildContext context) => EditOcrPage(
product: product,
helper: OcrIngredientsHelper(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class _AddNewProductPageState extends State<AddNewProductPage> {
}
// Photo can change in the ConfirmAndUploadPicture widget, the user
// may choose to retake the image.
// TODO(monsieurtanuki): careful, waiting for pop'ed value
//ignore: use_build_context_synchronously
final File? finalPhoto = await Navigator.push<File?>(
context,
Expand Down Expand Up @@ -269,6 +270,7 @@ class _AddNewProductPageState extends State<AddNewProductPage> {
if (!mounted) {
return;
}
// TODO(monsieurtanuki): careful, waiting for pop'ed value
final Product? result = await Navigator.push<Product?>(
context,
MaterialPageRoute<Product>(
Expand Down Expand Up @@ -319,6 +321,8 @@ class _AddNewProductPageState extends State<AddNewProductPage> {
text: AppLocalizations.of(context).completed_basic_details_btn_text,
icon: Icons.edit,
onPressed: () async {
// TODO(monsieurtanuki): probably wrong as AddBasicDetailsPage pops nothing
// TODO(monsieurtanuki): careful, waiting for pop'ed value
final Product? result = await Navigator.push<Product?>(
context,
MaterialPageRoute<Product>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ class _AddNutritionButtonState extends State<AddNutritionButton> {
if (!mounted) {
return;
}
await Navigator.push<Product>(
await Navigator.push<void>(
context,
MaterialPageRoute<Product>(
MaterialPageRoute<void>(
builder: (BuildContext context) => NutritionPageLoaded(
widget.product,
cache.orderedNutrients,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,9 @@ class _ProductListPageState extends State<ProductListPage>
if (!mounted) {
return;
}
await Navigator.push<Widget>(
await Navigator.push<void>(
context,
MaterialPageRoute<Widget>(
MaterialPageRoute<void>(
builder: (BuildContext context) =>
PersonalizedRankingPage(
barcodes: list,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ class _OcrWidget extends StatelessWidget {
onPressed: () async {
await onSubmitField();
//ignore: use_build_context_synchronously
Navigator.pop(context, product);
Navigator.pop(context);
},
),
),
Expand Down
25 changes: 13 additions & 12 deletions packages/smooth_app/lib/pages/product/edit_product_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ class _EditProductPageState extends State<EditProductPage> {
if (!await ProductRefresher().checkIfLoggedIn(context)) {
return;
}
await Navigator.push<Product?>(
await Navigator.push<void>(
context,
MaterialPageRoute<Product>(
MaterialPageRoute<void>(
builder: (_) => AddBasicDetailsPage(_product),
),
);
Expand All @@ -161,6 +161,7 @@ class _EditProductPageState extends State<EditProductPage> {
}
final List<ProductImageData> allProductImagesData =
getAllProductImagesData(_product, appLocalizations);
// TODO(monsieurtanuki): careful, waiting for pop'ed value
final bool? refreshed = await Navigator.push<bool>(
context,
MaterialPageRoute<bool>(
Expand Down Expand Up @@ -210,9 +211,9 @@ class _EditProductPageState extends State<EditProductPage> {
if (!await ProductRefresher().checkIfLoggedIn(context)) {
return;
}
await Navigator.push<Product?>(
await Navigator.push<void>(
context,
MaterialPageRoute<Product>(
MaterialPageRoute<void>(
builder: (BuildContext context) => EditOcrPage(
product: _product,
helper: OcrIngredientsHelper(),
Expand Down Expand Up @@ -241,9 +242,9 @@ class _EditProductPageState extends State<EditProductPage> {
if (!mounted) {
return;
}
await Navigator.push<Product?>(
await Navigator.push<void>(
context,
MaterialPageRoute<Product>(
MaterialPageRoute<void>(
builder: (BuildContext context) =>
NutritionPageLoaded(
_product,
Expand All @@ -262,9 +263,9 @@ class _EditProductPageState extends State<EditProductPage> {
if (!await ProductRefresher().checkIfLoggedIn(context)) {
return;
}
await Navigator.push<Product?>(
await Navigator.push<void>(
context,
MaterialPageRoute<Product>(
MaterialPageRoute<void>(
builder: (BuildContext context) => EditOcrPage(
product: _product,
helper: OcrPackagingHelper(),
Expand Down Expand Up @@ -296,9 +297,9 @@ class _EditProductPageState extends State<EditProductPage> {
if (!await ProductRefresher().checkIfLoggedIn(context)) {
return;
}
await Navigator.push<Product>(
await Navigator.push<void>(
context,
MaterialPageRoute<Product>(
MaterialPageRoute<void>(
builder: (BuildContext context) => SimpleInputPage(
helper: helper,
product: _product,
Expand Down Expand Up @@ -344,9 +345,9 @@ class _EditProductPageState extends State<EditProductPage> {
if (!await ProductRefresher().checkIfLoggedIn(context)) {
return;
}
await Navigator.push<Product>(
await Navigator.push<void>(
context,
MaterialPageRoute<Product>(
MaterialPageRoute<void>(
builder: (BuildContext context) => SimpleInputPage.multiple(
helpers: helpers,
product: _product,
Expand Down
4 changes: 2 additions & 2 deletions packages/smooth_app/lib/pages/product/new_product_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ class _ProductPageState extends State<ProductPage> with TraceableClientMixin {
_buildActionBarItem(
Icons.edit,
appLocalizations.edit_product_label,
() async => Navigator.push<bool>(
() async => Navigator.push<void>(
context,
MaterialPageRoute<bool>(
MaterialPageRoute<void>(
builder: (BuildContext context) => EditProductPage(_product),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ class _ProductImageGalleryViewState extends State<ProductImageGalleryView> {
return;
}

// TODO(monsieurtanuki): careful, waiting for pop'ed value
// ignore: use_build_context_synchronously
final File? photoUploaded = await Navigator.push<File?>(
context,
Expand Down
16 changes: 8 additions & 8 deletions packages/smooth_app/lib/pages/product/summary_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,9 @@ class _SummaryCardState extends State<SummaryCard> {
addPanelButton(
localizations.completed_basic_details_btn_text,
onPressed: () async {
await Navigator.push<Product?>(
await Navigator.push<void>(
context,
MaterialPageRoute<Product>(
MaterialPageRoute<void>(
builder: (BuildContext context) =>
AddBasicDetailsPage(_product),
),
Expand Down Expand Up @@ -433,9 +433,9 @@ class _SummaryCardState extends State<SummaryCard> {
InkWell(
borderRadius: const BorderRadius.only(topRight: ROUNDED_RADIUS),
onTap: widget.isSettingClickable
? () async => Navigator.push<Widget>(
? () async => Navigator.push<void>(
context,
MaterialPageRoute<Widget>(
MaterialPageRoute<void>(
builder: (BuildContext context) =>
const UserPreferencesPage(
type: PreferencePageType.FOOD,
Expand Down Expand Up @@ -621,9 +621,9 @@ class _SummaryCardState extends State<SummaryCard> {
if (questions.isNotEmpty && !_annotationVoted) {
return InkWell(
onTap: () async {
await Navigator.push<Widget>(
await Navigator.push<void>(
context,
MaterialPageRoute<Widget>(
MaterialPageRoute<void>(
builder: (BuildContext context) => QuestionPage(
product: _product,
questions: questions,
Expand Down Expand Up @@ -740,9 +740,9 @@ class _SummaryCardState extends State<SummaryCard> {
final KnowledgePanelPanelGroupElement? group =
KnowledgePanelGroupCard.groupElementOf(context);

Navigator.push<Widget>(
Navigator.push<void>(
context,
MaterialPageRoute<Widget>(
MaterialPageRoute<void>(
builder: (BuildContext context) => KnowledgePanelPage(
groupElement: group,
panel: knowledgePanel,
Expand Down
4 changes: 2 additions & 2 deletions packages/smooth_app/lib/pages/question_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,9 @@ class CongratsWidget extends StatelessWidget {
action: SmoothActionButton(
text: appLocalizations.sign_in,
onPressed: () async {
await Navigator.push<Widget>(
await Navigator.push<void>(
context,
MaterialPageRoute<Widget>(
MaterialPageRoute<void>(
builder: (_) => const LoginPage(),
),
);
Expand Down
4 changes: 2 additions & 2 deletions packages/smooth_app/lib/pages/scan/scan_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ class _ScanHeaderState extends State<ScanHeader> {
if (!mounted) {
return;
}
await Navigator.push<Widget>(
await Navigator.push<void>(
context,
MaterialPageRoute<Widget>(
MaterialPageRoute<void>(
builder: (BuildContext context) =>
PersonalizedRankingPage(
barcodes: model.productList.barcodes,
Expand Down
4 changes: 2 additions & 2 deletions packages/smooth_app/lib/pages/scan/scan_product_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class ScanProductCard extends StatelessWidget {
}

Future<void> _openProductPage(BuildContext context) async {
await Navigator.push<Widget>(
await Navigator.push<void>(
context,
MaterialPageRoute<Widget>(
MaterialPageRoute<void>(
builder: (BuildContext context) => ProductPage(product),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class _LoginPageState extends State<LoginPage> with TraceableClientMixin {
onPressed: () {
Navigator.push(
context,
MaterialPageRoute<Widget>(
MaterialPageRoute<void>(
builder: (BuildContext context) =>
const ForgotPasswordPage(),
),
Expand All @@ -274,6 +274,8 @@ class _LoginPageState extends State<LoginPage> with TraceableClientMixin {
height: size.height * 0.06,
child: OutlinedButton(
onPressed: () async {
// TODO(monsieurtanuki): we probably don't need the returned value and could check the "logged in?" question differently
// TODO(monsieurtanuki): careful, waiting for pop'ed value
final bool? registered = await Navigator.push<bool>(
context,
MaterialPageRoute<bool>(
Expand Down