unable to use scoped model in flutter bottom sheet,dialogsHow to offset a scaffold widget in Flutter?Using Scoped Model to maintain app state in flutterFlutter : Bad state: Stream has already been listened toFlutter scoped model with multiple classesFlutter Using Multiple Models with Scoped ModelFlutter - Running animation from scoped modelMaster-detail using Flutter scoped modelhello ,,,,,when I am clicking on card then show me this error how to fix this errorFlutter Scoped Model - Passing multiple ModelsShow dialog using Scoped model
Canadian citizen who is presently in litigation with a US-based company
Could a space colony 1g from the sun work?
Why use a retrograde orbit?
Solenoid fastest possible release - for how long should reversed polarity be applied?
Why did the soldiers of the North disobey Jon?
Is Big Ben visible from the British museum?
Why would you put your input amplifier in front of your filtering for and ECG signal?
How can I make dummy text (like lipsum) grey?
Why is the marginal distribution/marginal probability described as "marginal"?
Assign the same string to multiple variables
How can the noun "moyen" be used to denote the meaning "they still don't stop complaining"?
Why is so much ransomware breakable?
Cuban Primes
Cannot remove door knob -- totally inaccessible!
Why are lawsuits between the President and Congress not automatically sent to the Supreme Court
What color to choose as "danger" if the main color of my app is red
When did Britain learn about American independence?
How to know the path of a particular software?
Cycling to work - 30mile return
How to handle professionally if colleagues has referred his relative and asking to take easy while taking interview
What dog breeds survive the apocalypse for generations?
How was the blinking terminal cursor invented?
How could it be that 80% of townspeople were farmers during the Edo period in Japan?
Omit property variable when using object destructuring
unable to use scoped model in flutter bottom sheet,dialogs
How to offset a scaffold widget in Flutter?Using Scoped Model to maintain app state in flutterFlutter : Bad state: Stream has already been listened toFlutter scoped model with multiple classesFlutter Using Multiple Models with Scoped ModelFlutter - Running animation from scoped modelMaster-detail using Flutter scoped modelhello ,,,,,when I am clicking on card then show me this error how to fix this errorFlutter Scoped Model - Passing multiple ModelsShow dialog using Scoped model
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
when i run this code it shows an error that correct scopedmodel was not found. i think we have to declare another scoped model for
bottomsheet,dialogs also did that using with same model but it behaving abnormally. how do i achive that how to use scoped models in such bottom sheets and dialogs.
i was noob at scoped model
any help apreciated
import 'package:flutter/material.dart';
import 'package:scoped_model/scoped_model.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
class ResourcesModel extends Model
String selectsubject = 'Select the subject';
List<String> sublist=[];
change(int index)
debugPrint('$sublist[index]');
selectsubject=sublist[index];
notifyListeners();
fetchsubjects()
Firestore.instance.collection("resources").document("17csea").get().then((DocumentSnapshot ds)
for (var item in ds['subjects'])
sublist.add(item);
notifyListeners();
);
class Resources extends StatelessWidget
final ResourcesModel resourcesModel =ResourcesModel();
void showbottomsheet(context) async
double height =MediaQuery.of(context).size.height;
await showModalBottomSheet(
context: context,
builder: (context)
return Container(
height: height/2,
child: ScopedModelDescendant<ResourcesModel>(
builder:(context,_,model)
debugPrint('helelel');
return (model.sublist.isEmpty)?Center(child:CircularProgressIndicator()):
ListView.separated(
itemCount: model.sublist.length,
separatorBuilder: (context,_)
return Divider(
color: Theme.of(context).primaryColor,
);
,
itemBuilder: (context,index)
return ListTile(
title: Text(model.sublist[index]),
onTap: model.change(index),
);
,
);
),
);
);
@override
Widget build(BuildContext context)
return ScpedModel<ResourcesModel>(
model:resourcesmodel,
chilld:ScopedModelDescendant<ResourcesModel>(
builder:(context,_,model)
return Container(
color: Color(0xFFF3F3F3),
child: RaisedButton(
child: Text(model.selectsubject),
onPressed: ()
if(resourcesModel.sublist.isEmpty)
resourcesModel.fetchsubjects();
,
),
);
),
);
dart
add a comment |
when i run this code it shows an error that correct scopedmodel was not found. i think we have to declare another scoped model for
bottomsheet,dialogs also did that using with same model but it behaving abnormally. how do i achive that how to use scoped models in such bottom sheets and dialogs.
i was noob at scoped model
any help apreciated
import 'package:flutter/material.dart';
import 'package:scoped_model/scoped_model.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
class ResourcesModel extends Model
String selectsubject = 'Select the subject';
List<String> sublist=[];
change(int index)
debugPrint('$sublist[index]');
selectsubject=sublist[index];
notifyListeners();
fetchsubjects()
Firestore.instance.collection("resources").document("17csea").get().then((DocumentSnapshot ds)
for (var item in ds['subjects'])
sublist.add(item);
notifyListeners();
);
class Resources extends StatelessWidget
final ResourcesModel resourcesModel =ResourcesModel();
void showbottomsheet(context) async
double height =MediaQuery.of(context).size.height;
await showModalBottomSheet(
context: context,
builder: (context)
return Container(
height: height/2,
child: ScopedModelDescendant<ResourcesModel>(
builder:(context,_,model)
debugPrint('helelel');
return (model.sublist.isEmpty)?Center(child:CircularProgressIndicator()):
ListView.separated(
itemCount: model.sublist.length,
separatorBuilder: (context,_)
return Divider(
color: Theme.of(context).primaryColor,
);
,
itemBuilder: (context,index)
return ListTile(
title: Text(model.sublist[index]),
onTap: model.change(index),
);
,
);
),
);
);
@override
Widget build(BuildContext context)
return ScpedModel<ResourcesModel>(
model:resourcesmodel,
chilld:ScopedModelDescendant<ResourcesModel>(
builder:(context,_,model)
return Container(
color: Color(0xFFF3F3F3),
child: RaisedButton(
child: Text(model.selectsubject),
onPressed: ()
if(resourcesModel.sublist.isEmpty)
resourcesModel.fetchsubjects();
,
),
);
),
);
dart
add a comment |
when i run this code it shows an error that correct scopedmodel was not found. i think we have to declare another scoped model for
bottomsheet,dialogs also did that using with same model but it behaving abnormally. how do i achive that how to use scoped models in such bottom sheets and dialogs.
i was noob at scoped model
any help apreciated
import 'package:flutter/material.dart';
import 'package:scoped_model/scoped_model.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
class ResourcesModel extends Model
String selectsubject = 'Select the subject';
List<String> sublist=[];
change(int index)
debugPrint('$sublist[index]');
selectsubject=sublist[index];
notifyListeners();
fetchsubjects()
Firestore.instance.collection("resources").document("17csea").get().then((DocumentSnapshot ds)
for (var item in ds['subjects'])
sublist.add(item);
notifyListeners();
);
class Resources extends StatelessWidget
final ResourcesModel resourcesModel =ResourcesModel();
void showbottomsheet(context) async
double height =MediaQuery.of(context).size.height;
await showModalBottomSheet(
context: context,
builder: (context)
return Container(
height: height/2,
child: ScopedModelDescendant<ResourcesModel>(
builder:(context,_,model)
debugPrint('helelel');
return (model.sublist.isEmpty)?Center(child:CircularProgressIndicator()):
ListView.separated(
itemCount: model.sublist.length,
separatorBuilder: (context,_)
return Divider(
color: Theme.of(context).primaryColor,
);
,
itemBuilder: (context,index)
return ListTile(
title: Text(model.sublist[index]),
onTap: model.change(index),
);
,
);
),
);
);
@override
Widget build(BuildContext context)
return ScpedModel<ResourcesModel>(
model:resourcesmodel,
chilld:ScopedModelDescendant<ResourcesModel>(
builder:(context,_,model)
return Container(
color: Color(0xFFF3F3F3),
child: RaisedButton(
child: Text(model.selectsubject),
onPressed: ()
if(resourcesModel.sublist.isEmpty)
resourcesModel.fetchsubjects();
,
),
);
),
);
dart
when i run this code it shows an error that correct scopedmodel was not found. i think we have to declare another scoped model for
bottomsheet,dialogs also did that using with same model but it behaving abnormally. how do i achive that how to use scoped models in such bottom sheets and dialogs.
i was noob at scoped model
any help apreciated
import 'package:flutter/material.dart';
import 'package:scoped_model/scoped_model.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
class ResourcesModel extends Model
String selectsubject = 'Select the subject';
List<String> sublist=[];
change(int index)
debugPrint('$sublist[index]');
selectsubject=sublist[index];
notifyListeners();
fetchsubjects()
Firestore.instance.collection("resources").document("17csea").get().then((DocumentSnapshot ds)
for (var item in ds['subjects'])
sublist.add(item);
notifyListeners();
);
class Resources extends StatelessWidget
final ResourcesModel resourcesModel =ResourcesModel();
void showbottomsheet(context) async
double height =MediaQuery.of(context).size.height;
await showModalBottomSheet(
context: context,
builder: (context)
return Container(
height: height/2,
child: ScopedModelDescendant<ResourcesModel>(
builder:(context,_,model)
debugPrint('helelel');
return (model.sublist.isEmpty)?Center(child:CircularProgressIndicator()):
ListView.separated(
itemCount: model.sublist.length,
separatorBuilder: (context,_)
return Divider(
color: Theme.of(context).primaryColor,
);
,
itemBuilder: (context,index)
return ListTile(
title: Text(model.sublist[index]),
onTap: model.change(index),
);
,
);
),
);
);
@override
Widget build(BuildContext context)
return ScpedModel<ResourcesModel>(
model:resourcesmodel,
chilld:ScopedModelDescendant<ResourcesModel>(
builder:(context,_,model)
return Container(
color: Color(0xFFF3F3F3),
child: RaisedButton(
child: Text(model.selectsubject),
onPressed: ()
if(resourcesModel.sublist.isEmpty)
resourcesModel.fetchsubjects();
,
),
);
),
);
dart
dart
edited Mar 24 at 3:05
Saikumarreddy2391
asked Mar 23 at 16:22
Saikumarreddy2391Saikumarreddy2391
84
84
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Scoped Model when wrapped this to a page then it only applicable to that page only.
bottom sheets and dialogs in flutter nothing but creating new context i.e a new page so either we have to wrap on top of the material app or wrap another scoped model on bottom sheet with same model. that should work. and in Ur code U have that onpressed calling a fuction in a model i think so.
then the model builds again and again so change it to like this
onpressed:()
call funtion;
pop;
i think it may be helpful for some might be
add a comment |
At the root of your app you need to start it using. This allows you to use the ScopedModelDescendent widgets lower down in the tree.
ScopedModel<AppModel>(
model: AppModel(),
child: Resources())
Wherever you're displaying your Resources from make sure it's wrapped like above then you'll be able to use that model lower in your tree.
i am sorry i edited my question I already had it on the top of the widget tree also same error . the error is showing in the bottom sheet saying couldn't find the correct scoped model once try to run this code in ur editor to get me
– Saikumarreddy2391
Mar 24 at 3:07
@Saikumarreddy2391 Not in your resources the root that's displaying your Resources widget. Where are you showing the resources widget? What is putting it on the screen. The place where you're putting it on the screen should be surrounded by the code I have in my answer. The child that you want to be a descendent should only be a descendent, it shouldn't provide it's own model. That's the whole point of using scoped model.
– Filled Stacks
Mar 24 at 3:42
i am using the tab bar and the whole code above was the 2nd tab
– Saikumarreddy2391
Mar 24 at 6:57
Okay.Can you post the code that adds Resources onto the screen.
– Filled Stacks
Mar 24 at 7:11
Above was full code of the one the tab
– Saikumarreddy2391
Mar 24 at 8:01
|
show 5 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55315845%2funable-to-use-scoped-model-in-flutter-bottom-sheet-dialogs%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Scoped Model when wrapped this to a page then it only applicable to that page only.
bottom sheets and dialogs in flutter nothing but creating new context i.e a new page so either we have to wrap on top of the material app or wrap another scoped model on bottom sheet with same model. that should work. and in Ur code U have that onpressed calling a fuction in a model i think so.
then the model builds again and again so change it to like this
onpressed:()
call funtion;
pop;
i think it may be helpful for some might be
add a comment |
Scoped Model when wrapped this to a page then it only applicable to that page only.
bottom sheets and dialogs in flutter nothing but creating new context i.e a new page so either we have to wrap on top of the material app or wrap another scoped model on bottom sheet with same model. that should work. and in Ur code U have that onpressed calling a fuction in a model i think so.
then the model builds again and again so change it to like this
onpressed:()
call funtion;
pop;
i think it may be helpful for some might be
add a comment |
Scoped Model when wrapped this to a page then it only applicable to that page only.
bottom sheets and dialogs in flutter nothing but creating new context i.e a new page so either we have to wrap on top of the material app or wrap another scoped model on bottom sheet with same model. that should work. and in Ur code U have that onpressed calling a fuction in a model i think so.
then the model builds again and again so change it to like this
onpressed:()
call funtion;
pop;
i think it may be helpful for some might be
Scoped Model when wrapped this to a page then it only applicable to that page only.
bottom sheets and dialogs in flutter nothing but creating new context i.e a new page so either we have to wrap on top of the material app or wrap another scoped model on bottom sheet with same model. that should work. and in Ur code U have that onpressed calling a fuction in a model i think so.
then the model builds again and again so change it to like this
onpressed:()
call funtion;
pop;
i think it may be helpful for some might be
answered Mar 28 at 6:40
Saikumarreddy atluriSaikumarreddy atluri
568
568
add a comment |
add a comment |
At the root of your app you need to start it using. This allows you to use the ScopedModelDescendent widgets lower down in the tree.
ScopedModel<AppModel>(
model: AppModel(),
child: Resources())
Wherever you're displaying your Resources from make sure it's wrapped like above then you'll be able to use that model lower in your tree.
i am sorry i edited my question I already had it on the top of the widget tree also same error . the error is showing in the bottom sheet saying couldn't find the correct scoped model once try to run this code in ur editor to get me
– Saikumarreddy2391
Mar 24 at 3:07
@Saikumarreddy2391 Not in your resources the root that's displaying your Resources widget. Where are you showing the resources widget? What is putting it on the screen. The place where you're putting it on the screen should be surrounded by the code I have in my answer. The child that you want to be a descendent should only be a descendent, it shouldn't provide it's own model. That's the whole point of using scoped model.
– Filled Stacks
Mar 24 at 3:42
i am using the tab bar and the whole code above was the 2nd tab
– Saikumarreddy2391
Mar 24 at 6:57
Okay.Can you post the code that adds Resources onto the screen.
– Filled Stacks
Mar 24 at 7:11
Above was full code of the one the tab
– Saikumarreddy2391
Mar 24 at 8:01
|
show 5 more comments
At the root of your app you need to start it using. This allows you to use the ScopedModelDescendent widgets lower down in the tree.
ScopedModel<AppModel>(
model: AppModel(),
child: Resources())
Wherever you're displaying your Resources from make sure it's wrapped like above then you'll be able to use that model lower in your tree.
i am sorry i edited my question I already had it on the top of the widget tree also same error . the error is showing in the bottom sheet saying couldn't find the correct scoped model once try to run this code in ur editor to get me
– Saikumarreddy2391
Mar 24 at 3:07
@Saikumarreddy2391 Not in your resources the root that's displaying your Resources widget. Where are you showing the resources widget? What is putting it on the screen. The place where you're putting it on the screen should be surrounded by the code I have in my answer. The child that you want to be a descendent should only be a descendent, it shouldn't provide it's own model. That's the whole point of using scoped model.
– Filled Stacks
Mar 24 at 3:42
i am using the tab bar and the whole code above was the 2nd tab
– Saikumarreddy2391
Mar 24 at 6:57
Okay.Can you post the code that adds Resources onto the screen.
– Filled Stacks
Mar 24 at 7:11
Above was full code of the one the tab
– Saikumarreddy2391
Mar 24 at 8:01
|
show 5 more comments
At the root of your app you need to start it using. This allows you to use the ScopedModelDescendent widgets lower down in the tree.
ScopedModel<AppModel>(
model: AppModel(),
child: Resources())
Wherever you're displaying your Resources from make sure it's wrapped like above then you'll be able to use that model lower in your tree.
At the root of your app you need to start it using. This allows you to use the ScopedModelDescendent widgets lower down in the tree.
ScopedModel<AppModel>(
model: AppModel(),
child: Resources())
Wherever you're displaying your Resources from make sure it's wrapped like above then you'll be able to use that model lower in your tree.
answered Mar 23 at 16:42
Filled StacksFilled Stacks
1,22911018
1,22911018
i am sorry i edited my question I already had it on the top of the widget tree also same error . the error is showing in the bottom sheet saying couldn't find the correct scoped model once try to run this code in ur editor to get me
– Saikumarreddy2391
Mar 24 at 3:07
@Saikumarreddy2391 Not in your resources the root that's displaying your Resources widget. Where are you showing the resources widget? What is putting it on the screen. The place where you're putting it on the screen should be surrounded by the code I have in my answer. The child that you want to be a descendent should only be a descendent, it shouldn't provide it's own model. That's the whole point of using scoped model.
– Filled Stacks
Mar 24 at 3:42
i am using the tab bar and the whole code above was the 2nd tab
– Saikumarreddy2391
Mar 24 at 6:57
Okay.Can you post the code that adds Resources onto the screen.
– Filled Stacks
Mar 24 at 7:11
Above was full code of the one the tab
– Saikumarreddy2391
Mar 24 at 8:01
|
show 5 more comments
i am sorry i edited my question I already had it on the top of the widget tree also same error . the error is showing in the bottom sheet saying couldn't find the correct scoped model once try to run this code in ur editor to get me
– Saikumarreddy2391
Mar 24 at 3:07
@Saikumarreddy2391 Not in your resources the root that's displaying your Resources widget. Where are you showing the resources widget? What is putting it on the screen. The place where you're putting it on the screen should be surrounded by the code I have in my answer. The child that you want to be a descendent should only be a descendent, it shouldn't provide it's own model. That's the whole point of using scoped model.
– Filled Stacks
Mar 24 at 3:42
i am using the tab bar and the whole code above was the 2nd tab
– Saikumarreddy2391
Mar 24 at 6:57
Okay.Can you post the code that adds Resources onto the screen.
– Filled Stacks
Mar 24 at 7:11
Above was full code of the one the tab
– Saikumarreddy2391
Mar 24 at 8:01
i am sorry i edited my question I already had it on the top of the widget tree also same error . the error is showing in the bottom sheet saying couldn't find the correct scoped model once try to run this code in ur editor to get me
– Saikumarreddy2391
Mar 24 at 3:07
i am sorry i edited my question I already had it on the top of the widget tree also same error . the error is showing in the bottom sheet saying couldn't find the correct scoped model once try to run this code in ur editor to get me
– Saikumarreddy2391
Mar 24 at 3:07
@Saikumarreddy2391 Not in your resources the root that's displaying your Resources widget. Where are you showing the resources widget? What is putting it on the screen. The place where you're putting it on the screen should be surrounded by the code I have in my answer. The child that you want to be a descendent should only be a descendent, it shouldn't provide it's own model. That's the whole point of using scoped model.
– Filled Stacks
Mar 24 at 3:42
@Saikumarreddy2391 Not in your resources the root that's displaying your Resources widget. Where are you showing the resources widget? What is putting it on the screen. The place where you're putting it on the screen should be surrounded by the code I have in my answer. The child that you want to be a descendent should only be a descendent, it shouldn't provide it's own model. That's the whole point of using scoped model.
– Filled Stacks
Mar 24 at 3:42
i am using the tab bar and the whole code above was the 2nd tab
– Saikumarreddy2391
Mar 24 at 6:57
i am using the tab bar and the whole code above was the 2nd tab
– Saikumarreddy2391
Mar 24 at 6:57
Okay.Can you post the code that adds Resources onto the screen.
– Filled Stacks
Mar 24 at 7:11
Okay.Can you post the code that adds Resources onto the screen.
– Filled Stacks
Mar 24 at 7:11
Above was full code of the one the tab
– Saikumarreddy2391
Mar 24 at 8:01
Above was full code of the one the tab
– Saikumarreddy2391
Mar 24 at 8:01
|
show 5 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55315845%2funable-to-use-scoped-model-in-flutter-bottom-sheet-dialogs%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown