Giter Site home page Giter Site logo

Comments (12)

brianegan avatar brianegan commented on July 19, 2024 2

As a heads up: Got a workaround going to properly support generics. I'll try to push it up soon-ish!

from flutter_redux.

xrigau avatar xrigau commented on July 19, 2024 1

Same issue here, glad I'm not the only one 😅

Meanwhile I replaced the dependency in the pubspec.yaml file with:

  flutter_redux:
    git:
      url: git://github.com/brianegan/flutter_redux.git
      ref: 0.4.0

and everything works again, thanks for your work @brianegan 💯

from flutter_redux.

brianegan avatar brianegan commented on July 19, 2024 1

Sure thing! Sorry for the delay in publishing the new version, test coverage isn't quite working with Dart 2 and I'd like to hold off until that's fixed.

That branch should totally work, however -- so feel free to play around and report issues!

from flutter_redux.

brianegan avatar brianegan commented on July 19, 2024

Hrm, interesting case.

I think the problem might be: you're constantly rebuilding a new Store in the build method and handing that off to the StoreProvider, and the library might not handling that properly.

So whenever you do a Hot Reload or that build method is called again, it's probably rebuilding the Store and stuff is going wrong.

I'll take a deeper look. For now, could you please try moving the Store out of the build method into an initState and see if it works?

from flutter_redux.

lwasylkowski avatar lwasylkowski commented on July 19, 2024

I'm not sure what you mean, but I moved the app to a stateful widget, created the entire tree (starting from StoreProvider in state's build method, but passed store field created in initState -- still no luck.

I'll add that initially I created store field inline final store = ..., much like in your sample actually. If you don't have more ideas, maybe I'll clean it up/rewrite and paste entire app for you to run?

from flutter_redux.

brianegan avatar brianegan commented on July 19, 2024

Yah that would be great... I haven't run into that issue before :(

from flutter_redux.

lwasylkowski avatar lwasylkowski commented on July 19, 2024
import 'package:flutter/material.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:redux/redux.dart';

void main() => runApp(new TestApp());

class TestApp extends StatelessWidget {

  final store = new Store<int>(
        (state, action) => state + 1,
    initialState: 0,
  );

  @override
  Widget build(BuildContext context) =>
      new StoreProvider<int>(
          store: this.store,
          child: new MaterialApp(
            title: "App",
            theme: new ThemeData(
              primarySwatch: Colors.blue,
            ),
            home: new Scaffold(
              appBar: new AppBar(
                title: new Text("App"),
              ),
              body: new MainScreen(),
            ),
          )
      );
}

class MainScreen extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return new StoreConnector<int, String>(
      converter: (state) => state.toString(),
      builder: (context, text) =>
      new Center(
        child: new Text(text),
      ),
    );
  }
}

Here it is. Only two new dependencies in pubspec:

redux: ^2.1.1
flutter_redux: ^0.3.5

Flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.1.5, on Mac OS X 10.13.3 17D102, locale en-PL)
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 9.2)
[✓] Android Studio
[✓] Android Studio
[✓] Android Studio (version 3.0)
[✓] IntelliJ IDEA Community Edition (version 2017.3.4)
[!] VS Code (version 1.19.2)
[✓] Connected devices (1 available)

! Doctor found issues in 1 category.

from flutter_redux.

brianegan avatar brianegan commented on July 19, 2024

Yep, you found a bug! This is an interesting problem with how Dart reifies types, and my current solution doesn't quite work unfortunately ;(

For now, please use new StoreProvider instead of new StoreProvider<int> and it should work!

Thanks for the report, good catch!

from flutter_redux.

santiagofm avatar santiagofm commented on July 19, 2024

I encountered the same issue with the example project and just found out it happens if i have the dart 2 preview enabled.. I'm not sure if it's the same issue but disabling the preview fixes it

Cheers

from flutter_redux.

brianegan avatar brianegan commented on July 19, 2024

Thanks for the report! I'm actually working on a few changes that fix both this bug and adds Dart2 support :)

from flutter_redux.

santiagofm avatar santiagofm commented on July 19, 2024

Awesome !! keep up the good work!

from flutter_redux.

xrigau avatar xrigau commented on July 19, 2024

Will do!

from flutter_redux.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.