chatter_sms 0.0.8 chatter_sms: ^0.0.8 copied to clipboard
SMS plugin for chatter
import 'package:chatter_sms/thread.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
List<Thread> _threads = [];
@override
void initState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
List<Thread> threads;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
threads = await ThreadQuery().getAllThreads;
} on PlatformException {
threads = [];
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {
_threads = threads;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: ListView.builder(
itemCount: _threads.length,
shrinkWrap: true,
itemBuilder: (context, index) {
var data = _threads[index];
return Text(data.address);
}),
),
);
}
}