flutter_andomie 0.5.5-alpha2 flutter_andomie: ^0.5.5-alpha2 copied to clipboard
Collection of utils with advanced style and controlling system.
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:flutter_andomie/core.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
runApp(const Application());
}
class Application extends StatelessWidget {
const Application({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const Home(),
);
}
}
class Home extends StatelessWidget {
const Home({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
var timeMills = DateTime.now().add(const Duration(
days: 0,
hours: 0,
minutes: 0,
seconds: 0,
));
return Scaffold(
body: SafeArea(
child: Text(timeMills.toRealtime(
showRealtime: true,
whenShowNow: 10,
)),
),
);
}
}
class User extends Entity<UserKey> {
final String? name;
final String? photo;
User({
super.id,
super.timeMills,
this.name,
this.photo,
});
factory User.from(dynamic source) {
var keys = UserKey.i;
return User(
id: source.entityId,
timeMills: source.entityTimeMills,
name: source.entityValue(keys.name),
photo: source.entityValue(keys.photo),
);
}
@override
Map<String, dynamic> get source => super.source.attach({
key.name: name,
key.photo: photo,
});
static User get i => Singleton.instanceOf(() => User());
@override
UserKey makeKey() {
log("makeKey");
return UserKey();
}
}
class UserKey extends EntityKey {
final String name = "name";
final String photo = "photo";
static UserKey get i => Singleton.instanceOf(() => UserKey());
}