Commit b80c4715 authored by kevin's avatar kevin

rename package and refactoring

parent a8804ef8
# async_widget_helper
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://flutter.io/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.io/docs/cookbook)
For help getting started with Flutter, view our
[online documentation](https://flutter.io/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
import 'dart:async';
import 'package:async_widget_helper/async_widget_helper.dart';
import 'package:async_mixin_helper/async_mixin_helper.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
......@@ -59,7 +59,9 @@ class _MyHomePageState extends State<MyHomePage> {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
MyFutureWidget(),
MyFutureWidget(
future: Future.delayed(Duration(seconds: 5), () => 2),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Divider(
......@@ -89,12 +91,14 @@ class MyStreamWidget extends StatelessWidget with StreamHelperWidget {
}
class MyFutureWidget extends StatelessWidget with FutureHelperWidget {
final Future<int> future;
MyFutureWidget({@required this.future});
@override
Future<Widget> buildFuture(BuildContext context) {
return Future.delayed(
Duration(seconds: 5),
() => Text('Future Completed !'),
);
Future<Widget> buildFuture(BuildContext context) async {
final value = await future;
return Text('Future result is $value');
}
@override
......
name: async_widget_helper_example
name: async_mixin_helper_example
description: A new Flutter project.
# The following defines the version and build number for your application.
......@@ -10,12 +10,12 @@ description: A new Flutter project.
version: 1.0.0+1
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
async_widget_helper:
async_mixin_helper:
path: ../
# The following adds the Cupertino Icons font to your application.
......
export 'src/future_mixin.dart';
export 'src/stream_mixin.dart';
export 'src/async_helper.dart';
......@@ -15,19 +15,3 @@ mixin FutureHelperWidget {
);
}
}
mixin StreamHelperWidget {
Widget get defaultWidget => null;
Stream<Widget> buildStream(BuildContext context);
Widget build(BuildContext context) {
return StreamBuilder(
initialData: defaultWidget ?? Container(),
stream: buildStream(context),
builder: (c, snapshot) {
return snapshot.data;
},
);
}
}
import 'package:flutter/widgets.dart';
mixin StreamHelperWidget {
Widget get defaultWidget => null;
Stream<Widget> buildStream(BuildContext context);
Widget build(BuildContext context) {
return StreamBuilder(
initialData: defaultWidget ?? Container(),
stream: buildStream(context),
builder: (c, snapshot) {
return snapshot.data;
},
);
}
}
name: async_widget_helper
name: async_mixin_helper
description: A new Flutter project.
version: 1.0.0+1
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment