You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create Singleton class. Class have a Two static method. method name is show and hide, show method
accept context as a parameter and add entry into Overlay and hide method remove that overlay. Class code is as below
import 'package:flutter/material.dart';
import 'package:harshal/utils/loger.dart';
class InternetError {
static final _instance = new InternetError.internal();
factory InternetError() => _instance;
InternetError.internal();
static OverlayEntry entry = null;
static void show(context) => addOverlayEntry(context);
static void hide() => removeOverlay();
bool get isshow => entry != null;
static addOverlayEntry(context) {
if (entry != null) return;
entry = new OverlayEntry(builder: (BuildContext context) {
return LayoutBuilder(builder: (_, BoxConstraints constraints) {
return new Material(
color: Colors.transparent,
child: new Center(
child: new Container(
width: 90.0,
height: 80.0,
child: Column(
children: <Widget>[
new CircularProgressIndicator(
strokeWidth: 4.0,
valueColor:
new AlwaysStoppedAnimation<Color>(Colors.red.shade400)),
new Text("No internet")
],
),
),
),
);
});
});
addoverlay(entry, context);
}
static addoverlay(OverlayEntry entry, context) async {
Overlay.of(context).insert(entry);
}
static removeOverlay() {
logger(entry == null);
entry?.remove();
entry = null;
}
}
First use show static method is show overlay successfully
When call hide method then below Exception was throw
Logs
: ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (15138): The following assertion was thrown building MediaQuery(MediaQueryData(size: Size(411.4, 683.4),
I/flutter (15138): devicePixelRatio: 3.5, textScaleFactor: 1.0, padding: EdgeInsets(0.0, 24.0, 0.0, 0.0), viewInsets:
I/flutter (15138): EdgeInsets.zero, alwaysUse24HourFormat: false)):
I/flutter (15138): 'package:flutter/src/widgets/overlay.dart': Failed assertion: line 133 pos 12: '_overlay != null':
I/flutter (15138): is not true.
I/flutter (15138): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter (15138): more information in this error message to help you determine and fix the underlying cause.
I/flutter (15138): In either case, please report this assertion by filing a bug on GitHub:
I/flutter (15138): https://github.com/flutter/flutter/issues/new
I/flutter (15138): When the exception was thrown, this was the stack:
I/flutter (15138): #2 OverlayEntry.remove (package:flutter/src/widgets/overlay.dart)
I/flutter (15138): #3 InternetError.removeOverlay (package:harshal/ui/sidebar/no_internet.dart:50:12)
I/flutter (15138): #4 InternetError.hide (package:harshal/ui/sidebar/no_internet.dart:12:25)
I/flutter (15138): #5 new SideBarState (package:harshal/ui/sidebar/sidebar.dart:34:20)
I/flutter (15138): #6 SideBar.createState (package:harshal/ui/sidebar/sidebar.dart:18:16)
I/flutter (15138): #7 new StatefulElement (package:flutter/src/widgets/framework.dart:3710:23)
I/flutter (15138): #8 StatefulWidget.createElement (package:flutter/src/widgets/framework.dart:789:42)
I/flutter (15138): #9 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2905:40)
I/flutter (15138): #10 Element.updateChild (package:flutter/src/widgets/framework.dart:2710:12)
I/flutter (15138): #11 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4654:14)
I/flutter (15138): #12 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2907:14)
I/flutter (15138): #13 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4759:32)
I/flutter (15138): #14 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2907:14)
I/flutter (15138): #15 Element.updateChild (package:flutter/src/widgets/framework.dart:2710:12)
I/flutter (15138): #16 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3653:16)
I/flutter (15138): #17 Element.rebuild (package:flutter/src/widgets/framework.dart:3495:5)
I/flutter (15138): #18 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3622:5)
I/flutter (15138): #19 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3617:5)
I/flutter (15138): #20 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2907:14)
I/flutter (15138): #21 Element.updateChild (package:flutter/src/widgets/framework.dart:2710:12)
Doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, v0.5.1, on Microsoft Windows [Version 10.0.17134.165], locale en-IN)
[√] Android toolchain - develop for Android devices (Android SDK 28.0.1)
[√] Android Studio (version 3.1)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[!] VS Code, 64-bit edition (version 1.25.1)
[√] Connected devices (1 available)
! Doctor found issues in 1 category.
The text was updated successfully, but these errors were encountered:
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
to Reproduce
Create Singleton class. Class have a Two static method. method name is show and hide, show method
accept context as a parameter and add entry into Overlay and hide method remove that overlay. Class code is as below
Logs
Doctor
The text was updated successfully, but these errors were encountered: