Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .fvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"flutter": "3.47.5",
"flavors": {}
}
4 changes: 3 additions & 1 deletion .github/workflows/flutter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ jobs:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
- uses: subosito/flutter-action@v2
with:
flutter-version-file: .fvmrc
- name: Install dependencies
run: flutter pub get

- name: Check code format
run: dart format . -o none --set-exit-if-changed

- name: Run code generation
run: cd example && flutter pub get && flutter pub run build_runner build && cd ..
run: cd example && flutter pub get && dart run build_runner build && cd ..

- name: Analyze project source
run: flutter analyze --fatal-infos
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.1.0
* **Breaking:** Requires Flutter `>=3.47.0` and Dart `^3.13.0`
* **Breaking:** Migrated from `package:flutter/material.dart` / `package:flutter/cupertino.dart` to the `material_ui` and `cupertino_ui` packages. Apps must migrate as well, see [doc/migrate_to_material_ui.md](doc/migrate_to_material_ui.md)
* Migrated classes to primary constructors; the public API is unchanged

## 0.0.22
* Added `BoltLogger.surge` and the `surge` extension method for logging at `Level.WARNING`, completing the `zap` (info) / `surge` (warning) / `shock` (severe) trio
* `DebugConsoleCharge` now prints warning level logs in yellow; severe logs and logs carrying an error or stack trace remain red
Expand Down
3 changes: 2 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ analyzer:
missing_required_param: error
exclude:
- "**/*.g.dart"
- "**/*.freezed.dart"
- "**/*.freezed.dart"
- build/**
5 changes: 5 additions & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
analyzer:
exclude:
- build/**
- android/**
- ios/**
include: package:flutter_lints/flutter.yaml

linter:
Expand Down
100 changes: 40 additions & 60 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ import 'package:dcc_toolkit/ui/native_dialog.dart';
import 'package:example/core/injectable/injectable.dart';
import 'package:example/profile/presentation/cubit/user_cubit.dart';
import 'package:example/profile/presentation/user_page.dart';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';

Future<void> main() async {
await configureDependencies();
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});

class const MyApp({super.key}) extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
Expand All @@ -26,9 +24,7 @@ class MyApp extends StatelessWidget {
}
}

class MyHomePage extends StatelessWidget {
const MyHomePage({super.key});

class const MyHomePage({super.key}) extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
Expand All @@ -38,75 +34,59 @@ class MyHomePage extends StatelessWidget {
Padding(
padding: const EdgeInsets.all(16),
child: AnnotatedText(
text:
'[Flutter](onFlutterTap) example of using a Rich Text with annotations with multiple [tap](onTap) actions.\nThis tap [action](action) does nothing. And [action] without () does nothing as well',
text: '[Flutter](onFlutterTap) example of using a Rich Text with annotations with multiple [tap](onTap) actions.\nThis tap [action](action) does nothing. And [action] without () does nothing as well',
defaultStyle: const TextStyle(color: Colors.black),
annotationStyle: const TextStyle(color: Colors.blue),
actions: {
'onFlutterTap':
() =>
ScaffoldMessenger.of(context)
..hideCurrentSnackBar()
..showSnackBar(
const SnackBar(content: Text('Flutter')),
),
'onTap':
() =>
ScaffoldMessenger.of(context)
..hideCurrentSnackBar()
..showSnackBar(
const SnackBar(content: Text('Tap')),
),
'onFlutterTap': () => ScaffoldMessenger.of(context)
..hideCurrentSnackBar()
..showSnackBar(const SnackBar(content: Text('Flutter'))),
'onTap': () => ScaffoldMessenger.of(context)
..hideCurrentSnackBar()
..showSnackBar(const SnackBar(content: Text('Tap'))),
},
),
),
ElevatedButton(
onPressed:
() => Navigator.of(context).push(
MaterialPageRoute(
builder:
(context) => UserPage(
onCreateCubit:
(context) =>
getIt<UserCubit>()..getRandomUser(),
),
),
onPressed: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => UserPage(
onCreateCubit: (context) =>
getIt<UserCubit>()..getRandomUser(),
),
),
),
child: const Text('Get user succesfully'),
),
ElevatedButton(
onPressed:
() => Navigator.of(context).push(
MaterialPageRoute(
builder:
(context) => UserPage(
onCreateCubit:
(context) =>
getIt<UserCubit>()..getRandomUserFails(),
),
),
onPressed: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => UserPage(
onCreateCubit: (context) =>
getIt<UserCubit>()..getRandomUserFails(),
),
),
),
child: const Text('Get user fails'),
),
ElevatedButton(
onPressed:
() => showNativeDialog(
context,
title: 'Title',
content: 'Content',
actions: [
DialogAction(
text: 'Action',
onTap: () {},
textStyle: const TextStyle(color: Colors.green),
),
DialogAction(
text: 'Action',
onTap: () {},
textStyle: const TextStyle(color: Colors.red),
),
],
onPressed: () => showNativeDialog(
context,
title: 'Title',
content: 'Content',
actions: [
DialogAction(
text: 'Action',
onTap: () {},
textStyle: const TextStyle(color: Colors.green),
),
DialogAction(
text: 'Action',
onTap: () {},
textStyle: const TextStyle(color: Colors.red),
),
],
),
child: const Text('Show native dialog'),
),
],
Expand Down
2 changes: 1 addition & 1 deletion example/lib/profile/data/model/user.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:freezed_annotation/freezed_annotation.dart';

import 'name.dart';
import 'location.dart';
import 'name.dart';
import 'picture.dart';

part 'user.freezed.dart';
Expand Down
6 changes: 1 addition & 5 deletions example/lib/profile/data/user_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ import 'model/api_user_response.dart';
import 'user_service.dart';

@lazySingleton
class UserRepository {
const UserRepository(this._userService);

final UserService _userService;

class const UserRepository(final UserService _userService) {
Future<Result<ApiUserResponse>> getRandomUser() async {
return tryCall(() => _userService.getRandomUser());
}
Expand Down
7 changes: 3 additions & 4 deletions example/lib/profile/presentation/cubit/user_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ part 'user_cubit.freezed.dart';
part 'user_state.dart';

@injectable
class UserCubit extends Cubit<UserState>
class UserCubit(final UserRepository _userRepo)
extends Cubit<UserState>
with BlocPresentationMixin<UserState, UserEvent> {
UserCubit(this._userRepo) : super(const UserState(user: null));

final UserRepository _userRepo;
this : super(const UserState(user: null));

Future<void> getRandomUser() async {
final result = await _userRepo.getRandomUser();
Expand Down
17 changes: 8 additions & 9 deletions example/lib/profile/presentation/user_page.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import 'package:dcc_toolkit/ui/blocful_widget.dart';
import 'package:example/profile/presentation/cubit/user_cubit.dart';
import 'package:example/profile/presentation/cubit/user_event.dart';
import 'package:flutter/material.dart';
import 'package:material_ui/material_ui.dart';

class UserPage extends BlocfulWidget<UserCubit, UserState, UserEvent> {
const UserPage({required this.onCreateCubit, super.key})
: super(onCreateBloc: onCreateCubit);

final UserCubit Function(BuildContext)? onCreateCubit;
class const UserPage({
required final UserCubit Function(BuildContext)? onCreateCubit,
super.key,
}) extends BlocfulWidget<UserCubit, UserState, UserEvent> {
this : super(onCreateBloc: onCreateCubit);

@override
void onPresentationEvent(BuildContext context, UserEvent event) {
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text(event.reason)));
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text(event.reason)));
}

@override
Expand Down
Loading
Loading