wa_flutter_lib 0.0.4 copy "wa_flutter_lib: ^0.0.4" to clipboard
wa_flutter_lib: ^0.0.4 copied to clipboard

This package includes whitelabel app common screens, services and modules.

example/lib/main.dart

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


void main() async{
  WidgetsFlutterBinding.ensureInitialized();
  initWA(
    screen: const MyHomePage(),
    domain: "wa_flutter_lib",
    apiUrl: "api",
    theme: const Color(0xffffb800),
    primary: const Color(0xffffffff),
    secondary: const Color(0xffd3d3d3),
    loginRequired: true,
    firebaseToken: "",
  );
  await SharedPreference.init();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Wa flutter lib example',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  TextEditingController firstNameController = TextEditingController();
  TextEditingController lastNameController = TextEditingController();
  TextEditingController emailController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Home page"),
      ),
      body: Center(
        child: Padding(
          padding: const EdgeInsets.all(20.0),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Widgets().textFormField(
                controller: firstNameController,
                labelText: "first name",
              ),
              const SizedBox(height: 10,),
              Widgets().textFormField(
                controller: lastNameController,
                labelText: "last name",
              ),
              const SizedBox(height: 10,),
              Widgets().textFormField(
                controller: emailController,
                labelText: "email",
              ),
              const SizedBox(height: 30,),
              Widgets().textButton(
                onPressed: (){
                  if(firstNameController.text.isEmpty){
                    CommonFunctions().showAlertDialog(alertMessage: "First name should not be empty", context: context);
                  }else if(lastNameController.text.isEmpty){
                    CommonFunctions().showAlertDialog(alertMessage: "Last name should not be empty", context: context);
                  }else if(emailController.text.isEmpty){
                    CommonFunctions().showAlertDialog(alertMessage: "Email should not be empty", context: context);
                  }else {
                    CommonFunctions().showBottomSheet(
                      context: context,
                      child: Container(
                        padding: const EdgeInsets.all(20),
                        constraints: const BoxConstraints(
                          maxHeight: 300,
                          maxWidth: 300,
                          minWidth: 300,
                        ),
                        decoration: BoxDecoration(
                          color: Colors.white,
                          borderRadius: BorderRadius.circular(20),
                        ),
                        child: IntrinsicHeight(
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              const Text(
                                "First name",
                                style: TextStyle(
                                  fontSize: 16,
                                  fontWeight: FontWeight.bold,
                                ),
                              ),
                              Text(
                                firstNameController.text,
                                style: const TextStyle(
                                  fontSize: 18,
                                  // fontWeight: FontWeight.bold,
                                ),
                              ),
                              const SizedBox(height: 10,),
                              const Text(
                                "Last name",
                                style: TextStyle(
                                  fontSize: 16,
                                  fontWeight: FontWeight.bold,
                                ),
                              ),
                              Text(
                                lastNameController.text,
                                style: const TextStyle(
                                  fontSize: 18,
                                  // fontWeight: FontWeight.bold,
                                ),
                              ),
                              const SizedBox(height: 10,),
                              const Text(
                                "Email",
                                style: TextStyle(
                                  fontSize: 16,
                                  fontWeight: FontWeight.bold,
                                ),
                              ),
                              Text(
                                emailController.text,
                                style: const TextStyle(
                                  fontSize: 18,
                                  // fontWeight: FontWeight.bold,
                                ),
                              ),
                            ],
                          ),
                        ),
                      ),
                    );
                  }
                },
                text: "Submit",
              ),
            ],
          ),
        ),
      ),
    );
  }
}
4
likes
140
pub points
0%
popularity

Publisher

verified publisherspyhunteritsolution.in

This package includes whitelabel app common screens, services and modules.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, http, intl_phone_field, shared_preferences

More

Packages that depend on wa_flutter_lib