0

Below code mainform.dart when run individually i.e keeping Dart entrypint: as mainform.dart working fine and redirecting or navigating to the correct page i.e Feed();

mainform.dart

import 'package:sqlite_crud_flutter/detail.dart';
import 'package:sqlite_crud_flutter/login.dart';
import 'package:sqlite_crud_flutter/notifier/food_notifier.dart';
import 'package:sqlite_crud_flutter/feed.dart';

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import 'notifier/auth_notifier.dart';


void main() => runApp(MultiProvider(
      providers: [
        ChangeNotifierProvider(
          create: (context) => AuthNotifier(),
        ),
        ChangeNotifierProvider(
          create: (context) => FoodNotifier(),
        ),
      ],
      child: MainFormPage(),
    ));

class MainFormPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Application Name',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        accentColor: Colors.lightBlue,
      ),
      home: Consumer<AuthNotifier>(
        builder: (context, notifier, child) {
          return  Feed();
        },
      ),
    );
  }
}

But where as when I want to redirect to the Feed() page from another screen or page of my main application using

 onTap: () {

Navigator.push(context, MaterialPageRoute(builder: (context) =>
MainFormPage()

)
);

},

I am seeing a blank screen with error

Another exception was thrown: Instance of 'DiagnosticsProperty<void>'"

How to the Feed page from another screen?

Screenshot of the error shown on mobile when debugged:

error screenshot

James Z
  • 12,209
  • 10
  • 24
  • 44
srk2K21
  • 11
  • 1
  • 6
  • Can you add logs with error from console to the question? – fartem Jan 21 '21 at 09:40
  • Ok I have already given the error shown i.e . " Another exception was thrown: Instance of 'DiagnosticsProperty'" . I will try to find out the error log as well. – srk2K21 Jan 21 '21 at 09:45
  • The relevant error-causing widget was: Consumer When the exception was thrown, this was the stack: #0 Provider._inheritedElementOf (package:provider/src/provider.dart:309:7) #1 Provider.of (package:provider/src/provider.dart:261:30) #2 Consumer.buildWithChild (package:provider/src/consumer.dart:177:16) #3 SingleChildStatelessWidget.build (package:nested/nested.dart:260:41) #4 StatelessElement.build (package:flutter/src/widgets/framework.dart:4620:28) – srk2K21 Jan 21 '21 at 09:52
  • @srk2K21 you mean to say when you are navigating from second page to `MainFormPage()` then this error occurred? – Shubham Narkhede Jan 21 '21 at 10:02
  • Yes I have a main Application and in that from one of the page or screen ex "mobiles.dart" page I want to redirect to the MainFormPage() which should ultimately redirect me to the Feed page i.e Feed() as shown in the code – srk2K21 Jan 21 '21 at 11:12
  • Hi Shubham please try to fix my problem asap..if you still have any queries please let me know – srk2K21 Jan 23 '21 at 08:18
  • Anyone still trying to fix my issue. Please et me know if you have any queries still? – srk2K21 Jan 25 '21 at 04:40
  • Hi Shubham still trying to fix my issue. Please et me know if you have any queries still? – srk2K21 Jan 25 '21 at 05:18
  • somebody please try to fix my blank screen widget issue. Urgent – srk2K21 Jan 26 '21 at 20:39
  • Hi fartem and shubham please try to fix this issue asap. – srk2K21 Jan 27 '21 at 05:57
  • No body trying to fix this issue. – srk2K21 Jan 28 '21 at 10:11

0 Answers0