1
0
mirror of https://github.com/nisrulz/flutter-examples.git synced 2026-08-25 01:05:36 +00:00
Files
flutter-examples/stateless_widgets/lib/main.dart
Nishant Srivastava 5c53498119 refactor: standardize Dart and Android config across all 54 apps
- Bump all apps to sdk >=3.0.0 <4.0.0 and add flutter_lints + a shared
  analysis_options.yaml to every app (flutter analyze is now green repo-wide)
- Fix real compile errors in firebase_google_authentication and image_editor,
  plus deprecated APIs (Matrix4, SvgPicture.color, textScaleFactor),
  missing async 'mounted' guards, and misc lints via dart fix + manual fixes
- Align pubspec 'name' with each folder and Android namespace/applicationId
  with the documented github.nisrulz.* convention
- Convert bmi_calculator from a legacy Flutter module to a standard app
  with a proper android/ scaffold; fix missing android:exported in launcher
  manifests across 22 apps so all Android builds pass
- Untrack generated build files (GeneratedPluginRegistrant,
  .flutter-plugins-dependencies) and ignore them
2026-08-17 17:26:39 +02:00

95 lines
2.5 KiB
Dart

import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
home: MyApp(),
// Define the theme, set the primary swatch
theme: ThemeData(primarySwatch: Colors.green),
));
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
// Declare some constants
final double myTextSize = 30.0;
final double myIconSize = 40.0;
final TextStyle myTextStyle =
TextStyle(color: Colors.grey, fontSize: myTextSize);
var column = Column(
// Makes the cards stretch in horizontal axis
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
// Setup the card
MyCard(
// Setup the text
title: Text(
"Favorite",
style: myTextStyle,
),
// Setup the icon
icon: Icon(Icons.favorite, size: myIconSize, color: Colors.red)),
MyCard(
title: Text(
"Alarm",
style: myTextStyle,
),
icon: Icon(Icons.alarm, size: myIconSize, color: Colors.blue)),
MyCard(
title: Text(
"Airport Shuttle",
style: myTextStyle,
),
icon: Icon(Icons.airport_shuttle,
size: myIconSize, color: Colors.amber)),
MyCard(
title: Text(
"Done",
style: myTextStyle,
),
icon: Icon(Icons.done, size: myIconSize, color: Colors.green)),
],
);
return Scaffold(
appBar: AppBar(
title: Text("Stateless Widget"),
),
body: Container(
// Sets the padding in the main container
padding: const EdgeInsets.only(bottom: 2.0),
child: Center(
child: SingleChildScrollView(child: column),
),
),
);
}
}
// Create a reusable stateless widget
class MyCard extends StatelessWidget {
final Widget icon;
final Widget title;
// Constructor. {} here denote that they are optional values i.e you can use as: MyCard()
const MyCard({super.key, required this.title, required this.icon});
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.only(bottom: 1.0),
child: Card(
child: Container(
padding: const EdgeInsets.all(20.0),
child: Column(
children: <Widget>[title, icon],
),
),
),
);
}
}