Mobile App Development

How to Display Protected Images with Tokens in Flutter

In many cases, we may have to display images in our Flutter app that are protected by web middleware and require a token to access them. In this tutorial, we’ll see how to accomplish this using the widget along with an authentication mechanism to pass the token to the server.


Before we get started, make sure you have the following:

  • Flutter installed on your system.
  • An image URL that is protected by web middleware and requires a token to access it.
  • A valid authentication token for the image URL.

The Code

Here is an example code snippet that demonstrates how to display protected images with tokens in Flutter:

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;

class ImageWithToken extends StatefulWidget {
  final String imageUrl;
  final String token;

  const ImageWithToken({Key? key, required this.imageUrl, required this.token})
      : super(key: key);

  _ImageWithTokenState createState() => _ImageWithTokenState();

class _ImageWithTokenState extends State<ImageWithToken> {
  late http.Response _response;
  late String _imageBase64;

  void initState() {

  Future<void> _fetchImage() async {
    _response = await http.get(
      headers: {HttpHeaders.authorizationHeader: 'Bearer ${widget.token}'},

    setState(() {
      _imageBase64 = base64Encode(_response.bodyBytes);

  Widget build(BuildContext context) {
    return _imageBase64.isNotEmpty
        ? Image.memory(
        : const CircularProgressIndicator();

How to Create an Eloquent Relationship with Pivot Table in Laravel

To create an eloquent relationship for OperatingUnit has many Stakeholder with a pivot table in the middle in Laravel, follow the steps below:

  1. Create a migration for the pivot table:
php artisan make:migration create_operating_unit_stakeholder_table
  1. In the migration file, define the schema for the pivot table:
Schema::create('operating_unit_stakeholder', function (Blueprint $table) {
  1. Run the migration to create the pivot table:
php artisan migrate
  1. Define the relationship in the OperatingUnit model:
class OperatingUnit extends Model
    public function stakeholders()
        return $this->belongsToMany(Stakeholder::class)->withTimestamps();
  1. Define the relationship in the Stakeholder model:
class Stakeholder extends Model
    public function operatingUnits()
        return $this->belongsToMany(OperatingUnit::class)->withTimestamps();
  1. To retrieve the stakeholders for an operating unit, you can use the stakeholders relationship:
$operatingUnit = OperatingUnit::find(1);
$stakeholders = $operatingUnit->stakeholders;
  1. To add a stakeholder to an operating unit, you can use the attach method:
$operatingUnit = OperatingUnit::find(1);
$stakeholder = Stakeholder::find(1);
  1. To remove a stakeholder from an operating unit, you can use the detach method:
$operatingUnit = OperatingUnit::find(1);
$stakeholder = Stakeholder::find(1);

Note: Laravel assumes the pivot table name by the singular name of the related models in alphabetical order. If you need to change the pivot table name, you can specify it as a second argument to the belongsToMany method.


Building a User-Friendly Interface for Your Indie App

As an indie app developer, you have likely put countless hours into developing a product that provides valuable features to its users. However, if your app’s interface is confusing or difficult to use, you may be missing out on the full potential of your product. The user interface (UI) of an app is one of the most important aspects of its design, as it is the first thing users see and interact with. A well-designed UI can make all the difference in how users perceive your app, and whether they choose to use it regularly or move on to another app that is easier to use.

When building a UI for your indie app, there are several key elements to consider.

  1. Consistency: One of the most important elements of a user-friendly interface is consistency. Users should be able to quickly and easily find the buttons and navigation elements they need, and these elements should work the same way each time they are used.
  2. Clarity: Your UI should clearly convey the purpose of each button, link, and page within your app. Avoid using ambiguous icons or text that could be interpreted in multiple ways.
  3. Usability: Your app’s UI should be designed with the end user in mind. This means that buttons and links should be easy to press and swipe, and that navigation should be straightforward and intuitive.
  4. Visual appeal: A visually appealing UI can help users feel more engaged with your app. Choose colors and fonts that are aesthetically pleasing, and incorporate graphics and animations that enhance the user experience.
  5. Feedback: Your UI should provide users with clear and instant feedback when they perform an action. This feedback can be in the form of a pop-up message, a change in the button color, or any other visual indicator that the user’s action has been processed.

There are many UI design tools and frameworks available to help indie app developers create user-friendly interfaces. Some popular options include Sketch, Adobe XD, and Figma. Whichever tool you choose, be sure to take the time to thoroughly test your UI on different devices and screen sizes to ensure that it works well for all users.

In conclusion, a user-friendly interface is an essential element of a successful indie app. By considering the key elements of consistency, clarity, usability, visual appeal, and feedback, you can create an interface that users will love and appreciate. Don’t skimp on the design and development of your UI, as it can make or break the success of your app.


Securing Your WordPress Site: A Guide to Proper File Permissions for the Source Code

When it comes to setting up a WordPress website, one important aspect to consider is file and folder permissions. These permissions determine who can access and make changes to the various files and folders that make up your WordPress installation. In this blog post, we’ll discuss the recommended file and folder permissions for a typical WordPress installation.

First and foremost, it’s important to note that the use of 777 (rwxrwxrwx) permissions is not recommended. This permission level allows anyone with access to your server to read, write, and execute files, which could lead to security vulnerabilities. Instead, we recommend the following permissions:

  • wp-content folder: 755 (rwxr-xr-x)
  • All files within wp-content: 644 (rw-r–r–)
  • wp-config.php file: 600 (rw——-)

The wp-content folder is where your themes, plugins, and uploads are stored. By setting the folder permissions to 755, you’re allowing WordPress to read and execute the necessary files while also protecting against unauthorized access.

All files within the wp-content folder should be set to 644, which allows the server to read and write to these files while preventing others from making changes.

The wp-config.php file contains sensitive information such as your database credentials and security keys. To protect this information, we recommend setting the permissions to 600, which prevents anyone other than the owner of the file from reading or writing to it.

It’s important to keep in mind that different hosting providers and server configurations may require slightly different permissions. If you encounter any issues with your installation, it’s a good idea to check with your hosting provider or consult the documentation for your server software.

In conclusion, setting the proper file and folder permissions for your WordPress installation is crucial for both the functionality and security of your website. By following the recommendations outlined in this post, you can ensure that your WordPress site is properly protected while still allowing it to function as intended.