adamjohnlea / Flutter-Login-With-BLoC-Pattern

A new Flutter project featuring a faked authentication interface to demonstrate validation. Implemented with BloC pattern.
80 stars 16 forks source link

Login button is not getting activated when used in routes #3

Closed pravinarr closed 5 years ago

pravinarr commented 5 years ago

I am creating a new app with navigation declared on the material app

class App extends StatelessWidget {
  Widget build(BuildContext context) {
    return  MaterialApp(
        title: 'Log Me In!',
        routes: {
          '/':(context) => Provider(
            child: Scaffold(
              body: LoginScreen(),
            ),
          )
        },
       );
  }
}

If I use the above code Login button is not getting activated. I tried debugging, but Stream get submitValid => Observable.combineLatest2(email, password, (e, p) => true); submitValid stream is always empty.

If I am not using the navigation and it works fine as expected.

I am new to flutter, I might be missing something here. So any help in finding the issue will help me a lot.

thanks in advance

pravinarr commented 5 years ago

The issue was due to multiple instance of Bloc being created when used with routes. To solve this issue, use final bloc or instantiate all the blocs in initState method