flutter_gherkin 2.0.0 copy "flutter_gherkin: ^2.0.0" to clipboard
flutter_gherkin: ^2.0.0 copied to clipboard

A Gherkin / Cucumber parser and test runner for Dart and Flutter

example/lib/main.dart

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Counter App',
      home: MyHomePage('Counter App Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage(this.title) : super();

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;
  bool hasLongPressedText = false;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      drawer: Drawer(
        key: const Key('drawer'),
        child: ListView(
          padding: EdgeInsets.zero,
          children: <Widget>[
            DrawerHeader(
              decoration: BoxDecoration(
                color: Colors.blue,
              ),
              child: const Text('Drawer Header'),
            ),
            ListTile(
              title: const Text('Item 1'),
              onTap: () {
                // Update the state of the app
                // ...
                // Then close the drawer
                Navigator.pop(context);
              },
            ),
            ListTile(
              title: const Text('Item 2'),
              onTap: () {
                // Update the state of the app
                // ...
                // Then close the drawer
                Navigator.pop(context);
              },
            ),
          ],
        ),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              // Provide a Key to this specific Text Widget. This allows us
              // to identify this specific Widget from inside our test suite and
              // read the text.
              key: const Key('counter'),
              style: Theme.of(context).textTheme.headline4,
            ),
            TextButton(
              key: Key('openPage2'),
              onLongPress: () {
                Future.delayed(
                    Duration(seconds: 12),
                    () => Navigator.push(
                          context,
                          MaterialPageRoute(builder: (context) => PageTwo()),
                        ));
              },
              onPressed: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(builder: (context) => PageTwo()),
                );
              },
              child: Text('Open page 2'),
            ),
            GestureDetector(
              onLongPress: () {
                setState(() {
                  hasLongPressedText = true;
                });
              },
              child: Container(
                color:
                    hasLongPressedText ? Colors.blueGrey : Colors.transparent,
                child: Text(
                  hasLongPressedText
                      ? 'Text has been long pressed!'
                      : 'Text that has not been long pressed',
                  key: const Key('longPressText'),
                ),
              ),
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        // Provide a Key to this the button. This allows us to find this
        // specific button and tap it inside the test suite.
        key: const Key('increment'),
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}

class PageTwo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      key: Key('pageTwo'),
      appBar: AppBar(
        automaticallyImplyLeading: true,
        title: Text('Page 2'),
      ),
      body: SafeArea(
        child: Center(
          child: Text('Contents of page 2'),
        ),
      ),
    );
  }
}
131
likes
140
pub points
90%
popularity

Publisher

unverified uploader

A Gherkin / Cucumber parser and test runner for Dart and Flutter

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_driver, flutter_test, gherkin, meta

More

Packages that depend on flutter_gherkin