Skip to content

Instantly share code, notes, and snippets.

View perymerdeka's full-sized avatar

Feri Lukmansyah perymerdeka

View GitHub Profile
@perymerdeka
perymerdeka / main.dart
Last active June 26, 2021 12:13
Flutter App to Display Image
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
@perymerdeka
perymerdeka / text_widget.dart
Created June 27, 2021 06:33
explain Text widget in Flutter Application
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
@perymerdeka
perymerdeka / assets_path_reader.dart
Created June 30, 2021 15:44
assets path reader example
// read image path
loadJson({String assetsPath='assets/AssetManifest.json'}) async {
final imageAssets = await rootBundle.loadString(assetsPath);
List<WallpaperModel> wallpaperModel = (json.decode(imageAssets) as List).map((e) => WallpaperModel.fromJson(e)).toList();
wallpaperModel.forEach((element) => print(element.imagePath));
}
import 'dart:convert';
import 'dart:io';
void main() async {
assetsGenerator();
}
void assetsGenerator({String assetsDir='/assets/images/'}) async {
var assetsPaths = Directory(Directory.current.path + assetsDir);
// login page dart
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Container(
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height,
maxWidth: MediaQuery.of(context).size.width),
decoration: BoxDecoration(
├── Makefile
├── manage.py
├── projects
│   ├── blog
│   │   ├── api
│   │   │   ├── __init__.py
│   │   │   ├── routes.py
│   │   │   └── views.py
│   │   ├── __init__.py
│   │   └── models.py
import os
from flask import Flask
from flask_mongoengine import MongoEngine
from projects.blog.api.routes import blog_api_blueprint
db = MongoEngine()
@perymerdeka
perymerdeka / models.py
Created September 2, 2021 14:17
models mapping for mongo
import mongoengine as me
from datetime import datetime
class Posts(me.Document):
title: str = me.StringField(required=True, max_length=200)
contents: str = me.StringField(required=True)
created_on = me.DateTimeField(default=datetime.now())
import os
class BaseConfig:
TESTING: bool = False
SECRET_KEY: str = '@Flaskr-MongoSeCretKeyS'
DEBUG: bool = False
class DevelopmentConfig(BaseConfig):
MONGODB_SETTINGS: dict = {
@perymerdeka
perymerdeka / Makefile
Created September 2, 2021 14:46
automation using Makefile for flask_blog application
run-dev:
export FLASK_APP=manage.py && export FLASK_ENV=development && export APP_SETTINGS='projects.config.DevelopmentConfig' && flask run