flutter_control 0.14.1+11 flutter_control: ^0.14.1+11 copied to clipboard
Flutter Control is library to simply maintain App and State management. Provides some basic Widgets and Controllers to start with.
import 'package:flutter/material.dart';
import 'package:flutter_control/core.dart';
import 'cards_controller.dart';
import 'menu_page.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget with LocalizationProvider, PrefsProvider {
final _theme = ActionControl<ThemeData>.broadcastListener(
key: 'theme',
defaultValue: ThemeData(
primaryColor: Colors.orange,
),
);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return ControlBase(
debug: true,
defaultLocale: 'en',
locales: {
'en': AssetPath().localization('en'),
'cs': 'assets/localization/cs.json',
},
entries: {
'cards': CardsController(),
},
initializers: {
DetailController: (args) => DetailController(),
},
theme: (context) => MyTheme.of(context),
root: (context) => MenuPage(),
app: (context, key, home) {
return ControlBuilder<ThemeData>(
controller: _theme,
builder: (context, theme) {
return MaterialApp(
key: key,
home: home,
title: localization.isActive ? localize('app_name') : 'Flutter Example',
theme: theme,
);
});
},
);
}
}
class MyTheme extends ControlTheme {
@override
final padding = 24.0;
@override
final paddingHalf = 12.0;
final superColor = Colors.red;
MyTheme(Device device, ThemeData data) : super(device, data);
factory MyTheme.of(BuildContext context) {
return MyTheme(Device.of(context), Theme.of(context));
}
MyTheme copy(ThemeData data) => MyTheme(
device,
data,
);
}