digitowl_flutter_base_library 0.0.11
digitowl_flutter_base_library: ^0.0.11 copied to clipboard
Digitowl UI library for private uset.
example/lib/main.dart
import 'dart:async';
import 'package:digitowl_flutter_base_library/digitowl_flutter_base_library.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
final _digitowlFlutterBaseLibraryPlugin = DigitowlFlutterBaseLibrary();
@override
void initState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
// We also handle the message potentially returning null.
try {
platformVersion =
await _digitowlFlutterBaseLibraryPlugin.getPlatformVersion() ??
'Unknown platform version';
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {
_platformVersion = platformVersion;
});
}
@override
Widget build(BuildContext context) {
final baseColor = DigitowlColorThemeData.lightWithDefaults(
brand: const ForegroundBackground(
foreground: Color(0xFF885110),
background: Color(0xFFFFEFDB),
),
onBrandForeground: const Color(0xFFFFEFDB),
);
final darkBaseColor = DigitowlColorThemeData.darkWithDefaults(
brand: const ForegroundBackground(
foreground: Color(0xFFFFEFDB),
background: Color(0xFF6D410D),
),
onBrandForeground: const Color(0xFF6D410D),
);
return MaterialApp(
theme: ThemeData.light().copyWith(extensions: <ThemeExtension<dynamic>>{
DigitowlThemeExtension(
color: baseColor,
text: DigitowlTextThemeData.buildWithColor(context,
fontFamily: 'Roboto', color: baseColor.text.main),
textOnBrand: DigitowlTextThemeData.buildWithColor(context,
fontFamily: 'Roboto', color: baseColor.onBrandForeground),
widget: DigitowlWidgetThemeData.fromColorTheme(context, baseColor),
),
}),
darkTheme:
ThemeData.dark().copyWith(extensions: <ThemeExtension<dynamic>>{
DigitowlThemeExtension(
color: darkBaseColor,
text: DigitowlTextThemeData.buildWithColor(context,
fontFamily: 'Roboto', color: darkBaseColor.text.main),
textOnBrand: DigitowlTextThemeData.buildWithColor(context,
fontFamily: 'Roboto', color: darkBaseColor.onBrandForeground),
widget:
DigitowlWidgetThemeData.fromColorTheme(context, darkBaseColor),
),
}),
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Builder(builder: (context) {
return Center(
child: Wrap(
alignment: WrapAlignment.center,
runAlignment: WrapAlignment.center,
spacing: 16,
runSpacing: 16,
children: [
SolidButton.disabled(context, label: 'Blablabla'),
BorderedButton.disabled(context, label: 'Blablabla'),
SolidButton.disabled(context, label: 'Blablabla'),
SolidButton.disabled(context, label: 'Blablabla')
],
),
);
}),
),
);
}
}