Skip to content

Instantly share code, notes, and snippets.

Working from home

Mohammed CHAHBOUN M97Chahboun

Working from home
View GitHub Profile
View simple_flutter_example.dart
// Copyright 2018 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:english_words/english_words.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
View use-env-var.yaml
- name: Set color
id: random-color-generator
run: echo "SELECTED_COLOR=green" >> $GITHUB_OUTPUT
- name: Get color
run: echo "The selected color is ${{ steps.random-color-generator.outputs.SELECTED_COLOR }}"
View bump-version-based-on-labels.yaml
name: Bump app version based on PR labels
# Workflow for every new feature/enhance/fix
- dev
- closed
View labels_to_version_parts.dart
import 'dart:io';
const List<String> options = ["major", "minor", "patch"];
Future<void> main(List<String> labels) async {
List<String> versionParts = List.from(labels);
versionParts.removeWhere((e) => !options.contains(e));
String parts = "";
if (versionParts.isNotEmpty) {
parts = versionParts.join(",");
parts = "parts=bump:$parts";
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
// [get] return value
// [remove]
// remove with condition
View main.dart
// Set it in first screen
const String baseUrl = '';
// 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) =>
// endpoint
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;