Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flutterflow project from Firebase example for download #24

Open
FerTirado opened this issue Oct 30, 2022 · 2 comments
Open

Flutterflow project from Firebase example for download #24

FerTirado opened this issue Oct 30, 2022 · 2 comments

Comments

@FerTirado
Copy link

The custom widget you guys have done is great, but unfortunately I'm not very good with flutter and had trouble connecting the widget with my firebase database and displaying its data + creating documents for new bookings.

I was wondering if you could share the flutterflow project from the firebase example so we can exactly replicate the widget and action you made in the firebase example.

It would be really helpful as I've been trying to put together the widget code for days and just haven't hit the nail.

Thanks in advance.

@FerTirado FerTirado changed the title Firebase project sample for download Flutterflow project from Firebase example for download Oct 30, 2022
@hprager07
Copy link

Im in the same place and trying to figure this out now. @FerTirado let me know if you get anywhere.

Personally would love to see another mock example connecting it to firebase.

@hprager07
Copy link

Add:

// Get a reference to the Firestore database
final firestore = FirebaseFirestore.instance;

Then update your getBookingStreamMock to: (my collection is called privateSessions so change that to your collection - you will need a start_time and end_time timestamp)


  Stream<dynamic> getBookingStreamMock({DateTime? end, DateTime? start}) {
    return firestore.collection("privateSessions").snapshots().map((snapshot) {
      return snapshot.docs.map((doc) {
        var data = doc.data();
        return DateTimeRange(
          start: data["start_time"].toDate(),
          end: data["end_time"].toDate(),
        );
      }).toList();
    });
  }

The getBookingStream will query a list of booked appointments.

My class Call looks like this - bookingPage gives me the ability to apply an action in Flutterflow whenever someone clicks on book -

class Cal extends StatefulWidget {
  const Cal({
    Key? key,
    this.width,
    this.height,
    required this.bookingPage,
  }) : super(key: key);

  final double? width;
  final double? height;
  final Future<dynamic> Function() bookingPage;

  @override
  State<Cal> createState() => _CalState();
}

The last thing I've done so far is update the local state with the time selected so I can use that in my FlutterFlow action output. Here's the code I used to do that. My flutterflow local state is called privateDate

  Future<dynamic> uploadBookingMock({BookingService? newBooking}) async {
    await Future.delayed(const Duration(seconds: 1));
    FFAppState().update(() {
      FFAppState().privateDate = newBooking!.bookingStart;
    });
    print('${newBooking?.toJson()} has been uploaded');
    if (widget.bookingPage != null) {
      widget.bookingPage?.call();
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants