Third step of remaking the example

pull/1530/head
Ellet 1 year ago
parent 5d3e600645
commit 87b39bd33c
No known key found for this signature in database
GPG Key ID: C488CC70BBCEF0D1
  1. 3
      .github/workflows/main.yml
  2. 1
      example/lib/logic/empty.dart
  3. 67
      example/lib/main.dart
  4. 61
      example/lib/presentation/home/widgets/home_screen.dart
  5. 48
      example/lib/presentation/quill/quill_screen.dart
  6. 295
      example/lib/presentation/quill/samples/quill_default_sample.dart
  7. 21
      example/lib/presentation/quill/samples/quill_images_sample.dart
  8. 270
      example/lib/presentation/quill/samples/quill_text_sample.dart
  9. 8
      example/lib/presentation/settings/cubit/settings_cubit.g.dart
  10. 8
      example/lib/presentation/settings/cubit/settings_state.dart
  11. 1
      example/lib/presentation/settings/widgets/settings_screen.dart
  12. 31
      example/test/widget_test.dart

@ -31,6 +31,9 @@ jobs:
- name: Install quill_html_converter dependencies
run: flutter pub get -C packages/quill_html_converter
- name: Install old_example dependencies
run: flutter pub get -C old_example
- name: Run flutter analysis
run: flutter analyze

@ -6,6 +6,7 @@ import 'package:flutter_localizations/flutter_localizations.dart'
GlobalCupertinoLocalizations,
GlobalMaterialLocalizations,
GlobalWidgetsLocalizations;
import 'package:flutter_quill/flutter_quill.dart' show Document;
import 'package:flutter_quill/translations.dart' show FlutterQuillLocalizations;
import 'package:hydrated_bloc/hydrated_bloc.dart'
show HydratedBloc, HydratedStorage;
@ -13,7 +14,10 @@ import 'package:path_provider/path_provider.dart'
show getApplicationDocumentsDirectory;
import 'presentation/home/widgets/home_screen.dart';
import 'presentation/quill/quill_images_screen.dart';
import 'presentation/quill/quill_screen.dart';
import 'presentation/quill/samples/quill_default_sample.dart';
import 'presentation/quill/samples/quill_images_sample.dart';
import 'presentation/quill/samples/quill_text_sample.dart';
import 'presentation/settings/cubit/settings_cubit.dart';
import 'presentation/settings/widgets/settings_screen.dart';
@ -55,17 +59,66 @@ class MyApp extends StatelessWidget {
supportedLocales: FlutterQuillLocalizations.supportedLocales,
routes: {
SettingsScreen.routeName: (context) => const SettingsScreen(),
QuillImagesScreen.routeName: (context) =>
const QuillImagesScreen(),
},
onGenerateRoute: (settings) {
final name = settings.name ?? '/';
if (name == HomeScreen.routeName) {
return MaterialPageRoute(
builder: (context) {
return const HomeScreen();
},
);
}
if (name == QuillScreen.routeName) {
return MaterialPageRoute(
builder: (context) {
final args = settings.arguments as QuillScreenArgs;
return QuillScreen(
args: args,
);
},
);
}
return null;
},
onUnknownRoute: (settings) {
return MaterialPageRoute(
builder: (context) => Scaffold(
appBar: AppBar(
title: const Text('Not found'),
),
body: const Text('404'),
),
);
},
home: Builder(
builder: (context) {
final screen = switch (state.defaultScreen) {
DefaultScreen.home => const HomePage(),
DefaultScreen.home => const HomeScreen(),
DefaultScreen.settings => const SettingsScreen(),
DefaultScreen.images => const QuillImagesScreen(),
DefaultScreen.videos => null,
DefaultScreen.text => null,
DefaultScreen.imagesSample => QuillScreen(
args: QuillScreenArgs(
document: Document.fromJson(quillImagesSample),
),
),
DefaultScreen.videosSample => throw UnimplementedError(
'Not implemented for now',
),
DefaultScreen.textSample => QuillScreen(
args: QuillScreenArgs(
document: Document.fromJson(quillTextSample),
),
),
DefaultScreen.emptySample => QuillScreen(
args: QuillScreenArgs(
document: Document(),
),
),
DefaultScreen.defaultSample => QuillScreen(
args: QuillScreenArgs(
document: Document.fromJson(quillDefaultSample),
),
),
};
return AnimatedSwitcher(
duration: const Duration(milliseconds: 330),

@ -1,13 +1,17 @@
import 'package:flutter/material.dart';
import 'package:flutter_quill/flutter_quill.dart';
import '../../quill/quill_images_screen.dart';
import '../../quill/quill_screen.dart';
import '../../quill/samples/quill_default_sample.dart';
import '../../quill/samples/quill_images_sample.dart';
import '../../quill/samples/quill_text_sample.dart';
import '../../settings/widgets/settings_screen.dart';
import 'example_item.dart';
class HomePage extends StatelessWidget {
const HomePage({super.key});
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
static const routeName = '/home';
@override
Widget build(BuildContext context) {
@ -50,6 +54,23 @@ class HomePage extends StatelessWidget {
child: ListView(
padding: const EdgeInsets.all(16),
children: [
HomeScreenExampleItem(
title: 'Default',
icon: const Icon(
Icons.home,
size: 50,
),
text:
'If you want to see how the editor work with default content, '
'see any samples or you are working on it',
onPressed: () => Navigator.of(context).pushNamed(
QuillScreen.routeName,
arguments: QuillScreenArgs(
document: Document.fromJson(quillDefaultSample),
),
),
),
const SizedBox(height: 4),
HomeScreenExampleItem(
title: 'Images',
icon: const Icon(
@ -58,10 +79,12 @@ class HomePage extends StatelessWidget {
),
text: 'If you want to see how the editor work with images, '
'see any samples or you are working on it',
onPressed: () {
Navigator.of(context)
.pushNamed(QuillImagesScreen.routeName);
},
onPressed: () => Navigator.of(context).pushNamed(
QuillScreen.routeName,
arguments: QuillScreenArgs(
document: Document.fromJson(quillImagesSample),
),
),
),
const SizedBox(height: 4),
HomeScreenExampleItem(
@ -82,7 +105,12 @@ class HomePage extends StatelessWidget {
),
text: 'If you want to see how the editor work with text, '
'see any samples or you are working on it',
onPressed: () {},
onPressed: () => Navigator.of(context).pushNamed(
QuillScreen.routeName,
arguments: QuillScreenArgs(
document: Document.fromJson(quillTextSample),
),
),
),
HomeScreenExampleItem(
title: 'Empty',
@ -91,17 +119,12 @@ class HomePage extends StatelessWidget {
size: 50,
),
text: 'Want start clean? be my guest',
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) {
return QuillScreen(
document: Document(),
);
},
),
);
},
onPressed: () => Navigator.of(context).pushNamed(
QuillScreen.routeName,
arguments: QuillScreenArgs(
document: Document(),
),
),
),
],
),

@ -2,15 +2,27 @@ import 'package:flutter/material.dart';
import 'package:flutter_quill/flutter_quill.dart';
import 'package:flutter_quill_extensions/flutter_quill_extensions.dart';
import 'package:quill_html_converter/quill_html_converter.dart';
import 'package:share_plus/share_plus.dart' show Share;
import '../shared/widgets/home_screen_button.dart';
@immutable
class QuillScreenArgs {
const QuillScreenArgs({required this.document});
final Document document;
}
class QuillScreen extends StatefulWidget {
const QuillScreen({
required this.document,
required this.args,
super.key,
});
final Document document;
final QuillScreenArgs args;
static const routeName = '/quill';
@override
State<QuillScreen> createState() => _QuillScreenState();
@ -18,12 +30,12 @@ class QuillScreen extends StatefulWidget {
class _QuillScreenState extends State<QuillScreen> {
final _controller = QuillController.basic();
final _isReadOnly = false;
var _isReadOnly = false;
@override
void initState() {
super.initState();
_controller.document = widget.document;
_controller.document = widget.args.document;
}
@override
@ -33,6 +45,16 @@ class _QuillScreenState extends State<QuillScreen> {
title: const Text('Flutter Quill'),
actions: [
IconButton(
tooltip: 'Load with HTML',
onPressed: () {
final html = _controller.document.toDelta().toHtml();
_controller.document =
Document.fromDelta(DeltaHtmlExt.fromHtml(html));
},
icon: const Icon(Icons.html),
),
IconButton(
tooltip: 'Share',
onPressed: () {
final plainText = _controller.document.toPlainText(
FlutterQuillEmbeds.defaultEditorBuilders(),
@ -51,6 +73,7 @@ class _QuillScreenState extends State<QuillScreen> {
},
icon: const Icon(Icons.share),
),
const HomeScreenButton(),
],
),
body: QuillProvider(
@ -68,11 +91,12 @@ class _QuillScreenState extends State<QuillScreen> {
),
child: Column(
children: [
QuillToolbar(
configurations: QuillToolbarConfigurations(
embedButtons: FlutterQuillEmbeds.toolbarButtons(),
if (!_isReadOnly)
QuillToolbar(
configurations: QuillToolbarConfigurations(
embedButtons: FlutterQuillEmbeds.toolbarButtons(),
),
),
),
Expanded(
child: QuillEditor.basic(
configurations: QuillEditorConfigurations(
@ -87,6 +111,14 @@ class _QuillScreenState extends State<QuillScreen> {
],
),
),
floatingActionButton: FloatingActionButton(
child: Icon(_isReadOnly ? Icons.lock : Icons.edit),
onPressed: () {
setState(() {
_isReadOnly = !_isReadOnly;
});
},
),
);
}
}

@ -0,0 +1,295 @@
import '../../../gen/assets.gen.dart';
final quillDefaultSample = [
{
'insert': {'image': Assets.images.screenshot1.path},
'attributes': {
'width': '100',
'height': '100',
'style': 'width:500px; height:350px;'
}
},
{'insert': 'Flutter Quill'},
{
'attributes': {'header': 1},
'insert': '\n'
},
{
'insert': {
'video':
'https://www.youtube.com/watch?v=V4hgdKhIqtc&list=PLbhaS_83B97s78HsDTtplRTEhcFsqSqIK&index=1'
}
},
{
'insert': {
'video':
'https://user-images.githubusercontent.com/122956/126238875-22e42501-ad41-4266-b1d6-3f89b5e3b79b.mp4'
}
},
{'insert': '\nRich text editor for Flutter'},
{
'attributes': {'header': 2},
'insert': '\n'
},
{'insert': 'Quill component for Flutter'},
{
'attributes': {'header': 3},
'insert': '\n'
},
{
'attributes': {'link': 'https://bulletjournal.us/home/index.html'},
'insert': 'Bullet Journal'
},
{
'insert':
':\nTrack personal and group journals (ToDo, Note, Ledger) from multiple views with timely reminders'
},
{
'attributes': {'list': 'ordered'},
'insert': '\n'
},
{
'insert':
'Share your tasks and notes with teammates, and see changes as they happen in real-time, across all devices'
},
{
'attributes': {'list': 'ordered'},
'insert': '\n'
},
{'insert': 'Check out what you and your teammates are working on each day'},
{
'attributes': {'list': 'ordered'},
'insert': '\n'
},
{'insert': '\nSplitting bills with friends can never be easier.'},
{
'attributes': {'list': 'bullet'},
'insert': '\n'
},
{'insert': 'Start creating a group and invite your friends to join.'},
{
'attributes': {'list': 'bullet'},
'insert': '\n'
},
{'insert': 'Create a BuJo of Ledger type to see expense or balance summary.'},
{
'attributes': {'list': 'bullet'},
'insert': '\n'
},
{
'insert':
'\nAttach one or multiple labels to tasks, notes or transactions. Later you can track them just using the label(s).'
},
{
'attributes': {'blockquote': true},
'insert': '\n'
},
{'insert': "\nvar BuJo = 'Bullet' + 'Journal'"},
{
'attributes': {'code-block': true},
'insert': '\n'
},
{'insert': '\nStart tracking in your browser'},
{
'attributes': {'indent': 1},
'insert': '\n'
},
{'insert': 'Stop the timer on your phone'},
{
'attributes': {'indent': 1},
'insert': '\n'
},
{'insert': 'All your time entries are synced'},
{
'attributes': {'indent': 2},
'insert': '\n'
},
{'insert': 'between the phone apps'},
{
'attributes': {'indent': 2},
'insert': '\n'
},
{'insert': 'and the website.'},
{
'attributes': {'indent': 3},
'insert': '\n'
},
{'insert': '\n'},
{'insert': '\nCenter Align'},
{
'attributes': {'align': 'center'},
'insert': '\n'
},
{'insert': 'Right Align'},
{
'attributes': {'align': 'right'},
'insert': '\n'
},
{'insert': 'Justify Align'},
{
'attributes': {'align': 'justify'},
'insert': '\n'
},
{'insert': 'Have trouble finding things? '},
{
'attributes': {'list': 'ordered'},
'insert': '\n'
},
{'insert': 'Just type in the search bar'},
{
'attributes': {'indent': 1, 'list': 'ordered'},
'insert': '\n'
},
{'insert': 'and easily find contents'},
{
'attributes': {'indent': 2, 'list': 'ordered'},
'insert': '\n'
},
{'insert': 'across projects or folders.'},
{
'attributes': {'indent': 2, 'list': 'ordered'},
'insert': '\n'
},
{'insert': 'It matches text in your note or task.'},
{
'attributes': {'indent': 1, 'list': 'ordered'},
'insert': '\n'
},
{'insert': 'Enable reminders so that you will get notified by'},
{
'attributes': {'list': 'ordered'},
'insert': '\n'
},
{'insert': 'email'},
{
'attributes': {'indent': 1, 'list': 'ordered'},
'insert': '\n'
},
{'insert': 'message on your phone'},
{
'attributes': {'indent': 1, 'list': 'ordered'},
'insert': '\n'
},
{'insert': 'popup on the web site'},
{
'attributes': {'indent': 1, 'list': 'ordered'},
'insert': '\n'
},
{'insert': 'Create a BuJo serving as project or folder'},
{
'attributes': {'list': 'bullet'},
'insert': '\n'
},
{'insert': 'Organize your'},
{
'attributes': {'indent': 1, 'list': 'bullet'},
'insert': '\n'
},
{'insert': 'tasks'},
{
'attributes': {'indent': 2, 'list': 'bullet'},
'insert': '\n'
},
{'insert': 'notes'},
{
'attributes': {'indent': 2, 'list': 'bullet'},
'insert': '\n'
},
{'insert': 'transactions'},
{
'attributes': {'indent': 2, 'list': 'bullet'},
'insert': '\n'
},
{'insert': 'under BuJo '},
{
'attributes': {'indent': 3, 'list': 'bullet'},
'insert': '\n'
},
{'insert': 'See them in Calendar'},
{
'attributes': {'list': 'bullet'},
'insert': '\n'
},
{'insert': 'or hierarchical view'},
{
'attributes': {'indent': 1, 'list': 'bullet'},
'insert': '\n'
},
{'insert': 'this is a check list'},
{
'attributes': {'list': 'checked'},
'insert': '\n'
},
{'insert': 'this is a uncheck list'},
{
'attributes': {'list': 'unchecked'},
'insert': '\n'
},
{'insert': 'Font '},
{
'attributes': {'font': 'sans-serif'},
'insert': 'Sans Serif'
},
{'insert': ' '},
{
'attributes': {'font': 'serif'},
'insert': 'Serif'
},
{'insert': ' '},
{
'attributes': {'font': 'monospace'},
'insert': 'Monospace'
},
{'insert': ' Size '},
{
'attributes': {'size': 'small'},
'insert': 'Small'
},
{'insert': ' '},
{
'attributes': {'size': 'large'},
'insert': 'Large'
},
{'insert': ' '},
{
'attributes': {'size': 'huge'},
'insert': 'Huge'
},
{
'attributes': {'size': '15.0'},
'insert': 'font size 15'
},
{'insert': ' '},
{
'attributes': {'size': '35'},
'insert': 'font size 35'
},
{'insert': ' '},
{
'attributes': {'size': '20'},
'insert': 'font size 20'
},
{
'attributes': {'token': 'built_in'},
'insert': ' diff'
},
{
'attributes': {'token': 'operator'},
'insert': '-match'
},
{
'attributes': {'token': 'literal'},
'insert': '-patch'
},
{
'insert': {
'image':
'https://user-images.githubusercontent.com/122956/72955931-ccc07900-3d52-11ea-89b1-d468a6e2aa2b.png'
},
'attributes': {
'width': '230',
'style': 'display: block; margin: auto; width: 500px;'
}
},
{'insert': '\n'}
];

@ -1,23 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_quill/flutter_quill.dart' show Document;
import '../../../gen/assets.gen.dart';
import '../../gen/assets.gen.dart';
import 'quill_screen.dart';
class QuillImagesScreen extends StatelessWidget {
const QuillImagesScreen({super.key});
static const routeName = '/images';
@override
Widget build(BuildContext context) {
return QuillScreen(
document: Document.fromJson(_sample),
);
}
}
final _sample = [
final quillImagesSample = [
{'insert': 'This is an asset image: \n'},
{'insert': '\n'},
{

@ -0,0 +1,270 @@
const quillTextSample = [
{'insert': 'Flutter Quill'},
{
'attributes': {'header': 1},
'insert': '\n'
},
{'insert': '\nRich text editor for Flutter'},
{
'attributes': {'header': 2},
'insert': '\n'
},
{'insert': 'Quill component for Flutter'},
{
'attributes': {'color': 'rgba(0, 0, 0, 0.847)'},
'insert': ' and '
},
{
'attributes': {'link': 'https://bulletjournal.us/home/index.html'},
'insert': 'Bullet Journal'
},
{
'insert':
':\nTrack personal and group journals (ToDo, Note, Ledger) from multiple views with timely reminders'
},
{
'attributes': {'list': 'ordered'},
'insert': '\n'
},
{
'insert':
'Share your tasks and notes with teammates, and see changes as they happen in real-time, across all devices'
},
{
'attributes': {'list': 'ordered'},
'insert': '\n'
},
{'insert': 'Check out what you and your teammates are working on each day'},
{
'attributes': {'list': 'ordered'},
'insert': '\n'
},
{'insert': '\nSplitting bills with friends can never be easier.'},
{
'attributes': {'list': 'bullet'},
'insert': '\n'
},
{'insert': 'Start creating a group and invite your friends to join.'},
{
'attributes': {'list': 'bullet'},
'insert': '\n'
},
{'insert': 'Create a BuJo of Ledger type to see expense or balance summary.'},
{
'attributes': {'list': 'bullet'},
'insert': '\n'
},
{
'insert':
'\nAttach one or multiple labels to tasks, notes or transactions. Later you can track them just using the label(s).'
},
{
'attributes': {'blockquote': true},
'insert': '\n'
},
{'insert': "\nvar BuJo = 'Bullet' + 'Journal'"},
{
'attributes': {'code-block': true},
'insert': '\n'
},
{'insert': '\nStart tracking in your browser'},
{
'attributes': {'indent': 1},
'insert': '\n'
},
{'insert': 'Stop the timer on your phone'},
{
'attributes': {'indent': 1},
'insert': '\n'
},
{'insert': 'All your time entries are synced'},
{
'attributes': {'indent': 2},
'insert': '\n'
},
{'insert': 'between the phone apps'},
{
'attributes': {'indent': 2},
'insert': '\n'
},
{'insert': 'and the website.'},
{
'attributes': {'indent': 3},
'insert': '\n'
},
{'insert': '\n'},
{'insert': '\nCenter Align'},
{
'attributes': {'align': 'center'},
'insert': '\n'
},
{'insert': 'Right Align'},
{
'attributes': {'align': 'right'},
'insert': '\n'
},
{'insert': 'Justify Align'},
{
'attributes': {'align': 'justify'},
'insert': '\n'
},
{'insert': 'Have trouble finding things? '},
{
'attributes': {'list': 'ordered'},
'insert': '\n'
},
{'insert': 'Just type in the search bar'},
{
'attributes': {'indent': 1, 'list': 'ordered'},
'insert': '\n'
},
{'insert': 'and easily find contents'},
{
'attributes': {'indent': 2, 'list': 'ordered'},
'insert': '\n'
},
{'insert': 'across projects or folders.'},
{
'attributes': {'indent': 2, 'list': 'ordered'},
'insert': '\n'
},
{'insert': 'It matches text in your note or task.'},
{
'attributes': {'indent': 1, 'list': 'ordered'},
'insert': '\n'
},
{'insert': 'Enable reminders so that you will get notified by'},
{
'attributes': {'list': 'ordered'},
'insert': '\n'
},
{'insert': 'email'},
{
'attributes': {'indent': 1, 'list': 'ordered'},
'insert': '\n'
},
{'insert': 'message on your phone'},
{
'attributes': {'indent': 1, 'list': 'ordered'},
'insert': '\n'
},
{'insert': 'popup on the web site'},
{
'attributes': {'indent': 1, 'list': 'ordered'},
'insert': '\n'
},
{'insert': 'Create a BuJo serving as project or folder'},
{
'attributes': {'list': 'bullet'},
'insert': '\n'
},
{'insert': 'Organize your'},
{
'attributes': {'indent': 1, 'list': 'bullet'},
'insert': '\n'
},
{'insert': 'tasks'},
{
'attributes': {'indent': 2, 'list': 'bullet'},
'insert': '\n'
},
{'insert': 'notes'},
{
'attributes': {'indent': 2, 'list': 'bullet'},
'insert': '\n'
},
{'insert': 'transactions'},
{
'attributes': {'indent': 2, 'list': 'bullet'},
'insert': '\n'
},
{'insert': 'under BuJo '},
{
'attributes': {'indent': 3, 'list': 'bullet'},
'insert': '\n'
},
{'insert': 'See them in Calendar'},
{
'attributes': {'list': 'bullet'},
'insert': '\n'
},
{'insert': 'or hierarchical view'},
{
'attributes': {'indent': 1, 'list': 'bullet'},
'insert': '\n'
},
{'insert': 'this is a check list'},
{
'attributes': {'list': 'checked'},
'insert': '\n'
},
{'insert': 'this is a uncheck list'},
{
'attributes': {'list': 'unchecked'},
'insert': '\n'
},
{'insert': 'Font '},
{
'attributes': {'font': 'sans-serif'},
'insert': 'Sans Serif'
},
{'insert': ' '},
{
'attributes': {'font': 'serif'},
'insert': 'Serif'
},
{'insert': ' '},
{
'attributes': {'font': 'monospace'},
'insert': 'Monospace'
},
{'insert': ' Size '},
{
'attributes': {'size': 'small'},
'insert': 'Small'
},
{'insert': ' '},
{
'attributes': {'size': 'large'},
'insert': 'Large'
},
{'insert': ' '},
{
'attributes': {'size': 'huge'},
'insert': 'Huge'
},
{
'attributes': {'size': '15.0'},
'insert': 'font size 15'
},
{'insert': ' '},
{
'attributes': {'size': '35'},
'insert': 'font size 35'
},
{'insert': ' '},
{
'attributes': {'size': '20'},
'insert': 'font size 20'
},
{
'attributes': {'token': 'built_in'},
'insert': ' diff'
},
{
'attributes': {'token': 'operator'},
'insert': '-match'
},
{
'attributes': {'token': 'literal'},
'insert': '-patch'
},
{
'insert': {
'image':
'https://user-images.githubusercontent.com/122956/72955931-ccc07900-3d52-11ea-89b1-d468a6e2aa2b.png'
},
'attributes': {'width': '230', 'style': 'display: block; margin: auto;'}
},
{'insert': '\n'}
];

@ -30,7 +30,9 @@ const _$ThemeModeEnumMap = {
const _$DefaultScreenEnumMap = {
DefaultScreen.home: 'home',
DefaultScreen.settings: 'settings',
DefaultScreen.images: 'images',
DefaultScreen.videos: 'videos',
DefaultScreen.text: 'text',
DefaultScreen.defaultSample: 'defaultSample',
DefaultScreen.imagesSample: 'imagesSample',
DefaultScreen.videosSample: 'videosSample',
DefaultScreen.textSample: 'textSample',
DefaultScreen.emptySample: 'emptySample',
};

@ -3,9 +3,11 @@ part of 'settings_cubit.dart';
enum DefaultScreen {
home,
settings,
images,
videos,
text,
defaultSample,
imagesSample,
videosSample,
textSample,
emptySample,
}
@freezed

@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_quill/translations.dart';
import '../../shared/widgets/dialog_action.dart';
import '../../shared/widgets/home_screen_button.dart';

@ -1,30 +1 @@
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility in the flutter_test package. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:example/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
void main() {}

Loading…
Cancel
Save