We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i'm using StreamBuilder to build a DatePickerWidget if initial data changed, but it don't working, why? import 'dart:async';
import 'package:LunarCalendar/models/app_utils.dart'; import 'package:dotted_border/dotted_border.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_holo_date_picker/flutter_holo_date_picker.dart'; import 'package:flutter_screenutil/screenutil.dart';
class DoiNgayPage extends StatefulWidget { static const String routeName = '/DNPage';
@OverRide State createState() { return DoiNgayPageState(); } }
class DoiNgayPageState extends State { DateTime solarDay = DateTime.now(); DateTime lunarDay = DateTime.now();
final dateTimeStream = StreamController();
@OverRide void dispose() { super.dispose(); dateTimeStream.close(); }
@OverRide void initState() { super.initState();
DateTime dateTime = AppUtils().GetLunarDateFromSolarDate(solarDay.day, solarDay.month, solarDay.year); lunarDay = new DateTime(dateTime.year, dateTime.month, dateTime.day); dateTimeStream.sink.add(lunarDay);
}
@OverRide Widget build(BuildContext context) { ScreenUtil.init(context, width: 1280, height: 720, allowFontScaling: false);
return Scaffold( backgroundColor: Colors.white, appBar: AppBar( automaticallyImplyLeading: false, centerTitle: true, title: Text('ĐỔI NGÀY', style: TextStyle(fontSize: 22)), backgroundColor: Color(0xff4965e0), ), body: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[ new Container( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Image.asset( "assets/images/duonglich.png", height: 50, width: 50, fit: BoxFit.fill, ), Text( ' Dương lịch: ${AppUtils().formatViewDay(solarDay)}', style: TextStyle( fontSize: ScreenUtil().setSp(70), color: Colors.orangeAccent, fontWeight: FontWeight.w500, ), ), ], ), ), new Container( padding: EdgeInsets.only(left: ScreenUtil().setWidth(120), right: ScreenUtil().setWidth(120)), child: DottedBorder( color: Colors.lightBlueAccent, borderType: BorderType.RRect, radius: Radius.circular(5), child: DatePickerWidget( looping: false, initialDate: solarDay, onChange: (DateTime date, _) { setState(() { solarDay = date; DateTime dateTime = AppUtils().GetLunarDateFromSolarDate(solarDay.day, solarDay.month, solarDay.year); lunarDay = new DateTime(dateTime.year, dateTime.month, dateTime.day); }); dateTimeStream.sink.add(lunarDay); }, dateFormat: "dd-MMMM-yyyy", locale: DateTimePickerLocale.vi, pickerTheme: DateTimePickerTheme( itemTextStyle: TextStyle(color: Colors.black, fontSize: 19, fontWeight: FontWeight.bold), dividerColor: Colors.orange[200], ), ), ), ), new Container( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Image.asset( "assets/images/amlich.png", height: 50, width: 55, fit: BoxFit.fill, ), Text( ' Âm lịch: ${AppUtils().formatViewDay(lunarDay)}', style: TextStyle( fontSize: ScreenUtil().setSp(70), color: Colors.orangeAccent, fontWeight: FontWeight.w500, ), ), ], ), ), amlichbuilder(), ], ), );
amlichbuilder() { return StreamBuilder( stream: dateTimeStream.stream, builder: (context, snapshot) { if (!snapshot.hasData) return CircularProgressIndicator();
return new Container( padding: EdgeInsets.only(left: ScreenUtil().setWidth(120), right: ScreenUtil().setWidth(120)), child: DottedBorder( color: Colors.lightBlueAccent, borderType: BorderType.RRect, radius: Radius.circular(5), child: DatePickerWidget( looping: false, initialDate: snapshot.data, onChange: (DateTime date, _) { setState(() { lunarDay = date; DateTime dateTime = AppUtils().GetSolarDateFromLunarDate(lunarDay.day, lunarDay.month, lunarDay.year); solarDay = new DateTime(dateTime.year, dateTime.month, dateTime.day); }); }, dateFormat: "dd-MMMM-yyyy", locale: DateTimePickerLocale.vi, pickerTheme: DateTimePickerTheme( itemTextStyle: TextStyle(color: Colors.black, fontSize: 19, fontWeight: FontWeight.bold), dividerColor: Colors.orange[200], ), ), ), ); }, );
} }
The text was updated successfully, but these errors were encountered:
Hi, Can you send a link to the repository? It's hard to understand what the problem you face with or what you expected to happen
Sorry, something went wrong.
No branches or pull requests
i'm using StreamBuilder to build a DatePickerWidget if initial data changed, but it don't working, why?
import 'dart:async';
import 'package:LunarCalendar/models/app_utils.dart';
import 'package:dotted_border/dotted_border.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_holo_date_picker/flutter_holo_date_picker.dart';
import 'package:flutter_screenutil/screenutil.dart';
class DoiNgayPage extends StatefulWidget {
static const String routeName = '/DNPage';
@OverRide
State createState() {
return DoiNgayPageState();
}
}
class DoiNgayPageState extends State {
DateTime solarDay = DateTime.now();
DateTime lunarDay = DateTime.now();
final dateTimeStream = StreamController();
@OverRide
void dispose() {
super.dispose();
dateTimeStream.close();
}
@OverRide
void initState() {
super.initState();
}
@OverRide
Widget build(BuildContext context) {
ScreenUtil.init(context, width: 1280, height: 720, allowFontScaling: false);
}
amlichbuilder() {
return StreamBuilder(
stream: dateTimeStream.stream,
builder: (context, snapshot) {
if (!snapshot.hasData) return CircularProgressIndicator();
}
}
The text was updated successfully, but these errors were encountered: