noor_go 0.0.17 copy "noor_go: ^0.0.17" to clipboard
noor_go: ^0.0.17 copied to clipboard

Noor Go

example/lib/main.dart

import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:noor_go/noor_go.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  NoorGo.init();
  runApp(
    const MaterialApp(
      debugShowCheckedModeBanner: false,
      home: MyApp(),
    ),
  );
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        backgroundColor: Colors.white,
        surfaceTintColor: Colors.transparent,
        elevation: 10,
        scrolledUnderElevation: 10,
        shadowColor: Colors.black.withOpacity(.1),
        title: const Text('Noor Go'),
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Center(
            child: ElevatedButton(
              onPressed: () {
                NoorGo.startDelivery(context);
              },
              style: ElevatedButton.styleFrom(backgroundColor: Colors.white),
              child: const Text(
                'Start Delivery',
                style: TextStyle(color: Colors.black),
              ),
            ),
          ),
          const SizedBox(
            height: 10,
          ),
          Center(
            child: ElevatedButton(
              onPressed: () {
                Navigator.push(
                    context,
                    MaterialPageRoute(
                      fullscreenDialog: true,
                      builder: (context) => const NoorGoPage(),
                    ));
              },
              style: ElevatedButton.styleFrom(backgroundColor: Colors.white),
              child: const Text(
                'Navigate to NoorPage',
                style: TextStyle(color: Colors.black),
              ),
            ),
          ),
          const SizedBox(
            height: 10,
          ),
          if (NoorGo.isLoggedIn())
            Center(
              child: ElevatedButton(
                onPressed: () {
                  NoorGo.logout();
                  setState(() {});
                },
                style: ElevatedButton.styleFrom(backgroundColor: Colors.white),
                child: const Text(
                  'Logout',
                  style: TextStyle(color: Colors.black),
                ),
              ),
            ),
        ],
      ),
    );
  }
}

class NoorGoPage extends StatelessWidget {
  const NoorGoPage({super.key});

  @override
  Widget build(BuildContext context) {
    return const NoorGoMap();
  }
}