Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
feat: add riverpod and flutter hooks (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
wesbillman authored Dec 20, 2023
1 parent 9e14ab2 commit be9196a
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lib/features/app/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
title: 'Flutter Starter App',
theme: lightTheme(context),
darkTheme: darkTheme(context),
home: const HomePage(),
Expand Down
22 changes: 6 additions & 16 deletions lib/features/home/home_page.dart
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:flutter_starter/l10n/app_localizations.dart';

class HomePage extends StatefulWidget {
class HomePage extends HookWidget {
const HomePage({super.key});

@override
State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
int _counter = 0;

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

@override
Widget build(BuildContext context) {
final counter = useState(0);

return Scaffold(
appBar: AppBar(title: Text(Loc.of(context).appName)),
body: Padding(
Expand All @@ -32,15 +22,15 @@ class _HomePageState extends State<HomePage> {
textAlign: TextAlign.center,
),
Text(
'$_counter',
'${counter.value}',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
onPressed: () => counter.value++,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
Expand Down
3 changes: 2 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_starter/features/app/app.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';

void main() {
runApp(const App());
runApp(const ProviderScope(child: App()));
}
41 changes: 41 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_hooks:
dependency: "direct main"
description:
name: flutter_hooks
sha256: "7c8db779c2d1010aa7f9ea3fbefe8f86524fcb87b69e8b0af31e1a4b55422dec"
url: "https://pub.dev"
source: hosted
version: "0.20.3"
flutter_lints:
dependency: "direct dev"
description:
Expand All @@ -67,11 +75,27 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_riverpod:
dependency: transitive
description:
name: flutter_riverpod
sha256: da9591d1f8d5881628ccd5c25c40e74fc3eef50ba45e40c3905a06e1712412d5
url: "https://pub.dev"
source: hosted
version: "2.4.9"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
hooks_riverpod:
dependency: "direct main"
description:
name: hooks_riverpod
sha256: c12a456e03ef9be65b0be66963596650ad7a3220e96c7e7b0a048562ea32d6ae
url: "https://pub.dev"
source: hosted
version: "2.4.9"
intl:
dependency: "direct main"
description:
Expand Down Expand Up @@ -120,6 +144,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.8.3"
riverpod:
dependency: transitive
description:
name: riverpod
sha256: "942999ee48b899f8a46a860f1e13cee36f2f77609eb54c5b7a669bb20d550b11"
url: "https://pub.dev"
source: hosted
version: "2.4.9"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -141,6 +173,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.11.1"
state_notifier:
dependency: transitive
description:
name: state_notifier
sha256: b8677376aa54f2d7c58280d5a007f9e8774f1968d1fb1c096adcb4792fba29bb
url: "https://pub.dev"
source: hosted
version: "1.0.0"
stream_channel:
dependency: transitive
description:
Expand Down Expand Up @@ -191,3 +231,4 @@ packages:
version: "0.3.0"
sdks:
dart: ">=3.2.0-194.0.dev <4.0.0"
flutter: ">=3.0.0"
3 changes: 3 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ dependencies:
sdk: flutter
flutter_localizations:
sdk: flutter

flutter_hooks: ^0.20.3
hooks_riverpod: ^2.4.9
intl: ^0.18.1

dev_dependencies:
Expand Down

0 comments on commit be9196a

Please sign in to comment.