yet_another_layout_builder 0.2.0 yet_another_layout_builder: ^0.2.0 copied to clipboard
Yet another Flutter library for building layouts from xml assets (YALB). Using builder for generating most of needed code to perform transform from xml to widgets.
import 'package:flutter/material.dart';
import 'interaction_example.dart';
import 'listview_example.dart';
import 'semiconst_example.dart';
import 'style_2_example.dart';
import 'widget_repository.g.dart';
import 'custom_registry.dart';
import 'style_example.dart';
import 'external_data_example.dart';
import 'blocks_example.dart';
void main() {
registerWidgetBuilders();
registerItems();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'YALB Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Yet Another Layout Builder'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _SelectorState();
}
class _SelectorState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
children: [
TextButton(
onPressed: () => _goto(const StyleExample()),
child: const Text("Style example")),
TextButton(
onPressed: () => _goto(const StyleTwoExample()),
child: const Text("Style Special case example")),
TextButton(
onPressed: () => _goto(const ExternalDataExample()),
child: const Text("External Data example")),
TextButton(
onPressed: () => _goto(const BlocksExample()),
child: const Text("Blocks example")),
TextButton(
onPressed: () => _goto(const ListViewExample()),
child: const Text("List View example")),
TextButton(
onPressed: () => _goto(const InteractionExample()),
child: const Text("Interaction example")),
TextButton(
onPressed: () => _goto(const SemiConstExample()),
child: const Text("Semi const example"))
],
),
));
}
void _goto(StatefulWidget dest) {
setState(() {
Navigator.of(context).push(MaterialPageRoute(builder: (context) => dest));
});
}
}