coder0211 0.0.45 coder0211: ^0.0.45 copied to clipboard
This is a package with functions and widgets to make app development faster and more convenient, currently it is developed by one developer.
import 'package:coder0211/coder0211.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:mobx/mobx.dart';
part 'example_store.g.dart';
void main() {
runApp(const MyApp());
}
/// Clean before updating:
/// flutter packages pub run build_runner watch --delete-conflicting-outputs
class ExampleStore = _ExampleStore with _$ExampleStore;
abstract class _ExampleStore with Store {
@observable
int _ic = 0;
int get ic => _ic;
set ic(int ic) {
_ic = ic;
}
List<int> lists = [];
@observable
ObservableList<int> listsInt = ObservableList<int>();
@action
ice() {
ic++;
}
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MultiProvider(
providers: [Provider<ExampleStore>(create: (context) => ExampleStore())],
child: MaterialApp(
home: const Example(),
),
);
}
}
class Example extends BaseScreen {
const Example({Key? key}) : super(key: key);
@override
State<Example> createState() => _ExampleState();
}
class _ExampleState extends BaseScreenState<Example, ExampleStore> {
@override
Widget build(BuildContext context) {
super.build(context);
return Scaffold(
appBar: AppBar(),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
width: 1.0.w(context),
),
Observer(builder: (_) {
return Text(
'${store.ic}',
style: Theme.of(context).textTheme.headline4,
);
}),
'heelo'.d1()
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
store.ice();
},
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
}