Navigation Issue in my flutter Application. Unable to redirect to the required page or screen in flutter

541 Views Asked by At

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

0

There are 0 best solutions below