Monday, April 18, 2022

ps command doesn't work in docker container

I want to do a ps command in a docker container derived from Debian official Docker hub repository:


$ docker run -ti debian:wheezy /bin/bash

root@51afd6b09af8:/# ps

bash: ps: command not found


alternative 1:

use docker top

docker top <container ID>


alternative 2 (but your container will be bloated):


ps is not installed in the base wheezy image. Try this from within the container:


apt-get update && apt-get install procps

or add the following line to the Dockerfile:

RUN apt-get update && apt-get install -y procps && rm -rf /var/lib/apt/lists/*

Tuesday, April 12, 2022

How to Install MXLinux 21.1 (AHS Desktop Edition)

 On this article, we gonna install MXLinux version 21.1 codename "wildflower". MX Linux, a desktop-oriented Linux distribution based on Debian's "Stable" branch, is a cooperative venture between the antiX and former MEPIS Linux communities. Using Xfce as the default desktop (with separate KDE Plasma and Fluxbox editions also available), it is a mid-weight operating system designed to combine an elegant and efficient desktop with simple configuration, high stability, solid performance and medium-sized footprint.

MXLinux currently sit on No. 1 as The Most Popular Linux Distribution by Distrowatch. This distribution is crafted beutifully and packed with top-quality in-house software called 'MX-Tool'.

Monday, April 4, 2022

Flutter Tutorial: How to Add Firebase to Flutter Project (2022 Update)

In this article, we will discuss how to add Firebase in our flutter based application.

Create and Prepare the Firebase Project

  • Go to Google Firebase and create a project. You will need a Gmail E-Mail to access Firebase.
  • Navigate to the console page of Firebase. Create a new project by clicking on add project.
  • After clicking the button you will be take to a new page. The project creation has two steps.
  • Give your project a name
  • Add Firebase Analytics to your project. I recommend disabling this option unless you really need it.
  • Finish the creation of your project by clicking *Create Project*

After creating your project you will be taken to the project overview. Unlike in previous times when adding Firebase to Flutter you are done inside the Firebase console now.

We also need firebase-cli installed on our computer. So for those who have not installed firebase-cli, please install it first according to their respective OS.

Insert Firebase to Flutter Project

Create a Flutter project or use your desired project. To add the Firebase Core Package to your pubscpec run this command:

flutter pub add firebase_core 

Also run the following three commands

dart pub global activate flutterfire_cli 
//In case you get an error or warning after command 1: export 
PATH=”$PATH”:”$HOME/.pub-cache/bin”
flutterfire configure

If you have done everything correctly the following file will be created: firebase_options.dart. Import those file inside your main.dart by adding this line:

import ‘firebase_options.dart’;

and add this syntax to add firebase function

  void main() async { 
    WidgetsFlutterBinding.ensureInitialized(); await 
    Firebase.initializeApp( options: 
      DefaultFirebaseOptions.currentPlatform, ); runApp(const MyApp());
}
That’s it. Your Firebase has been added.

Flutter Tutorial: Save GPS Data from the Devices

In this article we will cover how to collect the value of the speed of a vehicle through GPS. We will use as a basis for this project the Flutter framework that has been widely used by several developers.

We will cover the following topics:

  • Creating a Standard Project with Flutter
  • Installing and configuring the “geolocator: ^8.2.0” plugin
  • Save the speed data as the device moves.

Step 1. Creating a Standard Project with Flutter

flutter create -i objc -a java my_speed

Step 2. Install & Configure Geolocator Plugin

How to Customize Flutter Stop Error Screen

 

In this short article, we will replace the message on the Stop Error display when developing in Flutter.

As we know, the default display when experiencing a stop error is like this.



To do this customization, please add accent parameters such as style, align, etc. with the following example:

void main() {
  ErrorWidget.builder = (FlutterErrorDetails details) => Material(
    child: Container(
      padding: const EdgeInsets.symmetric(vertical: 40.0, horizontal: 20.0),
      child: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          mainAxisSize: MainAxisSize.min,
          children: [
			//customize your stop error message here
         
             const Text(
              'Error',
              textAlign: TextAlign.center,
              style: TextStyle(
                color: Colors.redAccent,
                fontSize: 24,
                fontWeight: FontWeight.bold,
              ),
            ),
            const SizedBox(height: 20),
            Text(
              details.exceptionAsString(),
              textAlign: TextAlign.justify,
              style: const TextStyle(
                color: Colors.red,
                fontSize: 18,
                fontWeight: FontWeight.normal,
              ),
            ),
          ],
        ),
      ),
    ),
  );
 runApp(MyApp());
}
and if you try to catch an error, you got this different stop error message:

What is StatefulBuilder Widget in Flutter?

 In this article we will discuss about the StatefulBuilder widget. A platonic widget that both has state and calls a closure to obtain its child widget.

The StateSetter function passed to the builder is used to invoke a rebuild instead of a typical State's State.setState.

Since the builder is re-invoked when the StateSetter is called, any variables that represent the state should be kept outside the builder function.

For more explanation, please see the video below:



Flutter Tutorial: Flutter Database for Dart-native Objects with Objectsbox



ObjectsBox is a super-fast Flutter database for storing and syncing Dart objects.
  • High performance - improving response rates and enabling real-time applications.
  • ACID compliant - Atomic, Consistent, Isolated, Durable.
  • Multiplatform - Android, iOS, macOS, Linux, Windows.
  • Scalable - grows with your app, handling millions of objects with ease.
  • Relations - object links / relationships are built-in.
  • Queries - filter data as needed, even across relations.
  • Statically typed - compile time checks & optimizations.
  • Schema migration - change your model with confidence.
  • Data Sync - keeps data in sync offline or online, between devices and servers.
ObjectsBox example code:

Flutter Tutorial: Create Speech to Text

 On this tutorial, we will learn to create a speech to text apps using Flutter. Just like other TTS, spech to text a very helpful and unique feature that can you add to your apps.

Step 1. Add dependencies
dependencies:
  flutter:
    sdk: flutter


  # The following adds the Cupertino Icons font to your application.
  # Use the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  speech_to_text:

and import this packages

Flutter Tutorial: Create Network Service Library for Better API Call in Flutter

 In this tutorial we will create a library function in flutter to provide easy API connection. Our function will use a better known flutter packages like HTTP and DIO. 

Our goals is create a network services that:

✅ Has No duplicate code 

✅ Has Not blocking main thread and dropping FPS

 ✅ Has No error-proof codebase 

✅ Has Minimised time on adding new services and API calls 

✅ Has Structured and strongly-typed error handling

Example code:

class NetworkService {
  NetworkService({
    required this.baseUrl,
    dioClient,
    httpHeaders,
  })  : this._dio = dioClient,
        this._headers = httpHeaders ?? {};
  Dio? _dio;
  final String baseUrl;
  Map _headers;
  Future _getDefaultDioClient() async {
    _headers['content-type'] = 'application/json; charset=utf-8';
    final dio = Dio()
      ..options.baseUrl = baseUrl
      ..options.headers = _headers
      ..options.connectTimeout = 5000 // 5 seconds
      ..options.receiveTimeout = 3000; // 3 seconds
      
    }
    return dio;
  }
  void addBasicAuth(String accessToken) {
    _headers['Authorization'] = 'Bearer $accessToken';
  }
  Future> execute(
    NetworkRequest request,
    Model Function(Map) parser, {
    ProgressCallback? onSendProgress = null,
    ProgressCallback? onReceiveProgress = null,
  }) async {
    if (_dio == null) {
      _dio = await _getDefaultDioClient();
    }
    final req = _PreparedNetworkRequest(
      request,
      parser,
      _dio!,
      {..._headers, ...(request.headers ?? {})},
      onSendProgress,
      onReceiveProgress,
    );
    final result = await compute(
      executeRequest,
      req,
    );
    return result;
  }
}

The History of Flutter

 The first version of Flutter was known as "Sky" and ran on the Android operating system. It was unveiled at the 2015 Dart developer summit with the stated intent of being able to render consistently at 120 frames per second.

During the keynote of Google Developer Days in Shanghai in September 2018, Google announced Flutter Release Preview 2, the last major release before Flutter 1.0. On December 4th of that year, Flutter 1.0 was released at the Flutter Live event, denoting the first stable version of the framework. 

On December 11, 2019, Flutter 1.12 was released at the Flutter Interactive event. On May 6, 2020, the Dart software development kit (SDK) version 2.8 and Flutter 1.17.0 were released, adding support for the Metal API which improves performance on iOS devices by approximately 50%, as well as new Material widgets and network tracking development tools. 

On March 3, 2021, Google released Flutter 2 during an online Flutter Engage event. This major update brought official support for web-based applications with a new CanvasKit renderer and web specific widgets, early-access desktop application support for Windows, macOS, and Linux and improved Add-to-App APIs.

 This release also utilized Dart 2.0 that featured sound null-safety, which caused many breaking changes and issues with many external packages; however, the Flutter team included instructions and tools to mitigate these issues.[12] On September 8th, 2021, Dart 2.14 and Flutter 2.5 were released by Google. The update brought improvements to the Android full-screen mode and the latest version of Google's Material Design called Material You. Dart received two new updates, standardizing lint conditions and marking support for Apple Silicon as stable. The current stable channel of Flutter is 2.16.1 and the Dart version is 2.16.1.

Better Tips to Developed/Released a Flutter App in a Day



Can you create the Flutter app with beautiful animations in 24 hours? And this is our tips you can try to boost your workflow. 

 1. Set the game plan 

 You have to plan everything as in before, that means todo/task list arranged in a sensible order, architecture, plugins that I want to use and even mockups already in place, so the only job left was coding and publishing in those 24 hours.