flutter_paradigm 1.0.3 copy "flutter_paradigm: ^1.0.3" to clipboard
flutter_paradigm: ^1.0.3 copied to clipboard

This package offers a collection of well-structured, predefined utility classes—including networking, shared preferences management, and common architectural patterns—to streamline the foundational se [...]

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_paradigm/flutter_paradigm.dart';

void main() async {
  Network.init(baseUrl: 'https://fakestoreapi.com/');
  await AppPreferences.instance.init();
  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: [
                    InkWell(
                      onTap:
                          () => AppPreferences.instance.setString(
                            "description",
                            snapshot.data[index]["description"],
                          ),
                      child: LoadImage(
                        image: snapshot.data[index]['image'],
                        type: ImageType.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: AppTextTheme.titleMedium,
                      ),
                    ),
                  ],
                );
              },
              separatorBuilder: (BuildContext context, int index) {
                return Divider(color: Colors.black);
              },
            );
          } else {
            return Text("Not Data");
          }
        },
        future: Network.instance.getMethod(endpoint: 'products'),
      ),
    );
  }
}
1
likes
115
points
37
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

This package offers a collection of well-structured, predefined utility classes—including networking, shared preferences management, and common architectural patterns—to streamline the foundational setup of Flutter projects, accelerate development, and promote consistency across codebases.

Homepage

License

unknown (license)

Dependencies

dio, flutter, flutter_bloc, shared_preferences

More

Packages that depend on flutter_paradigm