From eb8368b1ee7438dbfb59e38ce19f984d7f469e84 Mon Sep 17 00:00:00 2001 From: DahoudG Date: Mon, 26 Aug 2024 22:45:58 +0000 Subject: [PATCH] Application propre sans erreurs. Bonne base sur laquelle repartir de zero en cas de soucis majeurs. --- README.md | 16 +-- config/router.dart | 0 devtools_options.yaml | 3 + lib/config/injection/injection.dart | 22 ++++ lib/config/router.dart | 18 +++ lib/core/constants/urls.dart | 6 + lib/core/errors/exceptions.dart | 3 + lib/core/errors/failures.dart | 9 ++ lib/core/theme/app_theme.dart | 20 +++ lib/core/utils/input_converter.dart | 16 +++ .../datasources/user_remote_data_source.dart | 22 ++++ .../datasources/user_repository_impl.dart | 14 ++ lib/data/models/user_model.dart | 26 ++++ lib/domain/entities/user.dart | 12 ++ lib/domain/repositories/user_repository.dart | 5 + lib/domain/usecases/get_user.dart | 19 +++ lib/main.dart | 122 ++---------------- .../screens/event/event_screen.dart | 18 +++ .../screens/home/home_screen.dart | 17 +++ .../state_management/user_bloc.dart | 43 ++++++ lib/presentation/widgets/custom_button.dart | 17 +++ pubspec.lock | 80 ++++++++++++ pubspec.yaml | 60 +++------ test/widget_test.dart | 30 ----- 24 files changed, 397 insertions(+), 201 deletions(-) create mode 100644 config/router.dart create mode 100644 devtools_options.yaml create mode 100644 lib/config/injection/injection.dart create mode 100644 lib/config/router.dart create mode 100644 lib/core/constants/urls.dart create mode 100644 lib/core/errors/exceptions.dart create mode 100644 lib/core/errors/failures.dart create mode 100644 lib/core/theme/app_theme.dart create mode 100644 lib/core/utils/input_converter.dart create mode 100644 lib/data/datasources/user_remote_data_source.dart create mode 100644 lib/data/datasources/user_repository_impl.dart create mode 100644 lib/data/models/user_model.dart create mode 100644 lib/domain/entities/user.dart create mode 100644 lib/domain/repositories/user_repository.dart create mode 100644 lib/domain/usecases/get_user.dart create mode 100644 lib/presentation/screens/event/event_screen.dart create mode 100644 lib/presentation/screens/home/home_screen.dart create mode 100644 lib/presentation/state_management/user_bloc.dart create mode 100644 lib/presentation/widgets/custom_button.dart diff --git a/README.md b/README.md index bb9eabf..5f97a74 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,4 @@ -# afterwork +# AfterWork Project -A new Flutter project. -## Getting Started - -This project is a starting point for a Flutter application. - -A few resources to get you started if this is your first Flutter project: - -- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) -- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) - -For help getting started with Flutter development, view the -[online documentation](https://docs.flutter.dev/), which offers tutorials, -samples, guidance on mobile development, and a full API reference. +This project is structured according to best practices in Flutter development. diff --git a/config/router.dart b/config/router.dart new file mode 100644 index 0000000..e69de29 diff --git a/devtools_options.yaml b/devtools_options.yaml new file mode 100644 index 0000000..fa0b357 --- /dev/null +++ b/devtools_options.yaml @@ -0,0 +1,3 @@ +description: This file stores settings for Dart & Flutter DevTools. +documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states +extensions: diff --git a/lib/config/injection/injection.dart b/lib/config/injection/injection.dart new file mode 100644 index 0000000..271bc79 --- /dev/null +++ b/lib/config/injection/injection.dart @@ -0,0 +1,22 @@ +import 'package:get_it/get_it.dart'; +import 'package:http/http.dart' as http; + +import '../../data/datasources/user_remote_data_source.dart'; +import '../../data/datasources/user_repository_impl.dart'; +import '../../domain/usecases/get_user.dart'; + +final sl = GetIt.instance; + +void init() { + // Register Http Client + sl.registerLazySingleton(() => http.Client()); + + // Register Data Sources + sl.registerLazySingleton(() => UserRemoteDataSource(sl())); + + // Register Repositories + sl.registerLazySingleton(() => UserRepositoryImpl(remoteDataSource: sl())); + + // Register Use Cases + sl.registerLazySingleton(() => GetUser(sl())); +} diff --git a/lib/config/router.dart b/lib/config/router.dart new file mode 100644 index 0000000..e7eecde --- /dev/null +++ b/lib/config/router.dart @@ -0,0 +1,18 @@ +import 'package:flutter/material.dart'; +import 'package:afterwork/presentation/screens/home/home_screen.dart'; + +class AppRouter { + static Route generateRoute(RouteSettings settings) { + switch (settings.name) { + case '/': + return MaterialPageRoute(builder: (_) => const HomeScreen()); + // Ajoute d'autres routes ici + default: + return MaterialPageRoute( + builder: (_) => const Scaffold( + body: Center(child: Text('Page not found')), + ), + ); + } + } +} diff --git a/lib/core/constants/urls.dart b/lib/core/constants/urls.dart new file mode 100644 index 0000000..601083b --- /dev/null +++ b/lib/core/constants/urls.dart @@ -0,0 +1,6 @@ +class Urls { + static const String baseUrl = 'http://localhost:8085'; + // static const String login = baseUrl + 'auth/login'; + // static const String events = baseUrl + 'events'; +// Ajoute d'autres URLs ici +} diff --git a/lib/core/errors/exceptions.dart b/lib/core/errors/exceptions.dart new file mode 100644 index 0000000..451f647 --- /dev/null +++ b/lib/core/errors/exceptions.dart @@ -0,0 +1,3 @@ +class ServerException implements Exception {} + +class CacheException implements Exception {} diff --git a/lib/core/errors/failures.dart b/lib/core/errors/failures.dart new file mode 100644 index 0000000..80edf12 --- /dev/null +++ b/lib/core/errors/failures.dart @@ -0,0 +1,9 @@ +import 'package:equatable/equatable.dart'; + +abstract class Failure extends Equatable { + @override + List get props => []; +} + +class ServerFailure extends Failure {} +class CacheFailure extends Failure {} diff --git a/lib/core/theme/app_theme.dart b/lib/core/theme/app_theme.dart new file mode 100644 index 0000000..6a9666f --- /dev/null +++ b/lib/core/theme/app_theme.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; + +class AppTheme { + static final ThemeData lightTheme = ThemeData( + primaryColor: Colors.blue, + colorScheme: const ColorScheme.light( + secondary: Colors.orange, + ), + brightness: Brightness.light, + buttonTheme: const ButtonThemeData(buttonColor: Colors.blue), + ); + + static final ThemeData darkTheme = ThemeData( + primaryColor: Colors.black, + colorScheme: const ColorScheme.dark( + secondary: Colors.red, + ), + brightness: Brightness.dark, + ); +} diff --git a/lib/core/utils/input_converter.dart b/lib/core/utils/input_converter.dart new file mode 100644 index 0000000..1a4a72a --- /dev/null +++ b/lib/core/utils/input_converter.dart @@ -0,0 +1,16 @@ +import 'package:dartz/dartz.dart'; +import 'package:afterwork/core/errors/failures.dart'; + +class InputConverter { + Either stringToUnsignedInteger(String str) { + try { + final integer = int.parse(str); + if (integer < 0) throw const FormatException(); + return Right(integer); + } catch (e) { + return Left(InvalidInputFailure()); + } + } +} + +class InvalidInputFailure extends Failure {} diff --git a/lib/data/datasources/user_remote_data_source.dart b/lib/data/datasources/user_remote_data_source.dart new file mode 100644 index 0000000..62f3464 --- /dev/null +++ b/lib/data/datasources/user_remote_data_source.dart @@ -0,0 +1,22 @@ +import 'dart:convert'; +import 'package:afterwork/data/models/user_model.dart'; +import 'package:afterwork/core/constants/urls.dart'; +import 'package:http/http.dart' as http; + +import '../../core/errors/exceptions.dart'; + +class UserRemoteDataSource { + final http.Client client; + + UserRemoteDataSource(this.client); + + Future getUser(String id) async { + final response = await client.get(Uri.parse('${Urls.baseUrl}/user/$id')); + + if (response.statusCode == 200) { + return UserModel.fromJson(json.decode(response.body)); + } else { + throw ServerException(); + } + } +} diff --git a/lib/data/datasources/user_repository_impl.dart b/lib/data/datasources/user_repository_impl.dart new file mode 100644 index 0000000..164698b --- /dev/null +++ b/lib/data/datasources/user_repository_impl.dart @@ -0,0 +1,14 @@ +import 'package:afterwork/domain/entities/user.dart'; +import 'package:afterwork/domain/repositories/user_repository.dart'; +import 'package:afterwork/data/datasources/user_remote_data_source.dart'; + +class UserRepositoryImpl implements UserRepository { + final UserRemoteDataSource remoteDataSource; + + UserRepositoryImpl({required this.remoteDataSource}); + + @override + Future getUser(String id) async { + return await remoteDataSource.getUser(id); + } +} diff --git a/lib/data/models/user_model.dart b/lib/data/models/user_model.dart new file mode 100644 index 0000000..2fd509e --- /dev/null +++ b/lib/data/models/user_model.dart @@ -0,0 +1,26 @@ + +import '../../domain/entities/user.dart'; + +class UserModel extends User { + const UserModel({ + required super.id, + required super.name, + required super.email, + }); + + factory UserModel.fromJson(Map json) { + return UserModel( + id: json['id'], + name: json['name'], + email: json['email'], + ); + } + + Map toJson() { + return { + 'id': id, + 'name': name, + 'email': email, + }; + } +} diff --git a/lib/domain/entities/user.dart b/lib/domain/entities/user.dart new file mode 100644 index 0000000..1eed52c --- /dev/null +++ b/lib/domain/entities/user.dart @@ -0,0 +1,12 @@ +import 'package:equatable/equatable.dart'; + +class User extends Equatable { + final String id; + final String name; + final String email; + + const User({required this.id, required this.name, required this.email}); + + @override + List get props => [id, name, email]; +} diff --git a/lib/domain/repositories/user_repository.dart b/lib/domain/repositories/user_repository.dart new file mode 100644 index 0000000..4491667 --- /dev/null +++ b/lib/domain/repositories/user_repository.dart @@ -0,0 +1,5 @@ +import 'package:afterwork/domain/entities/user.dart'; + +abstract class UserRepository { + Future getUser(String id); +} diff --git a/lib/domain/usecases/get_user.dart b/lib/domain/usecases/get_user.dart new file mode 100644 index 0000000..c9f8077 --- /dev/null +++ b/lib/domain/usecases/get_user.dart @@ -0,0 +1,19 @@ +import 'package:dartz/dartz.dart'; +import 'package:afterwork/domain/entities/user.dart'; +import 'package:afterwork/domain/repositories/user_repository.dart'; +import 'package:afterwork/core/errors/failures.dart'; + +class GetUser { + final UserRepository repository; + + GetUser(this.repository); + + Future> call(String id) async { + try { + final user = await repository.getUser(id); + return Right(user); + } catch (e) { + return Left(ServerFailure()); + } + } +} diff --git a/lib/main.dart b/lib/main.dart index 8e94089..379d61d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,125 +1,21 @@ import 'package:flutter/material.dart'; +import 'config/router.dart'; +import 'core/theme/app_theme.dart'; void main() { - runApp(const MyApp()); + runApp(const AfterWorkApp()); } -class MyApp extends StatelessWidget { - const MyApp({super.key}); +class AfterWorkApp extends StatelessWidget { + const AfterWorkApp({super.key}); - // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( - title: 'Flutter Demo', - theme: ThemeData( - // This is the theme of your application. - // - // TRY THIS: Try running your application with "flutter run". You'll see - // the application has a purple toolbar. Then, without quitting the app, - // try changing the seedColor in the colorScheme below to Colors.green - // and then invoke "hot reload" (save your changes or press the "hot - // reload" button in a Flutter-supported IDE, or press "r" if you used - // the command line to start the app). - // - // Notice that the counter didn't reset back to zero; the application - // state is not lost during the reload. To reset the state, use hot - // restart instead. - // - // This works for code too, not just values: Most code changes can be - // tested with just a hot reload. - colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), - useMaterial3: true, - ), - home: const MyHomePage(title: 'Flutter Demo Home Page'), - ); - } -} - -class MyHomePage extends StatefulWidget { - const MyHomePage({super.key, required this.title}); - - // This widget is the home page of your application. It is stateful, meaning - // that it has a State object (defined below) that contains fields that affect - // how it looks. - - // This class is the configuration for the state. It holds the values (in this - // case the title) provided by the parent (in this case the App widget) and - // used by the build method of the State. Fields in a Widget subclass are - // always marked "final". - - final String title; - - @override - State createState() => _MyHomePageState(); -} - -class _MyHomePageState extends State { - int _counter = 0; - - void _incrementCounter() { - setState(() { - // This call to setState tells the Flutter framework that something has - // changed in this State, which causes it to rerun the build method below - // so that the display can reflect the updated values. If we changed - // _counter without calling setState(), then the build method would not be - // called again, and so nothing would appear to happen. - _counter++; - }); - } - - @override - Widget build(BuildContext context) { - // This method is rerun every time setState is called, for instance as done - // by the _incrementCounter method above. - // - // The Flutter framework has been optimized to make rerunning build methods - // fast, so that you can just rebuild anything that needs updating rather - // than having to individually change instances of widgets. - return Scaffold( - appBar: AppBar( - // TRY THIS: Try changing the color here to a specific color (to - // Colors.amber, perhaps?) and trigger a hot reload to see the AppBar - // change color while the other colors stay the same. - backgroundColor: Theme.of(context).colorScheme.inversePrimary, - // Here we take the value from the MyHomePage object that was created by - // the App.build method, and use it to set our appbar title. - title: Text(widget.title), - ), - body: Center( - // Center is a layout widget. It takes a single child and positions it - // in the middle of the parent. - child: Column( - // Column is also a layout widget. It takes a list of children and - // arranges them vertically. By default, it sizes itself to fit its - // children horizontally, and tries to be as tall as its parent. - // - // Column has various properties to control how it sizes itself and - // how it positions its children. Here we use mainAxisAlignment to - // center the children vertically; the main axis here is the vertical - // axis because Columns are vertical (the cross axis would be - // horizontal). - // - // TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint" - // action in the IDE, or press "p" in the console), to see the - // wireframe for each widget. - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Text( - 'You have pushed the button this many times:', - ), - Text( - '$_counter', - style: Theme.of(context).textTheme.headlineMedium, - ), - ], - ), - ), - floatingActionButton: FloatingActionButton( - onPressed: _incrementCounter, - tooltip: 'Increment', - child: const Icon(Icons.add), - ), // This trailing comma makes auto-formatting nicer for build methods. + title: 'AfterWork', + theme: AppTheme.lightTheme, + onGenerateRoute: AppRouter.generateRoute, + initialRoute: '/', ); } } diff --git a/lib/presentation/screens/event/event_screen.dart b/lib/presentation/screens/event/event_screen.dart new file mode 100644 index 0000000..ae876ad --- /dev/null +++ b/lib/presentation/screens/event/event_screen.dart @@ -0,0 +1,18 @@ +import 'package:flutter/material.dart'; + +class EventScreen extends StatelessWidget { + const EventScreen({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Événements'), + ), + body: const Center( + child: Text('Liste des événements'), + ), + ); + } +} + diff --git a/lib/presentation/screens/home/home_screen.dart b/lib/presentation/screens/home/home_screen.dart new file mode 100644 index 0000000..a86dfee --- /dev/null +++ b/lib/presentation/screens/home/home_screen.dart @@ -0,0 +1,17 @@ +import 'package:flutter/material.dart'; + +class HomeScreen extends StatelessWidget { + const HomeScreen({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('AfterWork'), + ), + body: const Center( + child: Text('Bienvenue sur AfterWork!'), + ), + ); + } +} diff --git a/lib/presentation/state_management/user_bloc.dart b/lib/presentation/state_management/user_bloc.dart new file mode 100644 index 0000000..b1cc3ab --- /dev/null +++ b/lib/presentation/state_management/user_bloc.dart @@ -0,0 +1,43 @@ +import 'package:afterwork/domain/entities/user.dart'; +import 'package:afterwork/domain/usecases/get_user.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class UserBloc extends Bloc { + final GetUser getUser; + + UserBloc({required this.getUser}) : super(UserInitial()); + + Stream mapEventToState(UserEvent event) async* { + if (event is GetUserById) { + yield UserLoading(); + final either = await getUser(event.id); + + yield either.fold( + (failure) => UserError(), + (user) => UserLoaded(user: user), + ); + } + } +} + +abstract class UserEvent {} + +class GetUserById extends UserEvent { + final String id; + + GetUserById(this.id); +} + +abstract class UserState {} + +class UserInitial extends UserState {} + +class UserLoading extends UserState {} + +class UserLoaded extends UserState { + final User user; + + UserLoaded({required this.user}); +} + +class UserError extends UserState {} diff --git a/lib/presentation/widgets/custom_button.dart b/lib/presentation/widgets/custom_button.dart new file mode 100644 index 0000000..485d6bd --- /dev/null +++ b/lib/presentation/widgets/custom_button.dart @@ -0,0 +1,17 @@ +import 'package:flutter/material.dart'; + +class CustomButton extends StatelessWidget { + final String text; + final VoidCallback onPressed; + + const CustomButton({super.key, required this.text, required this.onPressed}); + + @override + Widget build(BuildContext context) { + return ElevatedButton( + onPressed: onPressed, + child: Text(text), + ); + } +} + diff --git a/pubspec.lock b/pubspec.lock index 9e51fc8..781db0c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -9,6 +9,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.11.0" + bloc: + dependency: transitive + description: + name: bloc + sha256: "106842ad6569f0b60297619e9e0b1885c2fb9bf84812935490e6c5275777804e" + url: "https://pub.dev" + source: hosted + version: "8.1.4" boolean_selector: dependency: transitive description: @@ -49,6 +57,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.8" + dartz: + dependency: "direct main" + description: + name: dartz + sha256: e6acf34ad2e31b1eb00948692468c30ab48ac8250e0f0df661e29f12dd252168 + url: "https://pub.dev" + source: hosted + version: "0.10.1" + equatable: + dependency: "direct main" + description: + name: equatable + sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2 + url: "https://pub.dev" + source: hosted + version: "2.0.5" fake_async: dependency: transitive description: @@ -62,6 +86,14 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_bloc: + dependency: "direct main" + description: + name: flutter_bloc + sha256: b594505eac31a0518bdcb4b5b79573b8d9117b193cc80cc12e17d639b10aa27a + url: "https://pub.dev" + source: hosted + version: "8.1.6" flutter_lints: dependency: "direct dev" description: @@ -75,6 +107,30 @@ packages: description: flutter source: sdk version: "0.0.0" + get_it: + dependency: "direct main" + description: + name: get_it + sha256: d85128a5dae4ea777324730dc65edd9c9f43155c109d5cc0a69cab74139fbac1 + url: "https://pub.dev" + source: hosted + version: "7.7.0" + http: + dependency: "direct main" + description: + name: http + sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2" + url: "https://pub.dev" + source: hosted + version: "0.13.6" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" + source: hosted + version: "4.0.2" leak_tracker: dependency: transitive description: @@ -131,6 +187,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.15.0" + nested: + dependency: transitive + description: + name: nested + sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" + url: "https://pub.dev" + source: hosted + version: "1.0.0" path: dependency: transitive description: @@ -139,6 +203,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.0" + provider: + dependency: transitive + description: + name: provider + sha256: c8a055ee5ce3fd98d6fc872478b03823ffdb448699c6ebdbbc71d59b596fd48c + url: "https://pub.dev" + source: hosted + version: "6.1.2" sky_engine: dependency: transitive description: flutter @@ -192,6 +264,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.7.2" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.dev" + source: hosted + version: "1.3.2" vector_math: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 19c8718..6427867 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,61 +1,40 @@ name: afterwork description: "A new Flutter project." -# The following line prevents the package from being accidentally published to -# pub.dev using `flutter pub publish`. This is preferred for private packages. publish_to: 'none' # Remove this line if you wish to publish to pub.dev -# The following defines the version and build number for your application. -# A version number is three numbers separated by dots, like 1.2.43 -# followed by an optional build number separated by a +. -# Both the version and the builder number may be overridden in flutter -# build by specifying --build-name and --build-number, respectively. -# In Android, build-name is used as versionName while build-number used as versionCode. -# Read more about Android versioning at https://developer.android.com/studio/publish/versioning -# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. -# Read more about iOS versioning at -# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -# In Windows, build-name is used as the major, minor, and patch parts -# of the product and file versions while build-number is used as the build suffix. version: 1.0.0+1 environment: sdk: ^3.5.1 -# Dependencies specify other packages that your package needs in order to work. -# To automatically upgrade your package dependencies to the latest versions -# consider running `flutter pub upgrade --major-versions`. Alternatively, -# dependencies can be manually updated by changing the version numbers below to -# the latest version available on pub.dev. To see which dependencies have newer -# versions available, run `flutter pub outdated`. dependencies: flutter: sdk: flutter - - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.8 + # State management with flutter_bloc + flutter_bloc: ^8.0.1 + + # HTTP client for API requests + http: ^0.13.3 + + # Dependency injection with get_it + get_it: ^7.2.0 + + # Equatable for easier comparison of objects + equatable: ^2.0.3 + + # Functional programming utilities + dartz: ^0.10.1 + dev_dependencies: flutter_test: sdk: flutter - # The "flutter_lints" package below contains a set of recommended lints to - # encourage good coding practices. The lint set provided by the package is - # activated in the `analysis_options.yaml` file located at the root of your - # package. See that file for information about deactivating specific lint - # rules and activating additional ones. flutter_lints: ^4.0.0 -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter packages. flutter: - - # The following line ensures that the Material Icons font is - # included with your application, so that you can use the icons in - # the material Icons class. uses-material-design: true # To add assets to your application, add an assets section, like this: @@ -63,17 +42,10 @@ flutter: # - images/a_dot_burr.jpeg # - images/a_dot_ham.jpeg - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/to/resolution-aware-images - - # For details regarding adding assets from package dependencies, see - # https://flutter.dev/to/asset-from-package - # To add custom fonts to your application, add a fonts section here, # in this "flutter" section. Each entry in this list should have a # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: + # list giving the asset and other descriptors for the font. For example: # fonts: # - family: Schyler # fonts: diff --git a/test/widget_test.dart b/test/widget_test.dart index 3745161..e69de29 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -1,30 +0,0 @@ -// 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:afterwork/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); - }); -}