Site icon Flutter Packages | Pub dev Packages – Flutter Mobile App World

Log snapshot management solution built with Flutter/Dart using Bloc pattern

LogKeeper (Flutter & Firebase)

This is a log snapshot management solution used to save and share log snapshots within the development team. Supports iOS/Android/Web and utilizes Dart backend API (with client-server shared code). Logs stored in Firestore and Firebase Auth used to access some parts of the data.

By default, mock repositories are used. So just run the project to try it with mock data.

Usage scenario

Log ContentsLog Contents in Web view

All logs later can be found on the home screen which is accessible only for authorized users

Auth ScreenHome ScreenLog Deletion Popup
Settings ScreenUpload Log ScreenHome Screen Drawer

Structure

This tool uses:

Consists of the following parts:

Folders structure is based on https://hub.docker.com/r/google/dart-runtime-base in order to use shared code in log_keep_shared both on the client and server sides.

How to set it up

Firebase Account

Attach Firebase to your local copy

in log_keep:

var firebaseConfig = {
    apiKey: "..",
    authDomain: "..",
    projectId: "..",
    storageBucket: ".",
    messagingSenderId: "..",
    appId: "..",
    measurementId: ".."
};

firebase.initializeApp(firebaseConfig);

Moving from mock to Firebase data

Mock repositories used by default. When your Firebase account is ready please go to app.dart and uncomment Firebase repositories

firebaseApp = await Firebase.initializeApp();

getIt.registerSingleton<AuthRepository>(
    FirebaseAuthRepository(),
    signalsReady: true);

getIt.registerSingleton<LogsRepository>(
    FirestoreLogsRepository(FirebaseFirestore.instance),
    signalsReady: true);

To build and host Web client use

Google Service Account

For a backend to run you need a Google Service Account https://cloud.google.com/iam/docs/service-accounts.

Service account credentials could be passed to log_keep_back via .env file:

Instructions on how to build & deploy server can also be found here https://hub.docker.com/r/google/dart-runtime-base

Notes

EVERYTHING

Known issues and limitations

Example code of sending request to the LogKeeper

Unity, C#:

var form = new WWWForm();

// Prepare log data
form.AddField("title", title);
form.AddField("author", author);
form.AddField("project", project);
form.AddField("contents", contents); // the log contents

// Send
var uwr = UnityWebRequest.Post("your_url" + "/save", form);
yield return uwr.SendWebRequest();
if (uwr.isNetworkError || uwr.isHttpError)
{
    // error
    return;
}

// Read result
var raw = Encoding.UTF8.GetString(uwr.downloadHandler.data);
var id = JSON.Parse(raw)["body"]["id"].Value;
var urlFormat = JSON.Parse(raw)["body"]["url_format"].Value;

// Get the link to the log
var link = string.Format(urlFormat, id);
_clipboardService.SetText(link);
ShowNotifications("Report link copied to clipboard");

Download LogKeeper source code on GitHub

https://github.com/AlexeyPerov/LogKeeper-Flutter-Firebase
Exit mobile version