Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Oct 20 17:54
    Mickey-A-Mouse commented #313
  • Oct 18 18:26
    rrousselGit unlabeled #557
  • Oct 18 18:26
    rrousselGit unlabeled #557
  • Oct 18 18:26
    rrousselGit commented #557
  • Oct 18 18:16
    jtmuller5 labeled #557
  • Oct 18 18:16
    jtmuller5 labeled #557
  • Oct 18 18:16
    jtmuller5 opened #557
  • Oct 15 03:59
    feinstein closed #556
  • Oct 15 03:59
    feinstein commented #556
  • Oct 15 02:17
    feinstein labeled #556
  • Oct 15 02:17
    feinstein labeled #556
  • Oct 15 02:17
    feinstein opened #556
  • Oct 14 19:49
    astrO1 labeled #555
  • Oct 14 19:49
    astrO1 labeled #555
  • Oct 14 19:49
    astrO1 opened #555
  • Oct 14 00:36
    Mereep opened #554
  • Oct 12 03:20
    Tharindu-dart closed #553
  • Oct 12 03:20
    Tharindu-dart commented #553
  • Oct 12 02:57
    rrousselGit commented #553
  • Oct 12 02:51
    Tharindu-dart edited #553
Alan Trope
@atrope
Ok, in my tests i realised the problem was/is the 16ms limit for setstate. The stream was receiving all events but "losing"them because of that limitation
Rakesh Kumar
@RakeshKumar9x_twitter
@rrousselGit , Is there any way to lock the method. Only one thread can execute at one time. One request can be put into a queue. Something like that
Remi Rousselet
@rrousselGit
@RakeshKumar9x_twitter Could you elaborate?
Rakesh Kumar
@RakeshKumar9x_twitter

@RakeshKumar9x_twitter Could you elaborate?

I am inserting the data into a database on flutter. As one insertion request already executing then another request taking place. Because both requests having the same data

I am just trying to like to lock the method until it's done. One process being executed another process or request can be put into queue
Diego Tori
@diegotori
@rrousselGit Quick question: Suppose you have a MultiProvider and you want to want to add a nested MultiProvider within the list of providers. How would something like that look like?
Marc
@mscherer82
Hi, is it possible to use a ChangeNotifierProvider in side a ListView?
Marc
@mscherer82
I got the error message A Model was used after being disposed. E/flutter (10215): Once you have called dispose() on a Model, it can no longer be used. when trying to do this.
virgil246
@virgil246
Is there any example for futureprovider?
How to init Value inside of Provider with an async function
I need to get api query key when app start and keep it until app closed is a good situation to use provider?
I will get api query key with http request
Remi Rousselet
@rrousselGit
Use FutureProvider
virgil246
@virgil246
Use FutureProvider
Thx I figure out the solution
Adis Durakovic
@ad-on-is_gitlab
May I ask the difference between Provider<Foo>(create: (context) => Foo(api: Provider.of<Api>(context, listen: false))) and ProxyProvider<Api, Foo>()
Sameer Kashyap
@Sameerkash

Hello, I'm having a problem with my ChangeNotifier, I have this piece of code in my model

  class Comment with ChangeNotifiere{ ...

  RequestState _state = RequestState.initial;
  RequestState get state => _state;

  void setState(RequestState state) {
    _state = state;
    notifyListeners();

  .... }

And this is my API call method

  ///Get all comments for a particular review
  Future<void> getComments(
    CommentNotifer commentNotifer, String reviewId) async {
    if (reviewId != null) {
      try {

        commentNotifer.setState(RequestState.loading);
        _startComment = 0;

var response = await sendGet("/api/comment/readLimitedReviewComment/$reviewId?start=$_start&limit=10");
    ]if (response != nulll) 
    { 
    var comments = CommentResponse.fromJson(response);
    commentNotifer.setState(RequestState.hasData);
    }

     ....  }

I want to set the RequestConnection to loading before I make the call, but I get

setState() or markNeedsBuild()
This _InheritedProviderScope< CommentNotifer > widget cannot be marked as needing to build because the framework is already in the process of building widgets. A widget can be marked as needing to be built during the build phase only if one of its ancestors is currently building. This exception is allowed because the framework builds parent widgets before children, which means a dirty descendant will always be built.

this error, I understand what I'm doing wrong, I'm marking the widget to build when its already in the process of building, as I call the API in the

initState ()

method of my widget but what I don't understand is how to call this the right way. could you help me? @rrousselGit

virgil246
@virgil246
Will Provider auto call dispose method when app close?
farah bedoui
@farahbedoui96_gitlab
hello developers, does anyone of you know how to resolve this error , Error: Could not find the correct Provider<CardListModelView> above this WalletPage Widget To fix, please: Ensure the Provider is an ancestor to this WalletPage Widget
Provide types to Provider
Provide types to Consumer
Provide types to Provider.of()
Ensure the correct context is being used. ! I'm try to add card animation to my project (it does run in a separated project but mark this error when adding it to my project) !
I added my providers ( CardListModelView, CardModel) to multiprovider at the main class . and inject it to my locator (like registerLazySingleton) and trying to call it in my other views like this Provider.Of <CardListModelView>(context) but no clue and it shows this error to all widgets that try to call it this way .
P.S:
1.provider is marked at the top root of the project tree so normally children widget would access it with no problem.
  1. when trying to replace it as a consumer in WalletPage widget it goes right but it makes no sense to do it this way for others because i only need to access data from anywhere.
Rakesh Kumar
@RakeshKumar9x_twitter
Hi, do we have any way to hardware back button event trigger on flutter?
Here, I am not talking about appBar back button
can anyone help me out with this?
dt-ap
@dt-ap_gitlab
Hi @rrousselGit . Hypothetical question. Is it really hard/complex to write a source code generation using build_runner that static-ly analyze dependencies (dagger 2), and then generate the provider code? I like what libraries like kiwi, auto_route, or injectable do
DEVYANK SHAW
@DevyankShaw

Recent App Screen:

ListView.builder(
                padding: EdgeInsets.only(top: 15.0, right: 15.0, left: 15.0),
                itemCount: Provider.of<RecentAppsData>(context)
                    .recentAppItemList
                    .length,
                reverse: true,
                itemBuilder: (context, index) {
                  return RecentAppCard(
                    appIcon: Provider.of<RecentAppsData>(context)
                        .recentAppItemList[index]
                        .appIcon,
                    appName: Provider.of<RecentAppsData>(context)
                        .recentAppItemList[index]
                        .appName,
                    key: Key(Provider.of<RecentAppsData>(context)
                        .recentAppItemList[index]
                        .toString()),
                    onDismissed: (direction) =>
                        Provider.of<RecentAppsData>(context)
                            .removeFromRecentList(index),
                  );
                },
              ),`

Change Notifier:

class RecentAppsData extends ChangeNotifier {
  List<RecentAppsItem> recentAppItemList = [];

  void addToRecentList(RecentAppsItem recentAppsItem) {
    recentAppItemList.add(recentAppsItem);
    notifyListeners();
  }

  void removeFromRecentList(int index) {
    recentAppItemList.removeAt(index);
    notifyListeners();
  }
}

Navigating to Recent App Screen

onTap: () {
                          Navigator.push(
                            context,
                            PageRouteBuilder(
                                opaque: false,
                                barrierColor: Colors.transparent
                                    .withOpacity(0.7), // set to false
                                pageBuilder: (_, __, ___) {
                                  return ChangeNotifierProvider<
                                      RecentAppsData>.value(
                                    value: RecentAppsData(),
                                    child: RecentApps(),
                                  );
                                }),
                          );
                        },

While adding data to recentAppList like this:

Provider.of<RecentAppsData>(context,
                                      listen: false)
                                  .addToRecentList(RecentAppsItem(
                                appName: _iconWithNameList[index].iconName,
                                appIcon: _iconWithNameList[index].icon,
                              ));

Hey whenever i am adding to the recentAppItemList of the RecentAppData and navigating to the Recent App Screen the listview is not being updated as if the notifyListener is not working. Can anyone suggest me where should i make change so that the list view is updated.

Remi Rousselet
@rrousselGit
@dt-ap_gitlab it's feasible, but I don't get why you'd want to use provider.
Might as well don't use any dependency and build your own logic
DEVYANK SHAW
@DevyankShaw
@rrousselGit Can you help me with above the problem?
Remi Rousselet
@rrousselGit
It's hard to say like this. I don't know.
DEVYANK SHAW
@DevyankShaw
No problem @rrousselGit, I just figured out the solution by adding static before recentAppItem list declaration. But thanks for trying.
Pablo Maria Martelletti
@pmartelletti
Hi guys - I'm wondering if you could point me to any resource that I could help me better understand which of my models is the best candidate for being a ChangeNotifier using provider. I'm really struggling to do understand all the examples (like, the one in flutter docs, samples apps, etc), as in there they use the, eg "TaskData" (or repository) as the change notifier, but I can't really get my head around that instead of having the smaller model (eg, Task) being the ChangeNotifier. Example: by using the TaskData approach, whenever a Task Changes, my ListView (wrapped in a Consumer) will re-render the whole list, rather than the task that changed only. Tried wrapping that into a context.select<TaskRepo> inside the ListTile builder, but this wouldn't update my list at all.
Remi Rousselet
@rrousselGit
context.select should be the correct solution
Bigyan Ghimire
@Z3rolive
I have a listview which requires user type for each item in order to publish/unpublish list item. I am using provider to locate user type. I wanted to ask what is better, listening to user type on the widget build and passing that to list items or listening to user type on each list item?
Rakesh Kumar
@RakeshKumar9x_twitter
Hi, It's showing old image on NetworkImage and every time captured new urls and also debug url exactly during set on placeholder and It's showing old image
Josip Krnjic
@itsJoKr
You know how in bloc you can do BlocBuilder<MyBloc> or BlocBuilder(myBloc). Can I do something like that with Consumer and ChangeNotifier? If I have a composite ChangeNotifier, I would like to listen to it without providing all the little providers around.
Remi Rousselet
@rrousselGit
No you can't. Use ListenableBuilder/AnimatedBuilder instead
ChathuragaShan
@ChathuragaShan

Hi, I'm a developer who got into flutter development recently. I decided to use flutter as the state management in application. I try to apply it to my own simple application. I used the newest version of the flutter even though there are not many tutorials for that. I used pub.dev example to get an idea about how to use it. But I'm stuck with this issue for a few days. Can anyone guide me on how to overcome this?

https://stackoverflow.com/questions/63096979/could-not-find-the-correct-providerx-above-this-modalbottomsheet-widget

Thanks.

cbshivananda1998
@cbshivananda1998
hi guys I have published my first application in playstore .Please download and give your reviews .link-https://play.google.com/store/apps/details?id=shivananda.textrec Checkout the source code in github-https://github.com/cbshivananda1998/Text_Scanner_Flutter.git
Muhammad Kamel
@muhammadkamel
Hi there!
I have an issue... Anyone can help?
Selector<CounterProvider, int>(
builder: (context, myVal, child) {
print('Hi from FB builder');
return FlatButton(
color: Colors.red,
onPressed: () {},
child: Text('Add'),
);
},
selector: (context, myVal) => myVal.changeNumber(),
),
I have an issue with Provider Selector ^
Remi Rousselet
@rrousselGit
What's the problem with this code?
FaizanKamal7
@FaizanKamal7

I'm getting this error

E/flutter ( 9610): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: A CustRegViewModel was used after being disposed.
E/flutter ( 9610): Once you have called dispose() on a CustRegViewModel, it can no longer be used.

I have a View named CustRegView where I take a phone number form the user and send it to ViewModel named CustRegViewModel to authenticate which is supposed to return true or false base on it's authentication.

class CustRegView extends StatefulWidget {
  @override
  _CustRegViewState createState() => _CustRegViewState();
}

class CustRegView extends StatelessWidget{
  final TextEditingController _controller = TextEditingController();

  @override
  Widget build(BuildContext context) {
    final deviceSize = MediaQuery.of(context).size;
    return BaseView<CustRegViewModel>( 
          builder: (context, model, child) => Scaffold(

    ...<some code>

    FlatButton (
        onPressed: () async {
            var registerSuccess = await model.register( _controller.text, context);   <----- HERE I AM GETTING AN ERROR

            if (registerSuccess) {
                Navigator.pushNamed(context, 'newScreen');
            } else {
                UIHelper().showErrorButtomSheet(context, model.errorMessage);
            }
    )
}

CustRegViewModel looks like this

class CustRegViewModel extends BaseViewModel {

    final AuthService _authService = locator<AuthService>();
    final DialogService _dialogService = locator<DialogService>();
    dynamic newUserResult; 
    dynamic verifyResult;

    Future<bool> register(String phoneNo, BuildContext context) async {
        await verifyPhone;
        return    verifyResult ? true :  false;  // From here it returns true
    }

    Future<void> verifyPhone(phoneNo) async {

            await FirebaseAuth.instance.verifyPhoneNumber(
                    phoneNumber: updatedPhoneNo,
                    timeout: Duration(seconds: 50),
                    verificationCompleted: (AuthCredential authCred) async {...... <some code>
                    verificationFailed: (AuthException authException) {...... <some code>
                    codeSent: (String verID, [int forceCodeResend]) async {...... <some code>
                    codeAutoRetrievalTimeout: (String verID) {...
             ).catchError((error) {...... <some code>
    }
}

BaseView looks like this

class BaseView<T extends BaseViewModel> extends StatefulWidget {
  final Widget Function(BuildContext context, T model, Widget child) builder;
  final Function(T) onModelReady;
  BaseView({this.builder, this.onModelReady});
  @override
  _BaseViewState<T> createState() => _BaseViewState<T>();
}

class _BaseViewState<T extends BaseViewModel> extends State<BaseView<T>> {
  T model = locator<T>();

  @override
  void initState() {
    if (widget.onModelReady != null) {
      widget.onModelReady(model);
    }
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider<T>(
      create: (context) => model,
      child: Consumer<T>(builder: widget.builder),
    );
  }
}

BaseViewModel looks like this

class BaseViewModel extends ChangeNotifier {
  ViewState _state = ViewState.Idle;


  ViewState get state => _state;

  void setState(ViewState viewState) {
    _state = viewState;
    notifyListeners();
  }
}
Gerald
@campanagerald
@FaizanKamal7 what pattern do you use? is that mvvm?
FaizanKamal7
@FaizanKamal7
It is Stacked architecture. Yes, you can also say MVVM. It is a form of MVVM.
Gerald
@campanagerald
how to show a snackbar when some state change using just provider? in flutter bloc we can use BlocConsumer then add a value to listen property. in mobx there is a reactor. how about provider?
Web developer
@webdeveloper100100_gitlab
Consumer<DataBaseProvider>(
builder: (context, value, child) =>FutureBuilder<List<Student>>(
future: value.getDataList,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
List<Student> dataStudent = snapshot.data;
return ListView.builder(
itemCount: dataStudent.length,
itemBuilder: (context, index) =>
I am using provider and notifying change when data is updated deleted and inserted in db every time one of the given thing occur povider notify and consumer rebuild its child with new data but i dont won that i only wanna rebuild a change occur by that one of opertation not complete listView
As in android we have diff util class which notifyautomatically and show change where it ouccur
Andenet Alexander
@AndenetAlexand2_twitter
When I tried to expose Firebase authStateChange stream using StreamProvider.Value and consume it using Provider<User>.of(context).email, I got this error saying The getter 'email' was called on null.
Receiver: null
Tried calling: email
kiwi900
@stoneshowerer_twitter
Hello, I'm trying to understand how ProxyProvider works and I'm lost at how should we use ProxyProvider + ChangeNotifierProvider and ChangeNotifierProxyProvider. For me the both seems to do the same thing (ChangeNotifierProxyProvider is a bit verbose?) Here is the code I'm comparing. If the use cases of the both are same basically, can we just use ProxyProvider + ChangeNotifierProvider which I feel intuitively easier to understand?
// ProxyProvider
class SampleProxyProvider extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        ChangeNotifierProvider(
          create: (_) => Counter(),
        ),
        ProxyProvider<Counter, Translator>(
          update: (context, counter, translator) {
            return Translator(counter.count);
          },
        ),
      ],
      child: CounterWidget(),
    );
  }
}

// ChangeNotifierProxyProvider
class SampleChangeNotifierProxyProvider extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        ChangeNotifierProvider<Counter>(
          create: (_) => Counter(),
        ),
        ChangeNotifierProxyProvider<Counter, Translator>(
          create: (context) => Translator(
            Provider.of<Counter>(context, listen: false).count,
          ),
          update: (_, counter, translator) => Translator(counter.count),
        ),
      ],
      child: CounterWidget(),
    );
  }
}
Rakesh Kumar
@RakeshKumar9x_twitter

@RakeshKumar9x_twitter
On app killed getting fcm push and on click on push dart screen is being opened

I am working on calling based app on flutter and this is not ideal or good user experience that clicks on fcm push notification then have the call screen

Please recommend something