Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

CHAHBOUN Mohammed M97Chahboun

🏠
Working from home
View GitHub Profile
View mini_view.dart
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:mvc_rocket/mvc_rocket.dart';
class MiniView extends StatelessWidget {
MiniView({Key? key, required this.title}) : super(key: key);
final String title;
// use mini for convert value to RocketValue
final RocketValue<String> mcString = "Initial value".mini;
View controller_rocket.dart
// inside of object use rocket extension 
RocketController().add("key",value,readOnly:true); // you can't edit it if readonly true
// or
// [add] return value
rocket.add<Type>("key",value);
// [get] return value
rocket.get<Type>("key");
// [remove]
rocket.remove("key");
// remove with condition
View main.dart
// Set it in first screen
const String baseUrl = 'https://jsonplaceholder.typicode.com';
// create request object
RocketRequest request = RocketRequest(url: baseUrl);
// save it, for use it from any screen
rocket.add(rocketRequestKey, request);
View mvcRocket_post_view.dart
import 'dart:io';
import 'package:example/models/post_model.dart';
import 'package:example/requests/post_request.dart';
import 'package:flutter/material.dart';
import 'package:mvc_rocket/mvc_rocket.dart';
class PostExample extends StatelessWidget {
// Save your model to use on another screen
// readOnly means if you close and open this screen you will use same data without update it from Api
View mvcRocket_post_request.dart
import 'package:example/models/post_model.dart';
import 'package:mvc_rocket/mvc_rocket.dart';
const String postsEndpoint = "posts";
class PostRequests {
static Future getPosts(Post postModel) =>
RocketController().get(rocketRequestKey).getObjData(
// endpoint
postsEndpoint,
View mvcRocket_post_model.dart
import 'package:mvc_rocket/mvc_rocket.dart';
const String postUserIdKey = "userId";
const String postIdKey = "id";
const String postTitleKey = "title";
const String postBodyKey = "body";
class Post extends RocketModel<Post> {
int? userId;
int? id;
@M97Chahboun
M97Chahboun / flutter_github_ci.yml
Created Jun 5, 2022 — forked from rodydavis/flutter_github_ci.yml
Flutter Github Actions Build and Deploy Web to Firebase Hosting, iOS to Testflight, Android to Google Play (fastlane)
View flutter_github_ci.yml
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build_web: