Splash view body done
Presentation (Building the UI)
Summary
This lesson focuses on constructing the foundational UI for the Splash View while establishing best practices for project configuration. It covers defining a global scaffold background color via ThemeData to avoid redundant styling, extracting primary colors into a central constants file, and structuring asset paths cleanly using a static utility class. The lesson concludes with adding the logo asset, building the basic widget tree for the splash screen, and removing the debug banner.
Key Ideas
scaffoldBackgroundColorinsideMaterialApp'sThemeDataglobally applies a default background color to all scaffolds.constants.dartserves as a single source of truth for app-wide primitive values likekPrimaryColorto prevent hardcoding.- Assets directory must be located at the root of the Flutter project, alongside
pubspec.yaml, rather than nested inside thelibfolder. AssetsDatastatic class centralizes string paths for images, reducing the risk of runtime errors caused by typos.CrossAxisAlignment.stretchforces aColumn's children to expand to fill the maximum available cross-axis width.debugShowCheckedModeBanner: falseremoves the red debug banner from the application's UI.
Code Snippets
import 'package:flutter/material.dart';
const kPrimaryColor = Color(0xff100B20);class AssetsData {
static const logo = 'assets/images/Logo.png';
}import 'package:bookly/constants.dart';
import 'package:bookly/features/splash/presentation/views/splash_view.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
void main() {
runApp(const Bookly());
}
class Bookly extends StatelessWidget {
const Bookly({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return GetMaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData.dark().copyWith(
scaffoldBackgroundColor: kPrimaryColor,
),
home: const SplashView(),
);
}
}flutter:
uses-material-design: true
assets:
- assets/images/import 'package:bookly/core/utils/assets.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class SplashViewBody extends StatelessWidget {
const SplashViewBody({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Image.asset(AssetsData.logo),
],
);
}
}My Notes
- Asset Folder Location: A very common mistake (which the instructor makes and corrects) is placing the
assetsfolder inside thelibfolder. It must sit at the root level of your project alongsidepubspec.yaml. - Logo Formats & SVGs: For a minimalist, skeletal geometric logo composed of points and lines, utilizing the SVG format is highly recommended to maintain crisp vector resolution across all screen densities. Since Flutter doesn't render SVGs out of the box like it does PNGs, you would add the
flutter_svgpackage and useSvgPicture.asset(AssetsData.logo)instead ofImage.asset(). - Asset Management Upgrades: The
AssetsDatastatic class is a massive improvement over raw strings. However, as the project grows, manually updating this file becomes tedious. Look into theflutter_genpackage later—it automatically generates this exact class based on yourpubspec.yamlcontents. - Theming Strategy: Setting
scaffoldBackgroundColorglobally at the start is an excellent clean architecture practice. It separates the design configuration from the layout implementation.