Giter Club home page Giter Club logo

Comments (6)

Rannie avatar Rannie commented on May 20, 2024 1

@rizalgunawan FLUI-Dynamic will add dynamic value binding in the future, may also support this kind of splicing to meet your needs... thanks.

from flui.

Rannie avatar Rannie commented on May 20, 2024

hi @rizalgunawan, dynamic component is a container, u can use setState to change json object in dynamic or just return widget directly:

FutureBuilder<CommonModel>(
            future: fetchPost(),
            builder:
                (BuildContext context, AsyncSnapshot<CommonModel> snapshot) {
                  return FLDyContainer(
                     jsonObject: $JSON_STRING_OR_OBJECT,
                     placeholder: CircularProgressIndicator(
                       strokeWidth: 3.0,
                       valueColor: AlwaysStoppedAnimation(Theme.of(context).accentColor),
                     ),
                 );
            }),

from flui.

rizalgunawan avatar rizalgunawan commented on May 20, 2024

hi @rizalgunawan, dynamic component is a container, u can use setState to change json object in dynamic or just return widget directly:

FutureBuilder<CommonModel>(
            future: fetchPost(),
            builder:
                (BuildContext context, AsyncSnapshot<CommonModel> snapshot) {
                  return FLDyContainer(
                     jsonObject: $JSON_STRING_OR_OBJECT,

so what should I set inside $JSON_STRING_OR_OBJECT ?

what I mean is, I want to populate ListView children from FutureBuilder

    {
        "uniqueId": "flui-list01",
        "unitName": "ListView",
        "shrinkWrap": true,
        "separatedDivider": {
            "height": 1
        },
        "children": []
    }

basically, we can set widget to children like this, right?

return FutureBuilder(
    builder: (context, projectSnap) {
      return ListView.builder(
        itemCount: projectSnap.data.length,
        itemBuilder: (context, index) {
          ProjectModel project = projectSnap.data[index];
          return Column(
            children: <Widget>[
              // Widget to display the list of project
            ],
          );
        },
      );
    },
    future: getProjectDetails(),
  );

May I have an example?

Thank you, this is great's plugin btw..

from flui.

Rannie avatar Rannie commented on May 20, 2024

hi @rizalgunawan,i think you can try like this:

(jsonlist) => {
  final list = [];
  jsonlist.forEach((item) {
    list.add(FLDyContainer(
                     jsonObject: item));
  });
  // return list or set state to change children.
}

FLDyContainer will not add widget level, so u can use it like above.

from flui.

rizalgunawan avatar rizalgunawan commented on May 20, 2024

Hi @Rannie, thanks for your quick response,

I think you misinterpreted what I meant,
Try to see the example Dynamic ListView at :
https://github.com/Rannie/flui/blob/master/example/lib/pages/dylistview_page.dart

it contains a static widget from this :

const ListJson =
    '{
    "uniqueId": "flui-safearea",
    "unitName": "SafeArea",
    "child": {
        "uniqueId": "flui-list01",
        "unitName": "ListView",
        "shrinkWrap": true,
        "separatedDivider": {
            "height": 1
        },
        "children": [
            {
                "uniqueId": "tile-01",
                "unitName": "ListTile",
                "title": {
                    "unitName": "Text",
                    "text": "FLUI"
                },
                "subtitle": {
                    "unitName": "Text",
                    "text": "An UI framework for Flutter"
                }
            },
        ]
    }
}';

I want to refresh or load more data to the ListView children from the API, without re-creating ListView from json, is that possible?

Maybe we can add some params to the widget config, like this:

{
    "uniqueId": "flui-safearea",
    "unitName": "SafeArea",
    "child": {
        "uniqueId": "flui-list01",
        "unitName": "ListView",
        "loadMoreUrl" : "http://route-to-api.com/action?page=1&perPage=10",
        "children": [
        ]
    }
}

from flui.

Rannie avatar Rannie commented on May 20, 2024

@rizalgunawan i see, It is not supported to disassemble it for refreshing children. so i only can suggest you to write a list view in code and just change children...

from flui.

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.