API Table Investasi Admin
This commit is contained in:
84
templates/simple/screen.tmpl
Normal file
84
templates/simple/screen.tmpl
Normal file
@@ -0,0 +1,84 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:${appName}${relative}/index.dart';
|
||||
|
||||
class ${upperName}Screen extends StatefulWidget {
|
||||
const ${upperName}Screen({
|
||||
required ${upperName}Bloc ${privateName}Bloc,
|
||||
Key? key,
|
||||
}) : _${privateName}Bloc = ${privateName}Bloc,
|
||||
super(key: key);
|
||||
|
||||
final ${upperName}Bloc _${privateName}Bloc;
|
||||
|
||||
@override
|
||||
${upperName}ScreenState createState() {
|
||||
return ${upperName}ScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class ${upperName}ScreenState extends State<${upperName}Screen> {
|
||||
${upperName}ScreenState();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_load();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<${upperName}Bloc, ${upperName}State>(
|
||||
bloc: widget._${privateName}Bloc,
|
||||
builder: (
|
||||
BuildContext context,
|
||||
${upperName}State currentState,
|
||||
) {
|
||||
if (currentState is Un${upperName}State) {
|
||||
return Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
if (currentState is Error${upperName}State) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text(currentState.errorMessage ),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 32.0),
|
||||
child: RaisedButton(
|
||||
color: Colors.blue,
|
||||
child: Text('reload'),
|
||||
onPressed: _load,
|
||||
),
|
||||
),
|
||||
],
|
||||
));
|
||||
}
|
||||
if (currentState is In${upperName}State) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text(currentState.hello),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
void _load() {
|
||||
widget._${privateName}Bloc.add(Load${upperName}Event());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user