Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter 'No Overlay widget exists above EditableText' error when using Provider

Hey I've got a MultiProvider setup, and it's now throwing this error when tapping on a TextField whereas it didn't before I implemented the multi-provider:

No Overlay widget exists above EditableText

The error text does not give any helpful indication of what in the code is causing the issue, here is the code:

import 'package:***_mobile/Providers/user_auth_provider.dart';
import 'package:***_mobile/screens/browsing_page.dart';
import 'package:***_mobile/screens/film_details_page.dart';
import 'package:***_mobile/screens/login_screen.dart';
import 'package:***_mobile/screens/venue_details_page.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

void main() {
  runApp(***());
}

class *** extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
      create: (_) => UserRepository.instance(),
      child: Consumer(
        builder: (context, UserRepository user, _) {
          return MaterialApp(
            title: 'Flutter Demo',
            routes: {
              '/browsing': (ctx) => BrowsingPage(),
              '/venueDetails': (ctx) => VenueDetailPage(),
              '/filmDetails': (ctx) => FilmDetailPage(),
              '/login': (ctx) => LoginPage()
            },
            theme: ThemeData(
              primarySwatch: Colors.blue,
              visualDensity: VisualDensity.adaptivePlatformDensity,
            ),
            builder: (ctx, _) {
              switch (user.status) {
                case Status.Uninitialized:
                  return LoginPage();
                case Status.Unauthenticated:
                  return LoginPage();
                case Status.Authenticating:
                  return LoginPage();
                case Status.Authenticated:
                  return BrowsingPage();
                default:
                  return LoginPage();
              }
            },
          );
        },
      ),
    );
  }
}
like image 739
CertainlyNotAdrian Avatar asked Jul 27 '20 14:07

CertainlyNotAdrian


1 Answers

Excuse for my language, i hope you will understand, what i was wrote. You need wrap every widget, which you return from builder in Navigator

Navigator(
      
        onGenerateRoute: (_) => MaterialPageRoute(
          builder: (ctx) => Scaffold(
            body: Stack(
              children: [
                Positioned.fill(
                    child: buildBody(
                        context.watch<AuthScopeViewModel>().screenType))
              ],
            ),
          ),
        ),
      );
like image 98
danial Avatar answered Nov 09 '22 03:11

danial