Coder Social home page Coder Social logo

getx +supabase about supabase-dart HOT 4 CLOSED

hhamja avatar hhamja commented on September 27, 2024
getx +supabase

from supabase-dart.

Comments (4)

bdlukaa avatar bdlukaa commented on September 27, 2024

Can you provide more info about your issue?

from supabase-dart.

hhamja avatar hhamja commented on September 27, 2024

I'm trying to use the MVC pattern.

Specifically,
In controller,

class PostsController extends GetxController {
  SupabaseManager supabaseManager = SupabaseManager();
  var postList = <PostList>[].obs;

  @override
  void onInit() {
    super.onInit();
    readData();
  }

  Future<void> readData() async {
    var postData = await supabaseManager.readData();
    if (postData != null) {
      postList.value = postData;
    }
  }


In Model, 

class PostList {
  final int id;
  final String title;
  final String userName;
  final String gameMode;
  final int? favorite;
  final int? chat;
  final String date;

  PostList(
      {required this.id,
      required this.title,
      required this.userName,
      required this.gameMode,
      required this.favorite,
      required this.chat,
      required this.date});
}


In View,

lass HomePostList extends StatelessWidget {
  final postsController = Get.put(PostsController());

  @override
  Widget build(BuildContext context) {
    return Obx(
      () {
        return ListView.separated(
          padding: EdgeInsets.only(top: 10),
          separatorBuilder: (BuildContext context, int index) {
            return Divider(
              thickness: 1,
            );
          },
          itemCount: postsController.postList.length,
          itemBuilder: (BuildContext context, int index) {
            print(postsController.postList.length);
            return ListTile(
              onTap: () => {Get.toNamed('/postDetail')},
              leading: CircleAvatar(
                child: Icon(Icons.person_outline_rounded),
              ),
              title: Text(postsController.postList[index].title, maxLines: 1),
              subtitle: Column(
                children: [
                  Row(
                    children: [
                      Text(postsController.postList[index].userName),
                      SizedBox(
                        width: double.minPositive,
                      ),
                    ],
                  ),
                  Row(
                    children: [
                      Text(postsController.postList[index].gameMode),
                      SizedBox(width: 10),
                      Expanded(
                          child: Text(postsController.postList[index].date)),
                      Row(
                        children: [
                          Icon(Icons.chat_bubble_outline, size: 15),
                          Text('${postsController.postList[index].chat}'),
                          Icon(Icons.favorite_border_outlined, size: 15),
                          Text('${postsController.postList[index].favorite}'),
                        ],
                      ),
                    ],
                  ),
                ],
              ),
            );
          },
        );
      },
    );
  }
}

Sorry for being so new.

from supabase-dart.

hhamja avatar hhamja commented on September 27, 2024

문제에 대한 자세한 정보를 제공할 수 있습니까?

.

from supabase-dart.

bdlukaa avatar bdlukaa commented on September 27, 2024

Can you provide more information about your issue?

from supabase-dart.

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.