How to make CupertinoActivityIndicator top of every layout? - flutter

How to make CupertinoActivityIndicator top of every layout?
i need to show progress bar on when login and home page loading time

You could show a dialog like this:
void _showIndicator() {
showDialog(
barrierDismissible: false,
context: context,
builder: (BuildContext context) => Center(
child: CircularProgressIndicator(),
),
);
}
In this example, I am using CircularProgressIndicator, but you could replace that with CupertinoActivityIndicator. When you want to dismiss the indicator, call:
Navigator.pop(context);

Related

How to add youtube player in a modal bottom sheet flutter?

I am using youtube_player_flutter in a project, I need to implement this in a modal bottom sheet. How can I implement this?
Try the following code:
showModalBottomSheet(
context: context,
builder: (context) => Scaffold(
body: YoutubePlayer(…),
),
),

I want a similar screen (one on top of other) like following to complete my weather app made using flutter . Can anyone please help me out?

I want this type of screen one on top of other and the previous screen should be lightly blurred or it should slightly darkens
You could use 'ModalBottomSheet' or even 'DraggableScrollableSheet' if a list is associated.
ModalBottomSheet
showModalBottomSheet(
context: context,
builder: (context) {
return Container(
// widgets
),
);
});
DraggableScrollableSheet
DraggableScrollableSheet(
builder:
(BuildContext context, ScrollController scrollController) {
return Container(
// widgets
);
},
),

How to handle back button of browser in Flutter Web

this question had already asked in this link How to configure go back button in Browser for Flutter Web App
and I implement onWillPop, so when user is in A screen and then click the button See Detail I will navigate them to B screen and then.. when user is in B screen and click the back button of browser I will navigate them back to A screen... the first trial is success but when I do it second time I got an error like this
Error: Assertion failed: org-dartlang-sdk:///flutter_web_sdk/lib/_engine/engine/navigation/history.dart:288:14
_userProvidedRouteName != null
is not true
in my first screen (A Screen), I have a button like this:
FlatButton(
onPressed: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (BuildContext ctx) =>
Detail(
value:x[i])));
},
child: Text("See Detail"),
textColor: Colors.white,
color: Colors.blueAccent,
)
and for the Detail Screen (B Screen) I use onWillPop like this
WillPopScope(
onWillPop: () {
Navigator.pushReplacement(context,
MaterialPageRoute(builder: (BuildContext ctx) => FirstScreen()));
return Future.value(true);
},
child: Scaffold(
key: _globalKey,
....
is there something that I should add more?
Call Navigator.pop(context); inside the onWillPop of screen B.
Make sure when you navigate from Screen A to Screen B, you should not use Navigator.pushReplacement as it removes ScreenA from the screen stack(not sure if this is the right term)
Navigator.push(
context,
MaterialPageRoute(builder: (context) => ScreenB()),
);
Here is an example by flutter.
https://flutter.dev/docs/cookbook/navigation/navigation-basics

How to pop CupertinoPageRoute with swipe down?

Currently I'm using the following Code to get a FadeInTransition from the bottom when opening the page.
Navigator.of(context).push(
CupertinoPageRoute(
fullscreenDialog: true,
maintainState: true,
builder: (BuildContext context) => Routines(),
)
)
Normally in iOS you can just swipe left to close the current page. Is there an easy way to swipe down to pop the current page or do I have to implement a custom field with a GestureDetector()?
The goal is to have a closing transition like in the GIF below using a swipe down at the top
I considered using a DraggableScrollableSheet but I don't want to slide the Page into view from the bottom.
I ended up solving it with an DraggableScrollableSheet:
onPressed: () {
showModalBottomSheet(
backgroundColor: Colors.transparent,
context: context,
isScrollControlled: true,
builder: (BuildContext context) {
return Routines();
},
);
},
and Wrapping my new Page with:
return DraggableScrollableSheet( //TODO make same for Entries
expand: false,
initialChildSize: 1.0,
minChildSize: 0.8,
builder: (context, scrollController) {
return Page2();
}
);

How to close Flutter dialog from outside

This is how we close a dialog from INSIDE
showSomeDialog() {
return showDialog(
context: context,
builder: (BuildContext contextPopup) {
return AlertDialog(
content: Center(
child: RaisedButton(
onPressed: () {
Navigator.of(contextPopup).pop();
},
child: Text('Close me inside'),
),
),);
}
);
}
How to close this dialog from OUTSIDE ? In other words, how does the stateful widget creating this dialog can access the variable contextPopup ? The problem with Navigator.of(context).pop() is that it will close the topmost widget on the Navigation stack, not this specific dialog.
In Android, to close a dialog programmatically from outside, you just do:
dialog.dismiss();