Skip to content

Commit 0c2baa4

Browse files
authored
Merge pull request #47 from mhmzdev/example-dir-updated
Example dir updated to run within project (VSCode)
2 parents a1d6c56 + 5700a4b commit 0c2baa4

16 files changed

Lines changed: 374 additions & 5 deletions

.vscode/launch.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "awesome_snackbar_content_example",
6+
"request": "launch",
7+
"type": "dart",
8+
"program": "example/lib/main.dart",
9+
"args": [
10+
"--web-port",
11+
"8000",
12+
],
13+
"deviceId": "chrome"
14+
}
15+
]
16+
}

example/.gitignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.build/
9+
.buildlog/
10+
.history
11+
.svn/
12+
.swiftpm/
13+
migrate_working_dir/
14+
15+
# IntelliJ related
16+
*.iml
17+
*.ipr
18+
*.iws
19+
.idea/
20+
21+
# The .vscode folder contains launch configuration and tasks you configure in
22+
# VS Code which you may wish to be included in version control, so this line
23+
# is commented out by default.
24+
#.vscode/
25+
26+
# Flutter/Dart/Pub related
27+
**/doc/api/
28+
**/ios/Flutter/.last_build_id
29+
.dart_tool/
30+
.flutter-plugins
31+
.flutter-plugins-dependencies
32+
.pub-cache/
33+
.pub/
34+
/build/
35+
36+
# Symbolication related
37+
app.*.symbols
38+
39+
# Obfuscation related
40+
app.*.map.json
41+
42+
# Android Studio will place build artifacts here
43+
/android/app/debug
44+
/android/app/profile
45+
/android/app/release

example/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# example
2+
3+
A new Flutter project.
4+
5+
## Getting Started
6+
7+
This project is a starting point for a Flutter application.
8+
9+
A few resources to get you started if this is your first Flutter project:
10+
11+
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
12+
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
13+
14+
For help getting started with Flutter development, view the
15+
[online documentation](https://docs.flutter.dev/), which offers tutorials,
16+
samples, guidance on mobile development, and a full API reference.

example/analysis_options.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This file configures the analyzer, which statically analyzes Dart code to
2+
# check for errors, warnings, and lints.
3+
#
4+
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5+
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6+
# invoked from the command line by running `flutter analyze`.
7+
8+
# The following line activates a set of recommended lints for Flutter apps,
9+
# packages, and plugins designed to encourage good coding practices.
10+
include: package:flutter_lints/flutter.yaml
11+
12+
linter:
13+
# The lint rules applied to this project can be customized in the
14+
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15+
# included above or to enable additional rules. A list of all available lints
16+
# and their documentation is published at https://dart.dev/lints.
17+
#
18+
# Instead of disabling a lint rule for the entire project in the
19+
# section below, it can also be suppressed for a single line of code
20+
# or a specific dart file by using the `// ignore: name_of_lint` and
21+
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
22+
# producing the lint.
23+
rules:
24+
# avoid_print: false # Uncomment to disable the `avoid_print` rule
25+
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
26+
27+
# Additional information about this file can be found at
28+
# https://dart.dev/guides/language/analysis-options
Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
11
import 'package:flutter/material.dart';
22
import 'package:awesome_snackbar_content/awesome_snackbar_content.dart';
33

4+
void main() {
5+
runApp(const MyApp());
6+
}
7+
8+
class MyApp extends StatelessWidget {
9+
const MyApp({super.key});
10+
11+
// This widget is the root of your application.
12+
@override
13+
Widget build(BuildContext context) {
14+
return MaterialApp(
15+
title: 'Awesome SnackBar Example',
16+
theme: ThemeData(
17+
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
18+
useMaterial3: true,
19+
),
20+
home: const AweseomSnackBarExample(),
21+
);
22+
}
23+
}
24+
425
class AweseomSnackBarExample extends StatelessWidget {
5-
const AweseomSnackBarExample({Key? key}) : super(key: key);
26+
const AweseomSnackBarExample({super.key});
627

728
@override
829
Widget build(BuildContext context) {

example/pubspec.yaml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: example
2+
description: "A new Flutter project."
3+
# The following line prevents the package from being accidentally published to
4+
# pub.dev using `flutter pub publish`. This is preferred for private packages.
5+
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
6+
7+
# The following defines the version and build number for your application.
8+
# A version number is three numbers separated by dots, like 1.2.43
9+
# followed by an optional build number separated by a +.
10+
# Both the version and the builder number may be overridden in flutter
11+
# build by specifying --build-name and --build-number, respectively.
12+
# In Android, build-name is used as versionName while build-number used as versionCode.
13+
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
14+
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
15+
# Read more about iOS versioning at
16+
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
17+
# In Windows, build-name is used as the major, minor, and patch parts
18+
# of the product and file versions while build-number is used as the build suffix.
19+
version: 1.0.0+1
20+
21+
environment:
22+
sdk: '>=3.2.3 <4.0.0'
23+
24+
# Dependencies specify other packages that your package needs in order to work.
25+
# To automatically upgrade your package dependencies to the latest versions
26+
# consider running `flutter pub upgrade --major-versions`. Alternatively,
27+
# dependencies can be manually updated by changing the version numbers below to
28+
# the latest version available on pub.dev. To see which dependencies have newer
29+
# versions available, run `flutter pub outdated`.
30+
dependencies:
31+
flutter:
32+
sdk: flutter
33+
awesome_snackbar_content:
34+
path: ../
35+
36+
# The following adds the Cupertino Icons font to your application.
37+
# Use with the CupertinoIcons class for iOS style icons.
38+
cupertino_icons: ^1.0.2
39+
40+
dev_dependencies:
41+
flutter_test:
42+
sdk: flutter
43+
44+
# The "flutter_lints" package below contains a set of recommended lints to
45+
# encourage good coding practices. The lint set provided by the package is
46+
# activated in the `analysis_options.yaml` file located at the root of your
47+
# package. See that file for information about deactivating specific lint
48+
# rules and activating additional ones.
49+
flutter_lints: ^2.0.0
50+
51+
# For information on the generic Dart part of this file, see the
52+
# following page: https://dart.dev/tools/pub/pubspec
53+
54+
# The following section is specific to Flutter packages.
55+
flutter:
56+
57+
# The following line ensures that the Material Icons font is
58+
# included with your application, so that you can use the icons in
59+
# the material Icons class.
60+
uses-material-design: true
61+
62+
# To add assets to your application, add an assets section, like this:
63+
# assets:
64+
# - images/a_dot_burr.jpeg
65+
# - images/a_dot_ham.jpeg
66+
67+
# An image asset can refer to one or more resolution-specific "variants", see
68+
# https://flutter.dev/to/resolution-aware-images
69+
70+
# For details regarding adding assets from package dependencies, see
71+
# https://flutter.dev/to/asset-from-package
72+
73+
# To add custom fonts to your application, add a fonts section here,
74+
# in this "flutter" section. Each entry in this list should have a
75+
# "family" key with the font family name, and a "fonts" key with a
76+
# list giving the asset and other descriptors for the font. For
77+
# example:
78+
# fonts:
79+
# - family: Schyler
80+
# fonts:
81+
# - asset: fonts/Schyler-Regular.ttf
82+
# - asset: fonts/Schyler-Italic.ttf
83+
# style: italic
84+
# - family: Trajan Pro
85+
# fonts:
86+
# - asset: fonts/TrajanPro.ttf
87+
# - asset: fonts/TrajanPro_Bold.ttf
88+
# weight: 700
89+
#
90+
# For details regarding fonts from package dependencies,
91+
# see https://flutter.dev/to/font-from-package

example/test/widget_test.dart

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_test/flutter_test.dart';
3+
import 'package:awesome_snackbar_content/awesome_snackbar_content.dart';
4+
import 'package:example/main.dart';
5+
6+
void main() {
7+
group('AwesomeSnackBar Example Tests', () {
8+
testWidgets('App should render with two buttons',
9+
(WidgetTester tester) async {
10+
await tester.pumpWidget(const MyApp());
11+
12+
// Verify that both buttons are present
13+
expect(find.text('Show Awesome SnackBar'), findsOneWidget);
14+
expect(find.text('Show Awesome Material Banner'), findsOneWidget);
15+
});
16+
17+
testWidgets('Tapping SnackBar button shows snackbar with correct content',
18+
(WidgetTester tester) async {
19+
await tester.pumpWidget(const MyApp());
20+
21+
// Tap the snackbar button
22+
await tester.tap(find.text('Show Awesome SnackBar'));
23+
await tester.pump(); // Start the animation
24+
await tester
25+
.pump(const Duration(seconds: 1)); // Pump until animation ends
26+
27+
// Verify snackbar content
28+
expect(find.byType(SnackBar), findsOneWidget);
29+
expect(find.byType(AwesomeSnackbarContent), findsOneWidget);
30+
expect(find.text('On Snap!'), findsOneWidget);
31+
expect(
32+
find.text(
33+
'This is an example error message that will be shown in the body of snackbar!'),
34+
findsOneWidget);
35+
36+
// Verify snackbar properties
37+
final SnackBar snackBar = tester.widget(find.byType(SnackBar));
38+
expect(snackBar.elevation, 0);
39+
expect(snackBar.behavior, SnackBarBehavior.floating);
40+
expect(snackBar.backgroundColor, Colors.transparent);
41+
42+
// Verify AwesomeSnackbarContent properties
43+
final AwesomeSnackbarContent content =
44+
tester.widget(find.byType(AwesomeSnackbarContent));
45+
expect(content.contentType, ContentType.failure);
46+
});
47+
48+
testWidgets(
49+
'Tapping Material Banner button shows banner with correct content',
50+
(WidgetTester tester) async {
51+
await tester.pumpWidget(const MyApp());
52+
53+
// Tap the material banner button
54+
await tester.tap(find.text('Show Awesome Material Banner'));
55+
await tester.pump(); // Start the animation
56+
await tester
57+
.pump(const Duration(seconds: 1)); // Pump until animation ends
58+
59+
// Verify material banner content
60+
expect(find.byType(MaterialBanner), findsOneWidget);
61+
expect(find.byType(AwesomeSnackbarContent), findsOneWidget);
62+
expect(find.text('Oh Hey!!'), findsOneWidget);
63+
expect(
64+
find.text(
65+
'This is an example error message that will be shown in the body of materialBanner!'),
66+
findsOneWidget);
67+
68+
// Verify material banner properties
69+
final MaterialBanner banner = tester.widget(find.byType(MaterialBanner));
70+
expect(banner.elevation, 0);
71+
expect(banner.backgroundColor, Colors.transparent);
72+
expect(banner.forceActionsBelow, true);
73+
74+
// Verify AwesomeSnackbarContent properties
75+
final AwesomeSnackbarContent content =
76+
tester.widget(find.byType(AwesomeSnackbarContent));
77+
expect(content.contentType, ContentType.success);
78+
expect(content.inMaterialBanner, true);
79+
});
80+
});
81+
}

example/web/favicon.png

917 Bytes
Loading

example/web/icons/Icon-192.png

5.17 KB
Loading

example/web/icons/Icon-512.png

8.06 KB
Loading

0 commit comments

Comments
 (0)