Forum Replies Created

Viewing 15 posts - 1 through 15 (of 25 total)
  • Author
    Posts
  • Vram Adel Handrio
    Participant

      sudah bisa berjalan coach kode nya…terimakasih banyak coach atas penjelasan nya..

      in reply to: error setelah migrasi ke null safety #77572
      Vram Adel Handrio
      Participant

        Sudah bisa berjalan coach..terimakasih banyak coach arahan dan petunjuknya..

        in reply to: error setelah migrasi ke null safety #51819
        Vram Adel Handrio
        Participant

          Sudah saya hapus dan saya buat ulang di firebase coach..

          namun di emulator tetap error : Exception : Error terjadi kesalahan..

          di firebase:
          N01
          created_at:”2022-07-17T19:42:47.490535″
          isPinned:false
          note:”Test isi note”
          title:”Test title”
          updated_at:”2022-07-17T19:42:47.490535″

          ini full code saya coach di github: https://github.com/Vram-AH/aplikasi-notes-flutter

          in reply to: error setelah migrasi ke null safety #51814
          Vram Adel Handrio
          Participant

            dear coach jadi terhapus semua coach saat
            “note”: “123”,
            “title”: “123”,
            “updated_at”: “2022-07-17T13:08:53.668538″ di hapus..

            atau saya boleh minta source code untuk app note nya coach, biar saya samain code nya…terimakasih sebelumnya coach..

            in reply to: error setelah migrasi ke null safety #51800
            Vram Adel Handrio
            Participant

              sudah sesuai coach di VS code tidak ada &#8217, sepertinya berubah di forum itbox saat copy coach..

              in reply to: error setelah migrasi ke null safety #51791
              Vram Adel Handrio
              Participant

                maaf coach yang ini $#8217; dikode yang mana ya coach?

                in reply to: error setelah migrasi ke null safety #51790
                Vram Adel Handrio
                Participant

                  sudah saya ubah coach di Firebase..namun masih belum bisa berjalan di emulator..

                  in reply to: error setelah migrasi ke null safety #51786
                  Vram Adel Handrio
                  Participant

                    // fungsi untuk delete dan ubah atau kirim data tersebut ke server
                    Future<void> deleteNote(String? id) async {
                    final uri = Uri.parse(
                    ‘https://notes-9f78d-default-rtdb.asia-southeast1.firebasedatabase.app/notes/$id.json&#8217;);
                    try {
                    final response = await http.delete(uri);
                    if (response.statusCode != 200) {
                    throw Exception();
                    }
                    } on SocketException {
                    throw SocketException(‘Tidak dapat tersambung ke internet’);
                    } catch (e) {
                    throw Exception(‘Error, terjadi kesalahan’);
                    }
                    }
                    }

                    in reply to: error setelah migrasi ke null safety #51785
                    Vram Adel Handrio
                    Participant

                      // tambahkan fungsi toggleIspined agar saat note di PIN maka terupdate pada server
                      Future<void> toggleIsPinned(
                      String? id, bool? isPinned, DateTime updatedAt) async {
                      final uri = Uri.parse(
                      ‘https://notes-9f78d-default-rtdb.asia-southeast1.firebasedatabase.app/notes/$id.json&#8217;);
                      Map<String, dynamic> map = {
                      ‘isPinned’: isPinned,
                      ‘updated_at’: updatedAt.toIso8601String(),
                      };
                      try {
                      final body = json.encode(map);
                      final response = await http.patch(uri, body: body);
                      if (response.statusCode != 200) throw Exception();
                      } on SocketException {
                      throw SocketException(‘Tidak dapat tersambung ke internet’);
                      } catch (e) {
                      throw Exception(‘Error, terjadi kesalahan’);
                      }
                      }

                      in reply to: error setelah migrasi ke null safety #51783
                      Vram Adel Handrio
                      Participant

                        // tambahkan fungsi agar saat note diubah maka akan terupdate juga pada server
                        Future<void> updateNote(Note note) async {
                        final uri = Uri.parse(
                        ‘https://notes-9f78d-default-rtdb.asia-southeast1.firebasedatabase.app/notes/${note.id}.json’);
                        Map<String, dynamic> map = {
                        ‘title’: note.title,
                        ‘note’: note.note,
                        ‘updated_at’: note.updatedAt!.toIso8601String(),
                        };

                        try {
                        final body = json.encode(map);
                        final response = await http.patch(uri, body: body);
                        if (response.statusCode != 200) throw Exception();
                        } on SocketException {
                        throw SocketException(‘Tidak dapat tersambung ke internet’);
                        } catch (e) {
                        throw Exception(‘Error, terjadi kesalahan’);
                        }
                        }

                        in reply to: error setelah migrasi ke null safety #51780
                        Vram Adel Handrio
                        Participant

                          // Buat fungsi note API untuk post note baru
                          // tambahkan Future pada string dan async agar fungsi await bisa digunakan
                          Future<String?> postNote(Note note) async {
                          final uri = Uri.parse(
                          ‘https://notes-9f78d-default-rtdb.asia-southeast1.firebasedatabase.app/notes.json&#8217;);
                          // buat map untuk isi/body yang akan dikirim ke server
                          Map<String, dynamic> map = {
                          ‘title’: note.title,
                          ‘note’: note.note,
                          ‘isPinned’: note.isPinned,
                          //1. karena encode akan mengubah data menjadi string json maka note.updatedAt dan note.createdAt di ubah menjadi string dengan toIso8601String
                          //2. tambahkan validasi karena migrasi ke null agar tidak error
                          ‘updated_at’:
                          note.updatedAt == null ? null : note.updatedAt!.toIso8601String(),
                          ‘created_at’:
                          note.createdAt == null ? null : note.createdAt!.toIso8601String()
                          };

                          try {
                          // ubah map jadi string json
                          final body = json.encode(map);
                          // 1. melakukan post
                          // 2. tambahkan await agar kode dibawah menunggu proses get data selesai
                          final response = await http.post(uri, body: body);
                          if (response.statusCode == 200) {
                          return json.decode(response.body)[‘name’];
                          } else {
                          throw Exception();
                          }
                          } on SocketException {
                          throw SocketException(‘Tidak dapat tersambung ke internet’);
                          } catch (e) {
                          throw Exception(‘Error, terjadi kesalahan’);
                          }
                          }

                          in reply to: error setelah migrasi ke null safety #51779
                          Vram Adel Handrio
                          Participant

                            note.api

                            import ‘dart:convert’;
                            import ‘dart:io’;

                            import ‘package:notes/models/note.dart’;
                            import ‘package:http/http.dart’ as http;

                            // buat class yang berisi semua fungsi untuk koneksi ke server firebase
                            class NoteApi {
                            // buat fungsi untuk mendapatkan seluruh note (list)
                            // tambahkan Future dan async agar fungsi await bisa digunakan
                            Future<List<Note>> getAllNote() async {
                            // print(‘pertama dijalankan’);
                            final uri = Uri.parse(
                            ‘https://notes-9f78d-default-rtdb.asia-southeast1.firebasedatabase.app/notes.json&#8217;);
                            // tambahakan try & catch untuk mengatasi error no internet/SocketException dan merubah tulisannya
                            List<Note> notes = [];
                            try {
                            // tambahkan await agar kode dibawah menunggu proses get data selesai
                            final response = await http.get(uri);

                            print(response.statusCode);
                            if (response.statusCode == 200) {
                            // ubah data json menjadi map
                            final results = json.decode(response.body) as Map<String, dynamic>;
                            // looping map result ke List<Note>
                            results.forEach((key, value) {
                            notes.add(Note(
                            id: key,
                            title: value[‘title’],
                            note: value[‘note’],
                            isPinned: value[‘isPinned’],
                            updatedAt: DateTime.parse(value[‘updated_at’]),
                            createdAt: DateTime.parse(value[‘created_at’])));
                            });
                            } else {
                            throw Exception();
                            }
                            } on SocketException {
                            throw SocketException(‘Tidak dapat tersambung ke internet’);
                            } catch (e) {
                            throw Exception(‘Error terjadi kesalahan’);
                            }

                            return notes;
                            }

                            in reply to: error setelah migrasi ke null safety #51778
                            Vram Adel Handrio
                            Participant

                              namun saya ada dapat email dari fire base isinya:

                              notes
                              [Firebase] Akses klien ke ‘notes-9f78d-default-rtdb’ Realtime Database Anda akan berakhir dalam 4 hari

                              Anda memilih untuk mulai mengembangkan aplikasi dalam Mode Uji, yang membuat instance Realtime Database Anda sepenuhnya terbuka ke internet. Karena pilihan ini membuat aplikasi Anda rentan terhadap penyerang, aturan keamanan database Anda dikonfigurasi untuk berhenti mengizinkan permintaan setelah 30 hari pertama.
                              Dalam 4 hari, semua permintaan klien ke instance Realtime Database Anda akan ditolak. Sebelum waktu tersebut, harap perbarui aturan keamanan agar aplikasi Anda dapat berfungsi sekaligus melindungi data Anda dengan tepat. Analisis dijalankan setiap hari; jika Anda telah mengubah aturan dalam 24 jam terakhir, perubahan tersebut mungkin tidak diperhitungkan.
                              ATURAN YANG SEGERA BERAKHIR
                              notes
                              Database
                              notes-9f78d-default-rtdb

                              apa pengaruh ya coach ke API code nya?

                              in reply to: error setelah migrasi ke null safety #51774
                              Vram Adel Handrio
                              Participant

                                g bisa di paste disini coach..saya coba buat post pertanyaan baru coach..

                                in reply to: error setelah migrasi ke null safety #51769
                                Vram Adel Handrio
                                Participant

                                  ini yang notes_grid.dart coach

                                  import ‘package:flutter/material.dart’;
                                  import ‘package:notes/models/note.dart’;
                                  import ‘package:notes/providers/notes.dart’;
                                  import ‘package:notes/widgets/note_item.dart’;
                                  import ‘package:provider/provider.dart’;

                                  class NotesGrid extends StatefulWidget {
                                  @override
                                  State<NotesGrid> createState() => _NotesGridState();
                                  }

                                  class _NotesGridState extends State<NotesGrid> {
                                  @override
                                  Widget build(BuildContext context) {
                                  // gunakan data provider
                                  final notesProvider = Provider.of<Notes>(context);
                                  List<Note> listNote = notesProvider.notes;
                                  return Padding(
                                  padding: EdgeInsets.all(12),
                                  child: GridView.builder(
                                  itemCount: listNote.length,
                                  itemBuilder: (ctx, index) => NoteItem(
                                  id: listNote[index].id,
                                  ctx: context,
                                  ),
                                  gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                                  crossAxisCount: 2,
                                  crossAxisSpacing: 8,
                                  mainAxisSpacing: 8,
                                  ),
                                  ),
                                  );
                                  }
                                  }

                                Viewing 15 posts - 1 through 15 (of 25 total)
                                Shopping cart0
                                There are no products in the cart!
                                Continue shopping