testsweets 1.5.0 copy "testsweets: ^1.5.0" to clipboard
testsweets: ^1.5.0 copied to clipboard

outdated

A package to help sync flutter automation keys with TestSweets backend

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_driver/driver_extension.dart';
import 'package:stacked_services/stacked_services.dart';
import 'package:testsweets/testsweets.dart';

import 'app/app.locator.dart';
import 'app/app.router.dart';

const bool FLUTTER_DRIVER = bool.fromEnvironment(
  'FLUTTER_DRIVER',
  defaultValue: false,
);

Future<void> main() async {
  if (FLUTTER_DRIVER) {
    enableFlutterDriverExtension();
  }

  await setupTestSweets();
  setupLocator();
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      builder: (context, child) => TestSweetsOverlayView(
        projectId: '7lyZJXDJQtLodBvJsYsu',
        child: child!,
        captureWidgets: !FLUTTER_DRIVER,
      ),
      initialRoute: Routes.signUpView,
      navigatorKey: StackedService.navigatorKey,
      onGenerateRoute: StackedRouter().onGenerateRoute,
      navigatorObservers: [
        TestSweetsNavigatorObserver(),
      ],
    );
  }
}