flutter_widget_model 0.5.1+23
flutter_widget_model: ^0.5.1+23 copied to clipboard
Package that allows you to treat your models like widgets. Used with [flutter_hooks].
example/main.dart
import 'package:flutter/material.dart';
import 'package:flutter_widget_model/flutter_widget_model.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends HookWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
DataFieldModel("count").getInt(0).toString(),
style: Theme.of(context).textTheme.display1,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () => DataFieldModel("count").increment(),
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
}