Comments (11)
I confirm, mine too
from progress_dialog.
Can you show me the sample code to reproduce
from progress_dialog.
Hello there @fayaz07 i do have the same issue i will share my code with you
bool isHidden = await pr.hide(); if(isHidden){ Navigator.of(context).pop(); }
When i debug my code it works fine , but when i use it as normal it doesn't work . as the guys above mentioned sometimes it works sometimes not
from progress_dialog.
@khamisEDX , can you post full page sample code
from progress_dialog.
class AddUser extends StatefulWidget {
final Map<String, dynamic> data;
AddUser(this.data);
@override
_AddUserState createState() => _AddUserState();
}
class _AddUserState extends State<AddUser> {
MyModel model;
CustomDio customDio;
TextEditingController emailTEC;
TextEditingController fisrtNameTEC;
TextEditingController lastNameTEC;
TextEditingController phoneNumberTEC;
TextEditingController designationTEC;
String mobileNumber;
String mobileNumberFormData;
String phoneIsoCode = "";
bool visible = false;
String confirmedNumber = '';
bool enabled = true;
bool pointOfContact = false;
bool overrideSMS = false;
bool sendNotification = false;
Map test;
List<String> list;
bool isInternalUser = false;
ProgressDialog pr;
@override
void initState() {
super.initState();
pr = new ProgressDialog(context);
emailTEC = new TextEditingController();
fisrtNameTEC = new TextEditingController();
lastNameTEC = new TextEditingController();
phoneNumberTEC = new TextEditingController();
designationTEC = new TextEditingController();
model = widget.data[Constants.MODEL];
model.onInitStateChooseDefaultValue(RouteGenerater.ADMIN_ADD);
customDio = new CustomDio(context, new Dio(), model);
getApiData();
permissionAndPolicy();
}
@override
void dispose() {
super.dispose();
// wholePolicy
model.onDisposeWholePolicy();
emailTEC.dispose();
fisrtNameTEC.dispose();
lastNameTEC.dispose();
phoneNumberTEC.dispose();
designationTEC.dispose();
}
permissionAndPolicy() {
if (Constants.internalUsers
.contains(model.userPolicyAndRoleID['role_id'].toString())) {
isInternalUser = true;
}
model.userPolicyAndRoleID['user_policy']['Member Portal'].forEach((list) {
var map = new Map<String, List<String>>();
map[list.keys.toList()[0]] = new List<String>();
model.updateWholePolicy(map);
});
}
void onPhoneNumberChange(
String number, String internationalizedPhoneNumber, String isoCode) {
setState(() {
phoneIsoCode = internationalizedPhoneNumber.substring(0, internationalizedPhoneNumber.length - number.length);
mobileNumber = number;
mobileNumberFormData = "$phoneIsoCode-$number";
});
}
onValidPhoneNumber(
String number, String internationalizedPhoneNumber, String isoCode) {
setState(() {
visible = true;
confirmedNumber = internationalizedPhoneNumber;
});
}
getApiData() async {
if (model.allRoles.isEmpty) {
await customDio.getAllFiltersAdminLIST(true, 23, null);
await customDio.getAllFiltersAdminLIST(true, 25, null);
}
}
Future<void> onPressed() async {
pr.style(
insetAnimCurve: Curves.easeInOut,
backgroundColor: Colors.white,
borderRadius: 10.0,
progressWidget: Container(
padding: EdgeInsets.all(8.0),
child: CircularProgressIndicator(
backgroundColor: AllColors.primary,
)),
);
Map<String, dynamic> formData = new Map<String, dynamic>();
Map<String, dynamic> message = new Map<String, dynamic>();
formData['account_enabled'] = enabled;
formData['sms_otp_override'] = overrideSMS;
formData['point_of_contact'] = pointOfContact;
formData['send_email'] = sendNotification;
if (emailTEC.text.isEmpty) {
message['Email'] = null;
} else {
formData['email'] = emailTEC.text;
}
if (fisrtNameTEC.text.isEmpty) {
message['First Name'] = null;
} else {
formData['first_name'] = fisrtNameTEC.text;
}
if (lastNameTEC.text.isEmpty) {
message['Last Name'] = null;
} else {
formData['last_name'] = lastNameTEC.text;
}
if (model.selectedRole.id == null) {
message['Role'] = null;
}
if (mobileNumberFormData == null || mobileNumberFormData.isEmpty) {
message['Mobile number'] = null;
} else {
formData["mobile_number"] = mobileNumberFormData;
}
if (designationTEC.text.isEmpty) {
message['Desination'] = null;
} else {
formData['designation'] = designationTEC.text;
}
// check (choose a type)
if (model.wholePolicy.isEmpty) {
message['Policy'] = null;
}
if (model.selectedNotification.isEmpty) {
message['Components'] = "are required";
}
if (model.selectedMemberGroupAddUser.isEmpty) {
message['Member group'] = null;
}
if (message.isEmpty) {
pr.show();
var res = await customDio.adminAddUser(true, formData);
if(res != null){
if(!res.containsKey(Constants.CACHE_ERROR)){
bool isHidden = await pr.hide();
if(isHidden){
customShowDialogYesNo(context, AppLocalizations.of(context).tr("addSA_Success_msg"), AppLocalizations.of(context).tr("addUser_admin_msg") ,
(){
Navigator.of(context).pop();
}, false);
}
}
}
} else {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => DialogValidation(
{Constants.MODEL: model, Constants.WRONG_DATA: message}));
}
// print('''
// All member group => ${model.selectedMemberGroupAddUser.toString()}
// Email => ${emailTEC.text}
// firstName => ${fisrtNameTEC.text}
// LastName => ${lastNameTEC.text}
// Roles => ${model.selectedRole.name}
// Mobile Phone => ${mobileNumber.toString()}
// Phone Number => ${phoneNumberTEC.text}
// Designation => ${designationTEC.text}
// Choose Type => ${model.selectedNotification.toString()}
// Send Notification => $sendNotification
// Enabled => $enabled
// Points of Contact => $pointOfContact
// OverrideSMS => $overrideSMS
// Policy => ${model.wholePolicy}
// ''');
}
@override
Widget build(BuildContext context) {
return ScopedModelDescendant<MyModel>(
builder: (_, child, dontusethis) {
return Scaffold(
bottomNavigationBar:
RaisedButton(child: Text('temp button'), onPressed: onPressed),
appBar: CustomizedAppbar(
model: model,
route: RouteGenerater.ADMIN_ADD,
showArrow: true,
title: "admin_add_title",
),
body: model.allRoles.isEmpty //&& model.allNotifications.isEmpty
? Center(
child: CircularProgressIndicator(
backgroundColor: AllColors.primary,
),
)
: ListView(
shrinkWrap: true,
children: <Widget>[
model.isMultiSelect
? Container(
//height: 100,
margin: const EdgeInsets.only(
left: 10.0, right: 10.0, bottom: 5.0, top: 10),
padding: const EdgeInsets.all(3.0),
color: Colors.transparent,
child: new Container(
decoration: new BoxDecoration(
color: Colors.white,
border: new Border.all(
color: Color(0xFFBDBDBD),
width: 2,
),
borderRadius: new BorderRadius.circular(12)),
child: DropdownButtonHideUnderline(
child: SearchableDropdown.multiple(
isCaseSensitiveSearch: false,
clearIcon: Icon(null),
dialogBox: true,
displayClearIcon: false,
doneButton: false,
isExpanded: true,
underline: "",
hint: "All member groups",
searchHint: "All member groups",
selectedItems: model
.selectedMemberGroupAddUser
.map((e) => model.allMemberGroupsAddUser
.indexWhere(
(element) => element.id == e.id))
.toList(),
items: model.allMemberGroupsAddUser.map((e) {
return DropdownMenuItem(
value: e.id,
child: Text(e.name),
);
}).toList(),
onChanged: (List<int> value) {
for (int item in value) {
model
.addAndRemoveFromListTilesCheckBoxesByCode(
24,
true,
model.allMemberGroupsAddUser[
item]);
}
},
),
),
))
: createSpinnerItem(
code: 24,
context: context,
model: model,
dataList: model.allMemberGroupsAddUser,
headingSpinner: "",
item: model.selectedMemberGroupAddUser[0]),
textField(emailTEC, "Email"),
textField(fisrtNameTEC, "First Name"),
textField(lastNameTEC, "Last Name"),
createSpinnerItem(
code: 23,
context: context,
model: model,
dataList: model.allRoles,
headingSpinner: "",
item: model.selectedRole),
Container(
height: 50,
margin: const EdgeInsets.only(
left: 10.0, right: 10.0, bottom: 5.0, top: 10),
padding: const EdgeInsets.all(3.0),
color: Colors.transparent,
child: new Container(
decoration: new BoxDecoration(
color: Colors.white,
border: new Border.all(
color: Color(0xFFBDBDBD),
width: 2,
),
borderRadius: new BorderRadius.circular(12)),
child: Center(
child: InternationalPhoneInput(
decoration: InputDecoration(
//counterText: '',
//enabled: true,
//helperText: '',
//isDense: false,
contentPadding:
EdgeInsets.symmetric(vertical: 15),
border: InputBorder.none,
focusedErrorBorder: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
//errorBorder: InputBorder.none,
disabledBorder: InputBorder.none,
),
onPhoneNumberChange: onPhoneNumberChange,
initialPhoneNumber: mobileNumber,
initialSelection: phoneIsoCode,
labelText: "Phone Number",
),
),
)),
textField(phoneNumberTEC, "Phone Number"),
textField(designationTEC, "Designation"),
createSpinnerMultipleSelection(
code: 25,
context: context,
model: model,
headingSpinner: '',
dataList: model.allNotifications,
item: model.selectedNotification,
label: model.selectedNotificationLabel),
SwitchListTile(
title: Text("Send Notification"),
activeColor: AllColors.primary,
value: sendNotification,
onChanged: (newValue) {
setState(() {
sendNotification = newValue;
});
}),
SwitchListTile(
title: Text("Enabled"),
activeColor: AllColors.primary,
value: enabled,
onChanged: (newValue) {
setState(() {
enabled = newValue;
});
}),
SwitchListTile(
title: Text("Point of Contacts"),
activeColor: AllColors.primary,
value: pointOfContact,
onChanged: (newValue) {
setState(() {
pointOfContact = newValue;
});
}),
SwitchListTile(
title: Text("Override SMS"),
activeColor: AllColors.primary,
value: overrideSMS,
onChanged: (newValue) {
setState(() {
overrideSMS = newValue;
});
}),
Container(height: 20),
Container(
color: Colors.white,
padding: EdgeInsets.all(10.0),
child: Table(
columnWidths: {
0: FlexColumnWidth(2.0),
1: FlexColumnWidth(1.0),
2: FlexColumnWidth(1.0),
},
border: TableBorder.all(
color: Colors.black.withOpacity(0.2)),
children: [
TableRow(children: [
TableCell(
verticalAlignment:
TableCellVerticalAlignment.middle,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Module",
textAlign: TextAlign.left,
),
)),
TableCell(
verticalAlignment:
TableCellVerticalAlignment.middle,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"View",
textAlign: TextAlign.left,
),
)),
TableCell(
verticalAlignment:
TableCellVerticalAlignment.middle,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Add",
textAlign: TextAlign.left,
),
)),
TableCell(
verticalAlignment:
TableCellVerticalAlignment.middle,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Edit",
textAlign: TextAlign.left,
),
)),
TableCell(
verticalAlignment:
TableCellVerticalAlignment.middle,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Delete",
textAlign: TextAlign.left,
),
)),
]),
for (Map item in model.wholePolicy)
TableRow(children: [
TableCell(
verticalAlignment:
TableCellVerticalAlignment.middle,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
item.keys.toList()[0],
textAlign: TextAlign.left,
),
)),
TableCell(
child: Center(
child: Switch(
activeColor: AllColors.primary,
value: item[item.keys.toList()[0]]
.contains("View")
? true
: false,
onChanged: (val) {
setState(() {
item[item.keys.toList()[0]].contains("View")
? {
item[item.keys.toList()[0]].contains("Add") ?
item[item.keys.toList()[0]].remove("Add") : null ,
item[item.keys.toList()[0]].contains("Edit") ?
item[item.keys.toList()[0]].remove("Edit") : null ,
item[item.keys.toList()[0]].contains("Delete") ?
item[item.keys.toList()[0]].remove("Delete") : null ,
item[item.keys.toList()[0]].remove("View"),
}:
item[item.keys.toList()[0]].add("View");
});
}),
),
),
TableCell(
child: Center(
child: Switch(
activeColor: AllColors.primary,
value: item[item.keys.toList()[0]]
.contains("Add")
? true
: false,
onChanged: (val) {
setState(() {
item[item.keys.toList()[0]].contains("Add")
? item[item.keys.toList()[0]]
.remove("Add")
: item[item.keys.toList()[0]].add("Add");
});
}),
),
),
TableCell(
child: Center(
child: Switch(
activeColor: AllColors.primary,
value: item[item.keys.toList()[0]]
.contains("Edit")
? true
: false,
onChanged: (val) {
setState(() {
item[item.keys.toList()[0]]
.contains("Edit")
? item[item.keys.toList()[0]]
.remove("Edit")
: item[item.keys.toList()[0]]
.add("Edit");
});
}),
),
),
TableCell(
child: Center(
child: Switch(
activeColor: AllColors.primary,
value: item[item.keys.toList()[0]]
.contains("Delete")
? true
: false,
onChanged: !isInternalUser
? null
: (val) {
setState(() {
item[item.keys.toList()[0]]
.contains("Delete")
? item[item.keys
.toList()[0]]
.remove("Delete")
: item[item.keys
.toList()[0]]
.add("Delete");
});
}),
),
),
])
]),
)
],
),
);
},
);
}
}
Widget textField(TextEditingController tec, String hint) {
return Container(
height: 40,
margin:
const EdgeInsets.only(left: 10.0, right: 10.0, bottom: 5.0, top: 10),
padding: const EdgeInsets.all(3.0),
color: Colors.transparent,
child: new Container(
decoration: new BoxDecoration(
color: Colors.white,
border: new Border.all(
color: Color(0xFFBDBDBD),
width: 2,
),
borderRadius: new BorderRadius.circular(12)),
child: TextFormField(
controller: tec,
decoration: new InputDecoration(
border: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
errorBorder: InputBorder.none,
disabledBorder: InputBorder.none,
contentPadding:
EdgeInsets.only(left: 8, bottom: 11, top: 11, right: 8),
hintText: hint),
),
));
}
from progress_dialog.
@khamisEDX can you make it a bit simple :)
from progress_dialog.
@khamisEDX can you make it a bit simple :)
Yes sorry for the previous 👍
from progress_dialog.
@fayaz07 any news ?
from progress_dialog.
Sorry @khamisEDX can you give me shorter code
from progress_dialog.
Basically this is the function you need to see @fayaz07
Future<void> onPressed() async {
pr.style(
insetAnimCurve: Curves.easeInOut,
backgroundColor: Colors.white,
borderRadius: 10.0,
progressWidget: Container(
padding: EdgeInsets.all(8.0),
child: CircularProgressIndicator(
backgroundColor: AllColors.primary,
)),
);
Map<String, dynamic> formData = new Map<String, dynamic>();
Map<String, dynamic> message = new Map<String, dynamic>();
if (emailTEC.text.isEmpty) {
message['Email'] = null;
} else {
formData['email'] = emailTEC.text;
}
if (fisrtNameTEC.text.isEmpty) {
message['First Name'] = null;
} else {
formData['first_name'] = fisrtNameTEC.text;
}
if (message.isEmpty) {
pr.show();
var res = await customDio.adminAddUser(true, formData);
if(res != null){
if(!res.containsKey(Constants.CACHE_ERROR)){
bool isHidden = await pr.hide();
if(isHidden){
customShowDialogYesNo(context, AppLocalizations.of(context).tr("addSA_Success_msg"), AppLocalizations.of(context).tr("addUser_admin_msg") ,
(){
Navigator.of(context).pop();
}, false);
}
}
}
} else {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => DialogValidation(
{Constants.MODEL: model, Constants.WRONG_DATA: message}));
}
}
from progress_dialog.
the problem was not using await in show() , so using await for both hide && show , you can use this class i made if you want to be a singleton class
class ProgressDialogSingleton {
static ProgressDialogSingleton instance;
ProgressDialog progressDialog;
ProgressDialogSingleton(BuildContext context) {
if (progressDialog == null) {
progressDialog = new ProgressDialog(context);
progressDialog.style(
insetAnimCurve: Curves.easeInOut,
backgroundColor: Colors.white,
borderRadius: 10.0,
progressWidget: Container(
padding: EdgeInsets.all(8.0),
child: Theme(
data: ThemeData(
accentColor: AllColors.primary
),
child: CircularProgressIndicator(),
)),
);
}
}
static getInstance(BuildContext context) {
if (instance == null) {
instance = new ProgressDialogSingleton(context);
}
return instance;
}
Future<void> showHide() async {
try {
if(progressDialog.isShowing()){
await progressDialog.hide();
}else{
await progressDialog.show();
}
} catch (e) {
print(e.toString());
}
}
void onDispose(){
instance = null;
progressDialog = null;
}
}
from progress_dialog.
Related Issues (20)
- Feature: Use showCupertinoModalPopup when used on IOS HOT 1
- Error: type 'FlutterError' is not a subtype of type 'String' HOT 1
- Issue when await finishes quickly. HOT 1
- Support for dark/light theme HOT 1
- a ProgressDialogType.Download bug for 1.2.3 HOT 9
- Custom Gif not working HOT 2
- The hide method will be close lastest dialog instead of it. HOT 1
- Handle library with Bloc Library HOT 6
- Show only circular indicator HOT 3
- RenderBox Size Isse Exception caught by rendering library HOT 2
- Can provide a close button on top right corner to interrupt a long progress? HOT 3
- Wrap MaterialApp to call progress dialog without context HOT 1
- Bug on hide HOT 6
- Multiple dialogs on multiple Routes
- Dynamically update not working well HOT 1
- Can I disable user interaction when loading? HOT 1
- Download progress decimal places pattern HOT 7
- PD not getting dismissed some times HOT 5
- Dialog not being hid after dispose() being called
- How to change the progressWidget size? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from progress_dialog.