files moved to src folder
added flutter_hooks support with example
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import 'package:fl_query/query_bowl.dart';
|
||||
import 'package:fl_query/fl_query.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AnotherComponent extends StatelessWidget {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import 'package:example/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fl_query/fl_query_hooks.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
|
||||
class HookExample extends HookWidget {
|
||||
const HookExample({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final query = useQuery(job: successJob, externalData: null);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text("Running the 1st example but with hooks instead"),
|
||||
),
|
||||
body: !query.hasData || query.isLoading || query.isRefetching
|
||||
? const CircularProgressIndicator()
|
||||
: TextButton(
|
||||
child: Text(query.data!),
|
||||
onPressed: () async {
|
||||
await query.refetch();
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:example/another_component.dart';
|
||||
import 'package:example/hooks_example.dart';
|
||||
import 'package:example/lazy_query.dart';
|
||||
import 'package:example/mutation_example.dart';
|
||||
import 'package:example/query_with_external_data.dart';
|
||||
@@ -167,6 +168,16 @@ class _MyHomePageState extends State<MyHomePage> with WidgetsBindingObserver {
|
||||
);
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
child: const Text("flutter_hooks Example"),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const HookExample(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const AnotherComponent(),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -76,6 +76,13 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_hooks:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_hooks
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.18.5"
|
||||
flutter_lints:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
@@ -207,4 +214,4 @@ packages:
|
||||
version: "2.1.2"
|
||||
sdks:
|
||||
dart: ">=2.17.1 <3.0.0"
|
||||
flutter: ">=1.17.0"
|
||||
flutter: ">=3.0.0"
|
||||
|
||||
@@ -36,6 +36,7 @@ dependencies:
|
||||
fl_query:
|
||||
path: ../fl_query
|
||||
http: ^0.13.4
|
||||
flutter_hooks: ^0.18.5
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
Reference in New Issue
Block a user