flutter_paradigm 1.0.0
flutter_paradigm: ^1.0.0 copied to clipboard
A skeleton classes for projects.
example/lib/main.dart
import 'package:bloc_skeleton/flutter_paradigm.dart';
import 'package:flutter/material.dart';
void main() {
Network.init(baseUrl: 'https://fakestoreapi.com/');
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: FutureBuilder(
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(child: CircularProgressIndicator());
}
if (snapshot.hasData) {
return ListView.separated(
itemCount: snapshot.data.length,
itemBuilder: (context, index) {
return Row(
children: [
LoadImage(
image: snapshot.data[index]['image'],
type: 'network',
height: 50,
width: 50,
),
Flexible(
child: LoadText(
value:
"$index => ${snapshot.data[index]["description"]}",
maxLines: 4,
overFlow: TextOverflow.ellipsis,
mergeStyle: TextStyle(color: Colors.black),
defaultTextStyle: 'titleMedium',
),
),
],
);
},
separatorBuilder: (BuildContext context, int index) {
return Divider(color: Colors.black);
},
);
} else {
return Text("Not Data");
}
},
future: Network.instance.getMethod(endpoint: 'products'),
),
);
}
}